Trans: Updated Gutenberg, see http://forums.zotero.org/discussion/15562
This commit is contained in:
parent
c1cfb039fd
commit
698f3964b4
1 changed files with 21 additions and 39 deletions
|
@ -2,13 +2,13 @@
|
||||||
"translatorID":"d770e7d2-106c-4396-8c32-b35cdc46376c",
|
"translatorID":"d770e7d2-106c-4396-8c32-b35cdc46376c",
|
||||||
"translatorType":4,
|
"translatorType":4,
|
||||||
"label":"Project Gutenberg",
|
"label":"Project Gutenberg",
|
||||||
"creator":"Adam Crymble",
|
"creator":"Adam Crymble, Avram Lyon",
|
||||||
"target":"http://www.gutenberg.org",
|
"target":"^http://www\\.gutenberg\\.org",
|
||||||
"minVersion":"1.0.0b4.r5",
|
"minVersion":"2.1",
|
||||||
"maxVersion":"",
|
"maxVersion":"",
|
||||||
"priority":100,
|
"priority":100,
|
||||||
"inRepository":true,
|
"inRepository":true,
|
||||||
"lastUpdated":"2009-07-07 00:15:00"
|
"lastUpdated":"2011-04-11 00:15:00"
|
||||||
}
|
}
|
||||||
|
|
||||||
function detectWeb(doc, url) {
|
function detectWeb(doc, url) {
|
||||||
|
@ -35,63 +35,46 @@ function scrape(doc, url) {
|
||||||
} : null;
|
} : null;
|
||||||
|
|
||||||
var dataTags = new Object();
|
var dataTags = new Object();
|
||||||
var odd = "yes";
|
|
||||||
var creatorType = new Array();
|
var creatorType = new Array();
|
||||||
var creatorField = new Array();
|
var creatorField = new Array();
|
||||||
var creatorContent = new Array();
|
var creatorContent = new Array();
|
||||||
|
|
||||||
var newItem = new Zotero.Item("book");
|
var newItem = new Zotero.Item("book");
|
||||||
|
|
||||||
var headingsEven = doc.evaluate('//tr[@class="oddrow"]/th', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
var headings = doc.evaluate('//table[@class="bibrec"]//tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||||
var headingsEvenCount = doc.evaluate('count(//tr[@class="oddrow"]/th)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
|
||||||
|
|
||||||
var headingsOdd = doc.evaluate('//tr[@class="evenrow"]/th', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
var content = doc.evaluate('//table[@class="bibrec"]//tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||||
var headingsOddCount = doc.evaluate('count(//tr[@class="evenrow"]/th)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
var i;
|
||||||
|
|
||||||
var content = doc.evaluate('//div[@class="pgdbdata"]/table/tbody//td', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
while (i = headings.iterateNext()) {
|
||||||
|
fieldTitle = i.textContent;
|
||||||
for (var i = 0; i < headingsEvenCount.numberValue + headingsOddCount.numberValue; i++) {
|
|
||||||
if (odd == "yes") {
|
|
||||||
fieldTitle = headingsOdd.iterateNext().textContent.replace(/\s+/g, '');
|
|
||||||
odd = "no";
|
|
||||||
} else {
|
|
||||||
fieldTitle = headingsEven.iterateNext().textContent.replace(/\s+/g, '');
|
|
||||||
odd = "yes";
|
|
||||||
}
|
|
||||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(content.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(content.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||||
|
Zotero.debug(i.textContent);
|
||||||
if (fieldTitle == "Creator") {
|
if (fieldTitle == "Creator") {
|
||||||
|
|
||||||
creatorType.push("author");
|
creatorType.push("author");
|
||||||
creatorField.push("Creator");
|
creatorField.push("Creator");
|
||||||
creatorContent.push(dataTags[fieldTitle]);
|
creatorContent.push(dataTags[fieldTitle]);
|
||||||
|
} else if (fieldTitle == "Author") {
|
||||||
|
creatorType.push("author");
|
||||||
|
creatorField.push("Author");
|
||||||
|
creatorContent.push(dataTags[fieldTitle]);
|
||||||
} else if (fieldTitle == "Illustrator") {
|
} else if (fieldTitle == "Illustrator") {
|
||||||
|
|
||||||
creatorType.push("illustrator");
|
creatorType.push("illustrator");
|
||||||
creatorField.push("Illustrator");
|
creatorField.push("Illustrator");
|
||||||
creatorContent.push(dataTags[fieldTitle]);
|
creatorContent.push(dataTags[fieldTitle]);
|
||||||
|
} else if (fieldTitle == "Translator") {
|
||||||
}else if (fieldTitle == "Translator") {
|
|
||||||
|
|
||||||
creatorType.push("translator");
|
creatorType.push("translator");
|
||||||
creatorField.push("Translator");
|
creatorField.push("Translator");
|
||||||
creatorContent.push(dataTags[fieldTitle]);
|
creatorContent.push(dataTags[fieldTitle]);
|
||||||
|
|
||||||
} else if (fieldTitle == "Editor") {
|
} else if (fieldTitle == "Editor") {
|
||||||
|
|
||||||
creatorType.push("editor");
|
creatorType.push("editor");
|
||||||
creatorField.push("Editor");
|
creatorField.push("Editor");
|
||||||
creatorContent.push(dataTags[fieldTitle]);
|
creatorContent.push(dataTags[fieldTitle]);
|
||||||
|
|
||||||
} else if (fieldTitle == "Commentator") {
|
} else if (fieldTitle == "Commentator") {
|
||||||
|
|
||||||
creatorType.push("commentator");
|
creatorType.push("commentator");
|
||||||
creatorField.push("Commentator");
|
creatorField.push("Commentator");
|
||||||
creatorContent.push(dataTags[fieldTitle]);
|
creatorContent.push(dataTags[fieldTitle]);
|
||||||
|
|
||||||
} else if (fieldTitle == "Contributor") {
|
} else if (fieldTitle == "Contributor") {
|
||||||
|
|
||||||
creatorType.push("contributor");
|
creatorType.push("contributor");
|
||||||
creatorField.push("Contributor");
|
creatorField.push("Contributor");
|
||||||
creatorContent.push(dataTags[fieldTitle]);
|
creatorContent.push(dataTags[fieldTitle]);
|
||||||
|
@ -101,7 +84,6 @@ function scrape(doc, url) {
|
||||||
newItem.place = place[0];
|
newItem.place = place[0];
|
||||||
Zotero.debug(place);
|
Zotero.debug(place);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fieldTitle == "Subject") {
|
if (fieldTitle == "Subject") {
|
||||||
newItem.tags[i] = dataTags["Subject"];
|
newItem.tags[i] = dataTags["Subject"];
|
||||||
}
|
}
|
||||||
|
@ -167,9 +149,9 @@ function doWeb(doc, url) {
|
||||||
for (var i in items) {
|
for (var i in items) {
|
||||||
articles.push(i);
|
articles.push(i);
|
||||||
}
|
}
|
||||||
|
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||||
|
Zotero.wait();
|
||||||
} else {
|
} else {
|
||||||
articles = [url];
|
scrape(doc, url);
|
||||||
}
|
}
|
||||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
}
|
||||||
Zotero.wait();
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue