-Wiley InterScience fixes.

This commit is contained in:
Michael Berkowitz 2008-07-01 18:50:16 +00:00
parent 7d31e7ebcb
commit 36f9213ee2

View File

@ -18171,7 +18171,7 @@ REPLACE INTO translators VALUES ('232903bc-7307-4058-bb1a-27cfe3e4e655', '1.0.0b
Zotero.wait(); Zotero.wait();
}'); }');
REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b4.r5', '', '2008-06-30 12:13:10', '1', '100', '4', 'Wiley InterScience', 'Sean Takats and Michael Berkowitz', 'https?:\/\/(?:www3\.|www\.)?interscience\.wiley\.com[^\/]*\/(?:search\/|(cgi-bin|journal)\/[0-9]+\/abstract|journal)', REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b4.r5', '', '2008-07-01 14:49:26', '1', '100', '4', 'Wiley InterScience', 'Sean Takats and Michael Berkowitz', 'https?:\/\/(?:www3\.|www\.)?interscience\.wiley\.com[^\/]*\/(?:search\/|(cgi-bin|journal)\/[0-9]+\/abstract|journal)',
'function detectWeb(doc, url){ 'function detectWeb(doc, url){
var namespace = doc.documentElement.namespaceURI; var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) { var nsResolver = namespace ? function(prefix) {
@ -18182,10 +18182,10 @@ REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b
if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
return "multiple"; return "multiple";
} }
if (url.match(/journal\/\d+\/(issue|home)/)) { if (url.match(/journal\/\d+\/(issue|home)$/)) {
return "multiple"; return "multiple";
} }
var m = url.match(/https?:\/\/[^\/]*\/(cgi-bin|journal)(\/(abstract|summary))?\/[0-9]+(\/abstract)?/); var m = url.match(/https?:\/\/[^\/]*\/(cgi-bin|journal)(\/(abstract|summary))?\/[0-9]+\/abstract/);
if (m){ if (m){
return "journalArticle"; return "journalArticle";
} }
@ -18195,7 +18195,8 @@ REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b
var nsResolver = namespace ? function(prefix) { var nsResolver = namespace ? function(prefix) {
if (prefix == ''x'') return namespace; else return null; if (prefix == ''x'') return namespace; else return null;
} : null; } : null;
var host = ''http://'' + doc.location.host + "/";
Zotero.debug(host);
var m = url.match(/https?:\/\/[^\/]*\/(journal|cgi-bin\/summary)\/([0-9]+)\/(abstract)?/); var m = url.match(/https?:\/\/[^\/]*\/(journal|cgi-bin\/summary)\/([0-9]+)\/(abstract)?/);
var ids = new Array(); var ids = new Array();
if(detectWeb(doc, url) == "multiple") { //search if(detectWeb(doc, url) == "multiple") { //search
@ -18232,41 +18233,38 @@ REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b
} else if (m){ //single article } else if (m){ //single article
ids.push(m[2]); ids.push(m[2]);
} }
var hostRe = new RegExp("^http(?:s)?://[^/]+"); for each (id in ids) {
var m = hostRe.exec(doc.location.href); var uri = host + ''tools/citex'';
var host = m[0]; var poststring = "clienttype=1&subtype=1&mode=1&version=1&id=" + id;
var uri = host+"/tools/citex";
var poststring = "";
for each(var id in ids) {
poststring = poststring + "&id=" + id;
}
poststring = "clienttype=1&subtype=1&mode=1&version=1" + poststring;
Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) {
uri = host+"/tools/CitEx";
poststring = "mode=2&format=3&type=2&file=3&exportCitation.x=16&exportCitation.y=10&exportCitation=submit";
Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) { Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) {
var m = text.match(/%A\s(.*)/); //following lines fix Wiley''s incorrect %A tag (should be separate tags for each author) uri = host+"tools/CitEx";
if (m){ poststring = "mode=2&format=3&type=2&file=3&exportCitation.x=16&exportCitation.y=10&exportCitation=submit";
var newauthors =""; Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) {
var authors = m[1].split(",") var m = text.match(/%A\s(.*)/); //following lines fix Wiley''s incorrect %A tag (should be separate tags for each author)
for each (var author in authors){ if (m){
if (author != ""){ var newauthors ="";
newauthors = newauthors + "%A "+Zotero.Utilities.unescapeHTML(Zotero.Utilities.trimInternal(author))+"\n"; var authors = m[1].split(",")
for each (var author in authors){
if (author != ""){
newauthors = newauthors + "%A "+Zotero.Utilities.unescapeHTML(Zotero.Utilities.trimInternal(author))+"\n";
}
} }
text = text.replace(/%A\s.*\n/, newauthors);
} }
text = text.replace(/%A\s.*\n/, newauthors); var translator = Zotero.loadTranslator("import");
} translator.setTranslator("881f60f2-0802-411a-9228-ce5f47b64c7d"); //EndNote/Refer/BibIX
var translator = Zotero.loadTranslator("import"); translator.setString(text);
translator.setTranslator("881f60f2-0802-411a-9228-ce5f47b64c7d"); //EndNote/Refer/BibIX translator.setHandler("itemDone", function(obj, item) {
translator.setString(text); var pdfurl = ''http://download.interscience.wiley.com/cgi-bin/fulltext?ID='' + id + ''&PLACEBO=IE.pdf&mode=pdf'';
translator.setHandler("itemDone", function(obj, item) { item.attachments.push({url:pdfurl, title:"Wiley Interscience PDF", mimeType:"application/pdf"});
item.DOI = item.url.match(/\.org\/(.*)$/)[1]; item.DOI = item.url.match(/\.org\/(.*)$/)[1];
item.complete(); item.complete();
});
translator.translate();
Zotero.done();
}); });
translator.translate();
Zotero.done();
}); });
}); };
Zotero.wait(); Zotero.wait();
}'); }');