From 440d692d33d03abdcf2567bd0568ac3b356e21d4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 29 Aug 2011 21:00:24 +0000 Subject: [PATCH] Update translators from GitHub --- repotime.txt | 2 +- translators/APA PsycNET.js | 3 +- translators/COinS.js | 29 ++- translators/Cambridge Journals Online.js | 3 +- translators/CrossRef.js | 4 +- translators/Highwire 2.0.js | 3 +- translators/Institute of Physics.js | 3 +- translators/JBJS Am.js | 201 ++++++++++++++++++ translators/MARC.js | 12 +- translators/MIT Press Journals.js | 4 +- translators/Musee du Louvre.js | 3 +- ...ry of Australia - Australian Newspapers.js | 166 +++++++++++++++ translators/PLoS Journals.js | 3 +- translators/ProQuest.js | 3 +- translators/Project Gutenberg.js | 3 +- translators/Project MUSE.js | 127 +++++++---- translators/RDF.js | 11 +- translators/Radio Liberty.js | 72 +++++-- translators/The Hindu.js | 3 +- translators/Wiley Online Library.js | 22 +- translators/cablegatesearch.net.js | 89 ++++++++ translators/eLibrary.ru.js | 3 +- translators/unAPI.js | 82 +++++-- 23 files changed, 739 insertions(+), 112 deletions(-) create mode 100644 translators/JBJS Am.js create mode 100644 translators/National Library of Australia - Australian Newspapers.js create mode 100644 translators/cablegatesearch.net.js diff --git a/repotime.txt b/repotime.txt index c12d05019..d4a22af37 100644 --- a/repotime.txt +++ b/repotime.txt @@ -1 +1 @@ -2011-08-21 05:25:00 +2011-08-29 18:20:00 diff --git a/translators/APA PsycNET.js b/translators/APA PsycNET.js index 449a8d554..14b50cdc0 100644 --- a/translators/APA PsycNET.js +++ b/translators/APA PsycNET.js @@ -6,9 +6,10 @@ "minVersion": "2.1", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-07-29 01:03:06" + "lastUpdated": "2011-08-22 22:43:11" } function detectWeb(doc, url) { diff --git a/translators/COinS.js b/translators/COinS.js index e61239422..0506da0bf 100644 --- a/translators/COinS.js +++ b/translators/COinS.js @@ -7,14 +7,14 @@ "maxVersion": "", "priority": 300, "inRepository": true, - "translatorType": 4, + "translatorType": 6, "browserSupport": "gcs", - "lastUpdated": "2011-07-01 19:16:28" + "lastUpdated": "2011-08-25 23:46:18" } function detectWeb(doc, url) { var spanTags = doc.getElementsByTagName("span"); - + var encounteredType = false; // This and the x: prefix in the XPath are to work around an issue with pages @@ -83,13 +83,13 @@ function completeCOinS(newItems, couldUseFullItems, doc) { for(var i in newItems) { selectArray[i] = newItems[i].title; } - + Zotero.selectItems(selectArray, function (selectArray) { - var useIndices = new Array(); - for(var i in selectArray) { - useIndices.push(i); - } - completeItems(newItems, useIndices, couldUseFullItems); + var useIndices = new Array(); + for(var i in selectArray) { + useIndices.push(i); + } + completeItems(newItems, useIndices, couldUseFullItems); }); } else if(newItems.length) { completeItems(newItems, [0], couldUseFullItems); @@ -195,6 +195,15 @@ function doWeb(doc, url) { } } +function doExport() { + var item; + var co; + + while (item = Zotero.nextItem()) { + co = Zotero.Utilities.createContextObject(item, "1.0"); + Zotero.write("\n"); + } +} /** BEGIN TEST CASES **/ var testCases = [ { @@ -269,4 +278,4 @@ var testCases = [ ] } ] -/** END TEST CASES **/ \ No newline at end of file +/** END TEST CASES **/ diff --git a/translators/Cambridge Journals Online.js b/translators/Cambridge Journals Online.js index 8ee29dca6..9820e07a3 100644 --- a/translators/Cambridge Journals Online.js +++ b/translators/Cambridge Journals Online.js @@ -6,9 +6,10 @@ "minVersion": "2.1", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-07-26 01:43:28" + "lastUpdated": "2011-08-22 22:29:49" } function detectWeb(doc, url) { diff --git a/translators/CrossRef.js b/translators/CrossRef.js index 1b3607520..9362a450e 100644 --- a/translators/CrossRef.js +++ b/translators/CrossRef.js @@ -9,7 +9,7 @@ "priority":90, "browserSupport":"gcs", "inRepository":true, - "lastUpdated":"2011-06-23 08:05:22" + "lastUpdated":"2011-07-29 18:13:47" } /* CrossRef uses unixref; documentation at http://www.crossref.org/schema/documentation/unixref1.0/unixref.html */ @@ -24,7 +24,7 @@ function detectSearch(item) { } function fixAuthorCapitalization(string) { - if(string.toUpperCase() == string) { + if(typeof string === "string" && string.toUpperCase() === string) { string = string.toLowerCase().replace(/\b[a-z]/g, function(m) { return m[0].toUpperCase() }); } return string; diff --git a/translators/Highwire 2.0.js b/translators/Highwire 2.0.js index f88188829..481ea84c6 100644 --- a/translators/Highwire 2.0.js +++ b/translators/Highwire 2.0.js @@ -6,9 +6,10 @@ "minVersion": "2.1", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-07-29 01:21:09" + "lastUpdated": "2011-08-22 22:43:24" } /* diff --git a/translators/Institute of Physics.js b/translators/Institute of Physics.js index 9b095b8c4..2ed9859e0 100644 --- a/translators/Institute of Physics.js +++ b/translators/Institute of Physics.js @@ -6,9 +6,10 @@ "minVersion": "2.1", "maxVersion": "", "priority": 99, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-07-30 12:25:40" + "lastUpdated": "2011-08-22 22:29:32" } function detectWeb(doc, url) { diff --git a/translators/JBJS Am.js b/translators/JBJS Am.js new file mode 100644 index 000000000..19397c76f --- /dev/null +++ b/translators/JBJS Am.js @@ -0,0 +1,201 @@ +{ + "translatorID": "8a325571-c2a8-417a-8a25-b1dca65154c3", + "label": "JBJS Am", + "creator": "Max Gordon and Avram Lyon", + "target": "^https?://(?:www\\.)?jbjs.org[^\\/]*/(?:searchresults|issue|article)\\.aspx", + "minVersion": "1.0", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcs", + "lastUpdated": "2011-08-26 00:33:07" +} + +/* + JBJS Translator + Copyright (C) 2011 Max Gordon and Avram Lyon + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + +/* + This translator is derived from the Wiley Online Library translator, which + was first written by Sean Takats and Michael Berkowitz. + */ + +function detectWeb(doc, url){ + var namespace = doc.documentElement.namespaceURI; + var nsResolver = namespace ? function(prefix) { + if (prefix == 'x') return namespace; else return null; + } : null; + + if (url.match(/\/issue|\/searchresults/)) { + return "multiple"; + } else return "journalArticle"; +} + +function doWeb(doc, url){ + var namespace = doc.documentElement.namespaceURI; + var nsResolver = namespace ? function(prefix) { + if (prefix == 'x') return namespace; else return null; + } : null; + var host = 'http://' + doc.location.host + "/"; + + var urls = new Array(); + if(detectWeb(doc, url) == "multiple") { //search + var title; + var availableItems = new Array(); + var articles = doc.evaluate('//div[@class="articleContent"]//a[@class="relatedArticle"]', doc, nsResolver, XPathResult.ANY_TYPE, null); + //Zotero.debug(articles); + var article = false; + while (article = articles.iterateNext()) { + availableItems[article.href] = article.textContent; + } + Zotero.selectItems(availableItems, function (items) { + if(!items) { + return true; + } + for (var i in items) { + urls.push(i); + } + Zotero.Utilities.processDocuments(urls, scrape, function () { Zotero.done(); }); + }); + } else { //single article + scrape(doc, url); + } + Zotero.wait(); +} + +function scrape(doc,url) +{ + var namespace = doc.documentElement.namespaceURI; + var nsResolver = namespace ? function(prefix) { + if (prefix == 'x') return namespace; else return null; + } : null; + + var newItem=new Zotero.Item("journalArticle"); + var temp; + var xpath; + var row; + var rows; + + newItem.url = doc.location.href; + var metaTags = doc.getElementsByTagName("meta"); + + var pages = [false, false]; + var doi = false; + var pdf = false; + var html = false; + for (var i = 0; i< metaTags.length; i++) { + var tag = metaTags[i].getAttribute("name"); + var value = metaTags[i].getAttribute("content"); + //Zotero.debug(pages + pdf + html); + //Zotero.debug("Have meta tag: " + tag + " => " + value); + switch (tag) { + // Google. + case "citation_journal_title": if (!newItem.publicationTitle) newItem.publicationTitle = value; break; + case "citation_journal_abbrev": if (!newItem.journalAbbreviation) newItem.journalAbbreviation = value; break; + case "citation_author": + newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); + case "citation_title": if (!newItem.title) newItem.title = value; break; + case "citation_publisher": if (!newItem.publisher) newItem.publisher = value; break; + case "citation_date": if (!newItem.date && value != "NaN" && value != "") newItem.date = value; break; + case "citation_year": if (!newItem.date && value != "NaN" && value != "") newItem.date = value; break; + case "citation_volume": if (!newItem.volume && value != "NaN" && value != "") newItem.volume = value; break; + case "citation_issue": if (!newItem.issue && value != "NaN" && value != "") newItem.issue = value; break; + case "citation_firstpage": if (!pages[0] && value != "NaN" && value != "") pages[0] = value; break; + case "citation_lastpage": if (!pages[1] && value != "NaN" && value != "") pages[1] = value; break; + case "citation_issn": if (!newItem.ISSN && value != "NaN" && value != "") newItem.ISSN = value; break; + case "citation_isbn": if (!newItem.ISBN && value != "NaN" && value != "") newItem.ISBN = value; break; + case "citation_doi": if (!newItem.DOI) newItem.DOI = value; break; + case "citation_reference": break; // These are citations in the paper-- Z doesn't use them + default: + Zotero.debug("Ignoring meta tag: " + tag + " => " + value); + } + } + + if (pages[0] && pages[1]) newItem.pages = pages.join('-') + else newItem.pages = pages[0] ? pages[1] : (pages[1] ? pages[1] : ""); + + // Get the abstract + var abstractNode = doc.evaluate('//div[h2/text()="Abstract"]/following-sibling::div[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); + if (abstractNode) newItem.abstractNote = abstractNode.textContent; + + newItem.complete(); +} + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "http://www.jbjs.org/article.aspx?articleid=35426", + "items": [ + { + "itemType": "journalArticle", + "creators": [ + { + "firstName": "Delamarter", + "lastName": "Rick", + "creatorType": "author" + }, + { + "firstName": "Zigler", + "lastName": "Jack E. ", + "creatorType": "author" + }, + { + "firstName": "Balderston", + "lastName": "Richard A. ", + "creatorType": "author" + }, + { + "firstName": "Cammisa", + "lastName": "Frank P. ", + "creatorType": "author" + }, + { + "firstName": "Goldstein", + "lastName": "Jeffrey A. ", + "creatorType": "author" + }, + { + "firstName": "Spivak", + "lastName": "Jeffrey M. ", + "creatorType": "author" + } + ], + "notes": [], + "tags": [], + "seeAlso": [], + "attachments": [], + "url": "http://www.jbjs.org/article.aspx?articleid=35426", + "publicationTitle": "The Journal of Bone and Joint Surgery (American)", + "journalAbbreviation": "JBJS", + "title": "Prospective, Randomized, Multicenter Food and Drug Administration Investigational Device Exemption Study of the ProDisc-L Total Disc Replacement Compared with Circumferential Arthrodesis for the Treatment of Two-Level Lumbar Degenerative Disc Disease: Results at Twenty-four Months", + "volume": "93", + "issue": "8", + "date": "4/20/2011 12:00:00 AM", + "ISSN": "0021-9355", + "DOI": "10.2106/JBJS.I.00680", + "publisher": "The Journal of Bone and Joint Surgery", + "pages": "705-715", + "abstractNote": "Background: \n Disc replacement arthroplasty previously has been shown to be an effective alternative to spine fusion for the treatment of single-level lumbar degenerative disc disease. The purpose of the present study was to determine the twenty-four-month results of a clinical trial of the ProDisc-L total disc replacement as compared with spinal fusion for the treatment of degenerative disc disease at two contiguous vertebral levels from L3 to S1.Methods: \n A total of 237 patients were treated in a randomized controlled trial designed as a non-inferiority study for regulatory application purposes. Blocked randomization was performed with use of a 2:1 ratio of total disc arthroplasty to circumferential arthrodesis. Evaluations, including patient self-assessments, physical and neurological examinations, and radiographic examinations, were performed preoperatively, six weeks postoperatively, and three, six, twelve, eighteen, and twenty-four months postoperatively.Results: \n At twenty-four months, 58.8% (eighty-seven) of 148 patients in the total disc replacement group were classified as a statistical success, compared with 47.8% (thirty-two) of sixty-seven patients in the arthrodesis group; non-inferiority was demonstrated. The mean Oswestry Disability Index in both groups significantly improved from baseline (p < 0.0001); the mean percentage improvement for the total disc replacement group was significantly better than that for the arthrodesis group (p = 0.0282). An established clinical criterion for success, a =15-point improvement in the Oswestry Disability Index from baseline, occurred in 73.2% (109) of 149 patients in the total disc replacement group and 59.7% (thirty-seven) of sixty-two patients in the arthrodesis group. The Short Form-36 physical component scores were significantly better for the total disc replacement group as compared with the arthrodesis group (p = 0.0141 at twenty-four months). Visual analog scale scores for satisfaction significantly favored total disc replacement from three to twenty-four months. At twenty-four months, 78.2% (111) of 142 patients in the total disc replacement group and 62.1% (thirty-six) of fifty-eight patients in the arthrodesis group responded “yes” when asked if they would have the same surgery again. Lumbar spine range of motion on radiographs averaged 7.8° at the superior disc and 6.2° at the inferior disc in patients with total disc replacement. Reduction in narcotics usage significantly favored the total disc replacement group at twenty-four months after surgery (p = 0.0020).Conclusions: \n Despite the relatively short duration of follow-up and design limitations, the present study suggests that two-level lumbar disc arthroplasty is an alternative to and offers clinical advantages in terms of pain relief and functional recovery in comparison with arthrodesis. Longer-term follow-up is needed to determine the risks for implant wear and/or degenerative segment changes.Level of Evidence: \n Therapeutic Level I. See Instructions to Authors for a complete description of levels of evidence.", + "libraryCatalog": "JBJS Am", + "shortTitle": "Prospective, Randomized, Multicenter Food and Drug Administration Investigational Device Exemption Study of the ProDisc-L Total Disc Replacement Compared with Circumferential Arthrodesis for the Treatment of Two-Level Lumbar Degenerative Disc Disease" + } + ] + } +] +/** END TEST CASES **/ diff --git a/translators/MARC.js b/translators/MARC.js index ca12087dd..e38edef86 100644 --- a/translators/MARC.js +++ b/translators/MARC.js @@ -9,7 +9,7 @@ "inRepository": true, "translatorType": 1, "browserSupport": "gcsn", - "lastUpdated": "2011-07-21 17:16:37" + "lastUpdated": "2011-08-22 23:29:49" } function detectImport() { @@ -563,10 +563,12 @@ function doImport() { } } -exports.record = record; -exports.fieldTerminator = fieldTerminator; -exports.recordTerminator = recordTerminator; -exports.subfieldDelimiter = subfieldDelimiter; +var exports = { + "record":record, + "fieldTerminator":fieldTerminator, + "recordTerminator":recordTerminator, + "subfieldDelimiter":subfieldDelimiter +}; /** BEGIN TEST CASES **/ var testCases = [ diff --git a/translators/MIT Press Journals.js b/translators/MIT Press Journals.js index d18ba029f..328eeab61 100644 --- a/translators/MIT Press Journals.js +++ b/translators/MIT Press Journals.js @@ -6,10 +6,10 @@ "minVersion": "1.0.0b4.r5", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "browserSupport": "g", - "lastUpdated": "2011-07-13 12:10:55" + "lastUpdated": "2011-08-22 22:31:06" } function detectWeb(doc, url) { diff --git a/translators/Musee du Louvre.js b/translators/Musee du Louvre.js index 585df8f3d..426c992ab 100644 --- a/translators/Musee du Louvre.js +++ b/translators/Musee du Louvre.js @@ -7,8 +7,9 @@ "minVersion":"1.0.0b4.r5", "maxVersion":"", "priority":100, + "browserSupport":"g", "inRepository":true, - "lastUpdated":"2008-08-21 15:45:00" + "lastUpdated":"2011-08-22 22:44:24" } function detectWeb(doc, url) { diff --git a/translators/National Library of Australia - Australian Newspapers.js b/translators/National Library of Australia - Australian Newspapers.js new file mode 100644 index 000000000..b29bfba6e --- /dev/null +++ b/translators/National Library of Australia - Australian Newspapers.js @@ -0,0 +1,166 @@ +{ + "translatorID": "fcfcfe9c-f6dd-48c6-aef9-61adbba31a4e", + "label": "National Library of Australia - Australian Newspapers", + "creator": "Tim Sherratt", + "target": "^https?://trove\\.nla\\.gov\\.au/(?:newspaper|ndp)/", + "minVersion": "2.0", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "g", + "lastUpdated": "2011-08-24 15:59:48" +} + +/* + National Library of Australia - Australian Newspapers Translator + Copyright (C) 2011 Tim Sherratt (tim@discontents.com.au, @wragge) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +function detectWeb(doc, url) { + if (url.match(/\/newspaper\/result/i) || url.match(/\/ndp\/del\/page/)) { + return "multiple"; + } else if (url.match(/\/ndp\/del\/article\//i)) { + return "newspaperArticle"; + } +} + +function doWeb(doc, url) { + var namespace = doc.documentElement.namespaceURI; + var nsResolver = namespace ? function(prefix) { + if (prefix == 'x') return namespace; else return null; + } : null; + var articles = new Array(); + var items = new Object(); + var nextTitle; + if (detectWeb(doc, url) == "multiple") { + // Search results + if (url.match(/\/newspaper\/result/i)) { + var titles = doc.evaluate('//div[@id="tnewspapers"]/ol/li[@class="article "]/dl/dt/a', doc, nsResolver, XPathResult.ANY_TYPE, null); + // All the articles on a page + } else if (url.match(/\/ndp\/del\/page/)) { + var titles = doc.evaluate('//ul[@class="articles"]/li/h4/a', doc, nsResolver, XPathResult.ANY_TYPE, null); + } + while (nextTitle = titles.iterateNext()) { + if (nextTitle.textContent != '[coming soon]') { + items[nextTitle.href] = nextTitle.textContent; } + } + items = Zotero.selectItems(items); + for (var i in items) { + articles.push(i); + } + } else { + articles = [url]; + } + Zotero.Utilities.processDocuments(articles, scrape, function(){Zotero.done();}); + Zotero.wait(); +} + +function scrape(doc) { + var namespace = doc.documentElement.namespaceURI; + var nsResolver = namespace ? function(prefix) { + if (prefix == 'x') return namespace; else return null; + } : null; + var nextTag, nextImg, nextLine; + var newItem = new Zotero.Item("newspaperArticle"); + newItem.libraryCatalog = 'National Library of Australia - Trove - Australian Newspapers'; + // Get the persistent identifier. + articleId = doc.location.href.match(/http:\/\/[a-z]+\.nla\.gov\.au\/ndp\/del\/article\/(\d+)/)[1]; + newItem.url = 'http://nla.gov.au/nla.news-article' + articleId + // Gather all the basic details + newItem.title = Zotero.Utilities.trimInternal(doc.evaluate('//meta[@name="newsarticle_headline"]/@content', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); + var pubDetails = doc.evaluate('//div[@class="box title"]/strong', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent; + newItem.publicationTitle = pubDetails.match(/(.+?) \(/)[1]; + if (pubDetails.indexOf(':') != -1) { + newItem.place = pubDetails.match(/\((.+?) :/)[1]; + } + newItem.date = doc.evaluate('//div[@class="box issue"]/strong', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent.match(/\w+ (\d{1,2} .+)/)[1]; + newItem.pages = Zotero.Utilities.trim(doc.evaluate('//select[@name="id"]/option[@selected="selected"]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); + // Get tags. + var tags = doc.evaluate('//p[@class="tags"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); + while (nextTag = tags.iterateNext()) { + newItem.tags.push(nextTag.textContent); + } + // Get OCRed text + var OCRLines = doc.evaluate('//p[@class="S8"]/span', doc, nsResolver, XPathResult.ANY_TYPE, null); + var OCRText = ''; + while (nextLine = OCRLines.iterateNext()) { + OCRText = OCRText + nextLine.textContent + '\n'; + } + if (OCRText != '') { + newItem.abstractNote = OCRText; + } + /* Uncomment this section if you want to save jpgs of the article (the pdfs are generally easier to work with). + // Change the number at the end of the string to alter zoom factor - '/3?print=n' + var imgDoc = Zotero.Utilities.retrieveDocument('http://trove.nla.gov.au/ndp/del/printArticleJpg/' + newItem.url.match(/.*?(\d+)/)[1] + '/3?print=n'); + var imgs = imgDoc.evaluate('//img[@id="articleImg"]', imgDoc, nsResolver, XPathResult.ANY_TYPE, null); + // With high zoom values or long articles there might be multiple images, so loop through and save them all. + var imgNum = 1; + while (nextImg = imgs.iterateNext()) { + newItem.attachments.push({url:nextImg.src, title: newItem.publicationTitle + ', ' + newItem.date + ', p. ' + newItem.pages + ' - ' + imgNum, mimeType:'image/jpeg'}); + imgNum++; + } + */ + // Save PDF version as attachment + newItem.attachments.push({url: 'http://trove.nla.gov.au/ndp/del/printArticlePdf/' + articleId + '/3?print=n', title: newItem.publicationTitle + ', ' + newItem.date + ', p. ' + newItem.pages, mimeType:'application/pdf'}); + newItem.complete(); +} + +// Search result test fails when run automatically: +// http://trove.nla.gov.au/newspaper/result?q=clement+wragge + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "http://trove.nla.gov.au/ndp/del/article/972415", + "items": [ + { + "itemType": "newspaperArticle", + "creators": [], + "notes": [], + "tags": [], + "seeAlso": [], + "attachments": [ + { + "url": false, + "title": "The Argus, 8 August 1945, p. 1", + "mimeType": "application/pdf" + } + ], + "libraryCatalog": "National Library of Australia - Trove - Australian Newspapers", + "url": "http://nla.gov.au/nla.news-article972415", + "title": "ATOMIC BOMB WARNING TO JAPS PEOPLE TOLD OF HORRORS OF NEW WEAPON Intensive Broadcast Campaign FROM OUR OWN CORRESPONDENT IN NEW YORK AND AAP NOW THAT AN ATOMIC BOMB HAS BEEN DROPPED ON JAPAN ALL POSSIBLE MEANS ARE BEING USED TO TELL THE JAPANESE OF THE HORRORS OF THE BOMB AND AT THE SAME TIME TO DRIVE HOME TO THEM THE POTSDAM SURRENDER TERMS. Four powerful Office of War Information stations are broadcasting news to Japan, while leaflets being produced at Saipan and Manila will be dropped over Japanese communities and troop concentrations. The two regular newspapers which are carried to Japan weekly by Super-Fortresses—\"Jiho,\" published on Saipan, and \"Rakkason,\" published in Manila—will lead with the atomic bomb story.", + "publicationTitle": "The Argus", + "place": "Melbourne, Vic.", + "date": "8 August 1945", + "pages": "1", + "abstractNote": "ATOMIC BOMB WARNING TO JAPS\n PEOPLE TOLD OF\n HORRORS\n OF NEW WEAPON\n Intensive Broadcast Campaign\n FROM OUR OWN CORRESPONDENT IN NEW YORK AND AAP\n NOW THAT AN ATOMIC BOMB HAS BEEN DROPPED ON JAPAN\n ALL POSSIBLE MEANS ARE BEING USED TO TELL THE\n JAPANESE OF THE HORRORS OF THE BOMB AND AT THE\n SAME TIME TO DRIVE HOME TO THEM THE POTSDAM\n SURRENDER TERMS.\n Four powerful Office of War Information stations are broadcasting\n news to Japan, while leaflets being produced at Saipan and Manila will\n be dropped over Japanese communities and troop concentrations.\n The two regular newspapers which are carried to Japan weekly by\n Super-Fortresses - \"Jiho,\" published on Saipan, and \"Rakkason,\"\n published in Manila-will lead with the atomic bomb story.\n The Office of War Information\n revealed yesterday that \n transmissions to Japan began\n immediately after President\n Truman's statement that the\n atomic bomb was already in use\n was issued.\n New York Times Washington\n correspondent says that while\n Mr Stimson, US War Secretary,\n said the atomic bomb should\n prove a tremendous aid in\n shortening the war against\n Japan, other responsible officials\n thought that that was an \n extreme understatement, and\n that Japan might be unable to\n remain in the war under the\n coming rain of atomic bombs.\n Obviously the news was \n released now, the correspondent\n adds, because of the possible\n psychological effect in forcing\n the Japanese to surrender.\n DETAILS AWAITED\n Meanwhile London is eagerly\n awaiting an official statement\n on the scientific details of the\n atomic bomb, which Sir John\n Anderson, who supervised \n research work in Britain, said\n would be issued in a few days.\n Press Association says it is\n clear from the announcements\n already made that the industrial\n application of this new \n source of energy will require\n many years of research and \n development before it is ready\n for exploitation.\n Reuter's military correspondent\n says: \"It seems that the \n secrets of the atomic bomb will\n not be shared by any power\n other than those directly \n concerned with its production.\n \"As soon as the Big Three's\n experts had an opportunity to\n study all the strategic implications,\n it is likely that consultations \n will begin to consider \n methods for the agreed control\n of the super-bomb's manufacture\n and use. \n \"Its offensive uses at the\n moment are in the limelight,\n but its use in defence may\n equally outmode the present\n forms of aerial warfare.\n \"So far experts have been \n unable to do anything more than\n grasp the sheer magnitude of\n the revolution facing them, but\n the Big Three Governments are\n expected to act speedily to\n regulate this unforeseen \n situation.\"\n DECISION OUTDATED\n The correspondent adds: \"The\n strategic decisions taken at\n Teheran, Yalta, and Potsdam,\n according to military experts,\n have already been outdated by\n the advent of the bomb.\n \"Security can no longer be \n defined for instance by control of\n the Dardanelles and the Suez\n Canal, and by possession of this\n or that port, river, or \n mountain." + } + ] + }, + { + "type": "web", + "url": "http://trove.nla.gov.au/newspaper/result?q=clement+wragge", + "items": "multiple" + }, + { + "type": "web", + "url": "http://trove.nla.gov.au/ndp/del/page/32665", + "items": "multiple" + } +] +/** END TEST CASES **/ diff --git a/translators/PLoS Journals.js b/translators/PLoS Journals.js index 616b3c518..a1a5eae13 100644 --- a/translators/PLoS Journals.js +++ b/translators/PLoS Journals.js @@ -6,10 +6,11 @@ "minVersion": "2.1", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, "browserSupport": "gcs", - "lastUpdated": "2011-07-03 14:59:21" + "lastUpdated": "2011-08-22 22:31:21" } function detectWeb(doc, url) { diff --git a/translators/ProQuest.js b/translators/ProQuest.js index 08b0fc8d1..a38f51449 100644 --- a/translators/ProQuest.js +++ b/translators/ProQuest.js @@ -6,9 +6,10 @@ "minVersion": "2.1", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-08-03 11:08:32" + "lastUpdated": "2011-08-22 22:32:08" } /* diff --git a/translators/Project Gutenberg.js b/translators/Project Gutenberg.js index d9b03a631..03cbd05f3 100644 --- a/translators/Project Gutenberg.js +++ b/translators/Project Gutenberg.js @@ -7,8 +7,9 @@ "minVersion":"2.1", "maxVersion":"", "priority":100, + "browserSupport":"gcs", "inRepository":true, - "lastUpdated":"2011-04-11 00:15:00" + "lastUpdated":"2011-08-22 22:31:32" } function detectWeb(doc, url) { diff --git a/translators/Project MUSE.js b/translators/Project MUSE.js index 91858e762..8cb9c7aae 100644 --- a/translators/Project MUSE.js +++ b/translators/Project MUSE.js @@ -1,14 +1,15 @@ { "translatorID": "c54d1932-73ce-dfd4-a943-109380e06574", "label": "Project MUSE", - "creator": "Simon Kornblith, Avram Lyon", - "target": "^https?://[^/]*muse\\.jhu\\.edu[^/]*/(?:journals/[^/]+/[^/]+/[^/]+\\.html|search/results)", - "minVersion": "1.0.0b4.r1", + "creator": "Simon Kornblith, Avram Lyon, Sean Takats", + "target": "^https?://[^/]*muse\\.jhu\\.edu[^/]*/(login\\?uri=/)?(?:journals/[^/]+/(summary/)?[^/]+/[^/]+\\.html|search/results)", + "minVersion": "2.1.9", "maxVersion": "", "priority": 100, - "inRepository": "1", + "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-03-02 23:38:17" + "browserSupport": "gcs", + "lastUpdated": "2011-08-25 10:00:51" } function detectWeb(doc, url) { @@ -21,70 +22,60 @@ function detectWeb(doc, url) { } function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - + var searchRe = new RegExp("^https?://[^/]+/search/results|/search/save"); if(detectWeb(doc, url) == "multiple") { - var items = new Array(); + var items = {}; var attachments = new Array(); var pdfRe = /PDF/; var htmlRe = /HTML/; if (searchRe.test(url)) { // Search results var tableRows = doc.evaluate('//save_form//tr[@class="resultsrow"]', - doc, nsResolver, XPathResult.ANY_TYPE, null); + doc, null, XPathResult.ANY_TYPE, null); var tableRow; // Go through table rows while(tableRow = tableRows.iterateNext()) { - var input = doc.evaluate('.//div[@class="links"]//a[last()]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var title = doc.evaluate('.//div[@class="title"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); + var input = doc.evaluate('.//div[@class="links"]//a[last()]', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext(); + var title = doc.evaluate('.//div[@class="title"]', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext(); if(input && input.href && title && title.textContent) { items[input.href] = title.textContent; } } } else if (url.match(/\/toc\//)) { - //Zotero.debug("here"); var results = doc.evaluate('//div[@class="article"]', - doc, nsResolver, XPathResult.ANY_TYPE, null); + doc, null, XPathResult.ANY_TYPE, null); var result; while(result = results.iterateNext()) { - //Zotero.debug(result.textContent); - var link = doc.evaluate('.//div[@class="links"]/p//a[last()]', result, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var title = doc.evaluate('.//div[@class="title"]', result, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - //Zotero.debug(link.textContent); + var link = doc.evaluate('.//div[@class="links"]/p//a[last()]', result, null, XPathResult.ANY_TYPE, null).iterateNext(); + var title = doc.evaluate('.//div[@class="title"]', result, null, XPathResult.ANY_TYPE, null).iterateNext(); if(link && link.href && title && title.textContent) { items[link.href] = title.textContent; - //Zotero.debug(link.href); } } // Some journals have old-style TOCs for back issues // Ex. http://muse.jhu.edu/journals/eighteenth-century_studies/toc/ecs33.4.html if (items.length == 0) { - var articles = doc.evaluate('//ul', doc, nsResolver, XPathResult.ANY_TYPE, null); + var articles = doc.evaluate('//ul', doc, null, XPathResult.ANY_TYPE, null); var article; while (article = articles.iterateNext()) { - var link = doc.evaluate('./li/a[contains(@href,".html")]', article, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var title = doc.evaluate('./li/i', article, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - //Zotero.debug(link.textContent); + var link = doc.evaluate('./li/a[contains(@href,".html")]', article, null, XPathResult.ANY_TYPE, null).iterateNext(); + var title = doc.evaluate('./li/i', article, null, XPathResult.ANY_TYPE, null).iterateNext(); if(link && link.href && title && title.textContent) { items[link.href] = title.textContent; - //Zotero.debug(link.href); } } } } - items = Zotero.selectItems(items); - if(!items) { - return true; - } - var i; - var urls = []; - for (i in items) {urls.push(i);}; - - Zotero.Utilities.processDocuments(urls, scrapeOne, function() {Zotero.done();}); + Zotero.selectItems(items, function(items) { + if(!items) { + return true; + } + var i; + var urls = []; + for (i in items) {urls.push(i);}; + Zotero.Utilities.processDocuments(urls, scrapeOne, function() {Zotero.done();}, null); + }); } else scrapeOne(doc); Zotero.wait(); } @@ -92,32 +83,25 @@ function doWeb(doc, url) { // Given an article page, get the RIS and open it function scrapeOne(doc) { var url = doc.location.href; - //Zotero.debug("scrapeOne has "+doc.location.href) - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; var hostRe = new RegExp("^(http://[^/]+)/"); var m = hostRe.exec(url); var host = m[1]; - var getPDF = doc.evaluate('//a[text() = "PDF Version"]', doc, - nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); + var getPDF = doc.evaluate('//a[text() = "PDF Version" or text() = "[Access article in PDF]"]', doc, + null, XPathResult.ANY_TYPE, null).iterateNext(); var DOI = doc.evaluate('//div[@class="doi"]', doc, - nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); + null, XPathResult.ANY_TYPE, null).iterateNext(); var abstract = doc.evaluate('//abstract', doc, - nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); + null, XPathResult.ANY_TYPE, null).iterateNext(); - var newUrl = url.replace(host, host+"/metadata/zotero").replace("/summary/","/");; - //Zotero.debug(newUrl); + var newUrl = url.replace(host, host+"/metadata/zotero").replace("/summary/","/").replace("/login?uri=",""); Zotero.Utilities.HTTP.doGet(newUrl, function(text) { var translator = Zotero.loadTranslator("import"); //set RIS translator translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); translator.setString(text); - Zotero.debug(text); translator.setHandler("itemDone", function(obj, item) { if(item.notes && item.notes[0]) { item.extra = item.notes[0].note; @@ -141,3 +125,52 @@ function scrapeOne(doc) { translator.translate(); }); } +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "http://muse.jhu.edu/journals/past_and_present/summary/v191/191.1higonnet.html", + "items": [ + { + "itemType": "journalArticle", + "creators": [ + { + "lastName": "Higonnet", + "firstName": "Patrice L. R.", + "creatorType": "author" + } + ], + "tags": [], + "seeAlso": [], + "attachments": [ + { + "document": false, + "title": "Project MUSE Snapshot" + }, + { + "title": "Project MUSE Full Text PDF", + "mimeType": "application/pdf", + "url": false + } + ], + "title": "Terror, Trauma and the 'Young Marx' Explanation of Jacobin Politics", + "publicationTitle": "Past & Present", + "volume": "191", + "pages": "121-164", + "date": "2006", + "publisher": "Oxford University Press", + "ISBN": "1477-464X", + "ISSN": "1477-464X", + "url": "http://muse.jhu.edu/journals/past_and_present/v191/191.1higonnet.html", + "extra": "

Number 191, May 2006

", + "libraryCatalog": "Project MUSE" + } + ] + }, + { + "type": "web", + "url": "http://muse.jhu.edu/journals/journal_of_social_history/toc/jsh.44.4.html", + "items": "multiple" + } +] +/** END TEST CASES **/ \ No newline at end of file diff --git a/translators/RDF.js b/translators/RDF.js index 165cc6de5..c78bd7e13 100644 --- a/translators/RDF.js +++ b/translators/RDF.js @@ -10,12 +10,11 @@ "browserSupport":"gcsn", "configOptions":{"dataMode":"rdf/xml"}, "inRepository":true, - "lastUpdated":"2011-07-08 04:51:41" + "lastUpdated":"2011-08-22 23:56:28" } function detectImport() { - // unfortunately, Mozilla will let you create a data source from any type - // of XML, so we need to make sure there are actually nodes + // Make sure there are actually nodes var nodes = Zotero.RDF.getAllResources(); if(nodes) { @@ -637,5 +636,7 @@ function doImport() { /** * Export doImport and defaultUnknownType to other translators */ -exports.doImport = doImport; -exports.defaultUnknownType = "book"; \ No newline at end of file +var exports = { + "doImport":doImport, + "defaultUnknownType":"book" +}; \ No newline at end of file diff --git a/translators/Radio Liberty.js b/translators/Radio Liberty.js index 8e49039d6..d0a5a54fd 100644 --- a/translators/Radio Liberty.js +++ b/translators/Radio Liberty.js @@ -1,14 +1,15 @@ { - "translatorID":"b1c90b99-2e1a-4374-a03b-92e45f1afc55", - "translatorType":4, - "label":"Radio Free Europe / Radio Liberty", - "creator":"Avram Lyon", - "target":"^http://www\\.rferl\\.org/|^http://www\\.azatliq\\.org/|^http://www\\.azattyq\\.org/|^http://rus\\.azattyq\\.org/|^http://da\\.azadiradio\\.org/|^http://pa\\.azadiradio\\.org/|^http://www\\.azattyk\\.org/|^http://www\\.ozodi\\.org/|^http://www\\.ozodlik\\.org/|^http://www\\.evropaelire\\.org/|^http://www\\.slobodnaevropa\\.org/|^http://www\\.makdenes\\.org/|^http://www\\.iraqhurr\\.org/|^http://www\\.radiofarda\\.com/|^http://www\\.azatutyun\\.am/|^http://www\\.azadliq\\.org/|^http://www\\.svaboda\\.org/|^http://www\\.tavisupleba\\.org/|^http://www\\.azathabar\\.com/|^http://www\\.svobodanews\\.ru/|^http://www\\.europalibera\\.org/|^http://www\\.radiosvoboda\\.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-05-24 00:45:00" + "translatorID": "b1c90b99-2e1a-4374-a03b-92e45f1afc55", + "label": "Radio Free Europe / Radio Liberty", + "creator": "Avram Lyon", + "target": "^http://www\\.rferl\\.org/|^http://www\\.azatliq\\.org/|^http://www\\.azattyq\\.org/|^http://rus\\.azattyq\\.org/|^http://da\\.azadiradio\\.org/|^http://pa\\.azadiradio\\.org/|^http://www\\.azattyk\\.org/|^http://www\\.ozodi\\.org/|^http://www\\.ozodlik\\.org/|^http://www\\.evropaelire\\.org/|^http://www\\.slobodnaevropa\\.org/|^http://www\\.makdenes\\.org/|^http://www\\.iraqhurr\\.org/|^http://www\\.radiofarda\\.com/|^http://www\\.azatutyun\\.am/|^http://www\\.azadliq\\.org/|^http://www\\.svaboda\\.org/|^http://www\\.tavisupleba\\.org/|^http://www\\.azathabar\\.com/|^http://www\\.svobodanews\\.ru/|^http://www\\.europalibera\\.org/|^http://www\\.radiosvoboda\\.org/", + "minVersion": "2.1.9", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcs", + "lastUpdated": "2011-08-18 15:31:42" } /* @@ -119,9 +120,9 @@ function doWeb(doc, url){ if ((author = author.iterateNext()) !== null) { author = author.textContent; // Sometimes we have "By Author" - if(author.substr(0, 3).toLowerCase() == "by ") { - author = author.substr(3); - } + if(author.substr(0, 3).toLowerCase() == "by ") { + author = author.substr(3); + } var cleaned = Zotero.Utilities.cleanAuthor(author, "author"); // If we have only one name, set the author to one-name mode if (cleaned.firstName == "") { @@ -221,4 +222,47 @@ function addAudio(text) { var audio = text.match(/http:\/\/realaudio\.rferl\.org[^"]*\.mp3/); if (audio) item.attachments.push({url:audio[0], mimeType:"application/octet-stream", title:"RFE/RL Audio"}) item.complete(); -} \ No newline at end of file +} + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "http://www.azatliq.org/content/article/24281041.html", + "items": [ + { + "itemType": "newspaperArticle", + "creators": [ + { + "firstName": "Гүзәл", + "lastName": "Мәхмүтова", + "creatorType": "author" + } + ], + "notes": [], + "tags": [], + "seeAlso": [], + "attachments": [ + { + "url": false, + "title": " Азатлык Радиосы Snapshot", + "mimeType": "text/html" + }, + { + "url": false, + "mimeType": "application/octet-stream", + "title": "RFE/RL Audio" + } + ], + "title": "Татар яшьләре татарлыкны сакларга тырыша", + "section": "татарстан", + "date": "29.07.2011", + "url": "http://www.azatliq.org/content/article/24281041.html", + "publicationTitle": "Азатлык Радиосы", + "language": "Tatar/Bashkir", + "libraryCatalog": "Radio Free Europe / Radio Liberty" + } + ] + } +] +/** END TEST CASES **/ diff --git a/translators/The Hindu.js b/translators/The Hindu.js index 9a65c9d3e..77d4e293a 100644 --- a/translators/The Hindu.js +++ b/translators/The Hindu.js @@ -6,9 +6,10 @@ "minVersion": "1.0.0b4.r5", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-08-16 03:36:22" + "lastUpdated": "2011-08-22 22:32:21" } function detectWeb(doc, url) { diff --git a/translators/Wiley Online Library.js b/translators/Wiley Online Library.js index a1c377cf4..eafe93146 100644 --- a/translators/Wiley Online Library.js +++ b/translators/Wiley Online Library.js @@ -6,12 +6,30 @@ "minVersion": "1.0.0b4.r5", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "browserSupport": "g", - "lastUpdated": "2011-08-18 01:25:48" + "lastUpdated": "2011-08-22 22:33:07" } +/* + Wiley Online Translator + Copyright (C) 2011 CHNM and Avram Lyon + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + */ + function detectWeb(doc, url){ var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { diff --git a/translators/cablegatesearch.net.js b/translators/cablegatesearch.net.js new file mode 100644 index 000000000..fdc187540 --- /dev/null +++ b/translators/cablegatesearch.net.js @@ -0,0 +1,89 @@ +{ + "translatorID": "8b73dd9c-b873-4d13-b36a-45922b9f04a1", + "label": "cablegatesearch.net", + "creator": "Yannick Ringot", + "target": "^https?://(?:www\\.)?cablegatesearch\\.net/cable\\.php\\?id=", + "minVersion": "2.1.9", + "maxVersion": "", + "priority": 100, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcs", + "lastUpdated": "2011-08-24 15:23:24" +} + +/* FW LINE 49:9c8b4db52e08 */ function flatten(c){var b=new Array();for(var d in c){var e=c[d];if(e instanceof Array){b=b.concat(flatten(e))}else{b.push(e)}}return b}var FW={_scrapers:new Array()};FW._Base=function(){this.callHook=function(b,c,e,a){if(typeof this["hooks"]==="object"){var d=this["hooks"][b];if(typeof d==="function"){d(c,e,a)}}};this.evaluateThing=function(f,e,c){var b=typeof f;if(b==="string"){return f}else{if(b==="object"){if(f instanceof Array){var d=this.evaluateThing;var a=f.map(function(g){return d(g,e,c)});return flatten(a)}else{return f.evaluate(e,c)}}else{if(b==="function"){return f(e,c)}else{return undefined}}}}};FW.Scraper=function(a){FW._scrapers.push(new FW._Scraper(a))};FW._Scraper=function(a){for(x in a){this[x]=a[x]}this._singleFieldNames=["abstractNote","applicationNumber","archive","archiveLocation","artworkMedium","artworkSize","assignee","audioFileType","audioRecordingType","billNumber","blogTitle","bookTitle","callNumber","caseName","code","codeNumber","codePages","codeVolume","committee","company","conferenceName","country","court","date","dateDecided","dateEnacted","dictionaryTitle","distributor","docketNumber","documentNumber","DOI","edition","encyclopediaTitle","episodeNumber","extra","filingDate","firstPage","forumTitle","genre","history","institution","interviewMedium","ISBN","ISSN","issue","issueDate","issuingAuthority","journalAbbreviation","label","language","legalStatus","legislativeBody","letterType","libraryCatalog","manuscriptType","mapType","medium","meetingName","nameOfAct","network","number","numberOfVolumes","numPages","pages","patentNumber","place","postType","presentationType","priorityNumbers","proceedingsTitle","programTitle","programmingLanguage","publicLawNumber","publicationTitle","publisher","references","reportNumber","reportType","reporter","reporterVolume","rights","runningTime","scale","section","series","seriesNumber","seriesText","seriesTitle","session","shortTitle","studio","subject","system","thesisType","title","type","university","url","version","videoRecordingType","volume","websiteTitle","websiteType"];this._makeAttachments=function(q,b,f,s){if(f instanceof Array){f.forEach(function(k){this._makeAttachments(q,b,k,s)},this)}else{if(typeof f==="object"){var p=f.urls||f.url;var m=f.types||f.type;var e=f.titles||f.title;var h=this.evaluateThing(p,q,b);var o=this.evaluateThing(e,q,b);var r=this.evaluateThing(m,q,b);var l=(r instanceof Array);var n=(o instanceof Array);if(!(h instanceof Array)){h=[h]}for(var j in h){var c=h[j];var g;var d;if(l){g=r[j]}else{g=r}if(n){d=o[j]}else{d=o}s.attachments.push({url:c,title:d,type:g})}}}};if(this.itemTrans!==undefined){this.makeItems=this.itemTrans.makeItems}else{this.makeItems=function(o,b,m,c,l){var q=new Zotero.Item(this.itemType);q.url=b;for(var h in this._singleFieldNames){var n=this._singleFieldNames[h];if(this[n]){var g=this.evaluateThing(this[n],o,b);if(g instanceof Array){q[n]=g[0]}else{q[n]=g}}}var r=["creators","tags"];for(var f in r){var p=r[f];var d=this.evaluateThing(this[p],o,b);if(d){for(var e in d){q[p].push(d[e])}}}this._makeAttachments(o,b,this["attachments"],q);c(q,this,o,b);l([q])}}};FW._Scraper.prototype=new FW._Base;FW.MultiScraper=function(a){FW._scrapers.push(new FW._MultiScraper(a))};FW._MultiScraper=function(a){for(x in a){this[x]=a[x]}this._mkSelectItems=function(e,d){var b=new Object;for(var c in e){b[d[c]]=e[c]}return b};this._selectItems=function(d,c,e){var b=new Array();Zotero.selectItems(this._mkSelectItems(d,c),function(f){for(var g in f){b.push(g)}e(b)})};this._mkAttachments=function(g,d,f){var b=this.evaluateThing(this["attachments"],g,d);var c=new Object();if(b){for(var e in f){c[f[e]]=b[e]}}return c};this._makeChoices=function(f,p,c,d,h){if(f instanceof Array){f.forEach(function(k){this._makeTitlesUrls(k,p,c,d,h)},this)}else{if(typeof f==="object"){var m=f.urls||f.url;var e=f.titles||f.title;var n=this.evaluateThing(m,p,c);var j=this.evaluateThing(e,p,c);var l=(j instanceof Array);if(!(n instanceof Array)){n=[n]}for(var g in n){var b=n[g];var o;if(l){o=j[g]}else{o=j}h.push(b);d.push(o)}}}};this.makeItems=function(j,b,g,c,f){if(this.beforeFilter){var k=this.beforeFilter(j,b);if(k!=b){this.makeItems(j,k,g,c,f);return}}var e=[];var h=[];this._makeChoices(this["choices"],j,b,e,h);var d=this._mkAttachments(j,b,h);this._selectItems(e,h,function(m){if(!m){f([])}else{var l=[];var n=this.itemTrans;Zotero.Utilities.processDocuments(m,function(q){var p=q.documentURI;var o=n;if(o===undefined){o=FW.getScraper(q,p)}if(o===undefined){}else{o.makeItems(q,p,d[p],function(r){l.push(r);c(r,o,q,p)},function(){})}},function(){f(l)})}})}};FW._MultiScraper.prototype=new FW._Base;FW.DelegateTranslator=function(a){return new FW._DelegateTranslator(a)};FW._DelegateTranslator=function(a){for(x in a){this[x]=a[x]}this._translator=Zotero.loadTranslator(this.translatorType);this._translator.setTranslator(this.translatorId);this.makeItems=function(g,d,b,f,c){var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});if(this.preProcess){h=this.preProcess(h)}this._translator.setString(h);this._translator.translate();f(e)},function(){c([e])})}};FW.DelegateTranslator.prototype=new FW._Scraper;FW._StringMagic=function(){this._filters=new Array();this.addFilter=function(a){this._filters.push(a);return this};this.split=function(a){return this.addFilter(function(b){return b.split(a).filter(function(c){return(c!="")})})};this.replace=function(c,b,a){return this.addFilter(function(d){if(d.match(c)){return d.replace(c,b,a)}else{return d}})};this.prepend=function(a){return this.replace(/^/,a)};this.append=function(a){return this.replace(/$/,a)};this.remove=function(b,a){return this.replace(b,"",a)};this.trim=function(){return this.addFilter(function(a){return Zotero.Utilities.trim(a)})};this.trimInternal=function(){return this.addFilter(function(a){return Zotero.Utilities.trimInternal(a)})};this.match=function(a,b){if(!b){b=0}return this.addFilter(function(d){var c=d.match(a);if(c===undefined||c===null){return undefined}else{return c[b]}})};this.cleanAuthor=function(b,a){return this.addFilter(function(c){return Zotero.Utilities.cleanAuthor(c,b,a)})};this.key=function(a){return this.addFilter(function(b){return b[a]})};this.capitalizeTitle=function(){return this.addFilter(function(a){return Zotero.Utilities.capitalizeTitle(a)})};this.unescapeHTML=function(){return this.addFilter(function(a){return Zotero.Utilities.unescapeHTML(a)})};this.unescape=function(){return this.addFilter(function(a){return unescape(a)})};this._applyFilters=function(c,e){for(i in this._filters){c=flatten(c);c=c.filter(function(a){return((a!==undefined)&&(a!==null))});for(var d=0;d0&&a[0]){return f}}return undefined};FW.getScraper=function(b,a){var c=FW.detectWeb(b,a);return FW._scrapers.filter(function(d){return(d.evaluateThing(d.itemType,b,a)==c)&&(d.evaluateThing(d.detect,b,a))})[0]};FW.doWeb=function(c,a){var b=FW.getScraper(c,a);b.makeItems(c,a,[],function(f,e,g,d){e.callHook("scraperDone",f,g,d);if(!f.title){f.title=""}f.complete()},function(){Zotero.done()});Zotero.wait()}; +function detectWeb(doc, url) { return FW.detectWeb(doc, url); } +function doWeb(doc, url) { return FW.doWeb(doc, url); } + +FW.Scraper({ + itemType : 'report', + detect : "always", + title : FW.Xpath('//div[@id="main"]//tr[2]/td[2]').text().prepend("Wikileaks Cable: "), + url : FW.Url().remove(/\&q=.+$/), + attachments : [{ + url : FW.Xpath('//div[@id="main"]//tr[6]/td[2]/a').text(), + title : "Snapshot from wikileaks.org/cable", + type : "text/html" }, + { + url : FW.Xpath('//div[@id="media-items"]//a').key('href').text(), + title : FW.Xpath('//div[@id="media-items"]//a').text().prepend("Snapshot of media item: "), + type : "text/html" + }], + date : FW.Xpath('//div[@id="main"]//tr[4]/td[2]').text().remove(/^....\s/) + .remove(/\s\d\d:\d\d\sUTC$/) + .replace(/(\d\d?)\s(.+?)\s(\d\d\d\d)/,"$3-$2-$1") + .replace(/Jan/,"01").replace(/Feb/,"02").replace(/Mar/,"03") + .replace(/Apr/,"04").replace(/May/,"05").replace(/Jun/,"06") + .replace(/Jul/,"07").replace(/Aug/,"08").replace(/Sep/,"09") + .replace(/Oct/,"10").replace(/Nov/,"11").replace(/Dec/,"12"), + place : FW.Xpath('//div[@id="main"]//tr[3]/td[2]').text().unescapeHTML().trim(), + extra : FW.Xpath('//div[@id="media-items"]').text().remove(/\[object XrayWrapper \[object HTMLDivElement\]\]/), + abstractNote : FW.Xpath('//div[@id="cable-body"]').text().unescapeHTML().match(/^.+?(Summary.+End Summary).+/i, 1).remove(/^Summary../i).remove(/ End Summary$/i).remove(/(------\s.\d\.\s\(.+?\)\s)?/), + tags : FW.Xpath('//div[@id="cable-body"]/a').text().remove(/\]/).remove(/\[/).trim(), + reportNumber : FW.Xpath('//input[@id="canonical_id-input"]').key('value').text(), // get report number from page content + publisher : "Wikileaks" +});/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "http://www.cablegatesearch.net/cable.php?id=10SHANGHAI60&q=fun", + "items": [ + { + "itemType": "report", + "creators": [], + "notes": [], + "tags": [ + "Economic Conditions", + "Financial and Monetary Affairs", + "Foreign Investments", + "Internal Governmental Affairs", + "China (Mainland)", + "United Arab Emirates" + ], + "seeAlso": [], + "attachments": [ + { + "url": false, + "title": "Snapshot from wikileaks.org/cable", + "type": "text/html" + }, + { + "url": false, + "title": false, + "type": "text/html" + } + ], + "url": "http://www.cablegatesearch.net/cable.php?id=10SHANGHAI60", + "date": "2010-02-26", + "place": "Consulate Shanghai (China)", + "publisher": "Wikileaks", + "reportNumber": "10SHANGHAI60", + "title": "Wikileaks Cable: Deflating Zhejiang's Property Bubble", + "libraryCatalog": "cablegatesearch.net", + "shortTitle": "Wikileaks Cable" + } + ] + } +] +/** END TEST CASES **/ \ No newline at end of file diff --git a/translators/eLibrary.ru.js b/translators/eLibrary.ru.js index b699a2b9b..8cde1e620 100644 --- a/translators/eLibrary.ru.js +++ b/translators/eLibrary.ru.js @@ -6,9 +6,10 @@ "minVersion": "2.1", "maxVersion": "", "priority": 100, + "browserSupport": "gcs", "inRepository": true, "translatorType": 4, - "lastUpdated": "2011-08-03 10:41:53" + "lastUpdated": "2011-08-22 22:43:15" } /* diff --git a/translators/unAPI.js b/translators/unAPI.js index 6c9517dcf..822c10c22 100644 --- a/translators/unAPI.js +++ b/translators/unAPI.js @@ -1,15 +1,15 @@ { - "translatorID":"e7e01cac-1e37-4da6-b078-a0e8343b0e98", - "translatorType":4, - "label":"unAPI", - "creator":"Simon Kornblith", - "target":null, - "minVersion":"2.1", - "maxVersion":"", - "priority":200, - "inRepository":true, - "detectXPath":"//link[@rel='unapi-server']", - "lastUpdated":"2011-06-09 01:57:14" + "translatorID": "e7e01cac-1e37-4da6-b078-a0e8343b0e98", + "label": "unAPI", + "creator": "Simon Kornblith", + "target": "", + "minVersion": "2.1", + "maxVersion": "", + "priority": 200, + "inRepository": true, + "translatorType": 4, + "browserSupport": "gcs", + "lastUpdated": "2011-08-26 18:39:33" } var RECOGNIZABLE_FORMATS = ["rdf_zotero", "rdf_bibliontology", "mods", "marc", "unimarc", "ris", @@ -168,13 +168,13 @@ UnAPIID.prototype = { */ "isSupported":function(callback) { if(this.hasOwnProperty("format")) { - callback(me.format.isSupported); + callback(this.format.isSupported); return; } var me = this; - getDefaultFormat(function() { + getDefaultFormat(function(defaultFormat) { // first try default format, since this won't require >1 HTTP request if(defaultFormat.isSupported) { me.format = defaultFormat; @@ -260,7 +260,11 @@ function determineDetectItemType(ids, supportedId) { determineDetectItemType(ids, (isSupported ? id : supportedId)); } else { // If all IDs have been handled, get foundItemType for only supported ID - supportedId.getItemType(Zotero.done); + if(isSupported) { + id.getItemType(Zotero.done); + } else { + Zotero.done(false); + } } }); } @@ -337,3 +341,53 @@ function doWeb(doc, url) { return; }); } + + +/** BEGIN TEST CASES **/ +var testCases = [ + { + "type": "web", + "url": "http://search8.library.utoronto.ca/UTL/index?N=0&Ntk=Anywhere&Ntt=nimni+challenge+of+post-zionism&Ntx=mode%2Bmatchallpartial&Nu=p_work_normalized&Np=1&formName=search_form_simple", + "items": [ + { + "itemType": "book", + "creators": [ + { + "lastName": "Nimni", + "firstName": "Ephraim.", + "creatorType": "contributor" + } + ], + "notes": [], + "tags": [ + "Post-Zionism.", + "Zionism -- Philosophy.", + "National characteristics, Israeli.", + "Israel -- Politics and government." + ], + "seeAlso": [], + "attachments": [ + { + "url": false + } + ], + "itemID": "4908720 (UTL catalogue ckey)", + "title": "The challenge of Post-Zionism : alternatives to Israeli fundamentalist politics", + "date": "2003", + "publisher": "Zed Books", + "place": "New York", + "ISBN": "185649893X", + "ISSN": "185649893X", + "url": "http://www.loc.gov/catdir/description/hol032/2002190908.html", + "libraryCatalog": "search8.library.utoronto.ca", + "shortTitle": "The challenge of Post-Zionism" + } + ] + }, + { + "type": "web", + "url": "http://search8.library.utoronto.ca/UTL/index?N=0&Ntk=Anywhere&Ntt=adam+smith&Ntx=mode%2Bmatchallpartial&Nu=p_work_normalized&Np=1&formName=search_form_simple", + "items": "multiple" + } +] +/** END TEST CASES **/ \ No newline at end of file