Update translators from GitHub

This commit is contained in:
Dan Stillman 2011-08-18 05:07:32 +00:00
parent 8c8e5f4b40
commit 413ed3e749
12 changed files with 453 additions and 347 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
"lastUpdated": "2011-08-03 01:00:36"
"lastUpdated": "2011-08-07 11:11:54"
}
function detectWeb(doc, url) {
@ -16,19 +16,9 @@ function detectWeb(doc, url) {
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') { return namespace; } else { return null; }
} : null;
// The Scientific American Archive breaks this translator, disabling
try {
var databases = doc.evaluate("//span[@class = 'selected-databases']", doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
if(databases.indexOf("Scientific American Archive Online") != -1) {
return false;
}
} catch(e) {
}
// See if this is a search results or folder results page
var searchResult = doc.evaluate('//ul[@class="result-list" or @class="folder-list"]/li/div[@class="result-list-record" or @class="folder-item"]', doc, nsResolver,
XPathResult.ANY_TYPE, null).iterateNext();
var searchResult = doc.evaluate('//ul[@class="result-list" or @class="folder-list"]/li/div[@class="result-list-record" or @class="folder-item"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
if(searchResult) {
return "multiple";
}
@ -44,7 +34,9 @@ function detectWeb(doc, url) {
* given the text of the delivery page, downloads an item
*/
function downloadFunction(text, url) {
var an = url.match(/_(\d+)_AN/);
var pdf = false;
var risDate = false;
var queryString = {};
url.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
@ -52,11 +44,16 @@ function downloadFunction(text, url) {
);
pdf = "/ehost/pdfviewer/pdfviewer?sid="+queryString["sid"]+"&vid="+queryString["vid"];
if (text.match(/^Y1\s+-(.*)$/m)) {
risDate = text.match(/^Y1\s+-(.*)$/m);
}
if (!text.match(/^TY\s\s-/m)) { text = text+"\nTY - JOUR\n"; }
// load translator for RIS
var translator = Zotero.loadTranslator("import");
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text);
Zotero.debug(text);
translator.setHandler("itemDone", function(obj, item) {
if (text.match(/^L3\s+-\s*(.*)/m)) {
item.DOI = text.match(/^L3\s+\-\s*(.*)/m)[1];
@ -70,42 +67,56 @@ function downloadFunction(text, url) {
if (text.match(/^T1\s+-/m)) {
item.title = text.match(/^T1\s+-\s*(.*)/m)[1];
}
// If we have a double year, eliminate one
var year = item.date.match(/\d{4}/);
if (year && item.date.replace(year[0],"").indexOf(year[0]) !== -1) {
item.date = item.date.replace(year[0],"");
// Get the accession number from URL or elsewhere
if (an) {
an = an[1];
item.callNumber = an;
} else {
an = item.url.match(/AN=([0-9]+)/);
if (an) an = an[1];
}
// RIS translator tries to download the link in "UR" this leads to unhappyness
item.attachments = [];
if (risDate) {
var year = risDate[1].match(/\d{4}/);
var extra = risDate[1].match(/\/([^\/]+)$/);
// If we have a double year in risDate, use last section
if (year && extra && extra[1].indexOf(year[0]) !== -1) {
item.date = extra[1];
}
}
// RIS translator tries to download the link in "UR"
item.attachments = [];
// But keep the stable link as a link attachment
if(item.url) {
item.attachments.push({url: item.url,
// Trim the ⟨=cs suffix -- EBSCO can't find the record with it!
item.url = item.url.replace(/(AN=[0-9]+)⟨=[a-z]{2}/,"$1");
item.attachments.push({url: item.url+"&scope=cite",
title: "EBSCO Record",
mimeType: "text/html",
snapshot: false});
item.url = "";
}
// A lot of extra info is jammed into notes by the RIS translator
item.notes = [];
Zotero.Utilities.doGet(pdf, function (text) {
//Z.debug(text);
// Since order of requests might matter, let's grab the stable link, then the PDF
Zotero.Utilities.doGet(item.url, function (doc) { Zotero.Utilities.doGet(pdf, function (text) {
var realpdf = text.match(/<embed id="pdfEmbed"[^>]*>/);
if(realpdf) {
realpdf = text.match(/<embed[^>]*src="([^"]+)"/);
if (realpdf) {
realpdf = realpdf[1];
item.attachments.push({url:realpdf.replace(/&amp;/g, "&"),
realpdf = realpdf[1].replace(/&amp;/g, "&").replace(/K=\d+/,"K="+an);
Zotero.debug("PDF for "+item.title+": "+realpdf);
item.attachments.push({url:realpdf,
title: "EBSCO Full Text",
mimeType:"application/pdf"});
}
}
}, function () { item.complete(); });
}, function () { item.complete(); }); }, function () { return true; });
});
translator.translate();
Zotero.done();
}
var host;
@ -159,16 +170,15 @@ function doWeb(doc, url) {
var run = function(urls, infos) {
var url, info;
if (urls.length == 0 || folderInfos.length == 0) {
if (urls.length == 0 || infos.length == 0) {
Zotero.done();
return true;
}
url = urls.shift();
info = infos.shift();
Zotero.Utilities.processDocuments(url,
function (newDoc) { doDelivery(doc, nsResolver, info); },
function () {run(urls, infos);
});
function (newDoc) { doDelivery(doc, nsResolver, info, function () { run(urls, infos) }); },
function () { return true; });
};
run(urls, infos);
@ -177,30 +187,37 @@ function doWeb(doc, url) {
});
} else {
/* Individual record. Record key exists in attribute for add to folder link in DOM */
doDelivery(doc, nsResolver, null);
doDelivery(doc, nsResolver, null, function () { Zotero.done(); return true; });
Zotero.wait();
}
}
function doDelivery(doc, nsResolver, folderData) {
function doDelivery(doc, nsResolver, folderData, onDone) {
if(folderData === null) {
/* Get the db, AN, and tag from ep.clientData instead */
var script;
var scripts = doc.evaluate('//script[@type="text/javascript"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
while (script = scripts.iterateNext().textContent) {
if (script.indexOf("var ep") > -1) { break; }
script = "";
var clientData = script.match(/var ep\s*=\s*({[^;]*});/);
if (clientData) break;
}
if (!clientData) {return false;}
/* We now have the script containing ep.clientData */
/* The JSON is technically invalid, since it doesn't quote the
attribute names-- we pull out the valid bit inside it. */
var clientData = script.match(/var ep\s*=\s*({[^;]*});/);
if (!clientData) { return false; }
clientData = clientData[1].match(/"currentRecord"\s*:\s*({[^}]*})/);
/* If this starts throwing exceptions, we should probably start try-elsing it */
folderData = JSON.parse(clientData[1]);
} else {
/* Ditto for this. */
// The attributes are a little different
folderData = JSON.parse(folderData);
folderData.Db = folderData.db;
folderData.Term = folderData.uiTerm;
folderData.Tag = folderData.uiTag;
}
if (script === "") { return; }
/* We now have the script containing ep.clientData */
/* The JSON is technically invalid, since it doesn't quote the
attribute names-- we pull out the valid bit inside it. */
var clientData = script.match(/var ep\s*=\s*({[^;]*});/);
if (!clientData) { return false; }
clientData = clientData[1].match(/"currentRecord"\s*:\s*({[^}]*})/);
/* If this starts throwing exceptions, we should probably start try-elsing it */
clientData = JSON.parse(clientData[1]);
var postURL = doc.evaluate('//form[@id="aspnetForm"]/@action', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
@ -211,9 +228,8 @@ function doDelivery(doc, nsResolver, folderData) {
);
/* ExportFormat = 1 for RIS file */
postURL = host+"/ehost/delivery/ExportPanelSave/"+clientData.Db+"_"+clientData.Term+"_"+clientData.Tag+"?sid="+queryString["sid"]+"&vid="+queryString["vid"]+"&bdata="+queryString["bdata"]+"&theExportFormat=1";
Zotero.Utilities.HTTP.doGet(postURL, function (text) { downloadFunction(text, postURL); });
postURL = host+"/ehost/delivery/ExportPanelSave/"+folderData.Db+"_"+folderData.Term+"_"+folderData.Tag+"?sid="+queryString["sid"]+"&vid="+queryString["vid"]+"&bdata="+queryString["bdata"]+"&theExportFormat=1";
Zotero.Utilities.HTTP.doGet(postURL, function (text) { downloadFunction(text, postURL); }, onDone);
}
/** BEGIN TEST CASES **/
var testCases = [

View file

@ -11,6 +11,24 @@
"lastUpdated": "2011-07-30 03:19:03"
}
/*
Google Blogs Translator
Copyright (C) 2011 Avram Lyon, ajlyon@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function detectWeb(doc, url) {
return "multiple";
}

View file

@ -2,7 +2,7 @@
"translatorID": "594ebe3c-90a0-4830-83bc-9502825a6810",
"label": "ISI Web of Knowledge",
"creator": "Michael Berkowitz, Avram Lyon",
"target": "(WOS_GeneralSearch|product=WOS|product=CABI)",
"target": "^https?://[^/]*webofknowledge\\.com/",
"minVersion": "2.1",
"maxVersion": "",
"priority": 100,
@ -12,9 +12,9 @@
}
function detectWeb(doc, url) {
if ((doc.title.indexOf("Web of Science Results") != -1) | (doc.title.indexOf("CABI Results") != -1)) {
if (url.indexOf("full_record.do") !== -1) {
return "multiple";
} else if (url.indexOf("full_record.do") != -1) {
} else if ((doc.title.indexOf(" Results") !== -1)) {
return "journalArticle";
}
}
@ -55,13 +55,24 @@ function fetchIds(ids, url) {
var product = url.match("product=([^\&]+)\&")[1];
Zotero.Utilities.processDocuments(ids, function (newDoc) {
var url = newDoc.location.href;
var sid = newDoc.evaluate('//input[@name="selectedIds"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
var nid = newDoc.evaluate('//input[@name="SID"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
var post2 = 'product='+product+'&product_sid=' + nid + '&plugin=&product_st_thomas=http://esti.isiknowledge.com:8360/esti/xrpc&export_ref.x=0&export_ref.y=0';
var post = 'action=go&mode=quickOutput&product='+product+'&SID=' + nid + '&format=ref&fields=BibAbs&mark_id='+product+'&count_new_items_marked=0&selectedIds=' + sid + '&qo_fields=bib&endnote.x=95&endnote.y=12&save_options=default';
Zotero.Utilities.doPost('http://apps.isiknowledge.com/OutboundService.do', post, function (text, obj) {
Zotero.Utilities.doPost('http://pcs.isiknowledge.com/uml/uml_view.cgi', post2, function (text, obj) {
//Zotero.debug(text);
var names = ["recordID", "colName", "SID", "selectedIds", "sortBy", "qid", "product" ];
var values = {};
var n;
for each (n in names) {
values[n] = newDoc.evaluate('//input[@name="'+n+'"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
}
var post2 = 'locale=en_US&fileOpt=fieldtagged'+
'&colName=' + values.colName + '&action=saveDataToRef'+
'&qid='+values.qid+'&sortBy='+values.sortBy.replace(/;/g,"%3;")+
'&SID='+values.SID+'&product='+values.product+'&filters=FUNDING+SUBJECT_CATEGORY+JCR_CATEGORY+LANG+IDS+PAGEC+SABBR+CITREFC+ISSN+PUBINFO+KEYWORDS+CITTIMES+ADDRS+CONFERENCE_SPONSORS+DOCTYPE+ABSTRACT+CONFERENCE_INFO+SOURCE+TITLE+AUTHORS++&numRecords=1&locale=en_US';
var post = 'action=go&viewType=fullRecord&product='+values.product
+'&mark_id='+values.product+'&colName=' + values.colName
+'&recordID='+values.recordID.replace(/;/g,"%3;")
+'&sortBy='+values.sortBy.replace(/;/g,"%3;")+'&mode=outputService'
+'&qid='+values.qid+'&SID='+values.SID+
+'&format=saveToRef&filters=FUNDING+SUBJECT_CATEGORY+JCR_CATEGORY+LANG+IDS+PAGEC+SABBR+CITREFC+ISSN+PUBINFO+KEYWORDS+CITTIMES+ADDRS+CONFERENCE_SPONSORS+DOCTYPE+ABSTRACT+CONFERENCE_INFO+SOURCE+TITLE+AUTHORS++&selectedIds=3&mark_to=&mark_from=&count_new_items_marked=0&value%28record_select_type%29=selrecords&marked_list_candidates=3&LinksAreAllowedRightClick=CitedRefList.do&LinksAreAllowedRightClick=CitingArticles.do&LinksAreAllowedRightClick=OneClickSearch.do&LinksAreAllowedRightClick=full_record.do&fields_selection=FUNDING+SUBJECT_CATEGORY+JCR_CATEGORY+LANG+IDS+PAGEC+SABBR+CITREFC+ISSN+PUBINFO+KEYWORDS+CITTIMES+ADDRS+CONFERENCE_SPONSORS+DOCTYPE+ABSTRACT+CONFERENCE_INFO+SOURCE+TITLE+AUTHORS++&save_options=fieldtagged';
Zotero.Utilities.doPost('http://apps.webofknowledge.com/OutboundService.do',post, function (text, obj) {
Zotero.Utilities.doPost('http://ets.webofknowledge.com/ETS/saveDataToRef.do',post2, function (text, obj) {
importer.setString(text);
importer.setHandler("itemDone", function (obj, item) {
item.attachments = [{url: url, type: "text/html", title: "ISI Web of Knowledge Record"}];
@ -87,8 +98,8 @@ function detectImport() {
return false;
}
}
}
}
}
}
function processTag(item, field, content) {
@ -140,8 +151,8 @@ function processTag(item, field, content) {
}
var year = item.date.match(/\d{4}/);
// If we have a double year, eliminate one
if (year && item.date.replace(year,"").indexOf(year) !== -1)
item.date = item.date.replace(year,"");
if (year && item.date.replace(year[0],"").indexOf(year[0]) !== -1)
item.date = item.date.replace(year[0],"");
} else if (field == "VL") {
item.volume = content;
} else if (field == "IS") {
@ -863,4 +874,4 @@ var testCases = [
]
}
]
/** END TEST CASES **/
/** END TEST CASES **/

View file

@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
"lastUpdated": "2011-08-02 02:41:31"
"lastUpdated": "2011-08-03 11:08:32"
}
/*
@ -102,8 +102,8 @@ function scrape (doc) {
var record_rows = doc.evaluate('//div[@class="display_record_indexing_row"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
var abstract_link = doc.evaluate('//a[@class="formats_base_sprite format_abstract"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
if (!record_rows && abstract_link) {
Zotero.Utilities.processDocuments(abstract_link.href, scrape, function() {Zotero.done();});
return true;
Zotero.Utilities.processDocuments(abstract_link.href, scrape, function() {Zotero.done();});
return true;
}
var url = doc.location.href;
@ -191,11 +191,15 @@ function scrape (doc) {
case "Copyright":
item.rights = value; break;
case "Database":
value = value.replace(/^\d\s+databasesView list\s+Hide list/,'');
value = value.replace(/(ProQuest.*)(ProQuest.*)/,'$1; $2');
item.libraryCatalog = value; break;
case "Document URL":
item.attachments.push({url:value.replace(/\?accountid=[0-9]+$/,''),
item.attachments.push({url:value.replace(/\?accountid=[0-9]+$/,'')+"/abstract",
title: "ProQuest Record",
mimeType: "text/html"}); break;
case "ProQuest Document ID":
item.callNumber = value; break;
case "Language of Publication":
item.language = value; break;
case "Section":
@ -337,6 +341,7 @@ var testCases = [
"publisher": "Menno Simons College",
"ISSN": "00084697",
"language": "English",
"callNumber": "213445241",
"rights": "Copyright Peace Research May 1995",
"proceedingsTitle": "Peace Research",
"libraryCatalog": "ProQuest",

View file

@ -11,6 +11,24 @@
"lastUpdated":"2009-12-31 16:20:00"
}
/*
Tatknigafund Translator
Copyright (C) 2009-2011 Avram Lyon, ajlyon@gmail.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
This translator is designed for the Tatar Book Repository, http://www.tatknigafund.ru/ .
At present, it imports the limited metadata that the repository exposes about its books,
@ -108,4 +126,4 @@ function doWeb(doc, url) {
item.complete();
}, function() {Zotero.done();});
Zotero.wait();
}
}

View file

@ -1,47 +1,44 @@
{
"translatorID":"9499c586-d672-42d6-9ec4-ee9594dcc571",
"translatorType":4,
"label":"The Hindu",
"creator":"Prashant Iyengar and Michael Berkowitz",
"target":"http://(www.)?hindu.com",
"minVersion":"1.0.0b4.r5",
"maxVersion":"",
"priority":100,
"inRepository":true,
"lastUpdated":"2008-05-08 20:30:00"
"translatorID": "9499c586-d672-42d6-9ec4-ee9594dcc571",
"label": "The Hindu",
"creator": "Prashant Iyengar and Michael Berkowitz",
"target": "^http://(www\\.)?hindu\\.com",
"minVersion": "1.0.0b4.r5",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"lastUpdated": "2011-08-16 03:36:22"
}
function detectWeb(doc, url) {
if (doc.evaluate('//h2[@class="r"]/a[@class="l"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
return "multiple";
} else {
return "newspaperArticle";
return "multiple";
} else {
return "newspaperArticle";
}
}
function regexMeta(str, item) {
var re = /NAME\=\"([\w\W]*?)\"\s+CONTENT\=\"([\w\W]*?)\"/;
var stuff = str.match(re);
if (stuff)
{
if (stuff[1] == "PAGEHEAD") {
if (stuff)
{
if (stuff[1] == "PAGEHEAD") {
item.section = stuff[2].split(/\s+/)[0];
}
if (stuff[1] == "ZONE") {
item.place = stuff[2].split(/\s+/)[0];
}
if (stuff[1] == "EXPORTTIME") {
item.date = stuff[2].split(/\s+/)[0];
}
if (stuff[1] == "PAGENUMBER") {
item.pages = stuff[2].split(/\s+/)[0];
}
}
}
function doWeb(doc, url) {
var arts = new Array();
if (detectWeb(doc, url) == "multiple") {
@ -68,20 +65,17 @@ function doWeb(doc, url) {
var t = /\<TITLE\>[\w\W]*\:([\w\W]*?)<\/TITLE/;
newItem.title = Zotero.Utilities.unescapeHTML(Zotero.Utilities.capitalizeTitle(text.match(t)[1]));
var ti = /\<FONT color\=black\>(.*)?\<\/FONT\>/;
newItem.date = text.match(ti)[1];
var auth = /\<font class\=storyhead[\w\W]*?justify\>([\w\W]*?)\<p\>/;
if (text.match(auth))
{
//newItem.author=Zotero.Utilities.cleanAuthor(text.match(auth)[1]);
cleanauth=Zotero.Utilities.cleanTags(text.match(auth)[1]);
newItem.creators.push(Zotero.Utilities.cleanAuthor(cleanauth, "author"));
//newItem.author=Zotero.Utilities.cleanAuthor(text.match(auth)[1]);
cleanauth=Zotero.Utilities.cleanTags(text.match(auth)[1]);
newItem.creators.push(Zotero.Utilities.cleanAuthor(cleanauth, "author"));
}
newItem.websiteTitle="The Hindu";
newItem.edition="Online";
newItem.publicationTitle="The Hindu";
newItem.attachments = [{"title":"The Hindu Snapshot", mimeType:"text/html", url:art}];
//hooray for real meta tags!
var meta = /<META NAME[\w\W]*?\>/g;
@ -94,4 +88,36 @@ function doWeb(doc, url) {
});
Zotero.wait();
}
}
}/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://www.hindu.com/lr/2004/01/04/stories/2004010400030100.htm",
"items": [
{
"itemType": "newspaperArticle",
"creators": [
{
"firstName": "To be torn between two languages, discovers H. MASUD TAJ, is to drown soul-deep in the",
"lastName": "present",
"creatorType": "author"
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [],
"publicationTitle": "The Hindu",
"url": "http://www.hindu.com/lr/2004/01/04/stories/2004010400030100.htm",
"title": "Falling at the speed of light",
"websiteTitle": "The Hindu",
"date": "01-01-2004",
"pages": "01",
"place": "CHEN",
"section": "LITERARY",
"libraryCatalog": "The Hindu"
}
]
}
]
/** END TEST CASES **/

View file

@ -1,14 +1,15 @@
{
"translatorID":"6b0b11a6-9b77-4b49-b768-6b715792aa37",
"translatorType":4,
"label":"Toronto Star",
"creator":"Adam Crymble",
"target":"http://www.thestar.com",
"minVersion":"1.0.0b4.r5",
"maxVersion":"",
"priority":100,
"inRepository":true,
"lastUpdated":"2008-08-06 17:00:00"
"translatorID": "6b0b11a6-9b77-4b49-b768-6b715792aa37",
"label": "Toronto Star",
"creator": "Adam Crymble, Avram Lyon",
"target": "^http://www\\.thestar\\.com",
"minVersion": "2.1.9",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcs",
"lastUpdated": "2011-08-18 01:03:09"
}
function detectWeb(doc, url) {
@ -22,6 +23,7 @@ function detectWeb(doc, url) {
//Toronto Star translator. code by Adam Crymble
function scrape(doc, url) {
if (!ZU) ZU = Zotero.Utilities;
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
@ -29,60 +31,32 @@ function scrape(doc, url) {
} : null;
var newItem = new Zotero.Item("newspaperArticle");
if (doc.title.match("TheStar.com | ")) {
var lineBreak = doc.title.lastIndexOf(" |");
newItem.section = doc.title.substr(14, lineBreak-14);
var date = doc.evaluate('//span[@class="ts-label_published"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
if(date) {
newItem.date = date.textContent.replace(/Published On/,'');
}
var byLine = doc.evaluate('//div[@id="ctl00_ContentPlaceHolder_article_NavWebPart_Article"]/div/span', doc, nsResolver, XPathResult.ANY_TYPE, null);
var abstractNote = doc.evaluate('//meta[@property="og:description"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
if(abstractNote) newItem.abstractNote = abstractNote.content;
var nextEntry;
while (nextEntry = byLine.iterateNext()) {
if (nextEntry.textContent.match(" PM") || nextEntry.textContent.match(" AM") && nextEntry.textContent.match(/\d\d\d\d/)) {
newItem.date = nextEntry.textContent;
} else {
newItem.abstractNote = nextEntry.textContent;
}
var authorNode = doc.evaluate('//div[@class="td-author"]/span[@class="ts-label"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
var author;
while (author = authorNode.iterateNext()) {
author = author.textContent;
if (author.toUpperCase() == author) author = ZU.capitalizeTitle(author.toLowerCase(),true);
newItem.creators.push(ZU.cleanAuthor(author.replace(/^By\s*/,'')));
}
var author1 = new Array();
var k = 0;
if (doc.evaluate('//span[@class="articleAuthor"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
var author = doc.evaluate(xPathAuthor, doc, nsResolver, XPathResult.ANY_TYPE, null);
var authorName;
while (authorName = author.iterateNext()) {
author1.push(authorName.textContent);
k++;
}
if (k>1) {
for (k in author1) {
var words = author1[k].toLowerCase().split(/\s/);
for (var i in words) {
words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase();
}
author1[k] = words.join(" ");
newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[k], "author"));
}
} else {
var words = author1[0].toLowerCase().split(/\s/);
for (var i in words) {
words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase();
}
author1[0] = words.join(" ");
newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[0], "author"));
}
}
var xPathTitle = '//span[@class="headlineArticle"][@id="ctl00_ContentPlaceHolder_article_NavWebPart_Article_ctl00___Title__"]';
var xPathTitle = '//h1[@class="ts-article_header"]';
newItem.title = doc.evaluate(xPathTitle, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
// The section is the first listed keyword
var keywords = doc.evaluate('//meta[@name="Keywords"][@content]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
if (keywords) newItem.section = keywords.content.split(',').shift();
newItem.attachments.push({document:doc, title:"Toronto Star Snapshot"});
newItem.url = doc.location.href;
newItem.publicationTitle = "The Toronto Star";
newItem.ISSN = "0319-0781";
@ -113,9 +87,74 @@ function doWeb(doc, url) {
for (var i in items) {
articles.push(i);
}
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
Zotero.wait();
} else {
articles = [url];
scrape(doc, url);
}
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
Zotero.wait();
}
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://www.thestar.com/news/world/article/755917--france-should-ban-muslim-veils-commission-says?bn=1",
"items": [
{
"itemType": "newspaperArticle",
"creators": [],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [
{
"document": false,
"title": "Toronto Star Snapshot"
}
],
"date": "2010/01/26 10:34:00",
"abstractNote": "France's National Assembly should pass a resolution denouncing full Muslim face veils and then vote the strictest law possible to ban women from wearing them, a parliamentary commission proposed on Tuesday.",
"title": "France should ban Muslim veils, commission says",
"section": "News",
"url": "http://www.thestar.com/news/world/article/755917--france-should-ban-muslim-veils-commission-says?bn=1",
"publicationTitle": "The Toronto Star",
"ISSN": "0319-0781",
"libraryCatalog": "Toronto Star"
}
]
},
{
"type": "web",
"url": "http://www.thestar.com/business/cleanbreak/article/1031551--hamilton-ontario-should-reconsider-offshore-wind",
"items": [
{
"itemType": "newspaperArticle",
"creators": [
{
"firstName": "Tyler",
"lastName": "Hamilton"
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [
{
"document": false,
"title": "Toronto Star Snapshot"
}
],
"date": "2011/07/29 21:43:00",
"abstractNote": "Theres no reason why Ontario cant regain the momentum it once had.",
"title": "Hamilton: Ontario should reconsider offshore wind",
"section": "Business",
"url": "http://www.thestar.com/business/cleanbreak/article/1031551--hamilton-ontario-should-reconsider-offshore-wind",
"publicationTitle": "The Toronto Star",
"ISSN": "0319-0781",
"libraryCatalog": "Toronto Star",
"shortTitle": "Hamilton"
}
]
}
]
/** END TEST CASES **/

View file

@ -8,7 +8,8 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
"lastUpdated": "2011-07-20 17:14:04"
"browserSupport": "g",
"lastUpdated": "2011-08-18 01:25:48"
}
function detectWeb(doc, url){
@ -51,7 +52,13 @@ function doWeb(doc, url){
}
Zotero.Utilities.processDocuments(urls, scrape, function () { Zotero.done(); });
} else { //single article
scrape(doc, url);
if (url.indexOf("/pdf/") != -1) {
url = url.replace(/\/pdf\/.+$/,'/abstract');
Z.debug("Redirecting to abstract page: "+url);
Zotero.Utilities.processDocuments([ url ], scrape, function () { Zotero.done(); });
} else {
scrape(doc, url);
}
}
Zotero.wait();
@ -424,6 +431,74 @@ var testCases = [
"libraryCatalog": "Wiley Online Library"
}
]
},
{
"type": "web",
"url": "http://onlinelibrary.wiley.com/doi/10.1002/14651858.CD007019.pub2/pdf/standard",
"items": [
{
"itemType": "journalArticle",
"creators": [
{
"firstName": "Michelle",
"lastName": "Butler",
"creatorType": "author"
},
{
"firstName": "Rita",
"lastName": "Collins",
"creatorType": "author"
},
{
"firstName": "Jonathan",
"lastName": "Drennan",
"creatorType": "author"
},
{
"firstName": "Phil",
"lastName": "Halligan",
"creatorType": "author"
},
{
"firstName": "Dónal P",
"lastName": "O'Mathúna",
"creatorType": "author"
},
{
"firstName": "Timothy J",
"lastName": "Schultz",
"creatorType": "author"
},
{
"firstName": "Ann",
"lastName": "Sheridan",
"creatorType": "author"
},
{
"firstName": "Eileen",
"lastName": "Vilis",
"creatorType": "author"
}
],
"notes": [],
"tags": [],
"seeAlso": [],
"attachments": [
{
"url": false,
"title": "Wiley Full Text PDF",
"mimeType": "application/pdf"
}
],
"url": "http://onlinelibrary.wiley.com/doi/10.1002/14651858.CD007019.pub2/abstract",
"DOI": "10.1002/14651858.CD007019.pub2",
"publisher": "John Wiley & Sons, Ltd",
"ISSN": "1465-1858",
"title": "Hospital nurse staffing models and patient and staffrelated outcomes",
"language": "en",
"libraryCatalog": "Wiley Online Library"
}
]
}
]
/** END TEST CASES **/

View file

@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
"lastUpdated": "2011-08-02 22:31:22"
"lastUpdated": "2011-08-03 10:41:53"
}
/*
@ -32,7 +32,7 @@
function detectWeb(doc, url){
if (url.match(/\/item.asp/)) {
return "journalArticle";
} else if (url.match(/\/(query_results|contents|org_items)\.asp/)){
} else if (url.match(/\/(query_results|contents|org_items|itembox_items)\.asp/)){
return "multiple";
}
}