Trans: Various IngentaConnect fixes, per http://forums.zotero.org/discussion/16959/

This commit is contained in:
Avram Lyon 2011-04-04 17:49:20 +00:00
parent a4cc84a7b4
commit 62edf3317d

View file

@ -3,12 +3,12 @@
"translatorType":4,
"label":"IngentaConnect",
"creator":"Michael Berkowitz",
"target":"http://(www.)?ingentaconnect.com",
"target":"^https?://(www\\.)?ingentaconnect\\.com",
"minVersion":"1.0.0b3r1",
"maxVersion":"",
"priority":100,
"inRepository":true,
"lastUpdated":"2009-01-08 08:19:07"
"lastUpdated":"2011-04-03 08:19:07"
}
function detectWeb(doc, url) {
@ -36,19 +36,27 @@ function doWeb(doc, url) {
} else {
articles = [url];
}
Zotero.debug(articles);
Zotero.Utilities.processDocuments(articles, function(newDoc) {
var risurl = newDoc.evaluate('//div[@id="export-formats"]/ul/li/a[@title="EndNote Export"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
if (newDoc.evaluate('//div[@id="abstract"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) var abs = Zotero.Utilities.trimInternal(newDoc.evaluate('//div[@id="abstract"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).substr(10);
var abs, pdf;
var risurl = newDoc.evaluate('//div[contains(@class,"export-formats")]/ul/li/a[@title="EndNote Export"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
if (newDoc.evaluate('//div[@id="abstract"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
abs = Zotero.Utilities.trimInternal(newDoc.evaluate('//div[@id="abstract"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).substr(10);
}
if (newDoc.evaluate('//div[@id="purchaseexpand"]//a[contains(@title,"download")]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
pdf = newDoc.evaluate('//div[@id="purchaseexpand"]//a[contains(@title,"download")]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
}
if (newDoc.evaluate('//div[@id="info"]/p[1]/a', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
var keywords = newDoc.evaluate('//div[@id="info"]/p[1]/a', newDoc, null, XPathResult.ANY_TYPE, null);
var key;
var keys = new Array();
while (key = keywords.iterateNext()) {
keys.push(Zotero.Utilities.capitalizeTitle(key.textContent));
keys.push(Zotero.Utilities.capitalizeTitle(key.textContent, true));
}
}
Zotero.Utilities.HTTP.doGet(risurl, function(text) {
// fix spacing per spec
text = text.replace(/([A-Z0-9]{2}) ?-/g,"$1 -");
Zotero.debug(text);
text = text.replace(/(PY\s+\-\s+)\/+/, "$1");
text = text.replace(/ER\s\s\-/, "") + "\nER - ";
var translator = Zotero.loadTranslator("import");
@ -56,10 +64,12 @@ function doWeb(doc, url) {
translator.setString(text);
translator.setHandler("itemDone", function(obj, item) {
if (abs) item.abstractNote = abs;
item.attachments = [{url:item.url, title:"IngentaConnect Snapshot", mimeType:"text/html"}];
if (pdf) item.attachments.push({url:pdf, title:"IngentaConnect Full Text PDF", mimeType:"application/pdf"});
// Note that the RIS translator gives us a link to the record already
item.url = null;
if (keys) item.tags = keys;
if (item.DOI) {
if (item.DOI.match(/doi/)) {
if (item.DOI.match(/^doi:/)) {
item.DOI = item.DOI.substr(4);
}
}
@ -68,4 +78,4 @@ function doWeb(doc, url) {
translator.translate();
});
}, function() {Zotero.done();});
}
}