www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 68553cc6dbf0d0826fbca6c8a93ad74615b6c429
parent 0a5f4946d3216c6fbaee469e30eb1af8fc96faf4
Author: Dan Stillman <dstillman@zotero.org>
Date:   Thu, 27 Oct 2011 02:08:15 -0400

Remove translator copies

Diffstat:
Dtranslators/3news.co.nz.js | 230-------------------------------------------------------------------------------
Dtranslators/A Contra Corriente.js | 49-------------------------------------------------
Dtranslators/ABC-CLIO Serials Web.js | 142------------------------------------------------------------------------------
Dtranslators/ACLWeb.js | 176-------------------------------------------------------------------------------
Dtranslators/ACM.js | 415-------------------------------------------------------------------------------
Dtranslators/ACS Publications.js | 117-------------------------------------------------------------------------------
Dtranslators/AGU Journals.js | 258-------------------------------------------------------------------------------
Dtranslators/AJHG.js | 85-------------------------------------------------------------------------------
Dtranslators/AMS Journals.js | 80-------------------------------------------------------------------------------
Dtranslators/AMS MathSciNet.js | 98-------------------------------------------------------------------------------
Dtranslators/APA PsycNET.js | 146-------------------------------------------------------------------------------
Dtranslators/APN.ru.js | 59-----------------------------------------------------------
Dtranslators/APS.js | 66------------------------------------------------------------------
Dtranslators/ARTFL Encyclopedie.js | 170-------------------------------------------------------------------------------
Dtranslators/ARTstor.js | 275-------------------------------------------------------------------------------
Dtranslators/ASCE.js | 76----------------------------------------------------------------------------
Dtranslators/Ab Imperio.js | 76----------------------------------------------------------------------------
Dtranslators/AcademicJournals.net.js | 92-------------------------------------------------------------------------------
Dtranslators/AdvoCAT.js | 118-------------------------------------------------------------------------------
Dtranslators/African Journals Online.js | 72------------------------------------------------------------------------
Dtranslators/AfroEuropa.js | 88-------------------------------------------------------------------------------
Dtranslators/Agencia del ISBN.js | 66------------------------------------------------------------------
Dtranslators/Alexander Street Press.js | 198-------------------------------------------------------------------------------
Dtranslators/AllAfrica.js | 71-----------------------------------------------------------------------
Dtranslators/AlterNet.js | 58----------------------------------------------------------
Dtranslators/Aluka.js | 192-------------------------------------------------------------------------------
Dtranslators/Amazon.com.js | 673-------------------------------------------------------------------------------
Dtranslators/American Institute of Aeronautics and Astronautics.js | 97-------------------------------------------------------------------------------
Dtranslators/Ancestry.com US Federal Census.js | 236-------------------------------------------------------------------------------
Dtranslators/Archeion.js | 157-------------------------------------------------------------------------------
Dtranslators/Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC).js | 76----------------------------------------------------------------------------
Dtranslators/Archives Canada-France.js | 149-------------------------------------------------------------------------------
Dtranslators/Archives Canada.js | 127-------------------------------------------------------------------------------
Dtranslators/Archives Network of Alberta.js | 153-------------------------------------------------------------------------------
Dtranslators/Artefacts Canada.js | 160-------------------------------------------------------------------------------
Dtranslators/AustLII and NZLII.js | 81-------------------------------------------------------------------------------
Dtranslators/Australian Dictionary of Biography.js | 79-------------------------------------------------------------------------------
Dtranslators/BAILII.js | 107-------------------------------------------------------------------------------
Dtranslators/BBC.js | 117-------------------------------------------------------------------------------
Dtranslators/BC Archival Information Network.js | 148-------------------------------------------------------------------------------
Dtranslators/BIBSYS.js | 67-------------------------------------------------------------------
Dtranslators/BIUM.js | 98-------------------------------------------------------------------------------
Dtranslators/BOCC.js | 212-------------------------------------------------------------------------------
Dtranslators/Berkeley Electronic Press.js | 85-------------------------------------------------------------------------------
Dtranslators/Berkeley Library Catalog.js | 96-------------------------------------------------------------------------------
Dtranslators/Bezneng Gajit.js | 68--------------------------------------------------------------------
Dtranslators/BibTeX.js | 2388-------------------------------------------------------------------------------
Dtranslators/Biblio.com.js | 126-------------------------------------------------------------------------------
Dtranslators/Bibliontology RDF.js | 1060-------------------------------------------------------------------------------
Dtranslators/Bibliotheque UQAM.js | 235-------------------------------------------------------------------------------
Dtranslators/Bibliotheque et Archives Nationale du Quebec (Pistard).js | 152------------------------------------------------------------------------------
Dtranslators/Bibliothèque et Archives nationales du Québec.js | 265-------------------------------------------------------------------------------
Dtranslators/Bibliothèque nationale de France.js | 736-------------------------------------------------------------------------------
Dtranslators/BioInfoBank.js | 122-------------------------------------------------------------------------------
Dtranslators/BioMed Central and More.js | 140-------------------------------------------------------------------------------
Dtranslators/BioOne.js | 67-------------------------------------------------------------------
Dtranslators/Blackwell Compass.js | 69---------------------------------------------------------------------
Dtranslators/Blackwell Synergy.js | 92-------------------------------------------------------------------------------
Dtranslators/Blaetter.js | 156-------------------------------------------------------------------------------
Dtranslators/Blogger.js | 126-------------------------------------------------------------------------------
Dtranslators/Bookmarks.js | 169-------------------------------------------------------------------------------
Dtranslators/Bracero History Archive.js | 172-------------------------------------------------------------------------------
Dtranslators/Bryn Mawr Classical Review.js | 86-------------------------------------------------------------------------------
Dtranslators/Business Standard.js | 67-------------------------------------------------------------------
Dtranslators/BusinessWeek.js | 59-----------------------------------------------------------
Dtranslators/CABI - CAB Abstracts.js | 133-------------------------------------------------------------------------------
Dtranslators/CARLABRC OAI Harvester.js | 122-------------------------------------------------------------------------------
Dtranslators/CNKI.js | 787-------------------------------------------------------------------------------
Dtranslators/COinS.js | 281-------------------------------------------------------------------------------
Dtranslators/CSIRO Publishing.js | 72------------------------------------------------------------------------
Dtranslators/CTX.js | 268-------------------------------------------------------------------------------
Dtranslators/Cambridge Journals Online.js | 184-------------------------------------------------------------------------------
Dtranslators/Cambridge Scientific Abstracts.js | 208-------------------------------------------------------------------------------
Dtranslators/CanLII.js | 113-------------------------------------------------------------------------------
Dtranslators/Canada.com.js | 154-------------------------------------------------------------------------------
Dtranslators/Canadian Letters and Images.js | 125-------------------------------------------------------------------------------
Dtranslators/Canadiana.org.js | 181-------------------------------------------------------------------------------
Dtranslators/Cell Press.js | 140-------------------------------------------------------------------------------
Dtranslators/Champlain Society - Collection.js | 168-------------------------------------------------------------------------------
Dtranslators/Christian Science Monitor.js | 151-------------------------------------------------------------------------------
Dtranslators/CiNii.js | 73-------------------------------------------------------------------------
Dtranslators/CiteSeer.js | 112-------------------------------------------------------------------------------
Dtranslators/CiteULike.js | 58----------------------------------------------------------
Dtranslators/Citebase.js | 95-------------------------------------------------------------------------------
Dtranslators/Civilization.ca.js | 133-------------------------------------------------------------------------------
Dtranslators/Code4Lib Journal.js | 69---------------------------------------------------------------------
Dtranslators/Columbia University Press.js | 70----------------------------------------------------------------------
Dtranslators/Common-Place.js | 167-------------------------------------------------------------------------------
Dtranslators/Copernicus.js | 187-------------------------------------------------------------------------------
Dtranslators/Cornell LII.js | 210-------------------------------------------------------------------------------
Dtranslators/Cornell University Press.js | 65-----------------------------------------------------------------
Dtranslators/CrossRef.js | 283-------------------------------------------------------------------------------
Dtranslators/Cyberpresse.js | 88-------------------------------------------------------------------------------
Dtranslators/DBLP Computer Science Bibliography.js | 171-------------------------------------------------------------------------------
Dtranslators/DOI.js | 156-------------------------------------------------------------------------------
Dtranslators/DSpace.js | 102-------------------------------------------------------------------------------
Dtranslators/DTIC.js | 127-------------------------------------------------------------------------------
Dtranslators/Davidson College Library.js | 82-------------------------------------------------------------------------------
Dtranslators/Der Freitag.js | 147-------------------------------------------------------------------------------
Dtranslators/Die Zeit.js | 183-------------------------------------------------------------------------------
Dtranslators/Digital Humanities Quarterly.js | 62--------------------------------------------------------------
Dtranslators/Digital Medievalist.js | 107-------------------------------------------------------------------------------
Dtranslators/Douban.js | 347-------------------------------------------------------------------------------
Dtranslators/EBSCOhost.js | 287-------------------------------------------------------------------------------
Dtranslators/ERIC.js | 135-------------------------------------------------------------------------------
Dtranslators/ESA Journals.js | 95-------------------------------------------------------------------------------
Dtranslators/ESpacenet.js | 176-------------------------------------------------------------------------------
Dtranslators/Early English Books Online.js | 75---------------------------------------------------------------------------
Dtranslators/Education Week.js | 96-------------------------------------------------------------------------------
Dtranslators/Edutopia.js | 140-------------------------------------------------------------------------------
Dtranslators/Eighteenth Century Collections Online.js | 161-------------------------------------------------------------------------------
Dtranslators/Electronic Colloquium on Computational Complexity.js | 113-------------------------------------------------------------------------------
Dtranslators/Embedded RDF.js | 135-------------------------------------------------------------------------------
Dtranslators/Emerald Publishing.js | 85-------------------------------------------------------------------------------
Dtranslators/Encyclopedia of Chicago.js | 165-------------------------------------------------------------------------------
Dtranslators/Engineering Village.js | 126-------------------------------------------------------------------------------
Dtranslators/Epicurious.js | 151-------------------------------------------------------------------------------
Dtranslators/Euclid.js | 143-------------------------------------------------------------------------------
Dtranslators/EurasiaNet.js | 46----------------------------------------------
Dtranslators/European Educational Research Journal.js | 88-------------------------------------------------------------------------------
Dtranslators/FAZ.NET.js | 196-------------------------------------------------------------------------------
Dtranslators/Factiva.js | 137-------------------------------------------------------------------------------
Dtranslators/Flickr.js | 158-------------------------------------------------------------------------------
Dtranslators/Florida University Libraries (Endeca 1).js | 105-------------------------------------------------------------------------------
Dtranslators/Foreign Policy.js | 144-------------------------------------------------------------------------------
Dtranslators/FreePatentsOnline.js | 125-------------------------------------------------------------------------------
Dtranslators/Frontiers.js | 283-------------------------------------------------------------------------------
Dtranslators/GPO Access e-CFR.js | 108-------------------------------------------------------------------------------
Dtranslators/GSA Journals Online.js | 61-------------------------------------------------------------
Dtranslators/Gale - Cengage Learning.js | 142------------------------------------------------------------------------------
Dtranslators/Gale Literature Resource Center.js | 174-------------------------------------------------------------------------------
Dtranslators/Gallica.js | 266-------------------------------------------------------------------------------
Dtranslators/Gasyrlar Awazy.js | 42------------------------------------------
Dtranslators/GeneOntology.org.js | 114-------------------------------------------------------------------------------
Dtranslators/Getty Research Library Catalog.js | 256-------------------------------------------------------------------------------
Dtranslators/Glenbow Library.js | 266-------------------------------------------------------------------------------
Dtranslators/Gmail.js | 49-------------------------------------------------
Dtranslators/Google Blogs.js | 76----------------------------------------------------------------------------
Dtranslators/Google Books.js | 448-------------------------------------------------------------------------------
Dtranslators/Google Patents.js | 177-------------------------------------------------------------------------------
Dtranslators/Google Scholar.js | 540-------------------------------------------------------------------------------
Dtranslators/Gulag Many Days, Many Lives.js | 143-------------------------------------------------------------------------------
Dtranslators/Hanrei Watch.js | 90-------------------------------------------------------------------------------
Dtranslators/Helsinki University of Technology.js | 82-------------------------------------------------------------------------------
Dtranslators/HighWire.js | 260-------------------------------------------------------------------------------
Dtranslators/Highwire 2.0.js | 309-------------------------------------------------------------------------------
Dtranslators/History Cooperative.js | 146-------------------------------------------------------------------------------
Dtranslators/Hurricane Digital Memory Bank.js | 115-------------------------------------------------------------------------------
Dtranslators/IEEE Computer Society.js | 225-------------------------------------------------------------------------------
Dtranslators/IEEE Xplore.js | 396-------------------------------------------------------------------------------
Dtranslators/IGN.js | 68--------------------------------------------------------------------
Dtranslators/IMDb.js | 123-------------------------------------------------------------------------------
Dtranslators/IRIS.js | 326-------------------------------------------------------------------------------
Dtranslators/ISI Web of Knowledge.js | 877-------------------------------------------------------------------------------
Dtranslators/InderScience.js | 84-------------------------------------------------------------------------------
Dtranslators/InfoTrac OneFile.js | 132-------------------------------------------------------------------------------
Dtranslators/InfoTrac.js | 215-------------------------------------------------------------------------------
Dtranslators/Informaworld.js | 277-------------------------------------------------------------------------------
Dtranslators/IngentaConnect.js | 81-------------------------------------------------------------------------------
Dtranslators/Innovate Online.js | 103-------------------------------------------------------------------------------
Dtranslators/Institute of Physics.js | 163-------------------------------------------------------------------------------
Dtranslators/Institute of Pure and Applied Physics.js | 125-------------------------------------------------------------------------------
Dtranslators/Inter-Research Science Center.js | 107-------------------------------------------------------------------------------
Dtranslators/International Herald Tribune.js | 129-------------------------------------------------------------------------------
Dtranslators/Internet Archive Wayback Machine.js | 64----------------------------------------------------------------
Dtranslators/Internet Archive.js | 415-------------------------------------------------------------------------------
Dtranslators/Investigative Ophthalmology and Visual Science.js | 85-------------------------------------------------------------------------------
Dtranslators/J-Stage.js | 86-------------------------------------------------------------------------------
Dtranslators/JBJS Am.js | 201-------------------------------------------------------------------------------
Dtranslators/JSTOR.js | 255-------------------------------------------------------------------------------
Dtranslators/Japan Times Online.js | 181-------------------------------------------------------------------------------
Dtranslators/Journal of Electronic Publishing.js | 69---------------------------------------------------------------------
Dtranslators/Journal of Vision.js | 77-----------------------------------------------------------------------------
Dtranslators/JurPC.js | 128-------------------------------------------------------------------------------
Dtranslators/KOBV.js | 94-------------------------------------------------------------------------------
Dtranslators/Kommersant.js | 100-------------------------------------------------------------------------------
Dtranslators/LA Times.js | 225-------------------------------------------------------------------------------
Dtranslators/Le Devoir.js | 143-------------------------------------------------------------------------------
Dtranslators/Le Monde Diplomatique_de.js | 139-------------------------------------------------------------------------------
Dtranslators/LexisNexis.js | 160-------------------------------------------------------------------------------
Dtranslators/Library Catalog (Aleph).js | 214-------------------------------------------------------------------------------
Dtranslators/Library Catalog (BiblioCommons).js | 220-------------------------------------------------------------------------------
Dtranslators/Library Catalog (DRA).js | 84-------------------------------------------------------------------------------
Dtranslators/Library Catalog (Dynix).js | 238-------------------------------------------------------------------------------
Dtranslators/Library Catalog (GEAC).js | 106-------------------------------------------------------------------------------
Dtranslators/Library Catalog (InnoPAC).js | 277-------------------------------------------------------------------------------
Dtranslators/Library Catalog (SIRSI).js | 376-------------------------------------------------------------------------------
Dtranslators/Library Catalog (TLCYouSeeMore).js | 107-------------------------------------------------------------------------------
Dtranslators/Library Catalog (VTLS).js | 137-------------------------------------------------------------------------------
Dtranslators/Library Catalog (Voyager 7).js | 82-------------------------------------------------------------------------------
Dtranslators/Library Catalog (Voyager).js | 261-------------------------------------------------------------------------------
Dtranslators/Library Catalog (X-OPAC).js | 54------------------------------------------------------
Dtranslators/LiveJournal.js | 544-------------------------------------------------------------------------------
Dtranslators/MAB2.js | 360-------------------------------------------------------------------------------
Dtranslators/MARC.js | 611-------------------------------------------------------------------------------
Dtranslators/MIT Press Journals.js | 124-------------------------------------------------------------------------------
Dtranslators/MODS.js | 995-------------------------------------------------------------------------------
Dtranslators/Mainichi Daily News.js | 121-------------------------------------------------------------------------------
Dtranslators/Matbugat.ru.js | 70----------------------------------------------------------------------
Dtranslators/Max Planck Institute for the History of Science Virtual Laboratory Library.js | 76----------------------------------------------------------------------------
Dtranslators/Melvyl.js | 138-------------------------------------------------------------------------------
Dtranslators/MetaPress.js | 58----------------------------------------------------------
Dtranslators/Musee du Louvre.js | 164-------------------------------------------------------------------------------
Dtranslators/NASA ADS.js | 82-------------------------------------------------------------------------------
Dtranslators/NCBI PubMed.js | 360-------------------------------------------------------------------------------
Dtranslators/NYTimes.com.js | 214-------------------------------------------------------------------------------
Dtranslators/NZZ.ch.js | 146-------------------------------------------------------------------------------
Dtranslators/Nagoya University OPAC.js | 300-------------------------------------------------------------------------------
Dtranslators/National Archives of Australia.js | 251-------------------------------------------------------------------------------
Dtranslators/National Archives of South Africa.js | 128-------------------------------------------------------------------------------
Dtranslators/National Bureau of Economic Research.js | 74--------------------------------------------------------------------------
Dtranslators/National Gallery of Art - U.S.A..js | 170-------------------------------------------------------------------------------
Dtranslators/National Library of Australia (new catalog).js | 147-------------------------------------------------------------------------------
Dtranslators/National Library of Australia - Australian Newspapers.js | 166-------------------------------------------------------------------------------
Dtranslators/National Library of Australia.js | 66------------------------------------------------------------------
Dtranslators/National Library of New Zealand.js | 167-------------------------------------------------------------------------------
Dtranslators/National Post.js | 124-------------------------------------------------------------------------------
Dtranslators/Nature.js | 254-------------------------------------------------------------------------------
Dtranslators/New Zealand Herald.js | 154-------------------------------------------------------------------------------
Dtranslators/Newsnetz.js | 140-------------------------------------------------------------------------------
Dtranslators/OAIster.js | 91-------------------------------------------------------------------------------
Dtranslators/OCLC WorldCat FirstSearch.js | 208-------------------------------------------------------------------------------
Dtranslators/OSTI Energy Citations.js | 51---------------------------------------------------
Dtranslators/Old Bailey Online.js | 183-------------------------------------------------------------------------------
Dtranslators/Open WorldCat.js | 132-------------------------------------------------------------------------------
Dtranslators/OpenJudis - Indian Supreme Court cases.js | 100-------------------------------------------------------------------------------
Dtranslators/Optical Society of America.js | 92-------------------------------------------------------------------------------
Dtranslators/Optics Express.js | 79-------------------------------------------------------------------------------
Dtranslators/Osterreichischer Bibliothekenverbund.js | 53-----------------------------------------------------
Dtranslators/Ovid.js | 207-------------------------------------------------------------------------------
Dtranslators/Oxford Music and Art Online.js | 60------------------------------------------------------------
Dtranslators/PEI Archival Information Network.js | 174-------------------------------------------------------------------------------
Dtranslators/PEP Web.js | 115-------------------------------------------------------------------------------
Dtranslators/PLoS Biology and Medicine.js | 88-------------------------------------------------------------------------------
Dtranslators/PLoS Journals.js | 274-------------------------------------------------------------------------------
Dtranslators/Papers Past.js | 171-------------------------------------------------------------------------------
Dtranslators/Paris Review.js | 116-------------------------------------------------------------------------------
Dtranslators/Patents - USPTO.js | 145-------------------------------------------------------------------------------
Dtranslators/Philosopher's Imprint.js | 89-------------------------------------------------------------------------------
Dtranslators/Pion Journals.js | 68--------------------------------------------------------------------
Dtranslators/Pleade.js | 264-------------------------------------------------------------------------------
Dtranslators/Potsdamer Neueste Nachrichten.js | 143-------------------------------------------------------------------------------
Dtranslators/Primo.js | 822-------------------------------------------------------------------------------
Dtranslators/ProMED.js | 51---------------------------------------------------
Dtranslators/ProQuest Legacy.js | 218-------------------------------------------------------------------------------
Dtranslators/ProQuest.js | 354-------------------------------------------------------------------------------
Dtranslators/Probing the Past.js | 103-------------------------------------------------------------------------------
Dtranslators/Progress of Theoretical Physics.js | 90-------------------------------------------------------------------------------
Dtranslators/Project Gutenberg.js | 194-------------------------------------------------------------------------------
Dtranslators/Project MUSE.js | 177-------------------------------------------------------------------------------
Dtranslators/Protein Data Bank.js | 87-------------------------------------------------------------------------------
Dtranslators/PubMed Central.js | 189-------------------------------------------------------------------------------
Dtranslators/Pubget.js | 63---------------------------------------------------------------
Dtranslators/RDF.js | 643-------------------------------------------------------------------------------
Dtranslators/RIS.js | 632-------------------------------------------------------------------------------
Dtranslators/RSC Publishing.js | 439-------------------------------------------------------------------------------
Dtranslators/Radio Liberty.js | 268-------------------------------------------------------------------------------
Dtranslators/RePEc.js | 182-------------------------------------------------------------------------------
Dtranslators/Readability.js | 82-------------------------------------------------------------------------------
Dtranslators/ReferBibIX.js | 286-------------------------------------------------------------------------------
Dtranslators/ReliefWeb.js | 59-----------------------------------------------------------
Dtranslators/Reuters.js | 81-------------------------------------------------------------------------------
Dtranslators/Revues.org.js | 345-------------------------------------------------------------------------------
Dtranslators/Rice University Library Catalog.js | 363-------------------------------------------------------------------------------
Dtranslators/Royal Historical Society.js | 89-------------------------------------------------------------------------------
Dtranslators/SAE International.js | 75---------------------------------------------------------------------------
Dtranslators/SFU IPinCH.js | 190-------------------------------------------------------------------------------
Dtranslators/SPIE Digital Library.js | 58----------------------------------------------------------
Dtranslators/SPIRES.js | 86-------------------------------------------------------------------------------
Dtranslators/SSRN.js | 112-------------------------------------------------------------------------------
Dtranslators/Sage Journals Online.js | 86-------------------------------------------------------------------------------
Dtranslators/SciELO.js | 107-------------------------------------------------------------------------------
Dtranslators/Science Links Japan.js | 74--------------------------------------------------------------------------
Dtranslators/ScienceDirect.js | 383-------------------------------------------------------------------------------
Dtranslators/ScientificCommons.js | 90-------------------------------------------------------------------------------
Dtranslators/Scitation.js | 79-------------------------------------------------------------------------------
Dtranslators/Scopus.js | 107-------------------------------------------------------------------------------
Dtranslators/Slate.js | 139-------------------------------------------------------------------------------
Dtranslators/SlideShare.js | 76----------------------------------------------------------------------------
Dtranslators/Spiegel Online.js | 221-------------------------------------------------------------------------------
Dtranslators/SpringerLink.js | 106-------------------------------------------------------------------------------
Dtranslators/Stuff.co.nz.js | 469-------------------------------------------------------------------------------
Dtranslators/Sudoc.js | 288-------------------------------------------------------------------------------
Dtranslators/Sueddeutsche.de.js | 185-------------------------------------------------------------------------------
Dtranslators/Sydney Morning Herald.js | 85-------------------------------------------------------------------------------
Dtranslators/TV by the Numbers.js | 138-------------------------------------------------------------------------------
Dtranslators/TVNZ.js | 215-------------------------------------------------------------------------------
Dtranslators/Tagesspiegel.js | 146-------------------------------------------------------------------------------
Dtranslators/TalisPrism.js | 435-------------------------------------------------------------------------------
Dtranslators/Tatknigafund.js | 129-------------------------------------------------------------------------------
Dtranslators/The Age.js | 110-------------------------------------------------------------------------------
Dtranslators/The Atlantic.js | 147-------------------------------------------------------------------------------
Dtranslators/The Australian.js | 105-------------------------------------------------------------------------------
Dtranslators/The Boston Globe.js | 221-------------------------------------------------------------------------------
Dtranslators/The Chronicle of Higher Education.js | 298-------------------------------------------------------------------------------
Dtranslators/The Daily Beast.js | 142------------------------------------------------------------------------------
Dtranslators/The Economist.js | 122-------------------------------------------------------------------------------
Dtranslators/The Free Dictionary.js | 30------------------------------
Dtranslators/The Globe and Mail.js | 222-------------------------------------------------------------------------------
Dtranslators/The Hamilton Spectator.js | 115-------------------------------------------------------------------------------
Dtranslators/The Hindu.js | 124-------------------------------------------------------------------------------
Dtranslators/The Microfinance Gateway.js | 60------------------------------------------------------------
Dtranslators/The Nation.js | 134-------------------------------------------------------------------------------
Dtranslators/The New York Review of Books.js | 65-----------------------------------------------------------------
Dtranslators/The New Yorker.js | 54------------------------------------------------------
Dtranslators/The Open Library.js | 174-------------------------------------------------------------------------------
Dtranslators/The Telegraph.js | 73-------------------------------------------------------------------------
Dtranslators/The Times UK.js | 105-------------------------------------------------------------------------------
Dtranslators/Time-Blog.com.js | 140-------------------------------------------------------------------------------
Dtranslators/Time.com.js | 161-------------------------------------------------------------------------------
Dtranslators/Toronto Star.js | 161-------------------------------------------------------------------------------
Dtranslators/Twitter.js | 94-------------------------------------------------------------------------------
Dtranslators/UBC Library Catalog.js | 183-------------------------------------------------------------------------------
Dtranslators/US National Archives Research Catalog.js | 169-------------------------------------------------------------------------------
Dtranslators/Unidade de Biologia da Conservaçao.js | 135-------------------------------------------------------------------------------
Dtranslators/Universiteit van Amsterdam.js | 107-------------------------------------------------------------------------------
Dtranslators/University of Chicago.js | 160-------------------------------------------------------------------------------
Dtranslators/University of Michigan.js | 98-------------------------------------------------------------------------------
Dtranslators/Unqualified Dublin Core RDF.js | 123-------------------------------------------------------------------------------
Dtranslators/Vanderbilt eJournals.js | 84-------------------------------------------------------------------------------
Dtranslators/Verniana-Jules Verne Studies.js | 84-------------------------------------------------------------------------------
Dtranslators/VoxEU.js | 49-------------------------------------------------
Dtranslators/Wanfang Data.js | 364-------------------------------------------------------------------------------
Dtranslators/Washington Monthly.js | 102-------------------------------------------------------------------------------
Dtranslators/Welt Online.js | 156-------------------------------------------------------------------------------
Dtranslators/Wikileaks Cables.js | 30------------------------------
Dtranslators/Wikipedia Citation Templates.js | 337-------------------------------------------------------------------------------
Dtranslators/Wildlife Biology in Practice.js | 84-------------------------------------------------------------------------------
Dtranslators/Wiley Online Library.js | 522-------------------------------------------------------------------------------
Dtranslators/WilsonWeb.js | 715-------------------------------------------------------------------------------
Dtranslators/Winnipeg Free Press.js | 99-------------------------------------------------------------------------------
Dtranslators/World History Connected.js | 126-------------------------------------------------------------------------------
Dtranslators/YouTube.js | 168-------------------------------------------------------------------------------
Dtranslators/Zhurnalnyi zal.js | 80-------------------------------------------------------------------------------
Dtranslators/Zotero RDF.js | 551-------------------------------------------------------------------------------
Dtranslators/arXiv.org.js | 253-------------------------------------------------------------------------------
Dtranslators/build_zip | 20--------------------
Dtranslators/cablegatesearch.net.js | 90-------------------------------------------------------------------------------
Dtranslators/dLibra.js | 167-------------------------------------------------------------------------------
Dtranslators/deleted.txt | 22----------------------
Dtranslators/eLibrary.ru.js | 317-------------------------------------------------------------------------------
Dtranslators/eMJA.js | 126-------------------------------------------------------------------------------
Dtranslators/eMedicine.js | 97-------------------------------------------------------------------------------
Dtranslators/ePrint IACR.js | 109-------------------------------------------------------------------------------
Dtranslators/fishpond.co.nz.js | 146-------------------------------------------------------------------------------
Dtranslators/fr-online.de.js | 176-------------------------------------------------------------------------------
Dtranslators/informIT database.js | 186-------------------------------------------------------------------------------
Dtranslators/jmlr.js | 116-------------------------------------------------------------------------------
Dtranslators/nips.js | 80-------------------------------------------------------------------------------
Dtranslators/taz.de.js | 177-------------------------------------------------------------------------------
Dtranslators/unAPI.js | 394-------------------------------------------------------------------------------
Dtranslators/washingtonpost.com.js | 121-------------------------------------------------------------------------------
Dtranslators/wsj.js | 43-------------------------------------------
Dtranslators/zotero.org.js | 194-------------------------------------------------------------------------------
354 files changed, 0 insertions(+), 63385 deletions(-)

diff --git a/translators/3news.co.nz.js b/translators/3news.co.nz.js @@ -1,230 +0,0 @@ -{ - "translatorID": "a9f7b277-e134-4d1d-ada6-8f7942be71a6", - "label": "3news.co.nz", - "creator": "Sopheak Hean", - "target": "^https?://www\\.3news\\.co\\.nz", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": false, - "translatorType": 4, - "lastUpdated": "2011-04-21 09:17:38" -} - -/* - 3news.co.nz Translator- Parses 3news.co.nz articles and creates Zotero-based metadata - Copyright (C) 2011 Sopheak Hean, University of Waikato, Faculty of Education - Contact: maxximuscool@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) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var blog= '//div[@class="newsWrapperDisp"]/div[@class="news"]/span'; - var blogObject = doc.evaluate(blog, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (blogObject){ - return "blogPost"; - } else { - var date='//div[@class="ModArticleDisplayC"]/div[@class="newsWrapperFullDisp09"]/div[@class="news"]/span'; - var dateObject = doc.evaluate(date, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (dateObject){ - return "newspaperArticle"; - } - } - return false; -} - -function scrape (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null - - if (detectWeb(doc, url) =="newspaperArticle"){ - var newItem = new Zotero.Item('newspaperArticle'); - newItem.url = doc.location.href; - newItem.publicationTitle = "3news.co.nz"; - newItem.language = "English"; - - if (dodate(doc, url) !=null){ - newItem.date = dodate(doc, url); - } - - if (doAbstract(doc, url) != null) { - newItem.abstractNote= doAbstract(doc, url); - } - var au = '//div[@id="newsbody"]/p/strong'; - var author = doAuthor(doc, url, au); - var title = '//h1'; - if (doTitle(doc, url, title) !=null){ - newItem.title = doTitle(doc, url, title); - } - if (author != null){ - - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - if(doSection(doc,url) !=null){ - newItem.section = doSection(doc,url); - } - if(doCopyright(doc,url) !=null){ - newItem.rights = doCopyright(doc,url); - } - newItem.attachments.push({title:"3news.co.nz Snapshot", mimeType:"text/html", url:newItem.url}); - newItem.complete(); - } - - - else if (detectWeb(doc,url) =="blogPost"){ - var newItem = new Zotero.Item('blogPost'); - newItem.url = doc.location.href; - //newItem.publicationTitle = "3news.co.nz"; - newItem.language = "English"; - if (doAbstract(doc, url) != null) { - newItem.abstractNote= doAbstract(doc, url); - } - if (dodate(doc, url) !=null){ - newItem.date = dodate(doc, url); - } - var title = '//h1'; - if (doTitle(doc, url, title) !=null){ - newItem.title = doTitle(doc, url, title); - } - var author ='//div[@class="news"]/p/strong'; - if (doAuthor(doc, url, author) != null){ - newItem.creators.push(Zotero.Utilities.cleanAuthor(doAuthor(doc, url, author), "author")); - } - if(doSection(doc,url) !=null){ - newItem.section = doSection(doc,url); - } - if(doCopyright(doc,url) !=null){ - newItem.rights = doCopyright(doc,url); - } - newItem.attachments.push({title:"3news.co.nz Snapshot", mimeType:"text/html", url:newItem.url}); - newItem.complete(); - - } -} - -function doSection (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var section = '//div[@id="newsBreadCrumb"]/span/a[1]'; - var sectionObject =doc.evaluate(section, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(sectionObject){ - return sectionObject.textContent; - } else return null; -} - -function dodate ( doc, url ) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var date='//div[@class="ModArticleDisplayC"]/div/div[@class="news"]/span'; - var dateObject = doc.evaluate(date, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (dateObject){ - dateObject = dateObject.textContent.replace(/\s(\d:{0,9})+:(\d{0,9})+([a-zA-Z.]{1,4})/, ''); - return dateObject; - } else return null; -} - -function doTitle(doc, url, title){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var titleObject = doc.evaluate(title, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (titleObject){ - var articleTitle= titleObject.textContent; - return articleTitle; - } - else return null; -} - - -function doAuthor(doc, url, author){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var author2 = author; - var authorObject = doc.evaluate(author2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (authorObject){ - authorObject= authorObject.textContent.replace(/By\s/, ''); - return authorObject; - } - else return null; -} - - -function doAbstract(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - var a= "//meta[@name='DESCRIPTION']"; - var abs= doc.evaluate(a, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abs){ - var abstractString = abs.content; - return abstractString; - - } - else return null; - -} - -function doCopyright(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var CP = '//meta[@name="COPYRIGHT"]'; - var copyrightObject = doc.evaluate(CP, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (copyrightObject){ - return copyrightObject.content; - - } - else return null; -} - -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(); - if (detectWeb(doc, url) == "newspaperArticle" || detectWeb(doc, url) == "blogPost") { - scrape(doc, url); - } else { - /** Multiple cannot be done for this translator **/ - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } -} diff --git a/translators/A Contra Corriente.js b/translators/A Contra Corriente.js @@ -1,48 +0,0 @@ -{ - "translatorID":"bbf1617b-d836-4665-9aae-45f223264460", - "translatorType":4, - "label":"A Contra Corriente", - "creator":"Michael Berkowitz", - "target":"http://www.ncsu.edu/project/acontracorriente", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-03 19:40:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//tr[td[1]//img][td[3]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var arts = doc.evaluate('//tr[td[1]//img][td[3]]', doc, null, XPathResult.ANY_TYPE, null); - var art; - var selectList = new Object(); - var items = new Object(); - while (art = arts.iterateNext()) { - var item = new Object(); - var title = doc.evaluate('.//a', art, null, XPathResult.ANY_TYPE, null).iterateNext(); - item['title'] = Zotero.Utilities.trimInternal(title.textContent); - item['pdfurl'] = title.href; - item['author'] = doc.evaluate('.//strong', art, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - selectList[item.title] = item.title; - items[item.title] = item; - } - var selected = Zotero.selectItems(selectList); - var voliss = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="red01"]/font[2]/strong', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - voliss = voliss.match(/Vol\.\s+(\d+),\s+No\.\s+(\d+)\.\s+([^|]+)|/); - Zotero.debug(voliss); - for each (var title in selected) { - var item = new Zotero.Item("journalArticle"); - var olditem = items[title]; - item.title = olditem.title; - item.creators = [Zotero.Utilities.cleanAuthor(olditem.author, "author")]; - item.volume = voliss[1]; - item.issue = voliss[2] - item.date = Zotero.Utilities.trimInternal(voliss[3]); - item.complete(); - } -} -\ No newline at end of file diff --git a/translators/ABC-CLIO Serials Web.js b/translators/ABC-CLIO Serials Web.js @@ -1,141 +0,0 @@ -{ - "translatorID":"a07bb62a-4d2d-4d43-ba08-d9679a0122f8", - "translatorType":4, - "label":"ABC-CLIO Serials Web", - "creator":"Simon Kornblith", - "target":"https?://[^/]*serials\\.abc-clio\\.com[^/]*/active/go/ABC-Clio-Serials_v4", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var result = doc.evaluate('//table[@class="rc_main"]', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - if(result) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var availableItems = new Array(); - var availableAttachments = new Array(); - - var elmts = doc.evaluate('//table[@class="rc_main"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var elmt; - while(elmt = elmts.iterateNext()) { - var title = doc.evaluate('./tbody/tr/td[b/text() = "Title:"]', - elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var checkbox = doc.evaluate('.//input[@type = "checkbox"]', - elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(title, checkbox) { - checkbox = checkbox.name; - availableItems[checkbox] = Zotero.Utilities.trimInternal(title.textContent).substr(6); - - var links = doc.evaluate('./tbody/tr/td[b/text() = "Fulltext: ["]/a', - elmt, nsResolver, XPathResult.ANY_TYPE, null); - var link; - - var attach = new Array(); - while(link = links.iterateNext()) { - attach.push({url:link.href, title:Zotero.Utilities.trimInternal(link.textContent)+" Full Text", - mimeType:"text/html"}); - } - availableAttachments[checkbox] = attach; - } - } - - var items = Zotero.selectItems(availableItems); - - if(!items) { - return true; - } - - var postString = "_defaultoperation=Download+Options&research_field=&research_value=&jumpto="; - var attachments = new Array(); - for(var i in availableItems) { - postString += "&_checkboxname="+i+(items[i] ? "&"+i+"=1" : ""); - if(items[i]) { - attachments.push(availableAttachments[i]); - } - } - - Zotero.Utilities.HTTP.doPost(url, postString, function(text) { - Zotero.Utilities.HTTP.doPost(url, "_appname=serials&_defaultoperation=Download+Documents&_formname=download&download_format=citation&download_which=tagged&download_where=ris&mailto=&mailreplyto=&mailsubject=&mailmessage=", - function(text) { - // get link - var linkRe = /<a\s+class="button"\s+href="([^"]+)"\s+id="resource_link"/i; - var m = linkRe.exec(text); - if(!m) { - throw("regular expression failed!"); - } - Zotero.Utilities.HTTP.doGet(m[1], function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if(item.notes && item.notes[0]) { - item.extra = item.notes[0].note; - - delete item.notes; - item.notes = undefined; - } - - // grab uni data from thesis - if(item.itemType == "thesis") { - var re = /^(.+?) ([0-9]{4})\. ([0-9]+) pp\.(.*)$/; - var m = re.exec(item.extra); - if(m) { - item.publisher = m[1]; - item.date = m[2]; - item.pages = m[3]; - item.extra = m[4]; - } - } - - // fix periods - for(var i in item.creators) { - var nameLength = item.creators[i].firstName.length; - - if(item.creators[i].firstName[nameLength-1] == ".") { - item.creators[i].firstName = item.creators[i].firstName.substr(0, nameLength-1); - } - } - for(var i in item.tags) { - var tagLength = item.tags[i].length; - - if(item.tags[i][tagLength-1] == ".") { - item.tags[i] = item.tags[i].substr(0, tagLength-1); - } - } - - // fix title - item.title = Zotero.Utilities.superCleanString(item.title); - - // add attachments - item.attachments = attachments.shift(); - - item.complete(); - }); - translator.translate(); - Zotero.done(); - }); - }); - }); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/ACLWeb.js b/translators/ACLWeb.js @@ -1,176 +0,0 @@ -{ - "translatorID":"f4a5876a-3e53-40e2-9032-d99a30d7a6fc", - "translatorType":4, - "label":"ACL", - "creator":"Nathan Schneider", - "target":"^http://(www[.])?aclweb.org/anthology-new/[^#]+", - "minVersion":"1.0.7", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2008-12-06 10:21:05" -} - -// based on ACM translator -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return prefix; else return null; - } : namespace; - - var bibXpath = "//a[./text() = 'bib']" - if(doc.evaluate(bibXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple" - } - //commenting out single stuff - // if (url.indexOf("/anthology-new/J/")>-1) - // return "journalArticle"; - // else - // return "conferencePaper"; -} - - -function scrapeIndex(doc, items) { - var results; - var doImport; - - if (items != null) { // Import user-selected item(s) - results = items; - doImport = true; - } - else { - bibFileNodes = doc.evaluate('//a[substring(@href, string-length(@href)-3, 4) = ".bib"]', doc, null, XPathResult.ANY_TYPE, null); - - results = new Array(); - doImport = false; - - var bibFileNode = bibFileNodes.iterateNext(); - - while (bibFileNode) { - var bibFileName = bibFileNode.getAttribute("href"); - var bibFile = bibFileName.substring(0, bibFileName.length-4); - - var bNodes = doc.evaluate('//a[@href="' + bibFileName + '"]/following-sibling::b[position()=1]', doc, null, XPathResult.ANY_TYPE, null); // These nodes contain author information - - // Extract authors' last names - var authorLasts = new Array(); - - var bNode = bNodes.iterateNext(); - var authorsS = bNode.innerHTML; // may include markup: potentially <author>, <first>, <von>, and/or <last> tags - authorsS = authorsS.replace(/[<][/]?author[>]/g, ""); - var authors = authorsS.split("; "); - for (var a in authors) { - var authorS = authors[a]; - var m = authorS.match(/[<]von[>]([^<]+)[<][/]von[>]/); - var last = ""; - if (m!=null) // we expect there is a <last> tag if there is a <von> tag - last = m[1] + " "; - m = authorS.match(/[<]last[>]([^<]+)[<][/]last[>]/); - if (m!=null) - last += m[1]; - else { - var name = authorS.replace(/[<][^>]+[>]/g, ""); // remove all markup - if (name=="Entire volume") - last = name; - else { - var parts = name.split(" "); - last = parts[parts.length-1]; - if (parts.length>1) { - var penultInitial = parts[parts.length-2].substr(0,1); - if (penultInitial.toUpperCase()!=penultInitial) // e.g. van Dyke - last = name[parts.length-2] + " " + last; - } - } - } - authorLasts.push(last); - } - - // Prepare result for this item, which consists of the relative path to the .bib file (minus the extension) - // followed by a space and the authors' last names (abbreviated format) - var result = bibFile + " "; - - if (authorLasts.length<3) - result += authorLasts.join(" & "); - else - result += authorLasts[0] + "+"; - - results.push(result); - bibFileNode = bibFileNodes.iterateNext(); - } - } - - - if (!doImport) - return results; - - for (var i in results) { - var ii = results[i].indexOf(" "); - var fileRelPath = results[i].substring(0, ii); - var authorsShort = results[i].substring(ii+1); - var fileName = fileRelPath.substring(fileRelPath.lastIndexOf("/")+1); - var bibFile = fileRelPath + ".bib"; - - var pageurl = doc.location.href; - var lastSlash = pageurl.lastIndexOf("/"); - var dirInUrl = pageurl.substring(0, lastSlash+1); - var fileInUrl = pageurl.substring(lastSlash+1, pageurl.indexOf("#", lastSlash)); - var bib = dirInUrl + fileRelPath + ".bib"; - var pdf = dirInUrl + fileRelPath + ".pdf"; - var j = fileRelPath.lastIndexOf("-"); - var yearShort = fileRelPath.substring(j-2, j); - var year = ""; - if (new Number(yearShort) < 50) - year = "20" + yearShort; - else - year = "19" + yearShort; - - var attachments = new Array(); - attachments.push({title:authorsShort + " " + year + ".pdf", mimeType:"application/pdf", url:pdf}); - - var type = ""; - if (pageurl.indexOf("/anthology-new/J/")>-1) - type = "journalArticle"; - else - type = "conferencePaper"; - - if (doImport) - callTranslator(bib, type, attachments); - - } -} - -function callTranslator(bibFileURL, type, attachments) { - Zotero.Utilities.HTTP.doGet(bibFileURL, function(text) { - - // load BibTex translator - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.itemType = type; - item.attachments = attachments; - item.repository = "Association for Computational Linguistics" - item.complete(); - }); - translator.translate(); - - }); -} - -function doWeb(doc, url) { - var searchResult = true; - if(searchResult) { - var possibleItems = scrapeIndex(doc, null); // items to present to user - - items = Zotero.selectItems(possibleItems); // items selected by the user - if(!items) return true; - - scrapeIndex(doc, items); - - } else { - //not implemented yet - scrape(doc); - } - - Zotero.wait(); -} diff --git a/translators/ACM.js b/translators/ACM.js @@ -1,415 +0,0 @@ -{ - "translatorID": "f3f092bf-ae09-4be6-8855-a22ddd817925", - "label": "ACM Digital Library", - "creator": "Simon Kornblith, Michael Berkowitz and John McCaffery", - "target": "^https?://[^/]*portal\\.acm\\.org[^/]*/(?:results\\.cfm|citation\\.cfm)", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-10 01:14:01" -} - -/** - * The XPath for all the search result <a> elements - */ -var searchResultX = '//td[@colspan="3"]/a[@class="medium-text" and @target="_self"]'; -/** - * The XPath for all the journal TOC <a> elements - */ -var tocResultX = '//td[@colspan="1"]/span[@style]/a[contains(@href,"citation.cfm")]'; - -/** - * The XPath for the tag elements in a justified format tags list - */ -var justifiedTagX = '//div[@id="divtags"]/p/a'; -/** - * The XPath for the tag elements in an un-justified format tags list - */ -var unjustifiedTagX = '//div[@id="divtags"]/a'; -/** - * the XPath for the "more tags" link element - */ -var moreTagsX = '//a[@href="javascript:ColdFusion.Window.show(' + "'thetags'" + ')"]'; -/** - * the XPath for the tag elements in the "more tags" popup - */ -var moreTagX = '//a/span[@class="small-text"]'; -/** - * the XPath for the title heading element - not strictly necessary, more helpful for debugging - */ -var titleX = '//div[@class="large-text"]/h1[@class="mediumb-text"]/strong'; -/** - * XPath for Table of Contents headline for journal issue - */ -var tocX = "//div[@id='citationdetails']//h5[@class='medium-text' and contains(.,'Table of Contents')]"; - - - -/** - * Scan to see what type of page this is - * @param doc The XML document describing the page - * @param url The URL of the page being scanned - * @return What type of article this page is (multiple, journal or conference proceedings) - */ -function detectWeb(doc, url) { - var nsResolver = getNsResolver(doc); - var title = getText(titleX, doc, nsResolver); - Zotero.debug("Title: " + title); - - if(url.indexOf("/results.cfm") != -1) { - Zotero.debug("Multiple items detected"); - return "multiple"; - } else if (url.indexOf("/citation.cfm") != -1) { - Zotero.debug("Single item detected"); - return getArticleType(doc, url, nsResolver); - /* - var type = getArticleType(doc, url, nsResolver); - if (type .indexOf("conferencePaper") != -1) { - return "conferencePaper"; - } else - return "journalArticle"; - }*/ - } -} - -/** - * Parse the page - * @param doc The XML document describing the page - * @param url The URL of the page being scanned - */ -function doWeb(doc, url) { - var nsResolver = getNsResolver(doc, url); - - //If there are multiple pages - if (getArticleType(doc, url) == "multiple") { - //If this is a search results page - if (url.indexOf("results.cfm") != -1) - scrapeMulti(doc, url, nsResolver, "search"); - else if(getText(tocX, doc, nsResolver) =="Table of Contents") - scrapeMulti(doc, url, nsResolver, "toc"); - Zotero.wait(); - } //If this is a single page - else - scrape(doc, url, nsResolver); -} - -/** - * Scrape search results and journal tables of contents - * @param doc The XML document describing the page - * @param url The URL of the page being scanned - * @param nsResolver the namespace resolver function - * @param type Type of result-- "search" or "toc" - */ -function scrapeMulti(doc, url, nsResolver, type) { - switch(type) { - case "toc": - Zotero.debug("Scraping journal TOC"); - var resultPath= doc.evaluate(tocResultX, doc, null, XPathResult.ANY_TYPE, null); - break; - case "search": - Zotero.debug("Scraping search"); - default: - var resultPath= doc.evaluate(searchResultX, doc, null, XPathResult.ANY_TYPE, null); - } - - //Count how mange pages have been scraped - var node; - var urls = {}; - //Iterate through all the results - while(node= resultPath.iterateNext()) { - urls[node.href + '&preflayout=flat'] = node.textContent; - } - - var items = Zotero.selectItems(urls); - if(!items) return true; - - var i; - urls = []; - for (i in items) urls.push(i); - - Zotero.Utilities.processDocuments(urls, scrape, function(){Zotero.done()}); -} - -/** - * Scrape a single page - * @param doc The XML document describing the page - */ -function scrape(doc) { - var url = doc.location.href; - var nsResolver = getNsResolver(doc, url); - - //Get all the details not scraped from the bibtex file - var tags = scrapeKeywords(doc); - var attachments = scrapeAttachments(doc, url); - var abs = scrapeAbstract(doc); - // Type not used, since it was less reliable than BibTeX - var type = getArticleType(doc, url, nsResolver); - // Manual journal not used. Some pieces are multiply published, see http://portal.acm.org/citation.cfm?id=52400.52432&coll=DL&dl=GUIDECFID=16073284&CFTOKEN=77905982 - // and also http://forums.zotero.org/discussion/17532/ - var journal = getText("//meta[@name='citation_journal_title']/@content",doc, nsResolver); - //Get the bibtex reference for this document as a string - var bibtex = scrapeBibtex(url, nsResolver); - - //Create the new item - var newItem = new Zotero.Item(type); - - //Use the bibtex translator to parse the bibtex string - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(bibtex ); - //Set the function to run when the bibtex string has been parsed - translator.setHandler("itemDone", function(obj, newItem) { - //Store all details not parsed from the bibtex - if(abs) newItem.abstractNote = abs; - newItem.tags = tags; - newItem.attachments = attachments; - // There were issues with grabbing type from the page; - // see http://forums.zotero.org/discussion/17246/ - //newItem.itemType= type; - /*if (journal && journal != newItem.publicationTitle) { - newItem.journalAbbreviation = newItem.publicationTitle; - newItem.publicationTitle = journal; - }*/ - // If the URL is just a DOI, clear it. - if (newItem.url && newItem.url.match(/^http:\/\/doi\.acm\.org\//)) newItem.url = ""; - if (newItem.DOI) newItem.DOI = newItem.DOI.replace(/^http:\/\/doi\.acm\.org\//, ''); - var acmid = bibtex.match(/acmid = {(\d+)}/); - if(acmid) newItem.extra = "ACM ID: "+ acmid[1]; - newItem.place = newItem.archiveLocation; - newItem.archiveLocation = null; - //Complete the parsing of the page - newItem.complete(); - }); - - //Trigger the translation - translator.translate(); -} - -/** - * Scrape all keywords attached to this document - * @param doc The XML document describing the page - * @return an array of all keywords attached to this document - */ -function scrapeKeywords(doc) { - Zotero.debug("Scraping Keywords"); - //Try scraping keywords from the "more keywords" popup - var keywords = scrapeMoreTagsKeywords(doc); - - if (keywords) return keywords; - - keywords = new Array(); - - //Otherwise look for the keywords - check justified format - var keywordPath = doc.evaluate(justifiedTagX, doc, null, XPathResult.ANY_TYPE, null); - var keywordNode = keywordPath.iterateNext(); - //If justified format didn't work check unjustified - if (!keywordNode) { - keywordPath = doc.evaluate(unjustifiedTagX, doc, null, XPathResult.ANY_TYPE, null); - keywordNode = keywordPath.iterateNext(); - } - //Iterate through all the keywords - while(keywordNode) { - keywords.push(Zotero.Utilities.trimInternal(keywordNode .textContent.toLowerCase())); - Zotero.debug("Keyword: " + keywordNode .textContent.toLowerCase()); - keywordNode = keywordPath.iterateNext(); - } - - return keywords; -} - -/** - * Scrape keywords from a "more tags" popup - * @param doc The XML document describing the page - * @return an array of all the keywords attached to the page which will be used as the tags for the document - */ -function scrapeMoreTagsKeywords(doc) { - var keywords = new Array(); - - //Look for a link for a javascript code for a "more tags" popup - var morePath = doc.evaluate(moreTagsX, doc, null, XPathResult.ANY_TYPE, null); - var moreNode = morePath ? morePath.iterateNext() : null; - //If there is no "more tags" popup - if (!moreNode) - return null; - - var keywordPath = doc.evaluate(moreTagX, doc, null, XPathResult.ANY_TYPE, null); - - var keywordNode; - //Iterate through all the keywords - while(keywordNode = keywordPath.iterateNext()) { - keywords.push(Zotero.Utilities.trimInternal(keywordNode .textContent.toLowerCase())); - Zotero.debug("Keyword: " + keywordNode .textContent.toLowerCase()); - } - return keywords; -} - -/** - * Scrape all the relevant attachments from the page. - * Firstly grabs a snapshot of the ACM page then looks for any links to the full text - * @param doc The XML document describing the page - * @param url The URL of the page being scanned - * @return an array of all the attachments - */ -function scrapeAttachments(doc, url) { - Zotero.debug("Scraping attachments"); - var attachments = new Array(); - - //Add the scrapeshot of this page - attachments.push({title:"ACM Snapshot", mimeType:"text/html", url:url}); - - //XPath for the full text links - var textPath = doc.evaluate('//a[@name="FullTextPdf" or @name="FullTextHtml" or @name="FullText Html"][not(ancestor::div[@class="flatbody"])]', doc, null, XPathResult.ANY_TYPE, null); - - var textNode; - //Iterate through all the links - while (textNode= textPath .iterateNext()) { - var textURL= textNode.href; - - //If the full text is a pdf - if (textNode.name == "FullTextPdf") { - Zotero.debug("Text PDF: " + textURL); - attachments.push({title:"ACM Full Text PDF", mimeType:"application/pdf", url:textURL}); - } else { //Otherwise the text is an HTML link - Zotero.debug("Text Page: " + textURL); - attachments.push({title:"ACM Full Text HTML", mimeType:"text/html", url:textURL}); - } - - // Break at a reasonable limit - if (attachments.length > 20) return attachments; - } - - return attachments; -} - -/** - * Scrape the abstract from the page - * @param doc The XML document describing the page - * @param url The URL of the page being scanned - * @return a string with the text of the abstract - */ -function scrapeAbstract(doc) { - Zotero.debug("Scraping abstract"); - var text = getText('//div[@class="flatbody" or @class="tabbody"]', doc); - return Zotero.Utilities.trimInternal(text); -} - -/** - * Get the text of the bibtex format reference - * @param url The URL of the page being scanned - * @param nsResolver the namespace resolver function - * @return the bibtex reference as a trimmed string - */ -function scrapeBibtex(url, nsResolver) { - Zotero.debug("Scraping full details from bibtex"); - //Get the ID of this document - var id = getId(url); - //The link of the bibtex popup - var bibtex = "http://portal.acm.org/exportformats.cfm?id=" + id + "&expformat=bibtex"; - - Zotero.debug("Bibtex: " + bibtex); - - //Get the xml document which will be loaded into the popup box - var texDoc = Zotero.Utilities.retrieveDocument(bibtex); - //Find the node with the bibtex text in it - var path = texDoc.evaluate('//pre', texDoc, nsResolver, XPathResult.ANY_TYPE, null); - var node = path.iterateNext(); - - if (node != null && node.textContent != null) { - var ref = node.textContent; - Zotero.debug("\nref : " + (ref == null ? "null":ref)); - ref = Zotero.Utilities.trimInternal(ref); - ref = Zotero.Utilities.trim(ref); - return ref; - } - return null; -} - -/** - * Get the unique identifier of this document - * @param url The URL of the page being scanned - * @param journal [optional]whether to get the ID of the journal the document is in or of the document itself - * @return a string containing the identifier of the document or journal the document is in - */ -function getId(url, journal) { - if (journal=== undefined) - journal= false; - - var cfmIndex = url.indexOf(".cfm"); - var atIndex = url.indexOf('&'); - - var id = url.substr(cfmIndex + 8); - - if (atIndex != -1) - id = id.replace(url.substring(atIndex), ""); - - var dotIndex = id.indexOf('.'); - if (dotIndex != -1) - if (!journal) - id = id.replace(id .substring(0, (dotIndex+1)), ""); - else - id = id.replace(id .substring(dotIndex), ""); - - return id; -} - -/** - * Find out what kind of document this is - * @param doc The XML document describing the page - * @param url The URL of the page being scanned - * @param nsResolver the namespace resolver function - * @return a string with either "multiple", "journalArticle" or "conferencePaper" in it, depending on the type of document - */ -function getArticleType(doc, url, nsResolver) { - var toc = doc.evaluate(tocX, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (url.indexOf("results.cfm") != -1 || toc) { - Zotero.debug("Type: multiple"); - return "multiple"; - } - - //XPath for the table cell which has either "Journal" or "Proceeding" in it - var text = getText('//td[@nowrap="nowrap" and @style="padding-bottom: 0px;"]', doc, nsResolver); - - Zotero.debug("Type: " + text); - if (text.indexOf("Proceeding") != -1) - return "conferencePaper"; - else if (text.indexOf("Magazine") != -1) - return "magazineArticle"; - else - return "journalArticle"; - -} - -/** - * Get the text from the first node defined by the given xPathString - * @param pathString the XPath indicating which node to get the text from - * @param doc The XML document describing the page - * @param nsResolver the namespace resolver function - * @return the text in the defined node or "Unable to scrape text" if the node was not found or if there was no text content - */ -function getText(pathString, doc, nsResolver) { - var path = doc.evaluate(pathString, doc, nsResolver, XPathResult.ANY_TYPE, null); - var node = path.iterateNext(); - - if (node == null || node.textContent == undefined || node.textContent == null) { - Zotero.debug("Unable to retrieve text for XPath: "+pathString); - return ""; - } - - return node.textContent; -} - -/** - * Get a function for returning the namespace of a given document given its prefix - * @param nsResolver the namespace resolver function - */ -function getNsResolver(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; - else return null; - } : null; - - return nsResolver; -} diff --git a/translators/ACS Publications.js b/translators/ACS Publications.js @@ -1,117 +0,0 @@ -{ - "translatorID":"938ebe32-2b2e-4349-a5b3-b3a05d3de627", - "translatorType":4, - "label":"ACS Publications", - "creator":"Sean Takats and Michael Berkowitz and Santawort", - "target":"http://[^/]*pubs3?.acs.org[^/]*/(?:wls/journals/query/(?:subscriberResults|query)\\.html|acs/journals/toc.page|cgi-bin/(?:article|abstract|sample|asap).cgi)?", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-06-04 19:20:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.evaluate('//input[@id="articleListHeader_selectAllToc"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("multiple"); - return "multiple"; - } else if (doc.evaluate('//div[@id="articleHead"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } - return false; -} - -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 + "/"; - Zotero.debug(host); - var m = url.match(/https?:\/\/[^\/]*\/doi\/(abs|full)\/([^\?]+)/); - var dois = new Array(); - if(detectWeb(doc, url) == "multiple") { //search - var doi; - var title; - var availableItems = new Array(); - var xpath = '//div[@class="articleBox" or @class="articleBox "]'; - if (doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - do { - title = doc.evaluate('./div[@class="articleBoxMeta"]/h2', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - doi = doc.evaluate('./div[@class="articleBoxMeta"]/h2/a/@href', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("/doi/abs/",""); - if (doi.indexOf("prevSearch") != -1){ - doi = doi.substring(0,doi.indexOf("?")); - } - availableItems[doi] = title; - } while (elmt = elmts.iterateNext()) - } - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - for(var i in items) { - dois.push(i); - } - } else if (m){ //single article - var doi = m[2]; - if (doi.match("prevSearch")) { - doi = doi.substring(0,doi.indexOf("?")); - } - Zotero.debug("DOI= "+doi); - dois.push(doi); - } - - var setupSets = []; - for each (doi in dois) { - var citUrl = host + 'action/showCitFormats?doi=' + doi; - setupSets.push({ doi: doi, citUrl: citUrl }); - } - - var setupCallback = function () { - //get citation export page's source code; - if (setupSets.length) { - var set = setupSets.shift(); - Zotero.Utilities.HTTP.doGet(set.citUrl, function(text){ - //get the exported RIS file name; - var downloadFileName = text.match(/name=\"downloadFileName\" value=\"([A-Za-z0-9_]+)\"/)[1]; - Zotero.debug("downloadfilename= "+downloadFileName); - processCallback(set.doi,downloadFileName); - }); - } - else { - Zotero.done(); - } - } - var processCallback = function (doi,downloadFileName) { - var baseurl = "http://pubs.acs.org/action/downloadCitation"; - var post = "doi=" + doi + "&downloadFileName=" + downloadFileName + "&include=abs&format=refman&direct=on&submit=Download+article+citation+data"; - Zotero.Utilities.HTTP.doPost(baseurl, post,function(text){ - // Fix the RIS doi mapping - text = text.replace("N1 - doi:","M3 - "); - Zotero.debug("ris= "+ text); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var pdfUrl = host + 'doi/pdf/' + doi; - var fullTextUrl = host + 'doi/full/' + doi; - item.attachments.push( - {title:"ACS Full Text PDF",url:pdfUrl, mimeType:"application/pdf"}, - {title:"ACS Full Text Snapshot",url:fullTextUrl, mimeType:"text/html"} - ); - item.complete(); - }); - translator.translate(); - setupCallback(); - }); - } - setupCallback(); - Zotero.wait(); -} diff --git a/translators/AGU Journals.js b/translators/AGU Journals.js @@ -1,258 +0,0 @@ -{ - "translatorID":"9220fa99-b936-430e-a8ea-43ca6cb04145", - "translatorType":4, - "label":"AGU Journals", - "creator":"Ben Parr", - "target":"^https?://(?:www.)?agu.org", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc,url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath; - - //abstract - xpath='//p[@id="citation"]'; - if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { return "journalArticle"; } - - //full text - xpath='//frameset[@rows="98, *"]'; - if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { return "journalArticle"; } - - //issue page - xpath='//tr/td/p[@class="title"]'; - if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { return "multiple"; } - - //Search Page - if(doc.title.indexOf("Query Results")>-1) - {return "multiple";} -} - - -function fixCaps(s) -{ - if(s!='') - { - words=Zotero.Utilities.trimInternal(s).toLowerCase().split(" "); - for (var j = 0 ; j < words.length ; j++) - { - if (j==0||(words[j][0] ==words[j][0].toLowerCase()&&words[j]!="or"&&words[j]!="and"&&words[j]!="of"&&words[j]!="in")) - { words[j]= words[j][0].toUpperCase() +words[j].substr(1); } - } - return words.join(" "); - } - return ''; -} - -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; - - xpath='//p[@id="title"]'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if(temp) - {newItem.title=temp.textContent;} - - xpath='//span[@id="published"]'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if(temp) - { - temp=Zotero.Utilities.trimInternal(temp.textContent).split(" ");; - newItem.date=temp[1]+" "+temp[0]+", "+temp[2]; - } - - xpath='//p[@class="author"]'; - rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - var count=0; - while(row=rows.iterateNext()) - {newItem.creators.push(Zotero.Utilities.cleanAuthor(row.textContent,"author")); - count++;} - - xpath='//tr/td/p'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - var temp2=temp.iterateNext(); - if(temp2) - { - for(var n=0;n<(3+2*count);n++) - {temp2=temp.iterateNext();} - newItem.abstractNote=Zotero.Utilities.trimInternal(temp2.textContent); - } - - xpath='//p[@id="runhead"]'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if(temp) - { - temp=Zotero.Utilities.trimInternal(temp.textContent).split(", "); - newItem.publicationTitle=fixCaps(temp[0]); - for(var n=1;temp[n];n++) - { - if(temp[n].indexOf("VOL")>-1) - {newItem.volume=temp[n].replace('VOL. ','');} - else if(temp[n].indexOf("NO.")>-1) - {newItem.issue=temp[n].replace('NO. ','');} - else if(temp[n].indexOf("doi:")>-1) - {newItem.DOI=temp[n].replace('doi:','');} - else if(temp[n+1]) - {newItem.pages=temp[n];} - } - } - - xpath='//p[@id="keywords"]'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if(temp) - { - temp=Zotero.Utilities.trimInternal(temp.textContent.replace('Keywords:','')); - newItem.tags=temp.replace('.','').split('; '); - } - xpath='//p[@id="citation"]/span[@id="journal"]'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if(temp) - {newItem.journalAbbreviation=temp.textContent;} - - newItem.complete(); -} - - -function processList(items) -{ - items = Zotero.selectItems(items); - var uris=new Array(); - - if (!items) - {return true;} - - for (var i in items) - {uris.push(i);} - - Zotero.Utilities.processDocuments(uris, scrape,function() {Zotero.done(); }); - Zotero.wait(); - - return true; -} - -function doWeb(doc,url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - //abstract - var xpath='//p[@id="citation"]'; - if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { - scrape(doc,url); - return true; - } - - //full text - xpath='//frameset[@rows="98, *"]'; - if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { - Zotero.Utilities.processDocuments(url+"0.shtml", scrape, function(){ Zotero.done(); }); - Zotero.wait(); - - return true; - } - - //issue page - xpath='//tr/td/p[@class="title"]'; - if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { - var titlerows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - xpath='//tr/td/p[@class="pubdate"]/a'; - var linkrows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - - var titlerow; - var linkrow; - var items=new Array(); - - while(titlerow=titlerows.iterateNext()) - { - linkrow=linkrows.iterateNext(); - while(linkrow.textContent.indexOf("Abstract")<0) - {linkrow=linkrows.iterateNext();} - items[linkrow.href]=titlerow.textContent; - } - - return processList(items); - } - - - //Search page - if(doc.title.indexOf("Query Results")>-1) - { - //FASTFind Search - - xpath='//tr/td/h2'; - var tt=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext().textContent; - if(tt.indexOf("FASTFIND")>-1) - { - xpath='//tr/td[1]/font'; - var citerows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - xpath='//tr/td[2]/font/a'; - var linkrows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - - var citerow; - var linkrow; - var items=new Array(); - var temp; - var title; - - while(citerow=citerows.iterateNext()) - { - linkrow=linkrows.iterateNext(); - items[linkrow.href]=Zotero.Utilities.trimInternal(citerow.textContent); - } - return processList(items); - } - else - { - //Advanced Search - - xpath='//tr/td[1]/font/a'; - var titlerows=doc.evaluate(xpath, doc,nsResolver,XPathResult.ANY_TYPE, null); - xpath='//tr/td[2]/font/a'; - var linkrows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - - var titlerow; - var linkrow; - var items=new Array(); - var temp; - - while(titlerow=titlerows.iterateNext()) - { - linkrow=linkrows.iterateNext(); - while(linkrow.textContent.indexOf("Abstract")<0) - {linkrow=linkrows.iterateNext();} - - items[linkrow.href]=titlerow.textContent; - } - return processList(items); - } - } - -} diff --git a/translators/AJHG.js b/translators/AJHG.js @@ -1,84 +0,0 @@ -{ - "translatorID":"0a01d85e-483c-4998-891b-24707728d83e", - "translatorType":4, - "label":"AJHG", - "creator":"Michael Berkowitz", - "target":"http://(www.)?ajhg.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-02-14 23:15:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="article_links"]/a[1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("abstract") != -1 || url.indexOf("fulltext") != -1) { - return "journalArticle"; - } -} - -function getID(str) { - str = str.match(/\/([^/]+)$/)[1]; - if (str.indexOf("#") != -1) { - str = str.substr(0, str.length - 1); - } - return str; -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.title.indexOf("Search Results") != -1) { - var xpath = '//table[@id="search_results"]/tbody/tr/td[1]'; - var titlex = './strong'; - var linkx = './div/a[1]'; - } else { - var xpath = '//div[@id="main_toc"]/dl'; - var titlex = './dt'; - var linkx = './dd/div/a[1]'; - } - var blocks = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_block; - while (next_block = blocks.iterateNext()) { - var title = doc.evaluate(titlex, next_block, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var link = doc.evaluate(linkx, next_block, null, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(getID(i)); - } - } else { - articles = [getID(url)]; - } - Zotero.debug(articles); - for (var i in articles) { - var poststr = 'format=cite-abs&citation-type=RIS&pii=' + articles[i] + '&action=download&Submit=Export'; - var pdfurl = 'http://download.ajhg.org/AJHG/pdf/PII' + articles[i].replace(/(\(|\)|\-)/g, "") + '.pdf'; - var newurl = 'http://www.ajhg.org/AJHG/fulltext/' + articles[i]; - Zotero.Utilities.HTTP.doPost('http://ajhg.org/AJHG/citationexport', poststr, function(text) { - var trans = Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - trans.setString(text); - trans.setHandler("itemDone", function(obj, item) { - item.attachments = [ - {url:newurl, title:"AJHG Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"AJHG Full Text PDF", mimeType:"application/pdf"} - ]; - - if (item.notes[0]["note"]) { - item.abstractNote = item.notes[0]["note"]; - } - item.notes = []; - item.complete(); - }); - trans.translate(); - Zotero.done(); - }); - } - Zotero.wait(); - -} -\ No newline at end of file diff --git a/translators/AMS Journals.js b/translators/AMS Journals.js @@ -1,79 +0,0 @@ -{ - "translatorID":"bdaac15c-b0ee-453f-9f1d-f35d00c7a994", - "translatorType":4, - "label":"AMS Journals", - "creator":"Michael Berkowitz", - "target":"http://www.ams.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/jour(nals|search)/)) { - return "multiple"; - } else if (url.match(/\d{4}\-\d{2}\-\d{2}/)) { - 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 articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (url.match(/joursearch/)) { - var titlex = '//table/tbody/tr/td/span[@class="searchResultsArticleTitle"]'; - var linkx = '//table/tbody/tr[td/span[@class="searchResultsArticleTitle"]]//a[contains(text(), "Abstract")]'; - } else { - var titlex = '//div[@class="contentList"]/dl/dt[@class="articleTitleInAbstract"]'; - var linkx = '//div[@class="contentList"]/dl/dd/a[contains(text(), "Abstract")]' - } - var titles = doc.evaluate(titlex, doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate(linkx, doc, nsResolver, XPathResult.ANY_TYPE, null); - var title, link; - while ((title = titles.iterateNext()) && (link = links.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(decodeURIComponent(i)); - } - } else { - articles = [url]; - } - Zotero.debug(articles); - Zotero.Utilities.processDocuments(articles, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.publicationTitle = doc.title; - item.ISSN = doc.evaluate('//span[@class="journalISSN"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/\(e\)\s+ISSN:?\s+(.*)\(p\)/)[1]; - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//p[@class="articleTitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var data = Zotero.Utilities.trimInternal(doc.evaluate('//p[span[@class="bibDataTag"]][1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - data = data.replace(/(Journal|MSC|Posted|Retrieve)/g, "\n$1"); - Zotero.debug(data); - var authors = data.match(/Author\(s\):\s+(.*)\n/)[1].split(/;\s+/); - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - var journalinfo = data.match(/Journal:\s+(.*)\n/)[1].match(/^([^\d]+)(\d+)\s+\((\d+)\),\s+(.*)$/); - item.journalAbbreviation = journalinfo[1]; - item.volume = journalinfo[2]; - item.pages = journalinfo[4]; - item.date = Zotero.Utilities.trimInternal(data.match(/Posted:\s+(.*)\n/)[1]); - item.url = doc.location.href; - item.issue = item.url.match(/(\d+)\/S/)[1]; - var pdfurl = item.url.replace(/([^/]+)\/home.html$/, "$1/$1.pdf"); - item.attachments = [ - {url:item.url, title:item.journalAbbreviation + " Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:item.journalAbbreviation + " PDF", mimeType:"application/pdf"} - ]; - item.abstract = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="bottomCell"]/p[4]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(10)); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/AMS MathSciNet.js b/translators/AMS MathSciNet.js @@ -1,98 +0,0 @@ -{ - "translatorID":"a354331-981b-43de-a61-bc26dd1be3a9", - "label":"AMS MathSciNet", - "creator":"Simon Kornblith", - "target":"^https?://www\\.ams\\.org[^/]*/mathscinet/search/(?:publications\\.html|publdoc\\.html)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-06-06 19:00:50" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var tableRows = doc.evaluate('//div[@id="content"]/form/div[@class="headline"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - if(tableRows.iterateNext()) { - return "multiple" - } else if(doc.evaluate('//div[@id="titleSeparator"]/div[@class="navbar"]/span[@class="PageLink"]/a[text() = "Up"]', - doc, nsResolver, XPathResult.ANY_TYPE, null)) { - return "journalArticle"; - } - - return false; -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var pub = "http://www.ams.org/mathscinet/search/publications.html?fmt=bibtex"; - - var tableRows = doc.evaluate('//div[@id="content"]/form/div[@class="headline"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var tableRow = tableRows.iterateNext(); - if(tableRow) { - // search page - var items = new Object(); - var links = new Object(); - - do { - var id = doc.evaluate('.//input[@type="checkbox"]', tableRow, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext().value; - items[id] = doc.evaluate('./div[@class="headlineText"]/span[@class="title"]', tableRow, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext().textContent; - links[id] = doc.evaluate('.//a', tableRow, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().href; - } while(tableRow = tableRows.iterateNext()) - - - items = Zotero.selectItems(items); - if(!items) return true; - - var docLinks = new Array(); - for(var id in items) { - pub += "&b="+id; - docLinks.push(links[id]); - } - } else { - var MR = doc.evaluate('//div[@id="content"]/div[@class="doc"]/div[@class="headline"]/strong', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - pub += "&b="+MR.replace(/^MR0*/, ""); - } - - Zotero.Utilities.HTTP.doGet(pub, function(text) { - var m = text.match(/<pre>(?:.|[\r\n])*?<\/pre>/g); - var bibTeXString = ""; - for each(var citation in m) { - // kill pre tags - citation = citation.substring(5, citation.length-6); - bibTeXString += citation; - } - - // import using BibTeX - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(bibTeXString); - translator.setHandler("itemDone", function(obj, item) { - if(docLinks) { - item.attachments.push({title:"MathSciNet Snapshot", url:docLinks.shift(), mimeType:"text/html"}); - } else { - item.attachments.push({title:"MathSciNet Snapshot", document:doc}); - } - - item.complete(); - }); - translator.translate(); - - Zotero.done(); - }); -} diff --git a/translators/APA PsycNET.js b/translators/APA PsycNET.js @@ -1,146 +0,0 @@ -{ - "translatorID": "1e1e35be-6264-45a0-ad2e-7212040eb984", - "label": "APA PsycNET", - "creator": "Michael Berkowitz", - "target": "^http://psycnet\\.apa\\.org/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:43:11" -} - -function detectWeb(doc, url) { - if (url.match(/search\.searchResults/)) { - return false; - //return "multiple"; - } else if (url.match(/search\.displayRecord/)) { - return "journalArticle"; - } -} - -function associateXPath(xpath, doc, ns) { - return Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//div[@class="srhcTitle"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - items[title.href] = title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - Zotero.Utilities.processDocuments(arts, scrape, function() {Zotero.done();}); - } else { - scrape(doc); - } - Zotero.wait(); -} - -function scrape (doc) { - var namespace = null; - var newurl = doc.location.href; - if (doc.evaluate('//input[@name="id"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var id = doc.evaluate('//input[@name="id"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().value; - var lstSelectedUIDs = doc.evaluate('//input[@name="lstUIDs"][@id="srhLstUIDs"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().value; - var get = 'http://psycnet.apa.org/index.cfm?fa=search.export' - var post = 'id=' + id + '&lstUIDs=' + lstSelectedUIDs + '&lstSelectedUIDs=&records=records&displayFormat=&exportFormat=referenceSoftware&printDoc=0'; - // http://psycnet.apa.org/index.cfm?fa=search.exportFormat&singlerecord=1 - // id=&lstSelectedUIDs=&lstUIDs=2004-16644-010&records=records&displayFormat=&exportFormat=referenceSoftware&printDoc=0 - Zotero.Utilities.HTTP.doPost(get, post, function(text) { - // http://psycnet.apa.org/index.cfm?fa=search.export - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - //Z.debug(text); - translator.setHandler("itemDone", function(obj, item) { - //item.url = newurl; - //item.attachments = [{url:newurl, title:"APA PsycNET Snapshot", mimeType:"text/html"}]; - item.complete(); - }); - translator.translate(); - }); - } else { - var item = new Zotero.Item("journalArticle"); - item.title = associateXPath('//div[@id="rdcTitle"]', doc, nsResolver); - var authors = associateXPath('//div[@id="rdcAuthors"]', doc, nsResolver).split(/;\s+/); - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true)); - } - var voliss = associateXPath('//div[@id="rdcSource"]', doc, nsResolver).match(/^([^\.]+)\.\s+(\d+\s+\w+)\s+Vol\s+(\d+)\((\d+)\)\s+(.*)$/); - item.publicationTitle = voliss[1]; - item.date = voliss[2]; - item.volume = voliss[3]; - item.issue = voliss[4]; - item.pages = voliss[5]; - item.abstractNote = associateXPath('//div[@id="rdRecord"]/div[@class="rdRecordSection"][2]', doc, nsResolver); - item.complete(); - } - }/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://psycnet.apa.org/index.cfm?fa=search.displayRecord&uid=2004-16644-010", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Hervey", - "firstName": "Aaron S.", - "creatorType": "author" - }, - { - "lastName": "Epstein", - "firstName": "Jeffery N.", - "creatorType": "author" - }, - { - "lastName": "Curry", - "firstName": "John F.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "attention-deficit/hyperactivity disorder", - "adults", - "behavioral inhibition", - "neuropsychological performance", - "developmental considerations", - "neuropsychological deficits", - "empirical methods" - ], - "seeAlso": [], - "attachments": [], - "itemID": "2004-16644-010", - "title": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder: A Meta-Analytic Review.", - "publicationTitle": "Neuropsychology", - "volume": "18", - "issue": "3", - "pages": "485-503", - "date": "2004", - "publisher": "US: American Psychological Association", - "ISBN": "1931-1559 (Electronic); 0894-4105 (Print)", - "ISSN": "1931-1559 (Electronic); 0894-4105 (Print)", - "abstractNote": "A comprehensive, empirically based review of the published studies addressing neuropsychological performance in adults diagnosed with attention-deficit/hyperactivity disorder (ADHD) was conducted to identify patterns of performance deficits. Findings from 33 published studies were submitted to a meta-analytic procedure producing sample-size-weighted mean effect sizes across test measures. Results suggest that neuropsychological deficits are expressed in adults with ADHD across multiple domains of functioning, with notable impairments in attention, behavioral inhibition, and memory, whereas normal performance is noted in simple reaction time. Theoretical and developmental considerations are discussed, including the role of behavioral inhibition and working memory impairment. Future directions for research based on these findings are highlighted, including further exploration of specific impairments and an emphasis on particular tests and testing conditions. (PsycINFO Database Record (c) 2010 APA, all rights reserved)", - "DOI": "10.1037/0894-4105.18.3.485", - "libraryCatalog": "APA PsycNET", - "shortTitle": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/APN.ru.js b/translators/APN.ru.js @@ -1,59 +0,0 @@ -{ - "translatorID": "737216af-fc48-4aa5-bfae-560c9cfc5df5", - "label": "Агенство политических новостей", - "creator": "Avram Lyon", - "target": "^https?:\\/\\/www\\.apn\\.ru\\/", - "minVersion": "2.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-24 00:34:40" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};/* - APN.ru (Агенство политических новостей) 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 FW.detectWeb(doc, url); -} -function doWeb(doc, url) { return FW.doWeb(doc, url); } - - -/** Articles */ -FW.Scraper({ itemType : 'newspaperArticle', - detect : FW.Xpath('//div[@class="block_div"]/div/*[@class="article_title"]'), - title : FW.Xpath('//div[@class="block_div"]/div/*[@class="article_title"]').text().trim(), - attachments : [ { - url : FW.Url().replace(/article/,"print"), - type: "text/html", - title: "APN.ru Printable" }], - creators : FW.Xpath('//div[@class="block_div"]/div/a[@class="pub_aname"]').text().cleanAuthor("author"), - date : FW.Xpath('//div[@class="block_div"]/div/span[@class="pub_date"]').text(), - publicationTitle : "Агенство политических новостей" - }); - - -/** Search results */ -FW.MultiScraper({ itemType : "multiple", - detect : FW.Xpath('//div[@class="search_content"]'), - choices : { - titles : FW.Xpath('//div[@class="search_content"]/div/a[@class="searchtitle"]').text(), - urls : FW.Xpath('//div[@class="search_content"]/div/a[@class="searchtitle"]').key('href').text() - } -}); diff --git a/translators/APS.js b/translators/APS.js @@ -1,65 +0,0 @@ -{ - "translatorID":"2c310a37-a4dd-48d2-82c9-bd29c53c1c76", - "translatorType":4, - "label":"APS", - "creator":"Eugeniy Mikhailov and Michael Berkowitz", - "target":"https?://(?:www\\.)?(prola|prl|pra|prb|prc|prd|pre|prst-ab|prst-per|rmp)\\.aps\\.org[^/]*/(toc|abstract|forward|showrefs|supplemental)/", - "minVersion":"1.0.0b3.r1", - "maxVersion":null, - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} -// Works for all APS journals: http://publish.aps.org/ - -function detectWeb(doc, url) { - // toc indicates table of contents, forward is a "Citing articles" page - if (/\/toc\//.test(url) || (/\/forward\//.test(url))){ - return "multiple"; - } else { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, "abstract"); - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - - Zotero.Utilities.processDocuments(arts, function(newDoc) { - Zotero.debug(newDoc.title); - // Use abstract only if we have one - if (newDoc.evaluate('//div[contains(@class, "aps-abstractbox")]/p', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) var abs = Zotero.Utilities.trimInternal(newDoc.evaluate('//div[contains(@class, "aps-abstractbox")]/p', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var urlRIS = newDoc.location.href; - urlRIS = urlRIS.replace(/(abstract|forward|showrefs|supplemental)/,"export"); - var post = "type=ris"; - var snapurl = newDoc.location.href; - var pdfurl = snapurl.replace(/(abstract|forward|showrefs|supplemental)/, "pdf"); - Zotero.Utilities.HTTP.doPost(urlRIS, post, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if (item.itemID) { - item.DOI = item.itemID; - } - item.attachments = [ - {url:snapurl, title:"APS Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"APS Full Text PDF", mimeType:"application/pdf"} - ]; - if (abs) item.abstractNote = abs; - item.complete(); - }); - translator.translate(); - }, null, 'UTF-8'); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/ARTFL Encyclopedie.js b/translators/ARTFL Encyclopedie.js @@ -1,169 +0,0 @@ -{ - "translatorID":"72cb2536-3211-41e0-ae8b-974c0385e085", - "translatorType":4, - "label":"ARTFL Encyclopedie", - "creator":"Sean Takats", - "target":"/cgi-bin/philologic31/(getobject\\.pl\\?c\\.[0-9]+:[0-9]+\\.encyclopedie|search3t\\?dbname=encyclopedie0507)", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if (url.indexOf("getobject.pl") != -1){ - return "encyclopediaArticle"; - } else { - return "multiple"; - } -} - -function reconcileAuthor(author){ - var authorMap = { - "Venel":"Venel, Gabriel-François", - "d'Aumont":"d'Aumont, Arnulphe", - "de La Chapelle":"de La Chapelle, Jean-Baptiste", - "Bourgelat":"Bourgelat, Claude", - "Dumarsais":"Du Marsais, César Chesneau", - "Mallet":"Mallet, Edme-François", - "Toussaint":"Toussaint, François-Vincent", - "Daubenton":"Daubenton, Louis-Jean-Marie", - "d'Argenville": "d'Argenville, Antoine-Joseph Desallier", - "Tarin":"Tarin, Pierre", - "Vandenesse":"de Vandenesse, Urbain", - "Blondel": "Blondel, Jacques-François", - "Le Blond":"Le Blond, Guillaume", - "Rousseau":"Rousseau, Jean-Jacques", - "Eidous":"Eidous, Marc-Antoine", - "d'Alembert":"d'Alembert, Jean le Rond", - "Louis":"Louis, Antoine", - "Bellin":"Bellin, Jacques-Nicolas", - "Diderot":"Diderot, Denis", - "Diderot1":"Diderot, Denis", - "Diderot2":"Diderot, Denis", - "de Jaucourt":"de Jaucourt, Chevalier Louis", - "Jaucourt":"de Jaucourt, Chevalier Louis", - "d'Holbach":"d'Holbach, Baron" - /* not yet mapped - Yvon - Forbonnais - Douchet and Beauzée - Boucher d'Argis - Lenglet Du Fresnoy - Cahusac - Pestré - Daubenton, le Subdélégué - Goussier - de Villiers - Barthès - Morellet - Malouin - Ménuret de Chambaud - Landois - Le Roy - */ - } - if(authorMap[author]) { - author = authorMap[author]; - } - // remove ARTFL's trailing 5 for odd contributors (e.g. Turgot5) - if (author.substr(author.length-1, 1)=="5"){ - author = author.substr(0, author.length-1); - } - return author; -} - -function scrape (doc){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var url = doc.location.href; - var newItem = new Zotero.Item("encyclopediaArticle"); - var xpath = '/html/body/div[@class="text"]/font'; - var titleElmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (titleElmt) { - var title = titleElmt.textContent; - } else { - xpath = '/html/body/div[@class="text"]/b'; - var title = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - newItem.title = title; - newItem.encyclopediaTitle = "Encyclopédie, ou Dictionnaire raisonné des sciences, des arts et des métiers"; - newItem.shortTitle = "Encyclopédie"; - newItem.date = "1751-1772"; - newItem.publisher = "Briasson"; - newItem.place = "Paris"; - newItem.url = url; - - newItem.attachments.push({title:"ARTFL Snapshot", mimeType:"text/html", url:url, snapshot:true}); - - // get author and tags - var hostRegexp = new RegExp("^(https?://[^/]+)/"); - var hMatch = hostRegexp.exec(url); - var host = hMatch[1]; - var getString1 = "/cgi-bin/philologic31/search3t?dbname=encyclopedie0507&word=&dgdivhead="; - var getString2 = "&dgdivocauthor=&dgdivocplacename=&dgdivocsalutation=&dgdivocclassification=&dgdivocpartofspeech=&dgdivtype=&CONJUNCT=PHRASE&DISTANCE=3&PROXY=or+fewer&OUTPUT=conc&POLESPAN=5&KWSS=1&KWSSPRLIM=500"; - - Zotero.Utilities.HTTP.doGet(host+getString1+title+getString2, function(text){ - var tagRe = new RegExp('>'+title+'</a>[^\[]*\\[([^\\]]*)\]', 'i'); - var m = tagRe.exec(text); - if(m[1] != "unclassified"){ - var tagstring = m[1].replace("&amp;", "&", "g"); - var tags = tagstring.split(";") - for(var j in tags) { - newItem.tags.push(Zotero.Utilities.trimInternal(tags[j])); - } - } - var authorRe = new RegExp('>'+title+'</a>,([^,]*),', "i"); - var m = authorRe.exec(text); - var author = m[1]; - author = Zotero.Utilities.trimInternal(author); - // reconcile author - author = reconcileAuthor(author); - if (author!="NA"){ // ignore unknown authors - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author", true)); - } - newItem.creators.push({firstName:"Denis", lastName:"Diderot", creatorType:"editor"}); - newItem.creators.push({firstName:"Jean le Rond", lastName:"d'Alembert", creatorType:"editor"}); - newItem.complete(); - }, function() {Zotero.done();}, null); - Zotero.wait(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (url.indexOf("getobject.pl") != -1){ - // single article - scrape(doc); - } else { - //search page - var items = new Object(); - var xpath = '/html/body/div[@class="text"]/p/a'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - while (elmt = elmts.iterateNext()){ - var title = elmt.textContent; - var link = elmt.href; - if (title && link){ - items[link] = title; - } - } - var items = Zotero.selectItems(items); - if(!items) { - return true; - } - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } - -} -\ No newline at end of file diff --git a/translators/ARTstor.js b/translators/ARTstor.js @@ -1,274 +0,0 @@ -{ - "translatorID":"5278b20c-7c2c-4599-a785-12198ea648bf", - "translatorType":4, - "label":"ARTstor", - "creator":"Ameer Ahmed and Michael Berkowitz", - "target":"http://[^/]artstor.org[^/]*", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-11-13 07:10:00" -} - -function detectWeb(doc, url) { - if (url.match(/(S|s)earch/) && (doc.evaluate('//div[@id="thumbContentWrap"]/div', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/\w+/))) return "multiple" -} - -function doWeb(doc, url) { - if (url.indexOf("|")!=-1){ - scrape(doc, url); - } -} - -// TODO: Remove this when we drop support for Fx3 -if (!JSON) { - var JSON = new function() { - this.parse = function (arg) { - var j; - if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(arg. - replace(/\\./g, '@'). - replace(/"[^"\\\n\r]*"/g, ''))) { - // Friendly AMO reviewer: This is the official json.org library and is safe. - j = eval('(' + arg + ')'); - return j; - } - throw new SyntaxError('parseJSON'); - } - } -} - -function scrape(doc, url){ - var savedItems = new Array(); - var saved = 0; - var urlstub = url.substring(url.indexOf('.org/')+5,url.length); - urlstub = url.substring(0,url.indexOf('.org/')+5) + urlstub.substring(0, urlstub.indexOf('/')+1) - var suburl = url.substring(url.indexOf('|')+1, url.length); - var groupname = suburl.substring(0, suburl.indexOf("|")); - var searchterm = '//*[@id="thumbSubTitle"]'; - var stt = doc.evaluate(searchterm, doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - var st = stt.firstChild.nodeValue; - var pageNn = '//*[@id="pageNo"]'; - var stt = doc.evaluate(pageNn, doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - var pg; - if (stt.value==1){ - pg = 1; - } else if (stt.value==2){ - pg = 25; - } else { - pg = ((stt.value-1) * 24) + 1; - } - var groupid; - //check if user is on search page if not construct the query using the 2nd pattern - if (groupname.indexOf("search")!=-1){ - groupid = "1/" + pg + "/24/0?tn=1&name=&id=all&kw=" +st + "&type=1"; - }else { - groupid = suburl.substring(suburl.indexOf('|')+1, suburl.indexOf('||')) + "//thumbnails/" + pg + "/24/0"; - } - // Initial query to get results from the service - primary purpose is to get objectids. which in turn are required for the 2nd service call, which exposes the actual metadata - Zotero.Utilities.HTTP.doGet(urlstub + "secure/" + groupname + "//" + groupid, function(text) { - var json = JSON.parse(text); - items = new Object(); - for(var i=0; i<json.thumbnails.length; i++) { - child = json.thumbnails[i]; - var tmpUrl = urlstub + "secure/metadata/" + child.objectId + "?_method=Infolder"; - //here we are saving the url service call to get each objects metadata - savedItems[saved] = tmpUrl; - items[tmpUrl]=child.objectId; - saved++; - } - // GET VALUES FROM THE WEB - var xpath = '//div[@id="thumbContentWrap"]'; - var elmts = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - var webitems = new Object(); - var selectedNums = new Array(); - var si=0; - var c = elmts.getElementsByTagName('*'); - var title = ""; - for(var i=0; i<c.length; i++) { - var child = c[i]; - if (child.id.indexOf("_imageHolder")!=-1){ - var csss = child.style; - var glow = csss.getPropertyValue('border'); - } - if (child.id.indexOf("_thumb1")!=-1){ - title = child.title; - } - if (child.id.indexOf("_thumb2")!=-1){ - title+= " :: " + child.title; - } - if (child.id.indexOf("_thumb3")!=-1){ - var childtitle = child.title; - var dialogTitle = title; - if (childtitle.length>1) { - dialogTitle+=" " + childtitle; - } - var sitem = child.id.substring(6,child.id.indexOf("_")); - webitems[sitem-1] = dialogTitle; - if (glow.indexOf(75)!=-1){ - selectedNums[si]=sitem-1; - si++; - } - title = null; - } - } - // GET VALUES FROM THE WEB - var tcount=0; - var newitems = null; - if (selectedNums.length>0){ - newitems = new Object(); - for (j=0; j<selectedNums.length;j++){ - var numnum = selectedNums[j]; - for (var x in items){ - if (numnum==tcount){ - newitems[x] = webitems[tcount]; - tcount=0; - break; - } else { - tcount++; - } - } - } - } else { - tcount = 0; - for (var x in items){ - items[x] = webitems[tcount]; - tcount++; - } - } - if (newitems!=null){ - items = newitems; - } - //show dialogbox - var items = Zotero.selectItems(items); - if(!items) { - return true; - } - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - //this gets called when an object is selected in the dialog box, fires off a get on the service url - Zotero.Utilities.HTTP.doGet(urls, function(text) { - var json = JSON.parse(text); - var newArticle = new Zotero.Item('artwork'); - for (var i=0; i<json.metaData.length; i++) { - child = json.metaData[i]; - // MISSING CULTURE!!! - if (child.fieldName.indexOf("Title")!=-1){ - if (newArticle.title!=null){ - newArticle.title+= ";" + child.fieldValue; - } else { - newArticle.title = child.fieldValue; - } - } - if (child.fieldName.indexOf("Creator")!=-1){ - if (child.fieldValue != "") { - if (child.fieldValue.match(/,/)) { - var aut = child.fieldValue.match(/^([^,]+),\s+(.*)$/); - if (aut[1].match(/\s/)) { - newArticle.notes.push({note:"Artist information: " + aut[2]}); - newArticle.creators.push(Zotero.Utilities.cleanAuthor(aut[1], "artist")); - } else { - var extras = aut[2].match(/^([^,]+),\s+(.*)$/); - newArticle.creators.push({firstName:extras[1], lastName:aut[1], creatorType:"author"}); - newArticle.notes.push({note:"Artist information: " + extras[2]}); - } - } else { - newArticle.creators.push(Zotero.Utilities.cleanAuthor(child.fieldValue, "artist")); - } - } - } - if (child.fieldName.indexOf("Culture")!=-1){ - newArticle.creators.push(Zotero.Utilities.cleanAuthor(child.fieldValue, "producer", true)); - } - if (child.fieldName.indexOf("Rights")!=-1){ - if (newArticle.rights!=null){ - newArticle.rights+= ";" + child.fieldValue.replace(/<wbr\/>/g, ""); - } else { - newArticle.rights = child.fieldValue.replace(/<wbr\/>/g, ""); - } - } - if (child.fieldName.indexOf("Subject")!=-1){ - newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue)); - } - if (child.fieldName.indexOf("Location")!=-1){ - newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue)); - } - if (child.fieldName.indexOf("Style Period")!=-1){ - newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue)); - } - if (child.fieldName.indexOf("Work Type")!=-1){ - newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue)); - } - if (child.fieldName.indexOf("Material")!=-1 || child.fieldName.indexOf("Technique")!=-1 ){ - if (newArticle.artworkMedium!=null){ - newArticle.artworkMedium+= ";" + Zotero.Utilities.trimInternal(child.fieldValue); - } else { - newArticle.artworkMedium = Zotero.Utilities.trimInternal(child.fieldValue); - } - } - if (child.fieldName.indexOf("Measurements")!=-1){ - if (newArticle.artworkSize!=null){ - newArticle.artworkSize+= ";" + Zotero.Utilities.trimInternal(child.fieldValue); - } else { - newArticle.artworkSize = Zotero.Utilities.trimInternal(child.fieldValue); - } - } - if (child.fieldName.indexOf("Date")!=-1){ - if (newArticle.date!=null){ - newArticle.date+= ";" + Zotero.Utilities.trimInternal(child.fieldValue); - } else { - //bug here!! when date parser fails, entire object is not saved in Zotero - works in Scaffold, fails in Zotero! to patch remove all occurrences of B.C - newArticle.date = Zotero.Utilities.trimInternal(child.fieldValue.replace(/B.C./i, "")); - } - } - if (child.fieldName.indexOf("Repository")!=-1){ - if (newArticle.repository!=null){ - newArticle.repository+= ";" + Zotero.Utilities.trimInternal(child.fieldValue); - } else { - newArticle.repository = Zotero.Utilities.trimInternal(child.fieldValue); - } - } - if (child.fieldName.indexOf("Source")!=-1){ - if (newArticle.archiveLocation!=null){ - newArticle.archiveLocation+= ";" + Zotero.Utilities.trimInternal(child.fieldValue); - } else { - newArticle.archiveLocation = Zotero.Utilities.trimInternal(child.fieldValue); - } - } - if (child.fieldName.indexOf("Description")!=-1){ - if (newArticle.abstractNote!=null){ - newArticle.abstractNote+= ";" + Zotero.Utilities.trimInternal(child.fieldValue); - } else { - newArticle.abstractNote = Zotero.Utilities.trimInternal(child.fieldValue); - } - } - if (child.fieldName.indexOf("Collection")!=-1){ - if (newArticle.extra!=null){ - newArticle.extra+= ";" + Zotero.Utilities.trimInternal(child.fieldValue); - } else { - newArticle.extra = Zotero.Utilities.trimInternal(child.fieldValue); - } - } - } - var objectId = json.objectId; - //this is called to get the url stub for the ARTstor viewer - Zotero.Utilities.HTTP.doGet(urlstub + "secure/metadata/" + objectId + "?_method=FpHtml", function(dom) { - var testurl = dom.substring(dom.lastIndexOf('<td class="data">')+21,dom.lastIndexOf('</td>')); - var t2 = "http://www.artstor.org"; - var tmp2 = testurl.replace(/<wbr\/>/g, ""); - tmp2 = tmp2.substring(0, tmp2.indexOf("&userId")); - //build ARTstorImageURL - artstorimgurl = t2+tmp2; - newArticle.url = artstorimgurl; - newArticle.callNumber = objectId; - newArticle.complete(); - Zotero.done(); - }); - Zotero.wait(); - }); - Zotero.wait(); -}); -Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/ASCE.js b/translators/ASCE.js @@ -1,76 +0,0 @@ -{ - "translatorID":"303bdfc5-11b8-4107-bca1-63ca97701a0f", - "translatorType":4, - "label":"ASCE", - "creator":"Michael Berkowitz", - "target":"^http://ascelibrary.aip.org/.+", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-09-06 19:30:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@id="sr-content-wrap"]//div[@class="sr-right"]/p[@class="sr-art-title"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else { - return "journalArticle"; - } -} - -function getRIS(doc, url) { - var newx = '//div[@id="sci-art-options-box"]//input[@name="SelectCheck"]'; - var key = doc.evaluate(newx, doc, null, XPathResult.ANY_TYPE, null).iterateNext().value; - Zotero.debug(key); - var citation = 'http://ascelibrary.aip.org/getabs/servlet/GetCitation?source=scitation&PrefType=ARTICLE&PrefAction=Add+Selected&SelectCheck=' + key + '&fn=open_refworks&downloadcitation=+Go+'; - Zotero.Utilities.HTTP.doGet(citation, function(text) { - var translator = Zotero.loadTranslator("import"); - text = text.replace(/RT/, "TY"); - text = text.replace(/VO/, "VL"); - text = text.replace(/LK/, "UR"); - text = text.replace(/YR/, "PY"); - Zotero.debug(text); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text.replace(/([A-Z][A-Z\d]\s)/g, "$1 - ")); - translator.setHandler("itemDone", function(obj, item) { - item.attachments = [ - {url:item.url, title:"ASCE Snapshot", mimeType:"text/html"}, - {url:"http://ascelibrary.aip.org/getpdf/servlet/GetPDFServlet?filetype=pdf&id=" + key + "&idtype=cvips&prog=search", title:"EAS Full Text PDF", mimeType:"application/pdf"} - ]; - //item.itemType = "journalArticle"; - item.complete(); - }); - translator.translate(); - Zotero.wait(); - Zotero.done(); - }); -} - -function doWeb(doc, url) { - var articles = new Array(); - var items = new Object(); - var xpath = '//div[@class="sr-right"]/p[@class="sr-art-title"]/a'; - if (doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - while (new_title = titles.iterateNext()) { - items[new_title.href] = new_title.textContent; - } - - items = Zotero.selectItems(items); - - for (var i in items) { - articles.push(i) - } - } else { - var newx = '//div[@id="sci-art-options-box"]//input[@name="SelectCheck"]'; - var stuff = doc.evaluate(newx, doc, null, XPathResult.ANY_TYPE, null).iterateNext().value; - Zotero.debug(stuff); - articles.push(url); - } - - Zotero.debug(articles); - Zotero.Utilities.processDocuments(articles, getRIS, function() {Zotero.done}); - Zotero.wait(); - -} diff --git a/translators/Ab Imperio.js b/translators/Ab Imperio.js @@ -1,76 +0,0 @@ -{ - "translatorID": "f3e31f93-c18d-4ba3-9aa6-1963702b5762", - "label": "Ab Imperio", - "creator": "Avram Lyon", - "target": "^https?://(?:www\\.)?abimperio\\.net/", - "minVersion": "2.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-24 00:28:49" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - -/* - Ab Imperio 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 FW.detectWeb(doc, url); -} -function doWeb(doc, url) { return FW.doWeb(doc, url); } - - -/** Articles */ -FW.Scraper({ itemType : 'journalArticle', - detect : FW.Xpath('//center[h3]/h3'), - title : FW.Xpath('//center[h3]/h3').text().trim(), - attachments : [ - { - url : FW.Xpath('//a[contains(@href,"pdf") and contains(text(),"PDF")]').key("href"), - type : "application/pdf", - title: "Ab Imperio PDF" - }, - { - url : FW.Url(), - type : "text/html", - title: "Ab Imperio Snapshot" - }, - { - url : FW.Xpath('//table//td/a[img[contains(@src,"doc.gif")]]').key("href"), - type : "text/html", - title: "Ab Imperio Snapshot" - }], - creators : FW.Xpath('//center[h3]').text().remove(/^[^\n]*\n/).remove(/\n.*/).cleanAuthor("author"), - // Of course, release date is always later, but we'll still call this a date and not a volume - date : FW.Xpath('//center[h3]/font').text().match(/\/([0-9]{4})/,1), - issue : FW.Xpath('//center[h3]/font').text().match(/([0-9]+)\//,1), - abstractNote : FW.Xpath('//center[h3]/following-sibling::p[1]').text(), - publicationTitle : "Ab Imperio" -}); - -/* This can be thrown off by articles that the user doesn't have access to... */ -/** Search results */ -FW.MultiScraper({ itemType : "multiple", - detect : FW.Url().match(/state=(?:shown|srch)/), - choices : { - titles : FW.Xpath('//a[contains(@href,"state=showa")]').text(), - urls : FW.Xpath('//a[contains(@href,"state=showa")]').key('href').text() - } -}); diff --git a/translators/AcademicJournals.net.js b/translators/AcademicJournals.net.js @@ -1,91 +0,0 @@ -{ - "translatorID":"252c6a50-0900-41c5-a66b-ec456137c43c", - "translatorType":4, - "label":"AcademicJournals.net", - "creator":"Michael Berkowitz", - "target":"http://www.academicjournals.net/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match('articleno=')) { - return "journalArticle"; - } else if (url.match('issueno=') || url.match('current.php')) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return prefix; else return null; - } : namespace; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//tr[2]/td//table/tbody/tr[1]/td[2]/font', doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - var links = doc.evaluate('//tr[4]/td[2]/div/a[@class="links"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var link; - while ((title = titles.iterateNext()) && (link = links.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.url = doc.location.href; - //title - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//td[2]/table/tbody/tr/td/div/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - - //voliss, etc. - var voliss = doc.evaluate('//table/tbody/tr/td[2]/font/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - voliss = voliss.match(/^([^\d]+)(\d+)\s+\((\d+)\):\s+([\d\-]+),\s+(\d+)/); - Zotero.debug(voliss); - item.publicationTitle = voliss[1]; - item.volume = voliss[2]; - item.issue = voliss[3]; - item.pages = voliss[4]; - item.date = voliss[5]; - - //authors - var authorsx = doc.evaluate('//td[2]/font/a[@class="links"]/font', doc, nsResolver, XPathResult.ANY_TYPE, null); - var author; - var authors = new Array(); - while (author = authorsx.iterateNext()) { - authors.push(author.textContent); - } - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//table/tbody/tr/td/div/table/tbody/tr/td[2]/div/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - - //attachments - var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - item.attachments = [ - {url:item.url, title:"AcademicJournals.net Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"AcademicJournals.net PDF", mimeType:"application/pdf"} - ]; - - //tags - var tagspath = doc.evaluate('//tbody/tr/td/table/tbody/tr[2]/td/font/a[@class="links"]/font', doc, nsResolver, XPathResult.ANY_TYPE, null); - var tag; - var tags = new Array(); - while (tag = tagspath.iterateNext()) { - tags.push(tag.textContent); - } - item.tags = tags; - item.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/AdvoCAT.js b/translators/AdvoCAT.js @@ -1,117 +0,0 @@ -{ - "translatorID":"138de272-0d2a-4ab5-8cfb-0fd879958d04", - "translatorType":4, - "label":"AdvoCAT", - "creator":"Adam Crymble", - "target":"^http://(142.57.32.51|library.lsuc.on.ca)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-25 17:40:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("Search_Code")) { - return "multiple"; - } else if (doc.title.match("Record View")) { - return "book"; - } -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - - var headers = doc.evaluate('//table[2]/tbody/tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//table[2]/tbody/tr/th)', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//table[2]/tbody/tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue; i++) { - - fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, ''); - if (!fieldTitle.match(/\w/)) { - fieldTitle = "Blank" + i; - } - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - - if (dataTags["MainAuthor:"]) { - var author = dataTags["MainAuthor:"]; - if (author.match(", ") && !author.match(":")) { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - - if (dataTags["Published:"]) { - - if (dataTags["Published:"].match(": ")) { - var place1 = dataTags["Published:"].indexOf(": "); - newItem.place = dataTags["Published:"].substr(0, place1); - var publisher1 = dataTags["Published:"].substr(place1 + 2); - - if (publisher1.match(", ")) { - var date1 = publisher1.lastIndexOf(", "); - newItem.date = publisher1.substr(date1 +2); - newItem.publisher = publisher1.substr(0, date1); - } else { - newItem.publisher = publisher1; - } - } else { - newItem.publisher = publisher1; - } - } - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "Database:", "repository"); - associateData (newItem, dataTags, "Description:", "pages"); - associateData (newItem, dataTags, "Edition:", "edition"); - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//form[2]/table/tbody/tr/td[3]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/African Journals Online.js b/translators/African Journals Online.js @@ -1,71 +0,0 @@ -{ - "translatorID":"9d822257-2eec-4674-b6d0-2504f54c8890", - "translatorType":4, - "label":"African Journals Online", - "creator":"Michael Berkowitz", - "target":"http://www.ajol.info", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-04-18 08:55:00" -} - -function detectWeb(doc, url) { - if (url.match(/viewarticle.php/)) { - return "journalArticle"; - } else if (url.match(/search.php/) || url.match(/viewissue.php/)) { - return "multiple"; - } -} - -function getID(str) { - return str.match(/(&|\?)id=(\d+)&?/)[2]; -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - if (url.match(/search.php/)) { - var items = Zotero.Utilities.getItemArray(doc, doc, "viewarticle.php?"); - } else if (url.match("viewissue.php")) { - var items = new Object(); - var titles = doc.evaluate('//span[@class="toctitle"]', doc, null, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//a[text() = "Abstract"]', doc, null, XPathResult.ANY_TYPE, null); - var title; - var link; - while ((title = titles.iterateNext()) && (link = links.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent); - } - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(getID(i)); - } - } else { - articles = [getID(url)]; - } - Zotero.debug(articles); - for each (var id in articles) { - var getstr = 'http://www.ajol.info/rst/rst.php?op=capture_cite&id=' + id + '&cite=refman'; - Zotero.Utilities.HTTP.doGet(getstr, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var pubinfo = item.publicationTitle.match(/(.*);([^;]+)$/); - item.publicationTitle = pubinfo[1]; - var voliss = pubinfo[2].toLowerCase(); - if (voliss.match(/v/)) item.volume = voliss.match(/v(ol\.)?\s+(\d+)/)[2]; - if (voliss.match(/n/)) item.issue = voliss.match(/n(o\.)?\s+(\d+)/)[2]; - if (voliss.match(/p(age)?/)) item.pages = voliss.match(/\d+\-\d+/)[0]; - item.date = voliss.match(/\(([^)]+)\)/)[1]; - item.attachments[0].title = "African Journals Online Snapshot"; - item.attachments[0].mimeType = "text/html"; - item.complete(); - }); - translator.translate(); - }); - } -} -\ No newline at end of file diff --git a/translators/AfroEuropa.js b/translators/AfroEuropa.js @@ -1,87 +0,0 @@ -{ - "translatorID":"4f62425a-c99f-4ce1-b7c1-5a3ac0d636a3", - "translatorType":4, - "label":"AfroEuropa", - "creator":"Michael Berkowitz", - "target":"http://journal.afroeuropa.eu/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-20 19:10:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//tr[td/a[2]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.match(/article\/view\//)) { - return "journalArticle"; - } -} - -function makeExport(site, str) { - var nums = str.match(/\d+(\/\d+)?/)[0]; - if (!nums.match(/\//)) nums += "/0"; - return site + 'rt/captureCite/' + nums + '/referenceManager'; -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var site = url.match(/^http:\/\/([^/]*\/)+index\.php\/[^/]*\//)[0]; - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var xpath = '//tr[td/a]'; - if (url.match(/search/)) { - var titlex = './td[2]'; - var linkx = './td[3]/a[1]'; - } else if (url.match(/issue/)) { - var titlex = './td[1]'; - var linkx = './td[2]/a[1]'; - } - var items = new Object(); - var results = doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - var title = Zotero.Utilities.trimInternal(doc.evaluate(titlex, result, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var link = doc.evaluate(linkx, result, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - items[makeExport(site, link)] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [makeExport(cite, url)]; - } - Zotero.Utilities.HTTP.doGet(arts, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.title = Zotero.Utilities.capitalizeTitle(item.title); - var voliss = item.publicationTitle.split(/;\s+/); - item.publicationTitle = Zotero.Utilities.trimInternal(voliss[0]); - voliss = voliss[1].match(/(\d+),\s+No\s+(\d+)\s+\((\d+)\)/); - item.volume = voliss[1]; - item.issue = voliss[2]; - item.date = voliss[3]; - var auts = new Array(); - for each (var aut in item.creators) { - auts.push(aut.lastName); - } - item.creators = new Array(); - for each (var aut in auts) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - item.attachments[0].mimeType = "text/html"; - item.attachments[0].title = "AfroEuropa Snapshot"; - item.complete(); - }); - translator.translate(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Agencia del ISBN.js b/translators/Agencia del ISBN.js @@ -1,65 +0,0 @@ -{ - "translatorID":"b8a86e36-c270-48c9-bdd1-22aaa167ef46", - "translatorType":4, - "label":"Agencia del ISBN", - "creator":"Michael Berkowitz", - "target":"http://www.mcu.es/webISBN", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="isbnResultado"]/div[@class="isbnResDescripcion"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//div[@class="fichaISBN"]/div[@class="cabecera"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -function doWeb(doc, url) { - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var boxes = doc.evaluate('//div[@class="isbnResultado"]/div[@class="isbnResDescripcion"]', doc, null, XPathResult.ANY_TYPE, null); - var box; - while (box = boxes.iterateNext()) { - var book = doc.evaluate('./p/span/strong/a', box, null, XPathResult.ANY_TYPE, null).iterateNext(); - items[book.href] = book.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - books.push(i); - } - } else { - books = [url]; - } - Zotero.Utilities.processDocuments(books, function(newDoc) { - var data = new Object(); - var rows = newDoc.evaluate('//div[@class="fichaISBN"]/table/tbody/tr', newDoc, null, XPathResult.ANY_TYPE, null); - var next_row; - while (next_row = rows.iterateNext()) { - var heading = newDoc.evaluate('./th', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var value = newDoc.evaluate('./td', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - data[heading.replace(/\W/g, "")] = value; - } - var isbn = Zotero.Utilities.trimInternal(newDoc.evaluate('//span[@class="cabTitulo"]/strong', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var item = new Zotero.Item("book"); - item.ISBN = isbn; - item.title = Zotero.Utilities.trimInternal(data['Ttulo']); - - author = data['Autores']; - if (author) { - var authors = author.match(/\b.*,\s+\w+[^([]/g); - for each (aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(aut), "author", true)); - } - } - if (data['Publicacin']) item.publisher = Zotero.Utilities.trimInternal(data['Publicacin']); - if (data['FechaEdicin']) item.date = Zotero.Utilities.trimInternal(data['FechaEdicin']); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Alexander Street Press.js b/translators/Alexander Street Press.js @@ -1,197 +0,0 @@ -{ - "translatorID":"0a84a653-79ea-4c6a-8a68-da933e3b504a", - "translatorType":4, - "label":"Alexander Street Press", - "creator":"John West and Michael Berkowitz", - "target":"http://(?:www\\.)alexanderstreet", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if( url.indexOf("object.details.aspx") != -1 ) { - var zitemtype = doc.getElementById("ctl00_ctl00_MasterContentBody_ContentPlaceHolder1_txtZType").value; - switch (zitemtype.toLowerCase()) { - case "book": - return "book"; - break; - case "chapter": - return "bookSection"; - break; - case "journal": - return "journalArticle"; - break; - case "manuscript": - return "manuscript"; - break; - case "audio": - return "audioRecording"; - break; - case "video": - return "videoRecording"; - break; - case "issue": - return "journalArticle"; - break; - case "article": - return "journalArticle"; - break; - case "series": - return "interview"; - break; - case "session": - return "interview"; - break; - default: - return "document"; - } - } else if (url.indexOf("results.aspx") != -1) { - return "multiple"; - } -} - -function scrape(doc, url) { - // set prefix for serverside control - var p = "ctl00_ctl00_MasterContentBody_ContentPlaceHolder1_txtZ"; - - // get values from hidden inputs - var ztype = GetItemType(doc.getElementById(p+"Type").value); - var ztitle = doc.getElementById(p+"Title").value; - var zbooktitle = doc.getElementById(p+"BookTitle").value; - var znotes = doc.getElementById(p+"Notes").value; - var zurl = doc.getElementById(p+"URL").value; - var zrights = doc.getElementById(p+"Rights").value; - var zseries = doc.getElementById(p+"Series").value; - var zvolume = doc.getElementById(p+"Volume").value; - var zissue = doc.getElementById(p+"Issue").value; - var zedition = doc.getElementById(p+"Edition").value; - var zplace = doc.getElementById(p+"Place").value; - var zpublisher = doc.getElementById(p+"Publisher").value; - var zpages = doc.getElementById(p+"Pages").value; - var zrepository = doc.getElementById(p+"Repository").value; - var zlabel = doc.getElementById(p+"Label").value; - var zrunningTime = doc.getElementById(p+"RunningTime").value; - var zlanguage = doc.getElementById(p+"Language").value; - var zauthor = doc.getElementById(p+"Author").value; - var zeditor = doc.getElementById(p+"Editor").value; - var ztranslator = doc.getElementById(p+"Translator").value; - var zinterviewee = doc.getElementById(p+"Interviewee").value; - var zinterviewer = doc.getElementById(p+"Interviewer").value; - var zrecipient = doc.getElementById(p+"Recipient").value; - var zdirector = doc.getElementById(p+"Director").value; - var zscriptwriter = doc.getElementById(p+"ScriptWriter").value; - var zproducer = doc.getElementById(p+"Producer").value; - var zcastMember = doc.getElementById(p+"CastMember").value; - var zperformer = doc.getElementById(p+"Performer").value; - var zcomposer = doc.getElementById(p+"Composer").value; - - // create Zotero item - var newArticle = new Zotero.Item(ztype); - - // populate Zotero item - newArticle.title = ztitle; - newArticle.bookTitle = zbooktitle; - newArticle.notes = znotes; - newArticle.url = zurl; - newArticle.place = zplace; - newArticle.publisher = zpublisher; - newArticle.pages = zpages; - newArticle.rights = zrights; - newArticle.series = zseries; - newArticle.volume = zvolume; - newArticle.issue = zissue; - newArticle.edition = zedition; - newArticle.repository = zrepository; - newArticle.label = zlabel; - newArticle.runningTime = zrunningTime; - newArticle.language = zlanguage; - newArticle.editor = zeditor; - newArticle.translator = ztranslator; - newArticle.interviewee = zinterviewee; - newArticle.interviewer = zinterviewer; - newArticle.recipient = zrecipient; - newArticle.director = zdirector; - newArticle.scriptwriter = zscriptwriter; - newArticle.producer = zproducer; - newArticle.castMember = zcastMember; - newArticle.performer = zperformer; - newArticle.composer = zcomposer; - var aus = zauthor.split(";"); - for (var i=0; i< aus.length ; i++) { - newArticle.creators.push(Zotero.Utilities.cleanAuthor(aus[i], "author", true)); - } - - newArticle.attachments = [{url:doc.location.href, title:"Alexander Street Press Snapshot", mimeType:"text/html"}]; - if (doc.evaluate('//a[contains(@href, "get.pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var pdfurl = doc.evaluate('//a[contains(@href, "get.pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - newArticle.attachments.push({url:pdfurl, title:"Alexander Street Press PDF", mimeType:"application/pdf"}); - } else if (doc.evaluate('//a[contains(@href, "get.jpg")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var imgurl = doc.evaluate('//a[contains(@href, "get.jpg")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.replace(/.{2}$/, "01"); - newArticle.attachments.push({url:imgurl, title:"Alexander Street Press Pg 1", mimeType:"image/jpg"}); - newArticle.notes = [{note:"Further page images can be found by following the URL of the 'Alexander Street Press Pg 1' attachment and iterating the final digits of the URL"}]; - } - // save Zotero item - newArticle.complete(); - -} - -function GetItemType(zitemtype) { - switch (zitemtype.toLowerCase()) { - case "book": - return "book"; - break; - case "chapter": - return "bookSection"; - break; - case "journal": - return "journalArticle"; - break; - case "manuscript": - return "manuscript"; - break; - case "audio": - return "audioRecording"; - break; - case "video": - return "videoRecording"; - break; - case "issue": - return "journalArticle"; - break; - case "article": - return "journalArticle"; - break; - case "series": - return "interview"; - break; - case "session": - return "interview"; - break; - default: - return "document"; - } -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath = '//tbody/tr/td[2][@class="data"]/a[1]'; - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/AllAfrica.js b/translators/AllAfrica.js @@ -1,70 +0,0 @@ -{ - "translatorID":"34B1E0EA-FD02-4069-BAE4-ED4D98674A5E", - "translatorType":4, - "label":"allAfrica.com", - "creator":"Matt Bachtell", - "target":"^http://allafrica\\.com/stories/*", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2009-05-05 07:15:00" -} - - -function detectWeb (doc, url) { - - return "newspaperArticle"; - -} - -function doWeb (doc, url){ - scrape(doc,url); -} - -function scrape(doc, url) { - var title = doc.evaluate("/html/body/div[3]/div/h1[@class='headline']", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var date = doc.evaluate("/html/body/div[3]/div/p[@class='date']", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - -// zotero entry creation code - var newItem = new Zotero.Item('newspaperArticle'); - newItem.title = title; - newItem.date = date; - newItem.url = url; - - //AUTHORS - try{ - var authors = doc.evaluate("/html/body/div[3]/div/p[@class='reporter']", doc, null, XPathResult.ANY_TYPE,null).iterateNext().textContent; - if (authors.match(/ &| And/)){ - var aus = authors.split(" And"); - for (var i=0; i < aus.length ; i++){ - newItem.creators.push(Zotero.Utilities.cleanAuthor(aus[i], "author")); - } - } - else if(authors.match(", ")){ - var aus = authors.split(/[,| And| & ]/); - for (var i=0; i < aus.length; i++){ - newItem.creators.push(Zotero.Utilities.cleanAuthor(aus[i], "author")); - } - } - else{ - var author = authors; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - catch(e){ - // DO NOTHING - } - - //SOURCE - try{ - var newspaper_source = doc.evaluate("/html/body/div[3]/div/p/a/img/@alt", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.publicationTitle = newspaper_source; - } - catch(e){ - var newspaper_source = doc.evaluate("/html/body/div[3]/div/p", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.publicationTitle = newspaper_source; - } - newItem.complete(); - -} // end scrape -\ No newline at end of file diff --git a/translators/AlterNet.js b/translators/AlterNet.js @@ -1,58 +0,0 @@ -{ - "translatorID": "ea531652-cdeb-4ec2-940e-627d4b107263", - "label": "AlterNet", - "creator": "Jesse Johnson, BBUCommander", - "target": "^http://(?:www\\.)alternet.org", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-04 22:46:35" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -// Articles -FW.Scraper({ - itemType : 'magazineArticle', - detect : FW.Xpath('//meta[@name="title"]/@content'), - title : FW.Xpath('//div[@class="headline"]/h1').text(), - creators : FW.Xpath('//meta[@name="author"]/@content').text().split(',').cleanAuthor("author"), - date : FW.Xpath('//div[@class="story-date"]/em').text(), - abstractNote : FW.Xpath('//div[@class="teaser"]').text().trim(), - extra : FW.Xpath('//meta[@name="source"]/@content').text().prepend("Source of article: "), - tags : FW.Xpath('//meta[@name="keywords"]/@content').text().split(",").trim(), - attachments : [ {url:FW.Xpath('//div[@class="story_tools_print"]/a').key("href"), type:"text/html", title:"AlterNet Article Snapshot"} ], - publicationTitle : "AlterNet", - url : FW.Url(), -}); - -// Blogs -FW.Scraper({ - itemType : 'blogPost', - detect : FW.Url().match(/blogs\.alternet/), - title : FW.Xpath('//div[@class="headline"]/h1').text(), - creators : FW.Xpath('//div[@class="byline body_"]/a').text().split(',').cleanAuthor("author"), - date : FW.Xpath('//div[@class="byline body_"]').text().match(/(am|pm)\s*(.*)$/, 2).trim(), - //abstractNote : FW.Xpath('// - //extra : FW.Xpath('// - //tags : FW.Xpath('// - //TODO print version of blog posts are CSS swaps and so would require a workaround to save - attachments : [ {url: FW.Url(), type:"text/html", title:"AlterNet Article Snapshot"} ], - publicationTitle : "AlterNet", - url : FW.Url(), -}); - -/** Search results -Erik's framework won't work, since the results are in an iframe -This will need to be done the traditional way, or the framework will need to be extended -FW.MultiScraper({ - itemType : "multiple", - detect : FW.Url().match(/google\.com.*search_results\.html/), - titles : FW.Xpath('//div[@id="res"]//ol/li//h2/a').text(), - urls : FW.Xpath('//div[@id="res"]//ol/li//h2/a').key('href').text() -}); -//*/ diff --git a/translators/Aluka.js b/translators/Aluka.js @@ -1,191 +0,0 @@ -{ - "translatorID":"e8fc7ebc-b63d-4eb3-a16c-91da232f7220", - "translatorType":4, - "label":"Aluka", - "creator":"Sean Takats", - "target":"https?://(?:www\\.)aluka.org/action/(?:showMetadata\\?doi=[^&]+|doSearch\\?|doBrowseResults\\?)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-02-12 10:00:00" -} - -function detectWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//a[@class="title"]'; - - if (url.match(/showMetadata\?doi=[^&]+/)){ - return "document"; - } else if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -// Aluka types we can import -// TODO: Improve support for other Aluka item types? -// Correspondence, Circulars, Newsletters, Interviews, Pamphlets, Policy Documents, Posters, Press Releases, Reports, Testimonies, Transcripts -var typeMap = { - "Books":"book", - "Aluka Essays":"report", - "photograph":"artwork", - "Photographs":"artwork", - "Panoramas":"artwork", - "Journals (Periodicals)":"journalArticle", - "Articles":"journalArticle", - "Correspondence":"letter", - "Interviews":"interview", - "Reports":"report" -} - -function doWeb(doc, url){ - var urlString = "http://www.aluka.org/action/showPrimeXML?doi=" ; - var uris = new Array(); - var m = url.match(/showMetadata\?doi=([^&]+)/); - if (m) { //single page - uris.push(urlString+ m[1]); - } else { //search results page - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//a[@class="title"]'; - var items = new Object(); - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - while (elmt = elmts.iterateNext()) { - var title = elmt.textContent; - var link = elmt.href; - var m = link.match(/showMetadata\?doi=([^&]+)/); - if (title && m){ - items[m[1]] = title; - } - } - - var items = Zotero.selectItems(items); - if(!items) { - return true; - } - - for(var i in items) { - uris.push(urlString + i); - } - } - // http://www.aluka.org/action/showPrimeXML?doi=10.5555/AL.SFF.DOCUMENT.cbp1008 - - Zotero.Utilities.HTTP.doGet(uris, function(text) { - text = text.replace(/<\?xml[^>]*\?>/, ""); // strip xml header - text = text.replace(/(<[^>\.]*)\.([^>]*>)/g, "$1_$2"); // replace dots in tags with underscores - var xml = new XML(text); - var metadata = xml..MetadataDC; - var itemType = "Unknown"; - if (metadata.length()){ - itemType = "document"; - if (metadata[0].Type.length()){ - var value = metadata[0].Type[0].text().toString(); - if(typeMap[value]) { - itemType = typeMap[value]; - } else { - Zotero.debug("Unmapped Aluka Type: " + value); - } - } - var newItem = new Zotero.Item(itemType); - var title = ""; - if (metadata[0].Title.length()){ - var title = Zotero.Utilities.trimInternal(metadata[0].Title[0].text().toString()); - if (title == ""){ - title = " "; - } - newItem.title = title; - } - if (metadata[0].Title_Alternative.length()){ - newItem.extra = Zotero.Utilities.trimInternal(metadata[0].Title_Alternative[0].text().toString()); - } - for(var i=0; i<metadata[0].Subject_Enriched.length(); i++) { - newItem.tags.push(Zotero.Utilities.trimInternal(metadata[0].Subject_Enriched[i].text().toString())); - } - for(var i=0; i<metadata[0].Coverage_Spatial.length(); i++) { - newItem.tags.push(Zotero.Utilities.trimInternal(metadata[0].Coverage_Spatial[i].text().toString())); - } - for(var i=0; i<metadata[0].Coverage_Temporal.length(); i++) { - newItem.tags.push(Zotero.Utilities.trimInternal(metadata[0].Coverage_Temporal[i].text().toString())); - } -// TODO: decide whether to uncomment below code to import species data as tags -// for(var i=0; i<xml..TopicName.length(); i++) { -// newItem.tags.push(Zotero.Utilities.trimInternal(xml..TopicName[i].text().toString())); -// } - - if (metadata[0].Date.length()){ - var date = metadata[0].Date[0].text().toString(); - if (date.match(/^\d{8}$/)){ - date = date.substr(0, 4) + "-" + date.substr(4, 2) + "-" + date.substr(6, 2); - } - newItem.date = date; - } - if (metadata[0].Creator.length()){ - var authors = metadata[0].Creator; - var type = "author"; - for(var j=0; j<authors.length(); j++) { - Zotero.debug("author: " + authors[j]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j].text().toString(),type,true)); - } - } - if (metadata[0].Contributor.length()){ - var authors = metadata[0].Contributor; - var type = "contributor"; - for(var j=0; j<authors.length(); j++) { - Zotero.debug("author: " + authors[j]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j].text().toString(),type,true)); - } - } - if (metadata[0].Publisher.length()){ - newItem.publisher = Zotero.Utilities.trimInternal(metadata[0].Publisher[0].text().toString()); - } - if (metadata[0].Format_Medium.length()){ - newItem.medium = Zotero.Utilities.trimInternal(metadata[0].Format_Medium[0].text().toString()); - } - if (metadata[0].Language.length()){ - newItem.language = Zotero.Utilities.trimInternal(metadata[0].Language[0].text().toString()); - } - if (metadata[0].Description.length()){ - newItem.abstractNote = metadata[0].Description[0].text().toString(); - } - if (metadata[0].Format_Extent.length()){ - newItem.pages = Zotero.Utilities.trimInternal(metadata[0].Format_Extent[0].text().toString()); - } - var doi = xml..DOI; - if (doi.length()){ - newItem.DOI = doi[0]; - var newUrl = "http://www.aluka.org/action/showMetadata?doi=" + doi[0]; - newItem.attachments.push({title:"Aluka Link", snapshot:false, mimeType:"text/html", url:newUrl}); - var pdfUrl = "http://ts-den.aluka.org/delivery/aluka-contentdelivery/pdf/" + doi[0] + "?type=img&q=high"; - newItem.attachments.push({url:pdfUrl}); - newItem.url = newUrl; - } - var rights = xml..Rights.Attribution; - if (rights.length()){ - newItem.rights = rights[0]; - } - if (metadata[0].Rights.length()){ - newItem.rights = Zotero.Utilities.trimInternal(metadata[0].Rights[0].text().toString()); - } - if (metadata[0].Source.length()){ - newItem.repository = "Aluka: " + Zotero.Utilities.trimInternal(metadata[0].Source[0].text().toString()); - } - if (metadata[0].Relation.length()){ - newItem.callNumber = Zotero.Utilities.trimInternal(metadata[0].Relation[0].text().toString()); - } - newItem.complete(); - } else { - Zotero.debug("No Dublin Core XML data"); - return false; - } - Zotero.done(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Amazon.com.js b/translators/Amazon.com.js @@ -1,673 +0,0 @@ -{ - "translatorID": "96b9f483-c44d-5784-cdad-ce21b984fe01", - "label": "Amazon.com", - "creator": "Sean Takats and Michael Berkowitz", - "target": "^https?://(?:www\\.)?amazon", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-19 00:16:21" -} - -function detectWeb(doc, url) { - var suffixRe = new RegExp("https?://(?:www\.)?amazon\.([^/]+)/"); - var suffixMatch = suffixRe.exec(url); - var suffix = suffixMatch[1]; - var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/|s\\?|[^/]+/lm/|gp/richpub/)'); - Zotero.debug(searchRe.test(doc.location.href)); - if(searchRe.test(doc.location.href)) { - return "multiple"; - } else { - var xpath = '//input[@name="ASIN"]'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var elmt = doc.evaluate('//input[@name="storeID"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if(elmt) { - var storeID = elmt.value; - Zotero.debug("store id: " + storeID); - if (storeID=="books"){ - return "book"; - } - else if (storeID=="music"){ - return "audioRecording"; - } - else if (storeID=="dvd"|storeID=="video"){ - return "videoRecording"; - } - else { - return "book"; - } - } - else { - return "book"; - } - } - } -} - -var suffix; -function doWeb(doc, url) { - var suffixRe = new RegExp("https?://(?:www\.)?amazon\.([^/]+)/"); - var suffixMatch = suffixRe.exec(url); - suffix = suffixMatch[1]; - - var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/|s\\?|[^/]+/lm/|gp/richpub/)'); - var m = searchRe.exec(doc.location.href); - var uris = new Array(); - if (suffix == "co.jp"){ - suffix = "jp"; - } - if (suffix == ".com") suffix = "com"; - if(m) { - var availableItems = new Array(); - - - if(doc.location.href.match(/gp\/richpub\//)){ // Show selector for Guides - var xpath = '//a[(contains(@href, "ref=cm_syf_dtl_pl") or contains(@href, "ref=cm_syf_dtl_top")) and preceding-sibling::b]'; - } else if (doc.location.href.match(/\/lm\//)) { // Show selector for Lists - var xpath = '//span[@id="lm_asinlink95"]//a' - } else { // Show selector for Search results - var xpath = '//div[@class="productTitle"]/a | //a[span[@class="srTitle"]] | //div[@class="title"]/a[@class="title"]'; - } - var elmts = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - var asins = new Array(); - var i = 0; - var asinRe = new RegExp('/(dp|product)/([^/]+)/'); - do { - var link = elmt.href; - var searchTitle = elmt.textContent; - if (asinRe.exec(link)) { - var asinMatch = asinRe.exec(link); - availableItems[i] = searchTitle; - asins[i] = asinMatch[2]; - i++; - } - } while (elmt = elmts.iterateNext()); - - Zotero.selectItems(availableItems, function(items) { - if(!items) { - return true; - } - - for(var i in items) { - var timestamp = encodeURIComponent(generateISODate()); - var params = "AWSAccessKeyId=AKIAIPYIWJ24AGZJ64AA&ItemId=" + Zotero.Utilities.trim(asins[i]) + "&Operation=ItemLookup&ResponseGroup=ItemAttributes&Service=AWSECommerceService&Timestamp="+timestamp+"&Version=2006-06-28"; - var signString = "GET\necs.amazonaws."+suffix+"\n/onca/xml\n"+params; - var signature = b64_hmac_sha256("054vk/Lt3LJMxch1srIHUbvI+2T/fZ6E5c0qwlbj", signString); - signature = encodeURIComponent(signature); - uris.push("http://ecs.amazonaws." + suffix + "/onca/xml?"+params+"&Signature="+signature+"%3D"); //wants the %3D for some reason - } - - Zotero.Utilities.HTTP.doGet(uris, parseXML, function() {Zotero.done();}, null); - }); - - } else { - var elmts = doc.evaluate('//input[@name = "ASIN"]', doc, null, XPathResult.ANY_TYPE, null); - var elmt; - while(elmt = elmts.iterateNext()) { - var asin = elmt.value; - } - var timestamp = encodeURIComponent(generateISODate()); - var params = "AWSAccessKeyId=AKIAIPYIWJ24AGZJ64AA&ItemId=" + Zotero.Utilities.trim(asin) + "&Operation=ItemLookup&ResponseGroup=ItemAttributes&Service=AWSECommerceService&Timestamp="+timestamp+"&Version=2006-06-28"; - var signString = "GET\necs.amazonaws."+suffix+"\n/onca/xml\n"+params; - var signature = b64_hmac_sha256("054vk/Lt3LJMxch1srIHUbvI+2T/fZ6E5c0qwlbj", signString); - signature = encodeURIComponent(signature); - uris.push("http://ecs.amazonaws." + suffix + "/onca/xml?"+params+"&Signature="+signature+"%3D"); //wants the %3D for some reason - Zotero.Utilities.HTTP.doGet(uris, parseXML, function() {Zotero.done();}, null); - } - Zotero.wait(); -} - -function parseXML(text) { - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - var texts = text.split("<Items>"); - texts = texts[1].split("</ItemLookupResponse>"); - text = "<Items>" + texts[0]; - var xml = (new DOMParser()).parseFromString(text, "text/xml"); - var publisher = ""; - - if (!ZU.xpath(xml, "//Errors").length) { - var publisher = getXPathNodeTrimmed(xml, "Publisher"); - var binding = getXPathNodeTrimmed(xml, "Binding"); - var productGroup = getXPathNodeTrimmed(xml, "ProductGroup"); - - if (productGroup=="Book") { - var newItem = new Zotero.Item("book"); - newItem.publisher = publisher; - } - else if (productGroup == "Music") { - var newItem = new Zotero.Item("audioRecording"); - newItem.label = publisher; - newItem.audioRecordingType = binding; - getCreatorNodes(xml, "Artist", newItem, "performer"); - } - else if (productGroup == "DVD" | productGroup == "Video") { - var newItem = new Zotero.Item("videoRecording"); - newItem.studio = publisher; - newItem.videoRecordingType = binding; - getCreatorNodes(xml, "Actor", newItem, "castMember"); - getCreatorNodes(xml, "Director", newItem, "director"); - } - else{ - var newItem = new Zotero.Item("book"); - newItem.publisher = publisher; - } - - newItem.runningTime = getXPathNodeTrimmed(xml, "RunningTime"); - - // Retrieve authors and other creators - getCreatorNodes(xml, "Author", newItem, "author"); - if (newItem.creators.length == 0){ - getCreatorNodes(xml, "Creator", newItem, "author"); - } - - newItem.date = getXPathNodeTrimmed(xml, "PublicationDate"); - if (!newItem.date){ - newItem.date = getXPathNodeTrimmed(xml, "ReleaseDate"); - } - newItem.edition = getXPathNodeTrimmed(xml, "Edition"); - newItem.ISBN = getXPathNodeTrimmed(xml, "ISBN"); - newItem.numPages = getXPathNodeTrimmed(xml, "NumberOfPages"); - var title = getXPathNodeTrimmed(xml, "Title"); - if(title.lastIndexOf("(") != -1 && title.lastIndexOf(")") == title.length-1) { - title = title.substring(0, title.lastIndexOf("(")-1); - } - var ASIN = getXPathNodeTrimmed(xml, "ASIN"); - if (ASIN){ - var url = "http://www.amazon." + suffix + "/dp/" + ASIN; - newItem.attachments.push({title:"Amazon.com Link", snapshot:false, mimeType:"text/html", url:url}); - } - - newItem.extra = getXPathNodeTrimmed(xml, "OriginalReleaseDate"); - - newItem.title = title; - newItem.complete(); - } -} - -function getXPathNodeTrimmed(xml, name) { - var node = ZU.xpath(xml, "//"+name); - var val = ""; - if(node.length){ - val = Zotero.Utilities.trimInternal(node[0].textContent); - } - return val; -} - -function getCreatorNodes(xml, name, newItem, creatorType) { - var nodes = ZU.xpath(xml, "//"+name); - for(var i=0; i<nodes.length; i++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(nodes[i].textContent, creatorType)); - } -} - -function generateISODate(){ - var ts = new Date(); - var isodate = ts.getUTCFullYear()+"-"+Zotero.Utilities.lpad(ts.getUTCMonth()+1, "0", 2)+"-"+Zotero.Utilities.lpad(ts.getUTCDate(), "0", 2)+"T"+Zotero.Utilities.lpad(ts.getUTCHours(), "0", 2)+":"+Zotero.Utilities.lpad(ts.getUTCMinutes(), "0", 2)+":"+Zotero.Utilities.lpad(ts.getUTCSeconds(), "0", 2)+"Z"; - return isodate; -} - -/* - * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined - * in FIPS 180-2 - * Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009. - * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet - * Distributed under the BSD License - * See http://pajhome.org.uk/crypt/md5 for details. - * Also http://anmar.eu.org/projects/jssha2/ - */ - -/* - * Configurable variables. You may need to tweak these to be compatible with - * the server-side, but the defaults work in most cases. - */ -var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */ -var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */ - -/* - * These are the functions you'll usually want to call - * They take string arguments and return either hex or base-64 encoded strings - */ -function hex_sha256(s) { return rstr2hex(rstr_sha256(str2rstr_utf8(s))); } -function b64_sha256(s) { return rstr2b64(rstr_sha256(str2rstr_utf8(s))); } -function any_sha256(s, e) { return rstr2any(rstr_sha256(str2rstr_utf8(s)), e); } -function hex_hmac_sha256(k, d) - { return rstr2hex(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d))); } -function b64_hmac_sha256(k, d) - { return rstr2b64(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d))); } -function any_hmac_sha256(k, d, e) - { return rstr2any(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d)), e); } - -/* - * Perform a simple self-test to see if the VM is working - */ -function sha256_vm_test() -{ - return hex_sha256("abc").toLowerCase() == - "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"; -} - -/* - * Calculate the sha256 of a raw string - */ -function rstr_sha256(s) -{ - return binb2rstr(binb_sha256(rstr2binb(s), s.length * 8)); -} - -/* - * Calculate the HMAC-sha256 of a key and some data (raw strings) - */ -function rstr_hmac_sha256(key, data) -{ - var bkey = rstr2binb(key); - if(bkey.length > 16) bkey = binb_sha256(bkey, key.length * 8); - - var ipad = Array(16), opad = Array(16); - for(var i = 0; i < 16; i++) - { - ipad[i] = bkey[i] ^ 0x36363636; - opad[i] = bkey[i] ^ 0x5C5C5C5C; - } - - var hash = binb_sha256(ipad.concat(rstr2binb(data)), 512 + data.length * 8); - return binb2rstr(binb_sha256(opad.concat(hash), 512 + 256)); -} - -/* - * Convert a raw string to a hex string - */ -function rstr2hex(input) -{ - try { hexcase } catch(e) { hexcase=0; } - var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef"; - var output = ""; - var x; - for(var i = 0; i < input.length; i++) - { - x = input.charCodeAt(i); - output += hex_tab.charAt((x >>> 4) & 0x0F) - + hex_tab.charAt( x & 0x0F); - } - return output; -} - -/* - * Convert a raw string to a base-64 string - */ -function rstr2b64(input) -{ - try { b64pad } catch(e) { b64pad=''; } - var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - var output = ""; - var len = input.length; - for(var i = 0; i < len; i += 3) - { - var triplet = (input.charCodeAt(i) << 16) - | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0) - | (i + 2 < len ? input.charCodeAt(i+2) : 0); - for(var j = 0; j < 4; j++) - { - if(i * 8 + j * 6 > input.length * 8) output += b64pad; - else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F); - } - } - return output; -} - -/* - * Convert a raw string to an arbitrary string encoding - */ -function rstr2any(input, encoding) -{ - var divisor = encoding.length; - var remainders = Array(); - var i, q, x, quotient; - - /* Convert to an array of 16-bit big-endian values, forming the dividend */ - var dividend = Array(Math.ceil(input.length / 2)); - for(i = 0; i < dividend.length; i++) - { - dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1); - } - - /* - * Repeatedly perform a long division. The binary array forms the dividend, - * the length of the encoding is the divisor. Once computed, the quotient - * forms the dividend for the next step. We stop when the dividend is zero. - * All remainders are stored for later use. - */ - while(dividend.length > 0) - { - quotient = Array(); - x = 0; - for(i = 0; i < dividend.length; i++) - { - x = (x << 16) + dividend[i]; - q = Math.floor(x / divisor); - x -= q * divisor; - if(quotient.length > 0 || q > 0) - quotient[quotient.length] = q; - } - remainders[remainders.length] = x; - dividend = quotient; - } - - /* Convert the remainders to the output string */ - var output = ""; - for(i = remainders.length - 1; i >= 0; i--) - output += encoding.charAt(remainders[i]); - - /* Append leading zero equivalents */ - var full_length = Math.ceil(input.length * 8 / - (Math.log(encoding.length) / Math.log(2))) - for(i = output.length; i < full_length; i++) - output = encoding[0] + output; - - return output; -} - -/* - * Encode a string as utf-8. - * For efficiency, this assumes the input is valid utf-16. - */ -function str2rstr_utf8(input) -{ - var output = ""; - var i = -1; - var x, y; - - while(++i < input.length) - { - /* Decode utf-16 surrogate pairs */ - x = input.charCodeAt(i); - y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0; - if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) - { - x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF); - i++; - } - - /* Encode output as utf-8 */ - if(x <= 0x7F) - output += String.fromCharCode(x); - else if(x <= 0x7FF) - output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F), - 0x80 | ( x & 0x3F)); - else if(x <= 0xFFFF) - output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F), - 0x80 | ((x >>> 6 ) & 0x3F), - 0x80 | ( x & 0x3F)); - else if(x <= 0x1FFFFF) - output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07), - 0x80 | ((x >>> 12) & 0x3F), - 0x80 | ((x >>> 6 ) & 0x3F), - 0x80 | ( x & 0x3F)); - } - return output; -} - -/* - * Encode a string as utf-16 - */ -function str2rstr_utf16le(input) -{ - var output = ""; - for(var i = 0; i < input.length; i++) - output += String.fromCharCode( input.charCodeAt(i) & 0xFF, - (input.charCodeAt(i) >>> 8) & 0xFF); - return output; -} - -function str2rstr_utf16be(input) -{ - var output = ""; - for(var i = 0; i < input.length; i++) - output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF, - input.charCodeAt(i) & 0xFF); - return output; -} - -/* - * Convert a raw string to an array of big-endian words - * Characters >255 have their high-byte silently ignored. - */ -function rstr2binb(input) -{ - var output = Array(input.length >> 2); - for(var i = 0; i < output.length; i++) - output[i] = 0; - for(var i = 0; i < input.length * 8; i += 8) - output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32); - return output; -} - -/* - * Convert an array of big-endian words to a string - */ -function binb2rstr(input) -{ - var output = ""; - for(var i = 0; i < input.length * 32; i += 8) - output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF); - return output; -} - -/* - * Main sha256 function, with its support functions - */ -function sha256_S (X, n) {return ( X >>> n ) | (X << (32 - n));} -function sha256_R (X, n) {return ( X >>> n );} -function sha256_Ch(x, y, z) {return ((x & y) ^ ((~x) & z));} -function sha256_Maj(x, y, z) {return ((x & y) ^ (x & z) ^ (y & z));} -function sha256_Sigma0256(x) {return (sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22));} -function sha256_Sigma1256(x) {return (sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25));} -function sha256_Gamma0256(x) {return (sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3));} -function sha256_Gamma1256(x) {return (sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10));} -function sha256_Sigma0512(x) {return (sha256_S(x, 28) ^ sha256_S(x, 34) ^ sha256_S(x, 39));} -function sha256_Sigma1512(x) {return (sha256_S(x, 14) ^ sha256_S(x, 18) ^ sha256_S(x, 41));} -function sha256_Gamma0512(x) {return (sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7));} -function sha256_Gamma1512(x) {return (sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6));} - -var sha256_K = new Array -( - 1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, - -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987, - 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522, - 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, - -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585, - 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291, - 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, - -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344, - 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218, - 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, - -1866530822, -1538233109, -1090935817, -965641998 -); - -function binb_sha256(m, l) -{ - var HASH = new Array(1779033703, -1150833019, 1013904242, -1521486534, - 1359893119, -1694144372, 528734635, 1541459225); - var W = new Array(64); - var a, b, c, d, e, f, g, h; - var i, j, T1, T2; - - /* append padding */ - m[l >> 5] |= 0x80 << (24 - l % 32); - m[((l + 64 >> 9) << 4) + 15] = l; - - for(i = 0; i < m.length; i += 16) - { - a = HASH[0]; - b = HASH[1]; - c = HASH[2]; - d = HASH[3]; - e = HASH[4]; - f = HASH[5]; - g = HASH[6]; - h = HASH[7]; - - for(j = 0; j < 64; j++) - { - if (j < 16) W[j] = m[j + i]; - else W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]), - sha256_Gamma0256(W[j - 15])), W[j - 16]); - - T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)), - sha256_K[j]), W[j]); - T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c)); - h = g; - g = f; - f = e; - e = safe_add(d, T1); - d = c; - c = b; - b = a; - a = safe_add(T1, T2); - } - - HASH[0] = safe_add(a, HASH[0]); - HASH[1] = safe_add(b, HASH[1]); - HASH[2] = safe_add(c, HASH[2]); - HASH[3] = safe_add(d, HASH[3]); - HASH[4] = safe_add(e, HASH[4]); - HASH[5] = safe_add(f, HASH[5]); - HASH[6] = safe_add(g, HASH[6]); - HASH[7] = safe_add(h, HASH[7]); - } - return HASH; -} - -function safe_add (x, y) -{ - var lsw = (x & 0xFFFF) + (y & 0xFFFF); - var msw = (x >> 16) + (y >> 16) + (lsw >> 16); - return (msw << 16) | (lsw & 0xFFFF); -} - - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.amazon.com/Test-William-Sleator/dp/0810989891/ref=sr_1_1?ie=UTF8&qid=1308010556&sr=8-1", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "William", - "lastName": "Sleator", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "title": "Amazon.com Link", - "snapshot": false, - "mimeType": "text/html", - "url": false - } - ], - "publisher": "Amulet Books", - "date": "2010-04-01", - "edition": "Reprint", - "ISBN": "0810989891", - "numPages": "320", - "title": "Test", - "libraryCatalog": "Amazon.com" - } - ] - }, - { - "type": "web", - "url": "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=foot&x=0&y=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.amazon.com/Loveless-My-Bloody-Valentine/dp/B000002LRJ/ref=ntt_mus_ep_dpi_1", - "items": [ - { - "itemType": "audioRecording", - "creators": [ - { - "firstName": "My Bloody", - "lastName": "Valentine", - "creatorType": "performer" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "title": "Amazon.com Link", - "snapshot": false, - "mimeType": "text/html", - "url": false - } - ], - "label": "Sire / London/Rhino", - "audioRecordingType": "Audio CD", - "date": "1991-11-05", - "extra": "1991-11-05", - "title": "Loveless", - "libraryCatalog": "Amazon.com" - } - ] - }, - { - "type": "web", - "url": "http://www.amazon.com/Adaptation-Superbit-Collection-Nicholas-Cage/dp/B00005JLRE/ref=sr_1_1?ie=UTF8&qid=1309683150&sr=8-1", - "items": [ - { - "itemType": "videoRecording", - "creators": [ - { - "firstName": "Nicholas", - "lastName": "Cage", - "creatorType": "castMember" - }, - { - "firstName": "Chris", - "lastName": "Cooper", - "creatorType": "castMember" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "title": "Amazon.com Link", - "snapshot": false, - "mimeType": "text/html", - "url": false - } - ], - "studio": "Sony Pictures Home Entertainment", - "videoRecordingType": "DVD", - "runningTime": "114", - "date": "2003-05-20", - "ISBN": "0767879805", - "extra": "2002-12-06", - "title": "Adaptation", - "libraryCatalog": "Amazon.com" - } - ] - }, - { - "type": "web", - "url": "http://www.amazon.com/s?ie=UTF8&keywords=The%20Harvard%20Concise%20Dictionary%20of%20Music%20and%20Musicians&index=blended&Go=o", - "items": "multiple" - } -] -/** END TEST CASES **/ diff --git a/translators/American Institute of Aeronautics and Astronautics.js b/translators/American Institute of Aeronautics and Astronautics.js @@ -1,96 +0,0 @@ -{ - "translatorID":"75edc5a1-6470-465a-a928-ccb77d95eb72", - "translatorType":4, - "label":"American Institute of Aeronautics and Astronautics", - "creator":"Michael Berkowitz", - "target":"http://www.aiaa.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-12 19:00:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//td/div[@class="title"]/b/div[@class="centerHeadlines"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var items = new Object(); - var oldItems = doc.evaluate('//table/tbody/tr/td[div[@class="title"]]', doc, ns, XPathResult.ANY_TYPE, null); - var nextItem; - while (nextItem = oldItems.iterateNext()) { - var data = new Object(); - data['title'] = Zotero.Utilities.trimInternal(doc.evaluate('./div[@class="title"]//div[@class="centerHeadlines"]', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - data['pages'] = Zotero.Utilities.trimInternal(doc.evaluate('./div[@class="title"]//div[@class="centerHeadlinesSub2"]', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/[\d\w]+\-[\d\w]+/)[0]); - data['authors'] = Zotero.Utilities.trimInternal(doc.evaluate('./ul/i', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var extra = Zotero.Utilities.trimInternal(doc.evaluate('./ul', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var extra = extra.replace(data['authors'], ""); - data['extra'] = Zotero.Utilities.trimInternal(extra); - var pdf = doc.evaluate('.//a', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - Zotero.debug(pdf); - data['pdfurl'] = pdf; - items[data['title']] = data; - } - var volume; - var issue; - var date; - if (doc.evaluate('//td[2]/table/tbody/tr/td[1]/strong', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - var voliss = Zotero.Utilities.trimInternal(doc.evaluate('//td[2]/table/tbody/tr/td[1]/strong', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - voliss = voliss.match(/(\d+)\s+vol\.\s*(\d+)\s+no\.\s*(\d+)/); - volume = voliss[2]; - issue = voliss[3]; - date = voliss[1]; - } else if (doc.evaluate('//select', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - var voliss = Zotero.Utilities.trimInternal(doc.evaluate('//select[@name="volume"]/option[@selected]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var issue = Zotero.Utilities.trimInternal(doc.evaluate('//select[@name="issue"]/option[@selected]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - voliss = voliss.match(/vol\.\s*(\d+)\s*\-\s*(\d+)/); - volume = voliss[1]; - date = voliss[2]; - } - if (doc.evaluate('//tr[1]/td/b/div[@class="centerHeadlines"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - var journal = Zotero.Utilities.trimInternal(doc.evaluate('//tr[1]/td/b/div[@class="centerHeadlines"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var ISSN = Zotero.Utilities.trimInternal(doc.evaluate('//tr[1]/td/font[@class="centerHeadlinesSub2"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/(\(|\))/g, "")); - } else if (doc.evaluate('//div[@class="centerHeadlinesTitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - var journal = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="centerHeadlinesTitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var ISSN = Zotero.Utilities.trimInternal(doc.evaluate('//tr/td[1]/table/tbody/tr[2]/td/div', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/ISSN\s*([\d\-]+)/)[1]); - } - var searchItems = new Array(); - for (var i in items) { - searchItems.push(i); - } - - searchItems = Zotero.selectItems(searchItems); - for (var i in items) { - for each (var title in searchItems) { - if (i == title) { - var data = items[i]; - var item = new Zotero.Item("journalArticle"); - item.volume = volume; - item.issue = issue; - item.date = date; - item.title = data['title']; - item.pages = data['pages']; - item.publicationTitle = Zotero.Utilities.capitalizeTitle(journal); - item.ISSN = ISSN; - if (data['authors'].match(/\w+/)) { - var authors = data['authors'].split(/(\band\b|,|;)/); - for each (var aut in authors) { - if (aut.match(/\w+/) && aut != "and") { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } - } - item.attachments = [{url:data['pdfurl'], title:"AIAA PDF (first page)", mimeType:"application/pdf"}]; - item.complete(); - } - } - } -} -\ No newline at end of file diff --git a/translators/Ancestry.com US Federal Census.js b/translators/Ancestry.com US Federal Census.js @@ -1,235 +0,0 @@ -{ - "translatorID":"0dda3f89-15de-4479-987f-cc13f1ba7999", - "translatorType":4, - "label":"Ancestry.com US Federal Census", - "creator":"Elena Razlogova", - "target":"^https?://search.ancestry.com/(.*)usfedcen|1890orgcen|1910uscenindex", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var result = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - - var rows = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]/table/tbody/tr[@class="tblrow record"]', - doc, nsResolver, XPathResult.ANY_TYPE, null); - var row; - while(row = rows.iterateNext()) { - links = doc.evaluate('.//a', row, nsResolver, XPathResult.ANY_TYPE, null); - var linkNo=0; - while(link=links.iterateNext()) { - linkNo=linkNo+1; - } - break; - } - - if(result && linkNo == 2) { - return "multiple"; - } else { - var indivRe = /indiv=1/; - var m = indivRe.exec(doc.location.href); - var indiv = 0; - if(m) { - indiv = 1; - } - - checkURL = doc.location.href.replace("pf=", ""); - if(doc.location.href == checkURL && indiv == 1) { - return "bookSection"; - } - } -} - -// this US Federal Census scraper is a hack - so far there is no proper item type in Zotero for this kind of data (added to trac as a low priority ticket) -// this scraper creates proper citation for the census as a whole (should be cited as book) -// but also adds name, city, and state for a particular individual to the citation to make scanning for names & places easier in the middle pane -// (that's why the resulting item type is a book section) -// it also adds all searchable text as a snapshot and a scan of the census record as an image - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // get initial census data; a proper census record item type should have separate fields for all of these except perhaps dbid - var info = doc.evaluate('//div[@class="facets"][@id="connect"]/div[@class="g_box"]/p/a', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if(info) { - - info = info.toString(); - var data = new Array(); - var parts = info.split(/[?&]/); - for each(var part in parts) { - var index = part.indexOf("="); - if(index !== -1) { - data[part.substr(0, index)] = part.substr(index+1); - } - } - - if(data.ln) { - var lastName = data.ln.replace(/\+/g, " "); - var firstName = data.fn.replace(/\+/g, " "); - } else { - var lastName = data.fn.replace(/\+/g, " "); - var firstName = ""; - } - var dOb = data.by; // this does not get saved yet because no field is available; the info is in the snapshot - if(data.rfd) { - var yearRe = /([0-9]{4})/; - var m = yearRe.exec(data.rfd); - if(m) { - var year = m[1]; - } - } else { var year = data.ry; } - var state = data.rs.replace(/\+/g, " "); - var county = data.rcnty.replace(/\+/g, " "); // this does not get saved yet because no field is available; the info is in the snapshot - var city = data.rcty.replace(/\+/g, " "); - var dbid = data.dbid; - } - - // set census number for citation - let me know if this can be done in a better way - var censusYear = 0; - var censusNo = ""; - var censusNos = new Array("1790", "First", "1800", "Second", "1810", "Third", "1820", "Fourth", "1830", "Fifth", "1840", "Sixth", "1850", "Seventh", "1860", "Eighth", "1870", "Ninth", - "1880", "Tenth", "1890", "Eleventh", "1900", "Twelfth", "1910", "Thirteenth", "1920", "Fourteenth", "1930", "Fifteenth") - for(var i in censusNos) { - if(censusYear == 1) { censusNo = censusNos[i] }; - if(censusNos[i] == year) { censusYear = 1 } else {censusYear= 0 }; - } - - //begin adding item - var newItem = new Zotero.Item("bookSection"); - newItem.title = city+", "+state; // this is not proper citation but is needed to easily scan for placenames in middle pane - newItem.publicationTitle = censusNo+" Census of the United States, "+year; - newItem.publisher = "National Archives and Records Administration"; - newItem.place = "Washington, DC"; - newItem.date = year; - - // get snapshot with all searchable text and a simplified link to the record for the URL field - var dbRe = /db=([0-9a-z]+)/; - var m = dbRe.exec(doc.location.href); - if(m) { - db = m[1]; - } - var snapshotRe = /\&h=([0-9]+)/; - var m = snapshotRe.exec(doc.location.href); - if(m) { - snapshotURL = "http://search.ancestry.com/cgi-bin/sse.dll?db="+db+"&indiv=1&pf=1&h="+m[1]; - newItem.attachments.push({title:"Ancestry.com Snapshot", mimeType:"text/html", url:snapshotURL, snapshot:true}); - cleanURL = "http://search.ancestry.com/cgi-bin/sse.dll?indiv=1&db="+db+"&fh=0&h="+m[1]; - newItem.url = cleanURL; - } - - // add particular individual being surveyed as contributor - this is not proper citation but is needed so one could easily scan for names in middle pane - var creator = new Array(); - creator.firstName = firstName; - creator.lastName = lastName; - creator.creatorType = "author"; - newItem.creators.push(creator); - - //add proper author for citation - var creator = new Array(); - creator.lastName = "United States of America, Bureau of the Census"; - creator.creatorType = "contributor"; - newItem.creators.push(creator); - - // get scan of the census image - var scanInfo = doc.evaluate('//div[@id="record-main"]/table[@class="p_recTable"]/tbody/tr/td[2][@class="recordTN"]/a', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if(scanInfo) { - var scanRe = /iid=([A-Z0-9_-]+)/; - var m = scanRe.exec(scanInfo); - if(m) { - scanURL = "http://content.ancestry.com/Browse/print_u.aspx?dbid="+dbid+"&iid="+m[1]; - Zotero.debug("scan url: " + scanURL); - } - } - - if(scanURL){ - Zotero.Utilities.HTTP.doGet(scanURL, function(text) { - Zotero.debug("running doGet"); - Zotero.debug(text); - var imageRe = /950 src="([^"]+)"/; - var m = imageRe.exec(text); - if(m) { - imageURL = m[1]; - Zotero.debug("image url: " + imageURL); - newItem.attachments.push({title:"Ancestry.com Image", mimeType:"image/jpeg", url:imageURL, snapshot:true}); - } - - newItem.complete(); - Zotero.done(); - }); - } else { - newItem.complete(); - Zotero.done(); - } -} - -function doWeb(doc, url) { - var resultsRegexp = /&h=/; - if(resultsRegexp.test(url)) { - scrape(doc); - } else { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // get census year for links to items - var yearRe = /db=([0-9]+)/; - var m = yearRe.exec(doc.location.href); - if(m) { - year = m[1]; - } - - var dbRe = /db=([0-9a-z]+)/; - var m = dbRe.exec(doc.location.href); - if(m) { - db = m[1]; - } - - //select items - var items = new Array(); - var listElts = doc.evaluate('//tr[@class="tblrow record keySelect"] | //tr[@class="tblrow record"] | //tr[@class="tblrowalt record"]', - doc, nsResolver, XPathResult.ANY_TYPE, null); - var recid; - var link; - var name; - while (listElt = listElts.iterateNext()) { - recInfo = doc.evaluate('.//a', listElt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var recidRe = /recid=([0-9]+)/; - var m = recidRe.exec(recInfo); - if(m) { - recid = m[1]; - } - link = "http://search.ancestry.com/cgi-bin/sse.dll?indiv=1&db="+db+"&fh=0&h="+recid; - name = doc.evaluate('.//span[@class="srchHit"]', listElt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - items[link] = Zotero.Utilities.trimInternal(name); - } - - items = Zotero.selectItems(items); - if(!items) return true; - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - - } -} -\ No newline at end of file diff --git a/translators/Archeion.js b/translators/Archeion.js @@ -1,157 +0,0 @@ -{ - "translatorID":"f6717cbb-2771-4043-bde9-dbae19129bb3", - "translatorType":4, - "label":"Archeion", - "creator":"Adam Crymble", - "target":"http://archeion-aao", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-24 05:15:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//td[@class="full"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//div[@class="main"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -//Archeion translator. code by Adam Crymble -//The way the site is formatted, I can't split the creators up logically. I have left them off for now. - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - newItem = new Zotero.Item("book"); - - var xPathHeadings = doc.evaluate('//th', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathContent = doc.evaluate('//table[@class="results"]/tbody/tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//th)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var fieldTitle; - var dataTags = new Object(); - var multiAuthorCheck = new Array(); - - - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle=xPathHeadings.iterateNext().textContent.replace(/\s+/g, ''); - - //This was Michael Berkowitz's suggested Fix. - - /*var ts = doc.getElementsByTagName(("table"), 1) = ts.length, ar = []; - while ((i--)) { - if (ts[i].className&&ts[i].className.match("results")) { - ar[ar.length] = ts[i].getElementsByTagName("td")[0].split(/\<br\>/); - } - } - Zotero.debug(ar[0][0]); */ - - //COULDN"T SPLIT BY ("\n") TO SEPARATE MULTIPLE CREATORS. - if (fieldTitle == "Creator:" | fieldTitle == "Créateur:") { - fieldTitle == "Creator:"; - - var authorContent = xPathContent.iterateNext().textContent; - //Zotero.debug(authorContent); - - //if (authorContent.match(' (*) ')) { - // Zotero.debug(doc.title); - //} - - - - //var test = authorContent.split(/\<br\>/); - //Zotero.debug(test); - - authors = authorContent.match(/\w+,?\s+[\w\(\)\.]+/g); - - //Zotero.debug(authors); - - - for (i = 0; i < authors.length; i++) { - - var author = authors[i].split(", "); - - if (author.length < 2) { - - dataTags["Creator:"] = author[0]; - newItem.creators.push({lastName: dataTags["Creator:"], creatorType: "creator"}); - - } else { - - dataTags["Creator:"] = (author[1] + (" ") + author[0]); - //Zotero.debug(authorArranged); - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Creator:"], "creator")); - } - } - - } else { - - - - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent); - //Zotero.debug(fieldTitle); - } - } - - associateData (newItem, dataTags, "Datesofmaterial:", "date"); - associateData (newItem, dataTags, "Repository:", "repository"); - associateData (newItem, dataTags, "ReferenceNumber:", "callNumber"); - associateData (newItem, dataTags, "PhysicalDescription:", "extra"); - associateData (newItem, dataTags, "Scopeandcontent", "abstractNote"); - - associateData (newItem, dataTags, "Dates:", "date"); - associateData (newItem, dataTags, "Centred'archives:", "repository"); - associateData (newItem, dataTags, "Numéroderéférence:", "callNumber"); - associateData (newItem, dataTags, "Descriptionmatérielle:", "extra"); - associateData (newItem, dataTags, "Portéeetcontenu", "abstractNote"); - - newItem.title = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xPathLinks = doc.evaluate('//td[@class="full"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var linksCounter = doc.evaluate('count (//td[@class="full"]/a)', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathTitles = doc.evaluate('//table[@class="results"]/tbody/tr[1]/td', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_link; - for (var i = 0; i < linksCounter.numberValue; i++) { - next_link = xPathLinks.iterateNext().href; - items[next_link] = xPathTitles.iterateNext().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(); - -} diff --git a/translators/Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC).js b/translators/Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC).js @@ -1,75 +0,0 @@ -{ - "translatorID":"dedcae51-073c-48fb-85ce-2425e97f128d", - "translatorType":4, - "label":"Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC)", - "creator":"Michael Berkowitz", - "target":"http://archivesic.ccsd.cnrs.fr/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.title.toLowerCase().match("fulltext search")) { - return "multiple"; - } else if (url.match(/sic_\d+/)) { - return "journalArticle"; - } -} - -var metaTags = { - "DC.relation":"url", - "DC.date":"date", - "DC.description":"abstractNote", - "DC.creator":"creators", - "DC.title":"title" -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, /sic_\d+\/fr\//); - items = Zotero.selectItems(items) - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - Zotero.Utilities.processDocuments(articles, function(doc) { - var xpath = '//meta[@name]'; - var data = new Object(); - var metas = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var meta; - while (meta = metas.iterateNext()) { - if (data[meta.name]) { - data[meta.name] = data[meta.name] + ";" + meta.content; - } else { - data[meta.name] = meta.content; - } - } - Zotero.debug(data); - var item = new Zotero.Item("journalArticle"); - for (var tag in metaTags) { - if (tag == "DC.creator") { - var authors = data['DC.creator'].split(";"); - for each (var aut in authors) { - aut = aut.replace(/^([^,]+),\s+(.*)$/, "$2 $1"); - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } else { - item[metaTags[tag]] = data[tag]; - } - } - var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.match(/url=([^&]+)&/)[1]; - Zotero.debug(pdfurl); - item.attachments = [ - {url:item.url, title:"AOSIC Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"AOSIC Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Archives Canada-France.js b/translators/Archives Canada-France.js @@ -1,148 +0,0 @@ -{ - "translatorID":"d9a16cf3-8b86-4cab-8610-dbd913ad1a44", - "translatorType":4, - "label":"Archives Canada-France", - "creator":"Adam Crymble", - "target":"http://bd.archivescanadafrance.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-24 05:30:00" -} - -function detectWeb(doc, url) { - - if (doc.location.href.match("doc.xsp?")) { - return "book"; - } else if (doc.evaluate('//li/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//td[1][@class="icones"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - var xPathHeaders = '//td[2]/div[@class="ead-c"]/div[@class="ead-did"]/table[@class="ead-did"]/tbody/tr/td[1]'; - - if (doc.evaluate(xPathHeaders, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var headers = doc.evaluate(xPathHeaders, doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//td[2][@class="did-content"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - while (fieldTitle = headers.iterateNext()) { - fieldTitle = fieldTitle.textContent.replace(/\s+/g, ''); - if (fieldTitle == "Origination" || fieldTitle == "Origine") { - fieldTitle = "Origination"; - } - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - - if (dataTags["Origination"]) { - var author = dataTags["Origination"]; - if (!author.match(", ")) { - newItem.creators.push({lastName: author, creatorType: "author"}); - } else { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - } - - - if (doc.evaluate('//h1[@class="doc-title"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//h1[@class="doc-title"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//td[2]/div[@class="notice"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//td[2]/div[@class="notice"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - newItem.title = doc.title + " Title Not Found"; - } - - associateData (newItem, dataTags, "PhysicalDescription", "pages"); - associateData (newItem, dataTags, "Descriptionmatérielle", "pages"); - - associateData (newItem, dataTags, "Repository", "repository"); - associateData (newItem, dataTags, "Lieudeconservation", "repository"); - - associateData (newItem, dataTags, "LanguageoftheMaterial", "language"); - associateData (newItem, dataTags, "Langue", "language"); - - associateData (newItem, dataTags, "Identifier", "callNumber"); - associateData (newItem, dataTags, "Cote", "callNumber"); - - associateData (newItem, dataTags, "Datesextrêmes", "date"); - associateData (newItem, dataTags, "Dates", "date"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - - var items = new Object(); - - if (doc.evaluate('//td[1][@class="icones"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var titles = doc.evaluate('//td[2][@class="ressource"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var titlesCount = doc.evaluate('count (//td[2][@class="ressource"])', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//td[1][@class="icones"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_link; - - for (var i = 0; i < titlesCount.numberValue; i++) { - next_link = links.iterateNext().href; - if (!next_link.match("doc.xsp")) { - next_link = links.iterateNext().href; - } - items[next_link] = titles.iterateNext().textContent; - } - } - - if (doc.evaluate('//li/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var titles = doc.evaluate('//li/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - } - - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - - } else if (doc.evaluate('//div[@class="ancestor"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var link = doc.evaluate('//div[@class="ancestor"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - - articles = [link]; - } else { - articles = [url] - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Archives Canada.js b/translators/Archives Canada.js @@ -1,126 +0,0 @@ -{ - "translatorID":"18bc329c-51af-497e-a7cf-aa572fae363d", - "translatorType":4, - "label":"Archives Canada", - "creator":"Adam Crymble", - "target":"http://(www.)?archivescanada.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-20 20:45:00" -} - -function detectWeb (doc, url) { - if (doc.location.href.match("RouteRqst")) { - return "multiple"; - } else if (doc.location.href.match("ItemDisplay")) { - return "book"; - } -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var cainNo; - var newItem = new Zotero.Item("book"); - - var data = doc.evaluate('//td/p', doc, nsResolver, XPathResult.ANY_TYPE, null); - var dataCount = doc.evaluate('count (//td/p)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<dataCount.numberValue; i++) { - data1 = data.iterateNext().textContent.replace(/^\s*|\s*$/g, '').split(":"); - fieldTitle = data1[0].replace(/\s+/g, ''); - - if (fieldTitle == "PROVENANCE") { - - var multiAuthors = data1[1].split(/\n/); - - for (var j = 0; j < multiAuthors.length; j++) { - if (multiAuthors[j].match(",")) { - - var authorName = multiAuthors[j].replace(/^\s*|\s*$/g, '').split(","); - - authorName[0] = authorName[0].replace(/\s+/g, ''); - dataTags["PROVENANCE"] = (authorName[1] + (" ") + authorName[0]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["PROVENANCE"], "author")); - - } else { - - newItem.creators.push({lastName: multiAuthors[j].replace(/^\s*|\s*$/g, ''), creatorType: "creator"}); - } - } - - } else if (fieldTitle == "SUBJECTS" | fieldTitle == "MATIÈRES") { - tagsContent = data1[1].split(/\n/); - - } else { - - dataTags[fieldTitle] = data1[1]; - } - } - - if (doc.evaluate('//tr[3]/td/table/tbody/tr[1]/td/table/tbody/tr[2]/td/table/tbody/tr/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - cainNo = doc.evaluate('//tr[3]/td/table/tbody/tr[1]/td/table/tbody/tr[2]/td/table/tbody/tr/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.extra = cainNo.replace(/^\s*|\s*$/g, ''); - } - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i].replace(/^\s*|\s*$/g, ''); - } - - associateData (newItem, dataTags, "TITLE", "title" ); - associateData (newItem, dataTags, "REPOSITORY", "repository" ); - associateData (newItem, dataTags, "RETRIEVALNUMBER", "callNumber" ); - associateData (newItem, dataTags, "DATES", "date" ); - associateData (newItem, dataTags, "SCOPEANDCONTENT", "abstractNote" ); - associateData (newItem, dataTags, "LANGUAGE", "language" ); - - associateData (newItem, dataTags, "LANGUE", "language" ); - associateData (newItem, dataTags, "TITRE", "title" ); - associateData (newItem, dataTags, "CENTRED'ARCHIVES", "repository" ); - associateData (newItem, dataTags, "NUMÉROD'EXTRACTION", "callNumber" ); - associateData (newItem, dataTags, "PORTÉEETCONTENU", "abstractNote" ); - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//td[3]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Archives Network of Alberta.js b/translators/Archives Network of Alberta.js @@ -1,152 +0,0 @@ -{ - "translatorID":"f39dbd1c-229e-4abb-8414-a09fdbda37b7", - "translatorType":4, - "label":"Archives Network of Alberta", - "creator":"Adam Crymble", - "target":"http://208.38.46.62:8080/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-29 21:10:00" -} - -function detectWeb(doc, url) { - - var xPathH3 = doc.evaluate('//h3', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - if (xPathH3.match("Search Results")) { - return "multiple"; - } else if (xPathH3.match("Display")) { - return "book"; - } -} - -//Archives Network of Alberta translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -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("book"); - - var dataTags = new Object(); - var manyAuthors = new Array(); - var tagsContent = new Array(); - var tagsContent1 = new Array(); - - var xPathHeaders = doc.evaluate('//td[1][@class="datalabel"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathContent = doc.evaluate('//td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//td[1][@class="datalabel"])', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = xPathHeaders.iterateNext().textContent.replace(/\s+/g, ''); - - if (fieldTitle =="Provenance:") { - - dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - - if (dataTags[fieldTitle].match("; ")) { - manyAuthors = dataTags[fieldTitle].split("; "); - } else { - manyAuthors.push(dataTags[fieldTitle]); - } - Zotero.debug(manyAuthors); - - for (var j = 0; j < manyAuthors.length; j++) { - if (manyAuthors[j].match(", ")) { - var authorName = manyAuthors[j].split(","); - authorName[0] = authorName[0].replace(/^\s*|\s*$/g, ''); - authorName[1] = authorName[1].replace(/^\s*|\s*$/g, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor((authorName[1] + (" ") + authorName[0]), "author")); - } else { - newItem.creators.push({lastName: manyAuthors[j], creatorType: "creator"}); - } - } - - } else if (fieldTitle == "Partof:") { - - dataTags[fieldTitle] = ("Part of " + Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''))); - - } else if (fieldTitle == "OnlineFindingAid:") { - dataTags[fieldTitle] = ("Online Finding Aid: " + xPathContent.iterateNext().textContent); - Zotero.debug(dataTags["OnlineFindingAid:"]); - - } else if (fieldTitle == "Names:") { - dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - tagsContent = dataTags[fieldTitle].split(";"); - - } else if (fieldTitle == "Topic:") { - dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - tagsContent1 = dataTags[fieldTitle].split(", "); - - } else { - - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - } - - for (i = 0; i < tagsContent.length; i++) { - tagsContent[i] = tagsContent[i].replace(/^\s*|\s*$/g, ''); - newItem.tags[i] = tagsContent[i]; - } - - for (i = 0; i < tagsContent1.length; i++) { - - newItem.tags.push(tagsContent1[i]); - } - - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "Dates:", "date"); - associateData (newItem, dataTags, "Physicaldesc.:", "pages"); - associateData (newItem, dataTags, "Repository:", "repository"); - associateData (newItem, dataTags, "Scope/Content:", "abstractNote"); - associateData (newItem, dataTags, "Partof:", "series"); - associateData (newItem, dataTags, "OnlineFindingAid:", "extra"); - associateData (newItem, dataTags, "Language:", "language"); - associateData (newItem, dataTags, "RecordNo.:", "callNumber"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var xPathTitles = doc.evaluate('//tr[1]/td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextTitle; - - var xPathLinks = doc.evaluate('//td[1][@class="dataleft"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - - while (nextTitle = xPathTitles.iterateNext()) { - items[xPathLinks.iterateNext().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(); -} -\ No newline at end of file diff --git a/translators/Artefacts Canada.js b/translators/Artefacts Canada.js @@ -1,160 +0,0 @@ -{ - "translatorID":"661fc39a-2500-4710-8285-2d67ddc00a69", - "translatorType":4, - "label":"Artefacts Canada", - "creator":"Adam Crymble", - "target":"http://daryl.chin.gc.ca", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:55:00" -} - -function detectWeb(doc, url) { - var multi1 = ''; - var single1 = ''; - - if (doc.evaluate('//div[@id="mainContent"]/table/tbody/tr/td[1]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - - multi1 = doc.evaluate('//div[@id="mainContent"]/table/tbody/tr/td[1]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - var xpath = '//tbody/tr[1]/td[2]/span'; - if (doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - single1 = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - if (multi1.match("Search Results") || multi1.match("Résultats de recherche")) { - return "multiple"; - } else if (single1.match("Document") || single1.match("Enregistrement")) { - return "artwork"; - } - -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("artwork"); - - var headers = doc.evaluate('//td[1][@class="leftResTitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//td[2][@class="pageText"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - while (fieldTitle = headers.iterateNext()) { - fieldTitle = fieldTitle.textContent.replace(/\s+/g, ''); - if (fieldTitle == "Titre:") { - fieldTitle = "Title:"; - } else if (fieldTitle == "Nomdel'objet:") { - fieldTitle = "NameofObject:"; - } else if (fieldTitle == "Sujetouimage:") { - fieldTitle = "Subject/Image:"; - } else if (fieldTitle == "Numérod'accession:") { - fieldTitle = "AccessionNumber:"; - } else if (fieldTitle == "Artisteouartisan:") { - fieldTitle = "Artist/Maker:"; - } else if (fieldTitle == "Fabricant:") { - fieldTitle = "Manufacturer:"; - } - - dataTags[fieldTitle] = contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '') - } - - Zotero.debug(dataTags); - - if (dataTags["Artist/Maker:"]) { - if (dataTags["Artist/Maker:"].match(", ")) { - var authors = dataTags["Artist/Maker:"].split(", "); - authors = authors[0] + ' ' + authors[1]; - newItem.creators.push(authors, "creator"); - } else { - newItem.creators.push(dataTags["Artist/Make:"], "creator"); - } - } - - if (dataTags["Manufacturer:"]) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Manufacturer:"], "creator")); - } - - if (dataTags["AccessionNumber:"]) { - newItem.locInArchive = "Accession Number: " + dataTags["AccessionNumber:"]; - } - - if (dataTags["Subject/Image:"]) { - if (dataTags["Subject/Image:"].match(/\n/)) { - var subjects = dataTags["Subject/Image:"].split(/\n/); - for (var i = 0; i < subjects.length; i++) { - newItem.tags[i] = subjects[i]; - } - } else { - newItem.tags[0] = dataTags["Subject/Image:"].match(/\n/); - } - } - - if (dataTags["Title:"]) { - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "NameofObject:", "medium"); - } else if (dataTags["NameofObject:"]) { - associateData (newItem, dataTags, "NameofObject:", "title"); - } else { - newItem.title = "No Title Found"; - } - - associateData (newItem, dataTags, "LatestProductionDate:", "date"); - associateData (newItem, dataTags, "Datedefindeproduction:", "date"); - - associateData (newItem, dataTags, "Institution:", "repository"); - associateData (newItem, dataTags, "Établissement:", "repository"); - - associateData (newItem, dataTags, "Description:", "description"); - - associateData (newItem, dataTags, "Medium:", "medium"); - associateData (newItem, dataTags, "Médium:", "medium"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//tr[1]/td[2][@class="pageText"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//td/a[@class="moreInfoink"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - - items[links.iterateNext().href] = next_title.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(); -} diff --git a/translators/AustLII and NZLII.js b/translators/AustLII and NZLII.js @@ -1,80 +0,0 @@ -{ - "translatorID":"5ed5ab01-899f-4a3b-a74c-290fb2a1c9a4", - "translatorType":4, - "label":"AustLII and NZLII", - "creator":"Bill McKinney", - "target":"http:\\/\\/www\\.(?:austlii\\.edu\\.au|nzlii\\.org)\\/(?:\\/cgi-bin\\/disp\\.pl\\/)?(?:au|nz)\\/cases\\/.+", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-06-18 18:15:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var austliiRegexp = /^http:\/\/www\.(?:austlii\.edu\.au|nzlii\.org)\/(?:\/cgi-bin\/disp\.pl\/)?(?:au|nz)\/cases\/.+/ - if(austliiRegexp.test(url)) { - return "book"; - } else { - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - if(articleRegexp.test(aTags[i].href)) { - return "multiple"; - } - } - } -} - - -function scrape(doc) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("case"); - newItem.title = doc.title; - newItem.url = doc.location.href; - - var titleRegexp = /^(.+)\s+\[(\d+)\]\s+(\w+)\s(\d+)\s+\((\d+)\s+(\w+)\s+(\d+)\)/ - var titleMatch = titleRegexp .exec(doc.title); - if (titleMatch ) { - newItem.caseName = titleMatch[1] + " [" + titleMatch[2] + "] " + titleMatch[3] + " " + titleMatch[4]; - newItem.dateDecided = titleMatch[7] + " " + titleMatch[6] + " " + titleMatch[5]; - newItem.court = titleMatch[3]; - } else { - newItem.caseName = doc.title; - newItem.dateDecided = "not found"; - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var austliiRegexp = /^http:\/\/www\.(?:austlii\.edu\.au|nzlii\.org)\/(?:\/cgi-bin\/disp\.pl\/)?(?:au|nz)\/cases\/.+/ - if(austliiRegexp.test(url)) { - scrape(doc); - } else { - - var items = Zotero.Utilities.getItemArray(doc, doc, austliiRegexp); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/Australian Dictionary of Biography.js b/translators/Australian Dictionary of Biography.js @@ -1,78 +0,0 @@ -{ - "translatorID":"0aea3026-a246-4201-a4b5-265f75b9a6a7", - "translatorType":4, - "label":"Australian Dictionary of Biography", - "creator":"Tim Sherratt and Michael Berkowitz", - "target":"http://www.adb.online.anu.edu.au", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if (url.match(/adbp-ent_search|browse_people|browse_authors/)) { - return "multiple"; - } else if (url.match(/biogs\/AS*\d+b.htm/)) { - return "bookSection"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - if (detectWeb(doc, url) == "multiple") { - var records = new Array(); - var items = new Object(); - if (url.match(/browse_people/)) { - var titles = doc.evaluate('//ul[@class="pb-results"]/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//ul[@class="pb-results"]/li/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } else if (url.match(/browse_authors/)) { - var titles = doc.evaluate('//div[@id="content"]/dl/dd', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//div[@id="content"]/dl/dd/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } else if (url.match(/adbp-ent_search/)) { - var titles = doc.evaluate('//div[@id="content"]/ol/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//div[@id="content"]/ol/li//a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - var title; - var link; - while ((link = links.iterateNext()) && (title = titles.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent); - } - - items = Zotero.selectItems(items); - for (var i in items) { - records.push(i); - } - } else { - records = [url]; - } - Zotero.Utilities.processDocuments(records, function(doc) { - var item = new Zotero.Item("bookSection"); - var author = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="content"]/p[strong="Author"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().lastChild.textContent); - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var pubdetails = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="content"]/p[strong="Print Publication Details"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - pubdetails = pubdetails.match(/Volume (\d+), ([\w ]+), (\d{4}), p+\.*\s+([\d-]+)/); - item.volume = RegExp.$1; - item.publisher = RegExp.$2; - item.date = RegExp.$3; - item.pages = RegExp.$4; - item.url = doc.location.href; - item.bookTitle = "Australian Dictionary of Biography"; - item.place = "Melbourne"; - item.repository = "Australian Dictionary of Biography"; - var tags = doc.evaluate('//li/a[starts-with(@title, "find people with the occupation")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (tag = tags.iterateNext()) { - item.tags.push(tag.textContent); - } - item.attachments = [ - {url:item.url, title: "Snapshot - " + item.title, mimeType:"text/html"}, - ]; - item.complete(); - - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/BAILII.js b/translators/BAILII.js @@ -1,106 +0,0 @@ -{ - "translatorID":"5ae63913-669a-4792-9f45-e089a37de9ab", - "translatorType":4, - "label":"BAILII", - "creator":"Bill McKinney", - "target":"http:\\/\\/www\\.bailii\\.org(?:\\/cgi\\-bin\\/markup\\.cgi\\?doc\\=)?\\/\\w+\\/cases\\/.+", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-06-18 18:15:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var liiRegexp= /^http:\/\/www\.bailii\.org(?:\/cgi\-bin\/markup\.cgi\?doc\=)?\/\w+\/cases\/.+/ - if(liiRegexp.test(url)) { - return "book"; - } else { - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - if(articleRegexp.test(aTags[i].href)) { - return "multiple"; - } - } - } -} - -function scrape(doc) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("case"); - newItem.title = doc.title; - newItem.url = doc.location.href; - - var titleRegexp = /^(.+)\s+\[(\d+)\]\s+(.+)\s+\((\d+)\s+(\w+)\s+(\d+)\)/ - var titleMatch = titleRegexp .exec(doc.title); - if (titleMatch ) { - newItem.caseName = titleMatch[1] + " [" + titleMatch[2] + "] " + titleMatch[3]; - newItem.dateDecided = titleMatch[4] + " " + titleMatch[5] + " " + titleMatch[6]; - } else { - newItem.caseName = doc.title; - newItem.dateDecided = "not found"; - } - - var courtRegexp = /cases\/([^\/]+)\/([^\/]+)\// - var courtMatch = courtRegexp.exec(doc.location.href); - if (courtMatch) { - var divRegexp = /\w+/ - var divMatch = divRegexp.exec(courtMatch[2]); - if (divMatch) { - newItem.court = courtMatch[1] + " (" + courtMatch[2] + ")"; - } else { - newItem.court = courtMatch[1]; - } - } else { - newItem.court = "not found"; - } - - // judge - var panel = doc.getElementsByTagName("PANEL"); - if (panel.length > 0) { - var tmp = panel[0].innerHTML; - newItem.creators.push({lastName:tmp, creatorType:"judge", fieldMode:true}); - - } - // citation - var cite = doc.getElementsByTagName("CITATION"); - if (cite.length > 0) { - var tmpc = cite[0].childNodes[0].innerHTML; - newItem.notes.push({note:tmpc}); - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var liiRegexp= /http:\/\/www\.bailii\.org(?:\/cgi\-bin\/markup\.cgi\?doc\=)?\/\w+\/cases\/.+/ - if(liiRegexp.test(url)) { - scrape(doc); - } else { - - var items = Zotero.Utilities.getItemArray(doc, doc, liiRegexp); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/BBC.js b/translators/BBC.js @@ -1,116 +0,0 @@ -{ - "translatorID":"f4130157-93f7-4493-8f24-a7c85549013d", - "translatorType":4, - "label":"BBC", - "creator":"Ben Parr", - "target":"^https?://(?:www|news?)\\.bbc\\.co.uk", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-08-27 05:00:00" -} - -function detectWeb(doc, url) -{ - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath; - - xpath='//meta[@name="Headline"]'; - if(content=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext()) - { return "newspaperArticle"; } - - xpath='//font[@class="poshead"]/b'; - if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext()) - { return "newspaperArticle"; } - - return null; -} - -function scrape(doc,url,title) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("newspaperArticle"); - - newItem.url=url; - newItem.repository="bbc.co.uk"; - newItem.publicationTitle="BBC"; - newItem.title=title; - - xpath='//meta[@name="OriginalPublicationDate"]/@content'; - var temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext(); - if(temp) - { - temp=temp.value; - temp=temp.split(" ")[0]; - newItem.date=temp; - } - else - { - xpath='//font[@class="postxt"][@size="1"]'; - var rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - var row; - while(row=rows.iterateNext()) - { - temp=row.textContent; - if(temp.substr(0,9)=="Created: ") - { - newItem.date=temp.substr(9); - break; - } - } - } - - xpath='//meta[@name="Section"]/@content'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext(); - if(temp) - { newItem.section=temp.value; } - - xpath='//meta[@name="Description"]/@content'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext(); - if(temp) - { newItem.abstractNote=temp.value; } - else - { - xpath='//meta[@name="description"]/@content'; - temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext(); - if(temp) - { newItem.abstractNote=temp.value; } - } - - newItem.attachments.push({url:url, title:"BBC News Snapshot",mimeType:"text/html"}); - - newItem.complete(); -} - - - -function doWeb(doc,url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath='//meta[@name="Headline"]/@content'; - var title; - if(title=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext()) - { scrape(doc,url,title.value) } - else - { - xpath='//font[@class="poshead"]/b'; - if(title=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext()) - { scrape(doc,url,title.textContent) } - } - - -} -\ No newline at end of file diff --git a/translators/BC Archival Information Network.js b/translators/BC Archival Information Network.js @@ -1,147 +0,0 @@ -{ - "translatorID":"c76d6c19-b4c6-4e51-bd7a-0a81752305ae", - "translatorType":4, - "label":"BC Archival Information Network", - "creator":"Adam Crymble", - "target":"http://(mayne.)?aabc.bc.ca/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-20 20:45:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - var entryType = (doc.evaluate('/html/body/h3', doc, nsResolver, XPathResult.ANY_TYPE, null)); - if (entryType.iterateNext()) { - var entryType1 = entryType.iterateNext().textContent; - - if (entryType1.match("Search") && entryType1 != ("Search Results - BCAUL Repositories")) { - return "multiple"; - } else if (entryType1.match("Display") && entryType1 != ("Display - BCAUL Repositories") && doc.location.href.match("display")) { - return "book"; - } - } -} - -//BCAIN translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -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("book"); - - var dataTags = new Object(); - var manyAuthors = new Array(); - var tagsContent = new Array(); - - var xPathHeaders = doc.evaluate('//td[1][@class="datalabel"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathContent = doc.evaluate('//td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//td[1][@class="datalabel"])', doc, nsResolver, XPathResult.ANY_TYPE, null); - - Zotero.debug(xPathCount.numberValue); - - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = xPathHeaders.iterateNext().textContent.replace(/\s+/g, ''); - - if (fieldTitle =="Provenance:") { - - dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - - if (dataTags[fieldTitle].match("; ")) { - manyAuthors = dataTags[fieldTitle].split("; "); - } else { - manyAuthors.push(dataTags[fieldTitle]); - } - - for (var j = 0; j < manyAuthors.length; j++) { - if (manyAuthors[j].match(", ")) { - var authorName = manyAuthors[j].split(","); - authorName[0] = authorName[0].replace(/^\s*|\s*$/g, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor((authorName[1] + (" ") + authorName[0]), "author")); - } else { - newItem.creators.push({lastName: dataTags["Provenance:"], creatorType: "creator"}); - } - } - - } else if (fieldTitle == "Partof:") { - - dataTags[fieldTitle] = ("Part of " + Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''))); - - } else if (fieldTitle == "OnlineFindingAid:") { - dataTags[fieldTitle] = ("Online Finding Aid: " + xPathContent.iterateNext().textContent); - Zotero.debug(dataTags["OnlineFindingAid:"]); - - } else if (fieldTitle == "Names:") { - dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - tagsContent = dataTags[fieldTitle].split(";"); - - } else { - - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - } - - for (var i = 0; i < tagsContent.length; i++) { - tagsContent[i] = tagsContent[i].replace(/^\s*|\s*$/g, ''); - newItem.tags[i] = tagsContent[i]; - } - - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "Dates:", "date"); - associateData (newItem, dataTags, "Physicaldesc.:", "pages"); - associateData (newItem, dataTags, "Repository:", "repository"); - associateData (newItem, dataTags, "Scope/Content:", "abstractNote"); - associateData (newItem, dataTags, "Partof:", "series"); - associateData (newItem, dataTags, "OnlineFindingAid:", "extra"); - - newItem.notes.push({title:"Title", note:"To view this entry in your browser, please go to'http://aabc.bc.ca/WWW.aabc.archbc/access' and search for the entry Title "}); - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var xPathTitles = doc.evaluate('//tr[1]/td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextTitle; - - var xPathLinks = doc.evaluate('//td[1][@class="dataleft"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextLink; - - while (nextTitle = xPathTitles.iterateNext()) { - items[xPathLinks.iterateNext().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(); -} -\ No newline at end of file diff --git a/translators/BIBSYS.js b/translators/BIBSYS.js @@ -1,66 +0,0 @@ -{ - "translatorID":"ab961e61-2a8a-4be1-b8a3-044f20d52d78", - "translatorType":4, - "label":"BIBSYS", - "creator":"Ramesh Srigiriraju", - "target":"^http://ask\\.bibsys\\.no/ask/action", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-07-31 16:45:00" -} - -function detectWeb(doc, url) { - var multireg=new RegExp("^http://ask\.bibsys\.no/ask/action/result"); - if(multireg.test(url)) - return "multiple"; - var singlereg=new RegExp("^http://ask\.bibsys\.no/ask/action/show"); - if(singlereg.test(url)) - return "book"; -} - -function doWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - var multireg=new RegExp("http://ask\.bibsys\.no/ask/action/result"); - if(multireg.test(url)) { - var titlpath='//tr/td[@width="49%"][@align="left"][@valign="top"]/a/text()'; - var titles=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var codepath='//tr/td/input[@type="checkbox"][@name="valg"]/@value'; - var codes=doc.evaluate(codepath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var items=new Array(); - var title; - titles.iterateNext(); - while(title=titles.iterateNext()) - items[codes.iterateNext().nodeValue]=title.nodeValue; - items=Zotero.selectItems(items); - var string="http://ask.bibsys.no/ask/action/result?control=ctr_top"; - for(var codes in items) - string+="&valg="+codes; - string+="&control=ctr_bottom&eksportFormat=refmanager&eksportEpostAdresse=&eksportEpostFormat=fortekst&cmd=sendtil"; - Zotero.Utilities.HTTP.doGet(string, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - trans.setString(text); - trans.translate(); - Zotero.done(); - }); - Zotero.wait(); - } - var singlereg=new RegExp("http://ask\.bibsys\.no/ask/action/show"); - if(singlereg.test(url)) { - var urlstring="http://ask.bibsys.no/ask/action/show"; - var data="visningsformat=fortekst_m_eksemplarer&eksportFormat=refmanager&eksportEpostAdresse=&eksportEpostFormat=fortekst&cmd=sendtil"; - Zotero.Utilities.HTTP.doPost(urlstring, data, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - trans.setString(text); - trans.translate(); - Zotero.done(); - }); - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/BIUM.js b/translators/BIUM.js @@ -1,97 +0,0 @@ -{ - "translatorID":"cae7d3ec-bc8d-465b-974f-8b0dcfe24290", - "translatorType":4, - "label":"BIUM", - "creator":"Michael Berkowitz", - "target":"http://hip.bium.univ-paris5.fr/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//td/a[@class="itemTitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//td[1]/span[@class="uportal-channel-strong"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -function makeMARCurl(link, rsId, rrsId, query) { - return 'http://hip.bium.univ-paris5.fr/uPortal/Print?link=' + link + '&xslFileName=com/dynix/hip/uportal/channels/standard/FullMarc.xsl&F=/searching/getmarcdata&responseSessionId=' + rsId + '&responseResultSetId=' + rrsId + '&searchGroup=BIUM-13&query=' + query + '&searchTargets=16&locale=fr_FR'; -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//a[@class="itemTitle"]', doc, ns, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - items = Zotero.selectItems(items); - var rsId = doc.evaluate('//input[@name="responseSessionId"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value; - var rrsId = doc.evaluate('//input[@name="responseResultSetId"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value; - var query = doc.evaluate('//input[@name="query"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value; - var linkRE = new RegExp("'([^']+)'", "g"); - for (var i in items) { - var link = linkRE.exec(i)[1]; - Zotero.debug(link); - books.push(makeMARCurl(link, rsId, rrsId, query)); - } - } else { - var link = url.match(/link=([^&]+)/)[1]; - var rsId = url.match(/responseSessionId=([^&]+)/)[1]; - var rrsId = url.match(/responseResultSetId=([^&]+)/)[1]; - var query = url.match(/query=([^&]+)/)[1]; - books = [makeMARCurl(link, rsId, rrsId, query)]; - } - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.processDocuments(books, function(doc) { - var rows = doc.evaluate('//center/table/tbody/tr', doc, ns, XPathResult.ANY_TYPE, null); - var row; - var record = new marc.record(); - while (row = rows.iterateNext()) { - var field = Zotero.Utilities.trimInternal(doc.evaluate('./td[1]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(":", "")); - if (field) { - var value = doc.evaluate('./td[2]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (value.split(/\n/)[1]) value = Zotero.Utilities.trimInternal(value.split(/\n/)[1]); - if (field == "LDR") { - record.leader = value; - } else if (field != "FMT") { - value = value.replace(/\¤([a-z])/g, marc.subfieldDelimiter+ "$1"); - var code = field.substring(0, 3); - var ind = ""; - if (field.length > 3) { - ind = field[3]; - if (field.length > 4) { - ind += field[4]; - } - } - record.addField(code, ind, value); - } - } - } - var item = new Zotero.Item(); - record.translate(item); - - var oldauthors = item.creators; - var newauthors = new Array(); - for each (var aut in oldauthors) { - if (aut.lastName.match(/^[A-Z][^\s]+\s[^\s]+/)) newauthors.push(Zotero.Utilities.cleanAuthor(aut.lastName.match(/^[A-Z][^\s]+\s[^\s]+/)[0].replace(/^([^\s]+)\s+(.*)$/, "$2 $1"), "author")); - } - item.creators = newauthors; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/BOCC.js b/translators/BOCC.js @@ -1,212 +0,0 @@ -{ - "translatorID":"ecd1b7c6-8d31-4056-8c15-1807b2489254", - "label":"BOCC", - "creator":"José Antonio Meira da Rocha", - "target":"^http:\\/\\/[^/]*bocc[^/]*/(?:_listas|_esp)", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "translatorType":4, - "lastUpdated":"2010-09-20 18:12:01" -} - -/* Translator for Biblioteca Online de Ciências da Comunicação (BOCC, -Communication Science Online Library, http://www.bocc.ubi.pt/) */ - -/* - BOCC Translator - Parses BOCC indexes and creates Zotero-based metadata. - Copyright (C) 2010 José Antonio Meira da Rocha - - 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/>. -*/ - -// Standard Zotero function -function detectWeb(doc, url) { - if (doc.evaluate("//table[@class='ag']/tbody/tr[1]/td[@class='agenda']", doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("multiple"); - return "multiple"; - } -} -/////////////////////////////////////// -function getAuthors(newItem, itemsAutors) { - //Formatting and saving "Author" field - if (items["AUTOR"]) { - var author = itemsAutors["AUTOR"]; - if (author.match(";")) { - var authors = author.split(";"); - for (var i in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } -} -// Standard Zotero translator entry point -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 itemsAutors = new Object(); - var itemDate = new Object(); - var nextTitle; - var urls = new Array(); - var bloco; - var lines = new Array(); - var resite = /^http:\/\/[^\/]*bocc[^\/]*\/(?:_listas|_esp)/; - var site = resite.exec(url); - site = site[0]; - site = site.replace("/_esp", ""); - site = site.replace("/_listas", ""); - Zotero.debug('Site===>'+site+'<==='); - if (detectWeb(doc, url) == "multiple") { - // Return XPathResult object - // accessible with .iterateNext() method - var content = doc.evaluate("//table[@class='ag']/tbody/tr[1]/td[@class='agenda']", doc, nsResolver, XPathResult.ANY_TYPE, null); - // All articles are in same <td> - // Get the first <td> data - bloco = content.iterateNext().innerHTML; - lines = bloco.split('<br><br>'); - //Zotero.debug('Artigo===>'+lines[0]+'<==='); - /////////////////////////////////////////////// - // Try get tags - var tematica = doc.evaluate("//title", doc, nsResolver, XPathResult.ANY_TYPE, null); - tematica = tematica.iterateNext().textContent; - //Zotero.debug('<Title>===>'+tematica+'<==='); - var isTematica = tematica.match('Temática'); - if (isTematica) { - // Get tematicas list to build tags list - var tematicanum; - var tematicasnums = doc.evaluate('//a[@class="tematica"]/@href', doc, nsResolver, XPathResult.ANY_TYPE, null); - var tematicasname; - var tematicasnames = doc.evaluate('//a[@class="tematica"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var tematicas = new Object(); - while (tematicanum = tematicasnums.iterateNext()) { - tematicanum = tematicanum.textContent; - tematicanum = tematicanum.match(/=[\d]+$/)[0]; - tematicanum = tematicanum.replace('=',''); - tematicaname = tematicasnames.iterateNext().textContent; - tematicas[tematicanum] = tematicaname; - } - //////////////////////////////////////////// - // Get current tematica - var tagsContent = new Array(); - - - tematica = tematica.match(/:\s[\d]*\s-/)[0]; - tematica = tematica.replace(': ',''); - tematica = tematica.replace(' -',''); - tematicaname = tematicas[tematica]; - //Zotero.debug('Tematica ===>'+tematicaname+'<==='); - // Build tags - if (tematicaname.match(' e ')) { - tagsContent = tematicaname.split(' e '); - if (tagsContent[0].match(',')) { - var temp = tagsContent[0].split(','); - tagsContent.push(temp[1]); - tagsContent[0] = temp[0]; - } - } else { - tagsContent[0] = tematicaname; - } - //for (var i in tagsContent) { - // Zotero.debug('Tag ===>'+i+'='+tagsContent[i]+'<==='); - //} - } // if (isTematica) - ///////////////////////////////////////////// - var title; - var docurl; - var autores = new Array(); - var reurl = /href="([^"]+)/ ; - var reautor= /autor.php[^>]+"agenda">([^<]+)/g ; - var redate = /(\d\d\d\d$)/g ; - for (var n in lines) { - title = Zotero.Utilities.cleanTags(lines[n].split('<br>')[0]); - title = Zotero.Utilities.trimInternal(Zotero.Utilities.trim(title)); - title = Zotero.Utilities.unescapeHTML(title); - docurl = reurl.exec(lines[n]); - if (docurl) { - if (docurl[1].match('autor')) { - docurl = ''; - } else { - items[docurl[1]] = title; - autores = lines[n].match(reautor); - for(var i in autores){ - autores[i] = autores[i].split('>')[1]; - } - itemsAutors[docurl[1]] = autores ; - date = lines[n].match(redate); - //Zotero.debug('Data===>'+date[0]+'<==='); - itemDate[docurl[1]] = date[0] ; - } - } - } - //Zotero.debug('URL===>'+docurl[1]+'<==='); - /* Zotero.selectItems() - * Presents items to select in the select box. - * Assumes window.arguments[0].dataIn is an object with - * URLs as keys and descriptions as values - */ - items = Zotero.selectItems(items); - for (var n in items) { - Zotero.debug('Item '+n+' ==>'+items[n]+'<=='); - }; - - var filetitle; - var filemime; - for (var item in items) { - var newItem = new Zotero.Item("journalArticle"); - newItem.title = items[item]; - newItem.date = itemDate[item]; - newItem.publicationTitle = "Biblioteca Online de Ciências da Comunicação"; - newItem.ISSN = '1646-3137'; - newItem.journalAbbreviation = 'BOCC' ; - // http://www.bocc.ubi.pt - newItem.url = site+item.replace("..", ""); - fileurl = site+item.replace("..", "") - Zotero.debug('Doc ===>'+fileurl+'<==='); - if (fileurl.match('.html$|.htm$|.HTML$|.HTM$')) { - filetitle = 'Anexo HTML'; - filemime = 'text/html'; - }; - if (fileurl.match('.pdf$|.PDF$')) { - filetitle = 'Anexo PDF'; - filemime = 'application/pdf'; - }; - Zotero.debug('File title ===>'+filetitle+'<==='); - Zotero.debug('File mime ===>'+filemime+'<==='); - newItem.attachments.push( - {url:fileurl, title:filetitle, mimeType:filemime} - ); - temp = itemsAutors[item]; - for (var i in temp) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(temp[i], "author")); - } - if (isTematica) { - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - } - newItem.complete(); - } - //debug - - Zotero.wait(); - } -} diff --git a/translators/Berkeley Electronic Press.js b/translators/Berkeley Electronic Press.js @@ -1,84 +0,0 @@ -{ - "translatorID":"2a5dc3ed-ee5e-4bfb-baad-36ae007e40ce", - "translatorType":4, - "label":"Berkeley Electronic Press", - "creator":"Michael Berkowitz", - "target":"http://www.bepress.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match("cgi/query.cgi")) { - return "multiple"; - } else if (url.match(/vol[\d+]\/iss[\d]+/)) { - return "journalArticle"; - } -} - -var tagMap = { - journal_title:"publicationTitle", - title:"title", - date:"date", - volume:"volume", - issue:"issue", - abstract_html_url:"url", - doi:"DOI" -} - -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(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//table[@id="query"]/tbody/tr/td[4]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - Zotero.debug(articles); - Zotero.Utilities.processDocuments(articles, function(newDoc) { - var metatags = new Object(); - var metas = newDoc.evaluate('//meta[contains(@name, "bepress_citation")]', newDoc, null, XPathResult.ANY_TYPE, null); - var next_meta; - while (next_meta = metas.iterateNext()) { - metatags[next_meta.name.replace("bepress_citation_", "")] = next_meta.content; - } - var item = new Zotero.Item("journalArticle"); - - //regularly mapped tags - for (var tag in tagMap) { - if (metatags[tag]) { - item[tagMap[tag]] = metatags[tag]; - } - } - - //authors - var authors = metatags['authors'].split(";"); - for each (var author in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - //attachments - item.attachments = [ - {url:item.url, title:item.title, mimeType:"text/html"}, - {url:metatags['pdf_url'], title:"Berkeley Electronic Press Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Berkeley Library Catalog.js b/translators/Berkeley Library Catalog.js @@ -1,95 +0,0 @@ -{ - "translatorID":"9c335444-a562-4f88-b291-607e8f46a9bb", - "translatorType":4, - "label":"Berkeley Library Catalog", - "creator":"Simon Kornblith", - "target":"^https?://[^/]*berkeley.edu[^/]*/WebZ/(?:html/results.html|FETCH)\\?.*sessionid=", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var resultsRegexp = /\/WebZ\/html\/results.html/i - if(resultsRegexp.test(url)) { - return "multiple"; - } else { - return "book"; - } -} - -function reformURL(url) { - return url.replace(/fmtclass=[^&]*/, "")+":fmtclass=marc"; -} - -function doWeb(doc, url) { - var resultsRegexp = /\/WebZ\/html\/results.html/i - - if(resultsRegexp.test(url)) { - var items = Zotero.Utilities.getItemArray(doc, doc, "/WebZ/FETCH", "^[0-9]*$"); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(reformURL(i)); - } - } else { - var urls = [reformURL(url)]; - } - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - - Zotero.Utilities.processDocuments(urls, function(newDoc) { - var uri = newDoc.location.href; - - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var elmts = newDoc.evaluate('//table/tbody/tr[@valign="top"]', - newDoc, nsResolver, XPathResult.ANY_TYPE, null); - - var record = new marc.record(); - while(elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./TD[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - var value = newDoc.evaluate('./TD[2]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - // remove spacing - value = value.replace(/^\s+/, ""); - value = value.replace(/\s+$/, ""); - if(field == 0) { - record.leader = "00000"+value; - } else { - var ind = value[3]+value[5]; - if (value.match(/^\d{1,2}\s{3}/)) value = Zotero.Utilities.trimInternal(value.replace(/^\d{1,2}\s{3}/, "")); - value = value.replace(/\$([a-z0-9]) /g, marc.subfieldDelimiter+"$1"); - if(value[0] != marc.subfieldDelimiter) { - value = marc.subfieldDelimiter+"a"+value; - } - record.addField(field, ind, value); - } - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - var oldTags = newItem.tags; - var newTags = new Array(); - for each (var tag in oldTags) { - if (newTags.indexOf(tag) == -1) newTags.push(tag) - } - newItem.tags = newTags; - newItem.repository = "Berkeley Library Catalog"; - - newItem.complete(); - }, function() { Zotero.done(); }, null); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Bezneng Gajit.js b/translators/Bezneng Gajit.js @@ -1,68 +0,0 @@ -{ - "translatorID": "7500180d-ca99-4ef7-a9a9-3e58bba91d28", - "label": "Безнең гәҗит", - "creator": "Avram Lyon", - "target": "^https?://(?:www\\.)?beznen\\.ru", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-26 13:03:49" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - -/* - Bezneng Gajit 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 FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'newspaperArticle', -detect : FW.Url().match(/\/basma\/[0-9-]+\/\w+/), -title : FW.Xpath('//h1[@class="entry-title"]').text().trim(), -attachments : [{ url: FW.Url(), - title: "Безнең гәҗит Snapshot", - type: "text/html" }], -creators : FW.Xpath('//div[@class="entry-meta"]/p[@class="authors"]//a') - .text().replace(/^.*Килгән\sхатлардан.*$/, "").cleanAuthor("author"), -date : FW.Xpath('//div[@class="entry-meta"]/p[@class="post-category"]').text().replace(/(\d{4}),\s№\s?\d+\s\((.*)\)/,"$2 $1"), -issue : FW.Xpath('//div[@class="entry-meta"]/p[@class="post-category"]').text().match(/№\s?(\d+)/,1), -publicationTitle : "Безнең гәҗит", -language : "татарча", -hooks : { "scraperDone": function (item,doc, url) { - for (i in item.creators) { - if (item.creators[i].lastName == item.creators[i].lastName.toUpperCase()) { - item.creators[i].lastName = Zotero.Utilities.capitalizeTitle( - item.creators[i].lastName.toLowerCase(),true); - } - }} -} -}); - -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Url().match(/\/rubric\/|\?s=/), -choices : { - titles : FW.Xpath('//h2[@class="entry-title"]/a').text().trim(), - urls : FW.Xpath('//h2[@class="entry-title"]/a').key("href") -} -}); diff --git a/translators/BibTeX.js b/translators/BibTeX.js @@ -1,2388 +0,0 @@ -{ - "translatorID": "9cb70025-a888-4a29-a210-93ec52da40d4", - "label": "BibTeX", - "creator": "Simon Kornblith and Richard Karnesky", - "target": "bib", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 200, - "displayOptions": { - "exportCharset": "UTF-8", - "exportNotes": true, - "exportFileData": false - }, - "inRepository": true, - "translatorType": 3, - "browserSupport": "gcs", - "lastUpdated": "2011-08-16 15:07:38" -} - -function detectImport() { - var maxChars = 1048576; // 1MB - - var inComment = false; - var block = ""; - var buffer = ""; - var chr = ""; - var charsRead = 0; - - var re = /^\s*@[a-zA-Z]+[\(\{]/; - while((buffer = Zotero.read(4096)) && charsRead < maxChars) { - Zotero.debug("Scanning " + buffer.length + " characters for BibTeX"); - charsRead += buffer.length; - for (var i=0; i<buffer.length; i++) { - chr = buffer[i]; - - if (inComment && chr != "\r" && chr != "\n") { - continue; - } - inComment = false; - - if(chr == "%") { - // read until next newline - block = ""; - inComment = true; - } else if((chr == "\n" || chr == "\r" - // allow one-line entries - || i == (buffer.length - 1)) - && block) { - // check if this is a BibTeX entry - if(re.test(block)) { - return true; - } - - block = ""; - } else if(" \n\r\t".indexOf(chr) == -1) { - block += chr; - } - } - } -} - -//%a = first author surname -//%y = year -//%t = first word of title -var citeKeyFormat = "%a_%t_%y"; - -var fieldMap = { - address:"place", - chapter:"section", - edition:"edition", - type:"type", - series:"series", - title:"title", - volume:"volume", - copyright:"rights", - isbn:"ISBN", - issn:"ISSN", - lccn:"callNumber", - location:"archiveLocation", - shorttitle:"shortTitle", - url:"url", - doi:"DOI", - "abstract":"abstractNote" -}; - -var inputFieldMap = { - booktitle :"publicationTitle", - school:"publisher", - institution:"publisher", - publisher:"publisher", - issue:"issue" -}; - -var zotero2bibtexTypeMap = { - "book":"book", - "bookSection":"incollection", - "journalArticle":"article", - "magazineArticle":"article", - "newspaperArticle":"article", - "thesis":"phdthesis", - "letter":"misc", - "manuscript":"unpublished", - "interview":"misc", - "film":"misc", - "artwork":"misc", - "webpage":"misc", - "conferencePaper":"inproceedings", - "report":"techreport" -}; - -var bibtex2zoteroTypeMap = { - "book":"book", // or booklet, proceedings - "inbook":"bookSection", - "incollection":"bookSection", - "article":"journalArticle", // or magazineArticle or newspaperArticle - "phdthesis":"thesis", - "unpublished":"manuscript", - "inproceedings":"conferencePaper", // check for conference also - "conference":"conferencePaper", - "techreport":"report", - "booklet":"book", - "manual":"book", - "mastersthesis":"thesis", - "misc":"book", - "proceedings":"book" -}; - -/* - * three-letter month abbreviations. i assume these are the same ones that the - * docs say are defined in some appendix of the LaTeX book. (i don't have the - * LaTeX book.) - */ -var months = ["jan", "feb", "mar", "apr", "may", "jun", - "jul", "aug", "sep", "oct", "nov", "dec"]; - -/* - * new mapping table based on that from Matthias Steffens, - * then enhanced with some fields generated from the unicode table. - */ - -var mappingTable = { - "\u00A0":"~", // NO-BREAK SPACE - "\u00A1":"{\\textexclamdown}", // INVERTED EXCLAMATION MARK - "\u00A2":"{\\textcent}", // CENT SIGN - "\u00A3":"{\\textsterling}", // POUND SIGN - "\u00A5":"{\\textyen}", // YEN SIGN - "\u00A6":"{\\textbrokenbar}", // BROKEN BAR - "\u00A7":"{\\textsection}", // SECTION SIGN - "\u00A8":"{\\textasciidieresis}", // DIAERESIS - "\u00A9":"{\\textcopyright}", // COPYRIGHT SIGN - "\u00AA":"{\\textordfeminine}", // FEMININE ORDINAL INDICATOR - "\u00AB":"{\\guillemotleft}", // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - "\u00AC":"{\\textlnot}", // NOT SIGN - "\u00AD":"-", // SOFT HYPHEN - "\u00AE":"{\\textregistered}", // REGISTERED SIGN - "\u00AF":"{\\textasciimacron}", // MACRON - "\u00B0":"{\\textdegree}", // DEGREE SIGN - "\u00B1":"{\\textpm}", // PLUS-MINUS SIGN - "\u00B2":"{\\texttwosuperior}", // SUPERSCRIPT TWO - "\u00B3":"{\\textthreesuperior}", // SUPERSCRIPT THREE - "\u00B4":"{\\textasciiacute}", // ACUTE ACCENT - "\u00B5":"{\\textmu}", // MICRO SIGN - "\u00B6":"{\\textparagraph}", // PILCROW SIGN - "\u00B7":"{\\textperiodcentered}", // MIDDLE DOT - "\u00B8":"{\\c\\ }", // CEDILLA - "\u00B9":"{\\textonesuperior}", // SUPERSCRIPT ONE - "\u00BA":"{\\textordmasculine}", // MASCULINE ORDINAL INDICATOR - "\u00BB":"{\\guillemotright}", // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - "\u00BC":"{\\textonequarter}", // VULGAR FRACTION ONE QUARTER - "\u00BD":"{\\textonehalf}", // VULGAR FRACTION ONE HALF - "\u00BE":"{\\textthreequarters}", // VULGAR FRACTION THREE QUARTERS - "\u00BF":"{\\textquestiondown}", // INVERTED QUESTION MARK - "\u00C6":"{\\AE}", // LATIN CAPITAL LETTER AE - "\u00D0":"{\\DH}", // LATIN CAPITAL LETTER ETH - "\u00D7":"{\\texttimes}", // MULTIPLICATION SIGN - "\U00D8":"{\\O}", // LATIN CAPITAL LETTER O WITH STROKE - "\u00DE":"{\\TH}", // LATIN CAPITAL LETTER THORN - "\u00DF":"{\\ss}", // LATIN SMALL LETTER SHARP S - "\u00E6":"{\\ae}", // LATIN SMALL LETTER AE - "\u00F0":"{\\dh}", // LATIN SMALL LETTER ETH - "\u00F7":"{\\textdiv}", // DIVISION SIGN - "\U00F8":"{\\o}", // LATIN SMALL LETTER O WITH STROKE - "\u00FE":"{\\th}", // LATIN SMALL LETTER THORN - "\u0131":"{\\i}", // LATIN SMALL LETTER DOTLESS I - "\u0132":"IJ", // LATIN CAPITAL LIGATURE IJ - "\u0133":"ij", // LATIN SMALL LIGATURE IJ - "\u0138":"k", // LATIN SMALL LETTER KRA - "\u0149":"'n", // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE - "\u014A":"{\\NG}", // LATIN CAPITAL LETTER ENG - "\u014B":"{\\ng}", // LATIN SMALL LETTER ENG - "\u0152":"{\\OE}", // LATIN CAPITAL LIGATURE OE - "\u0153":"{\\oe}", // LATIN SMALL LIGATURE OE - "\u017F":"s", // LATIN SMALL LETTER LONG S - "\u02B9":"'", // MODIFIER LETTER PRIME - "\u02BB":"'", // MODIFIER LETTER TURNED COMMA - "\u02BC":"'", // MODIFIER LETTER APOSTROPHE - "\u02BD":"'", // MODIFIER LETTER REVERSED COMMA - "\u02C6":"{\\textasciicircum}", // MODIFIER LETTER CIRCUMFLEX ACCENT - "\u02C8":"'", // MODIFIER LETTER VERTICAL LINE - "\u02C9":"-", // MODIFIER LETTER MACRON - "\u02CC":",", // MODIFIER LETTER LOW VERTICAL LINE - "\u02D0":":", // MODIFIER LETTER TRIANGULAR COLON - "\u02DA":"o", // RING ABOVE - "\u02DC":"\\~{}", // SMALL TILDE - "\u02DD":"{\\textacutedbl}", // DOUBLE ACUTE ACCENT - "\u0374":"'", // GREEK NUMERAL SIGN - "\u0375":",", // GREEK LOWER NUMERAL SIGN - "\u037E":";", // GREEK QUESTION MARK - "\u2000":" ", // EN QUAD - "\u2001":" ", // EM QUAD - "\u2002":" ", // EN SPACE - "\u2003":" ", // EM SPACE - "\u2004":" ", // THREE-PER-EM SPACE - "\u2005":" ", // FOUR-PER-EM SPACE - "\u2006":" ", // SIX-PER-EM SPACE - "\u2007":" ", // FIGURE SPACE - "\u2008":" ", // PUNCTUATION SPACE - "\u2009":" ", // THIN SPACE - "\u2010":"-", // HYPHEN - "\u2011":"-", // NON-BREAKING HYPHEN - "\u2012":"-", // FIGURE DASH - "\u2013":"{\\textendash}", // EN DASH - "\u2014":"{\\textemdash}", // EM DASH - "\u2015":"{\\textemdash}", // HORIZONTAL BAR or QUOTATION DASH (not in LaTeX -- use EM DASH) - "\u2016":"{\\textbardbl}", // DOUBLE VERTICAL LINE - "\u2017":"{\\textunderscore}", // DOUBLE LOW LINE - "\u2018":"{\\textquoteleft}", // LEFT SINGLE QUOTATION MARK - "\u2019":"{\\textquoteright}", // RIGHT SINGLE QUOTATION MARK - "`" : "\u2018", // LEFT SINGLE QUOTATION MARK - "'" : "\u2019", // RIGHT SINGLE QUOTATION MARK - "\u201A":"{\\quotesinglbase}", // SINGLE LOW-9 QUOTATION MARK - "\u201B":"'", // SINGLE HIGH-REVERSED-9 QUOTATION MARK - "\u201C":"{\\textquotedblleft}", // LEFT DOUBLE QUOTATION MARK - "\u201D":"{\\textquotedblright}", // RIGHT DOUBLE QUOTATION MARK - "\u201E":"{\\quotedblbase}", // DOUBLE LOW-9 QUOTATION MARK - "\u201F":"{\\quotedblbase}", // DOUBLE HIGH-REVERSED-9 QUOTATION MARK - "\u2020":"{\\textdagger}", // DAGGER - "\u2021":"{\\textdaggerdbl}", // DOUBLE DAGGER - "\u2022":"{\\textbullet}", // BULLET - "\u2023":">", // TRIANGULAR BULLET - "\u2024":".", // ONE DOT LEADER - "\u2025":"..", // TWO DOT LEADER - "\u2026":"{\\textellipsis}", // HORIZONTAL ELLIPSIS - "\u2027":"-", // HYPHENATION POINT - "\u202F":" ", // NARROW NO-BREAK SPACE - "\u2030":"{\\textperthousand}", // PER MILLE SIGN - "\u2032":"'", // PRIME - "\u2033":"'", // DOUBLE PRIME - "\u2034":"'''", // TRIPLE PRIME - "\u2035":"`", // REVERSED PRIME - "\u2036":"``", // REVERSED DOUBLE PRIME - "\u2037":"```", // REVERSED TRIPLE PRIME - "\u2039":"{\\guilsinglleft}", // SINGLE LEFT-POINTING ANGLE QUOTATION MARK - "\u203A":"{\\guilsinglright}", // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - "\u203C":"!!", // DOUBLE EXCLAMATION MARK - "\u203E":"-", // OVERLINE - "\u2043":"-", // HYPHEN BULLET - "\u2044":"{\\textfractionsolidus}", // FRACTION SLASH - "\u2048":"?!", // QUESTION EXCLAMATION MARK - "\u2049":"!?", // EXCLAMATION QUESTION MARK - "\u204A":"7", // TIRONIAN SIGN ET - "\u2070":"$^{0}$", // SUPERSCRIPT ZERO - "\u2074":"$^{4}$", // SUPERSCRIPT FOUR - "\u2075":"$^{5}$", // SUPERSCRIPT FIVE - "\u2076":"$^{6}$", // SUPERSCRIPT SIX - "\u2077":"$^{7}$", // SUPERSCRIPT SEVEN - "\u2078":"$^{8}$", // SUPERSCRIPT EIGHT - "\u2079":"$^{9}$", // SUPERSCRIPT NINE - "\u207A":"$^{+}$", // SUPERSCRIPT PLUS SIGN - "\u207B":"$^{-}$", // SUPERSCRIPT MINUS - "\u207C":"$^{=}$", // SUPERSCRIPT EQUALS SIGN - "\u207D":"$^{(}$", // SUPERSCRIPT LEFT PARENTHESIS - "\u207E":"$^{)}$", // SUPERSCRIPT RIGHT PARENTHESIS - "\u207F":"$^{n}$", // SUPERSCRIPT LATIN SMALL LETTER N - "\u2080":"$_{0}$", // SUBSCRIPT ZERO - "\u2081":"$_{1}$", // SUBSCRIPT ONE - "\u2082":"$_{2}$", // SUBSCRIPT TWO - "\u2083":"$_{3}$", // SUBSCRIPT THREE - "\u2084":"$_{4}$", // SUBSCRIPT FOUR - "\u2085":"$_{5}$", // SUBSCRIPT FIVE - "\u2086":"$_{6}$", // SUBSCRIPT SIX - "\u2087":"$_{7}$", // SUBSCRIPT SEVEN - "\u2088":"$_{8}$", // SUBSCRIPT EIGHT - "\u2089":"$_{9}$", // SUBSCRIPT NINE - "\u208A":"$_{+}$", // SUBSCRIPT PLUS SIGN - "\u208B":"$_{-}$", // SUBSCRIPT MINUS - "\u208C":"$_{=}$", // SUBSCRIPT EQUALS SIGN - "\u208D":"$_{(}$", // SUBSCRIPT LEFT PARENTHESIS - "\u208E":"$_{)}$", // SUBSCRIPT RIGHT PARENTHESIS - "\u20AC":"{\\texteuro}", // EURO SIGN - "\u2100":"a/c", // ACCOUNT OF - "\u2101":"a/s", // ADDRESSED TO THE SUBJECT - "\u2103":"{\\textcelsius}", // DEGREE CELSIUS - "\u2105":"c/o", // CARE OF - "\u2106":"c/u", // CADA UNA - "\u2109":"F", // DEGREE FAHRENHEIT - "\u2113":"l", // SCRIPT SMALL L - "\u2116":"{\\textnumero}", // NUMERO SIGN - "\u2117":"{\\textcircledP}", // SOUND RECORDING COPYRIGHT - "\u2120":"{\\textservicemark}", // SERVICE MARK - "\u2121":"TEL", // TELEPHONE SIGN - "\u2122":"{\\texttrademark}", // TRADE MARK SIGN - "\u2126":"{\\textohm}", // OHM SIGN - "\u212A":"K", // KELVIN SIGN - "\u212B":"A", // ANGSTROM SIGN - "\u212E":"{\\textestimated}", // ESTIMATED SYMBOL - "\u2153":" 1/3", // VULGAR FRACTION ONE THIRD - "\u2154":" 2/3", // VULGAR FRACTION TWO THIRDS - "\u2155":" 1/5", // VULGAR FRACTION ONE FIFTH - "\u2156":" 2/5", // VULGAR FRACTION TWO FIFTHS - "\u2157":" 3/5", // VULGAR FRACTION THREE FIFTHS - "\u2158":" 4/5", // VULGAR FRACTION FOUR FIFTHS - "\u2159":" 1/6", // VULGAR FRACTION ONE SIXTH - "\u215A":" 5/6", // VULGAR FRACTION FIVE SIXTHS - "\u215B":" 1/8", // VULGAR FRACTION ONE EIGHTH - "\u215C":" 3/8", // VULGAR FRACTION THREE EIGHTHS - "\u215D":" 5/8", // VULGAR FRACTION FIVE EIGHTHS - "\u215E":" 7/8", // VULGAR FRACTION SEVEN EIGHTHS - "\u215F":" 1/", // FRACTION NUMERATOR ONE - "\u2160":"I", // ROMAN NUMERAL ONE - "\u2161":"II", // ROMAN NUMERAL TWO - "\u2162":"III", // ROMAN NUMERAL THREE - "\u2163":"IV", // ROMAN NUMERAL FOUR - "\u2164":"V", // ROMAN NUMERAL FIVE - "\u2165":"VI", // ROMAN NUMERAL SIX - "\u2166":"VII", // ROMAN NUMERAL SEVEN - "\u2167":"VIII", // ROMAN NUMERAL EIGHT - "\u2168":"IX", // ROMAN NUMERAL NINE - "\u2169":"X", // ROMAN NUMERAL TEN - "\u216A":"XI", // ROMAN NUMERAL ELEVEN - "\u216B":"XII", // ROMAN NUMERAL TWELVE - "\u216C":"L", // ROMAN NUMERAL FIFTY - "\u216D":"C", // ROMAN NUMERAL ONE HUNDRED - "\u216E":"D", // ROMAN NUMERAL FIVE HUNDRED - "\u216F":"M", // ROMAN NUMERAL ONE THOUSAND - "\u2170":"i", // SMALL ROMAN NUMERAL ONE - "\u2171":"ii", // SMALL ROMAN NUMERAL TWO - "\u2172":"iii", // SMALL ROMAN NUMERAL THREE - "\u2173":"iv", // SMALL ROMAN NUMERAL FOUR - "\u2174":"v", // SMALL ROMAN NUMERAL FIVE - "\u2175":"vi", // SMALL ROMAN NUMERAL SIX - "\u2176":"vii", // SMALL ROMAN NUMERAL SEVEN - "\u2177":"viii", // SMALL ROMAN NUMERAL EIGHT - "\u2178":"ix", // SMALL ROMAN NUMERAL NINE - "\u2179":"x", // SMALL ROMAN NUMERAL TEN - "\u217A":"xi", // SMALL ROMAN NUMERAL ELEVEN - "\u217B":"xii", // SMALL ROMAN NUMERAL TWELVE - "\u217C":"l", // SMALL ROMAN NUMERAL FIFTY - "\u217D":"c", // SMALL ROMAN NUMERAL ONE HUNDRED - "\u217E":"d", // SMALL ROMAN NUMERAL FIVE HUNDRED - "\u217F":"m", // SMALL ROMAN NUMERAL ONE THOUSAND - "\u2190":"{\\textleftarrow}", // LEFTWARDS ARROW - "\u2191":"{\\textuparrow}", // UPWARDS ARROW - "\u2192":"{\\textrightarrow}", // RIGHTWARDS ARROW - "\u2193":"{\\textdownarrow}", // DOWNWARDS ARROW - "\u2194":"<->", // LEFT RIGHT ARROW - "\u21D0":"<=", // LEFTWARDS DOUBLE ARROW - "\u21D2":"=>", // RIGHTWARDS DOUBLE ARROW - "\u21D4":"<=>", // LEFT RIGHT DOUBLE ARROW - "\u2212":"-", // MINUS SIGN - "\u2215":"/", // DIVISION SLASH - "\u2216":"\\", // SET MINUS - "\u2217":"*", // ASTERISK OPERATOR - "\u2218":"o", // RING OPERATOR - "\u2219":".", // BULLET OPERATOR - "\u221E":"$\\infty$", // INFINITY - "\u2223":"|", // DIVIDES - "\u2225":"||", // PARALLEL TO - "\u2236":":", // RATIO - "\u223C":"\\~{}", // TILDE OPERATOR - "\u2260":"/=", // NOT EQUAL TO - "\u2261":"=", // IDENTICAL TO - "\u2264":"<=", // LESS-THAN OR EQUAL TO - "\u2265":">=", // GREATER-THAN OR EQUAL TO - "\u226A":"<<", // MUCH LESS-THAN - "\u226B":">>", // MUCH GREATER-THAN - "\u2295":"(+)", // CIRCLED PLUS - "\u2296":"(-)", // CIRCLED MINUS - "\u2297":"(x)", // CIRCLED TIMES - "\u2298":"(/)", // CIRCLED DIVISION SLASH - "\u22A2":"|-", // RIGHT TACK - "\u22A3":"-|", // LEFT TACK - "\u22A6":"|-", // ASSERTION - "\u22A7":"|=", // MODELS - "\u22A8":"|=", // TRUE - "\u22A9":"||-", // FORCES - "\u22C5":".", // DOT OPERATOR - "\u22C6":"*", // STAR OPERATOR - "\u22D5":"$\\#$", // EQUAL AND PARALLEL TO - "\u22D8":"<<<", // VERY MUCH LESS-THAN - "\u22D9":">>>", // VERY MUCH GREATER-THAN - "\u2329":"{\\textlangle}", // LEFT-POINTING ANGLE BRACKET - "\u232A":"{\\textrangle}", // RIGHT-POINTING ANGLE BRACKET - "\u2400":"NUL", // SYMBOL FOR NULL - "\u2401":"SOH", // SYMBOL FOR START OF HEADING - "\u2402":"STX", // SYMBOL FOR START OF TEXT - "\u2403":"ETX", // SYMBOL FOR END OF TEXT - "\u2404":"EOT", // SYMBOL FOR END OF TRANSMISSION - "\u2405":"ENQ", // SYMBOL FOR ENQUIRY - "\u2406":"ACK", // SYMBOL FOR ACKNOWLEDGE - "\u2407":"BEL", // SYMBOL FOR BELL - "\u2408":"BS", // SYMBOL FOR BACKSPACE - "\u2409":"HT", // SYMBOL FOR HORIZONTAL TABULATION - "\u240A":"LF", // SYMBOL FOR LINE FEED - "\u240B":"VT", // SYMBOL FOR VERTICAL TABULATION - "\u240C":"FF", // SYMBOL FOR FORM FEED - "\u240D":"CR", // SYMBOL FOR CARRIAGE RETURN - "\u240E":"SO", // SYMBOL FOR SHIFT OUT - "\u240F":"SI", // SYMBOL FOR SHIFT IN - "\u2410":"DLE", // SYMBOL FOR DATA LINK ESCAPE - "\u2411":"DC1", // SYMBOL FOR DEVICE CONTROL ONE - "\u2412":"DC2", // SYMBOL FOR DEVICE CONTROL TWO - "\u2413":"DC3", // SYMBOL FOR DEVICE CONTROL THREE - "\u2414":"DC4", // SYMBOL FOR DEVICE CONTROL FOUR - "\u2415":"NAK", // SYMBOL FOR NEGATIVE ACKNOWLEDGE - "\u2416":"SYN", // SYMBOL FOR SYNCHRONOUS IDLE - "\u2417":"ETB", // SYMBOL FOR END OF TRANSMISSION BLOCK - "\u2418":"CAN", // SYMBOL FOR CANCEL - "\u2419":"EM", // SYMBOL FOR END OF MEDIUM - "\u241A":"SUB", // SYMBOL FOR SUBSTITUTE - "\u241B":"ESC", // SYMBOL FOR ESCAPE - "\u241C":"FS", // SYMBOL FOR FILE SEPARATOR - "\u241D":"GS", // SYMBOL FOR GROUP SEPARATOR - "\u241E":"RS", // SYMBOL FOR RECORD SEPARATOR - "\u241F":"US", // SYMBOL FOR UNIT SEPARATOR - "\u2420":"SP", // SYMBOL FOR SPACE - "\u2421":"DEL", // SYMBOL FOR DELETE - "\u2423":"{\\textvisiblespace}", // OPEN BOX - "\u2424":"NL", // SYMBOL FOR NEWLINE - "\u2425":"///", // SYMBOL FOR DELETE FORM TWO - "\u2426":"?", // SYMBOL FOR SUBSTITUTE FORM TWO - "\u2460":"(1)", // CIRCLED DIGIT ONE - "\u2461":"(2)", // CIRCLED DIGIT TWO - "\u2462":"(3)", // CIRCLED DIGIT THREE - "\u2463":"(4)", // CIRCLED DIGIT FOUR - "\u2464":"(5)", // CIRCLED DIGIT FIVE - "\u2465":"(6)", // CIRCLED DIGIT SIX - "\u2466":"(7)", // CIRCLED DIGIT SEVEN - "\u2467":"(8)", // CIRCLED DIGIT EIGHT - "\u2468":"(9)", // CIRCLED DIGIT NINE - "\u2469":"(10)", // CIRCLED NUMBER TEN - "\u246A":"(11)", // CIRCLED NUMBER ELEVEN - "\u246B":"(12)", // CIRCLED NUMBER TWELVE - "\u246C":"(13)", // CIRCLED NUMBER THIRTEEN - "\u246D":"(14)", // CIRCLED NUMBER FOURTEEN - "\u246E":"(15)", // CIRCLED NUMBER FIFTEEN - "\u246F":"(16)", // CIRCLED NUMBER SIXTEEN - "\u2470":"(17)", // CIRCLED NUMBER SEVENTEEN - "\u2471":"(18)", // CIRCLED NUMBER EIGHTEEN - "\u2472":"(19)", // CIRCLED NUMBER NINETEEN - "\u2473":"(20)", // CIRCLED NUMBER TWENTY - "\u2474":"(1)", // PARENTHESIZED DIGIT ONE - "\u2475":"(2)", // PARENTHESIZED DIGIT TWO - "\u2476":"(3)", // PARENTHESIZED DIGIT THREE - "\u2477":"(4)", // PARENTHESIZED DIGIT FOUR - "\u2478":"(5)", // PARENTHESIZED DIGIT FIVE - "\u2479":"(6)", // PARENTHESIZED DIGIT SIX - "\u247A":"(7)", // PARENTHESIZED DIGIT SEVEN - "\u247B":"(8)", // PARENTHESIZED DIGIT EIGHT - "\u247C":"(9)", // PARENTHESIZED DIGIT NINE - "\u247D":"(10)", // PARENTHESIZED NUMBER TEN - "\u247E":"(11)", // PARENTHESIZED NUMBER ELEVEN - "\u247F":"(12)", // PARENTHESIZED NUMBER TWELVE - "\u2480":"(13)", // PARENTHESIZED NUMBER THIRTEEN - "\u2481":"(14)", // PARENTHESIZED NUMBER FOURTEEN - "\u2482":"(15)", // PARENTHESIZED NUMBER FIFTEEN - "\u2483":"(16)", // PARENTHESIZED NUMBER SIXTEEN - "\u2484":"(17)", // PARENTHESIZED NUMBER SEVENTEEN - "\u2485":"(18)", // PARENTHESIZED NUMBER EIGHTEEN - "\u2486":"(19)", // PARENTHESIZED NUMBER NINETEEN - "\u2487":"(20)", // PARENTHESIZED NUMBER TWENTY - "\u2488":"1.", // DIGIT ONE FULL STOP - "\u2489":"2.", // DIGIT TWO FULL STOP - "\u248A":"3.", // DIGIT THREE FULL STOP - "\u248B":"4.", // DIGIT FOUR FULL STOP - "\u248C":"5.", // DIGIT FIVE FULL STOP - "\u248D":"6.", // DIGIT SIX FULL STOP - "\u248E":"7.", // DIGIT SEVEN FULL STOP - "\u248F":"8.", // DIGIT EIGHT FULL STOP - "\u2490":"9.", // DIGIT NINE FULL STOP - "\u2491":"10.", // NUMBER TEN FULL STOP - "\u2492":"11.", // NUMBER ELEVEN FULL STOP - "\u2493":"12.", // NUMBER TWELVE FULL STOP - "\u2494":"13.", // NUMBER THIRTEEN FULL STOP - "\u2495":"14.", // NUMBER FOURTEEN FULL STOP - "\u2496":"15.", // NUMBER FIFTEEN FULL STOP - "\u2497":"16.", // NUMBER SIXTEEN FULL STOP - "\u2498":"17.", // NUMBER SEVENTEEN FULL STOP - "\u2499":"18.", // NUMBER EIGHTEEN FULL STOP - "\u249A":"19.", // NUMBER NINETEEN FULL STOP - "\u249B":"20.", // NUMBER TWENTY FULL STOP - "\u249C":"(a)", // PARENTHESIZED LATIN SMALL LETTER A - "\u249D":"(b)", // PARENTHESIZED LATIN SMALL LETTER B - "\u249E":"(c)", // PARENTHESIZED LATIN SMALL LETTER C - "\u249F":"(d)", // PARENTHESIZED LATIN SMALL LETTER D - "\u24A0":"(e)", // PARENTHESIZED LATIN SMALL LETTER E - "\u24A1":"(f)", // PARENTHESIZED LATIN SMALL LETTER F - "\u24A2":"(g)", // PARENTHESIZED LATIN SMALL LETTER G - "\u24A3":"(h)", // PARENTHESIZED LATIN SMALL LETTER H - "\u24A4":"(i)", // PARENTHESIZED LATIN SMALL LETTER I - "\u24A5":"(j)", // PARENTHESIZED LATIN SMALL LETTER J - "\u24A6":"(k)", // PARENTHESIZED LATIN SMALL LETTER K - "\u24A7":"(l)", // PARENTHESIZED LATIN SMALL LETTER L - "\u24A8":"(m)", // PARENTHESIZED LATIN SMALL LETTER M - "\u24A9":"(n)", // PARENTHESIZED LATIN SMALL LETTER N - "\u24AA":"(o)", // PARENTHESIZED LATIN SMALL LETTER O - "\u24AB":"(p)", // PARENTHESIZED LATIN SMALL LETTER P - "\u24AC":"(q)", // PARENTHESIZED LATIN SMALL LETTER Q - "\u24AD":"(r)", // PARENTHESIZED LATIN SMALL LETTER R - "\u24AE":"(s)", // PARENTHESIZED LATIN SMALL LETTER S - "\u24AF":"(t)", // PARENTHESIZED LATIN SMALL LETTER T - "\u24B0":"(u)", // PARENTHESIZED LATIN SMALL LETTER U - "\u24B1":"(v)", // PARENTHESIZED LATIN SMALL LETTER V - "\u24B2":"(w)", // PARENTHESIZED LATIN SMALL LETTER W - "\u24B3":"(x)", // PARENTHESIZED LATIN SMALL LETTER X - "\u24B4":"(y)", // PARENTHESIZED LATIN SMALL LETTER Y - "\u24B5":"(z)", // PARENTHESIZED LATIN SMALL LETTER Z - "\u24B6":"(A)", // CIRCLED LATIN CAPITAL LETTER A - "\u24B7":"(B)", // CIRCLED LATIN CAPITAL LETTER B - "\u24B8":"(C)", // CIRCLED LATIN CAPITAL LETTER C - "\u24B9":"(D)", // CIRCLED LATIN CAPITAL LETTER D - "\u24BA":"(E)", // CIRCLED LATIN CAPITAL LETTER E - "\u24BB":"(F)", // CIRCLED LATIN CAPITAL LETTER F - "\u24BC":"(G)", // CIRCLED LATIN CAPITAL LETTER G - "\u24BD":"(H)", // CIRCLED LATIN CAPITAL LETTER H - "\u24BE":"(I)", // CIRCLED LATIN CAPITAL LETTER I - "\u24BF":"(J)", // CIRCLED LATIN CAPITAL LETTER J - "\u24C0":"(K)", // CIRCLED LATIN CAPITAL LETTER K - "\u24C1":"(L)", // CIRCLED LATIN CAPITAL LETTER L - "\u24C2":"(M)", // CIRCLED LATIN CAPITAL LETTER M - "\u24C3":"(N)", // CIRCLED LATIN CAPITAL LETTER N - "\u24C4":"(O)", // CIRCLED LATIN CAPITAL LETTER O - "\u24C5":"(P)", // CIRCLED LATIN CAPITAL LETTER P - "\u24C6":"(Q)", // CIRCLED LATIN CAPITAL LETTER Q - "\u24C7":"(R)", // CIRCLED LATIN CAPITAL LETTER R - "\u24C8":"(S)", // CIRCLED LATIN CAPITAL LETTER S - "\u24C9":"(T)", // CIRCLED LATIN CAPITAL LETTER T - "\u24CA":"(U)", // CIRCLED LATIN CAPITAL LETTER U - "\u24CB":"(V)", // CIRCLED LATIN CAPITAL LETTER V - "\u24CC":"(W)", // CIRCLED LATIN CAPITAL LETTER W - "\u24CD":"(X)", // CIRCLED LATIN CAPITAL LETTER X - "\u24CE":"(Y)", // CIRCLED LATIN CAPITAL LETTER Y - "\u24CF":"(Z)", // CIRCLED LATIN CAPITAL LETTER Z - "\u24D0":"(a)", // CIRCLED LATIN SMALL LETTER A - "\u24D1":"(b)", // CIRCLED LATIN SMALL LETTER B - "\u24D2":"(c)", // CIRCLED LATIN SMALL LETTER C - "\u24D3":"(d)", // CIRCLED LATIN SMALL LETTER D - "\u24D4":"(e)", // CIRCLED LATIN SMALL LETTER E - "\u24D5":"(f)", // CIRCLED LATIN SMALL LETTER F - "\u24D6":"(g)", // CIRCLED LATIN SMALL LETTER G - "\u24D7":"(h)", // CIRCLED LATIN SMALL LETTER H - "\u24D8":"(i)", // CIRCLED LATIN SMALL LETTER I - "\u24D9":"(j)", // CIRCLED LATIN SMALL LETTER J - "\u24DA":"(k)", // CIRCLED LATIN SMALL LETTER K - "\u24DB":"(l)", // CIRCLED LATIN SMALL LETTER L - "\u24DC":"(m)", // CIRCLED LATIN SMALL LETTER M - "\u24DD":"(n)", // CIRCLED LATIN SMALL LETTER N - "\u24DE":"(o)", // CIRCLED LATIN SMALL LETTER O - "\u24DF":"(p)", // CIRCLED LATIN SMALL LETTER P - "\u24E0":"(q)", // CIRCLED LATIN SMALL LETTER Q - "\u24E1":"(r)", // CIRCLED LATIN SMALL LETTER R - "\u24E2":"(s)", // CIRCLED LATIN SMALL LETTER S - "\u24E3":"(t)", // CIRCLED LATIN SMALL LETTER T - "\u24E4":"(u)", // CIRCLED LATIN SMALL LETTER U - "\u24E5":"(v)", // CIRCLED LATIN SMALL LETTER V - "\u24E6":"(w)", // CIRCLED LATIN SMALL LETTER W - "\u24E7":"(x)", // CIRCLED LATIN SMALL LETTER X - "\u24E8":"(y)", // CIRCLED LATIN SMALL LETTER Y - "\u24E9":"(z)", // CIRCLED LATIN SMALL LETTER Z - "\u24EA":"(0)", // CIRCLED DIGIT ZERO - "\u2500":"-", // BOX DRAWINGS LIGHT HORIZONTAL - "\u2501":"=", // BOX DRAWINGS HEAVY HORIZONTAL - "\u2502":"|", // BOX DRAWINGS LIGHT VERTICAL - "\u2503":"|", // BOX DRAWINGS HEAVY VERTICAL - "\u2504":"-", // BOX DRAWINGS LIGHT TRIPLE DASH HORIZONTAL - "\u2505":"=", // BOX DRAWINGS HEAVY TRIPLE DASH HORIZONTAL - "\u2506":"|", // BOX DRAWINGS LIGHT TRIPLE DASH VERTICAL - "\u2507":"|", // BOX DRAWINGS HEAVY TRIPLE DASH VERTICAL - "\u2508":"-", // BOX DRAWINGS LIGHT QUADRUPLE DASH HORIZONTAL - "\u2509":"=", // BOX DRAWINGS HEAVY QUADRUPLE DASH HORIZONTAL - "\u250A":"|", // BOX DRAWINGS LIGHT QUADRUPLE DASH VERTICAL - "\u250B":"|", // BOX DRAWINGS HEAVY QUADRUPLE DASH VERTICAL - "\u250C":"+", // BOX DRAWINGS LIGHT DOWN AND RIGHT - "\u250D":"+", // BOX DRAWINGS DOWN LIGHT AND RIGHT HEAVY - "\u250E":"+", // BOX DRAWINGS DOWN HEAVY AND RIGHT LIGHT - "\u250F":"+", // BOX DRAWINGS HEAVY DOWN AND RIGHT - "\u2510":"+", // BOX DRAWINGS LIGHT DOWN AND LEFT - "\u2511":"+", // BOX DRAWINGS DOWN LIGHT AND LEFT HEAVY - "\u2512":"+", // BOX DRAWINGS DOWN HEAVY AND LEFT LIGHT - "\u2513":"+", // BOX DRAWINGS HEAVY DOWN AND LEFT - "\u2514":"+", // BOX DRAWINGS LIGHT UP AND RIGHT - "\u2515":"+", // BOX DRAWINGS UP LIGHT AND RIGHT HEAVY - "\u2516":"+", // BOX DRAWINGS UP HEAVY AND RIGHT LIGHT - "\u2517":"+", // BOX DRAWINGS HEAVY UP AND RIGHT - "\u2518":"+", // BOX DRAWINGS LIGHT UP AND LEFT - "\u2519":"+", // BOX DRAWINGS UP LIGHT AND LEFT HEAVY - "\u251A":"+", // BOX DRAWINGS UP HEAVY AND LEFT LIGHT - "\u251B":"+", // BOX DRAWINGS HEAVY UP AND LEFT - "\u251C":"+", // BOX DRAWINGS LIGHT VERTICAL AND RIGHT - "\u251D":"+", // BOX DRAWINGS VERTICAL LIGHT AND RIGHT HEAVY - "\u251E":"+", // BOX DRAWINGS UP HEAVY AND RIGHT DOWN LIGHT - "\u251F":"+", // BOX DRAWINGS DOWN HEAVY AND RIGHT UP LIGHT - "\u2520":"+", // BOX DRAWINGS VERTICAL HEAVY AND RIGHT LIGHT - "\u2521":"+", // BOX DRAWINGS DOWN LIGHT AND RIGHT UP HEAVY - "\u2522":"+", // BOX DRAWINGS UP LIGHT AND RIGHT DOWN HEAVY - "\u2523":"+", // BOX DRAWINGS HEAVY VERTICAL AND RIGHT - "\u2524":"+", // BOX DRAWINGS LIGHT VERTICAL AND LEFT - "\u2525":"+", // BOX DRAWINGS VERTICAL LIGHT AND LEFT HEAVY - "\u2526":"+", // BOX DRAWINGS UP HEAVY AND LEFT DOWN LIGHT - "\u2527":"+", // BOX DRAWINGS DOWN HEAVY AND LEFT UP LIGHT - "\u2528":"+", // BOX DRAWINGS VERTICAL HEAVY AND LEFT LIGHT - "\u2529":"+", // BOX DRAWINGS DOWN LIGHT AND LEFT UP HEAVY - "\u252A":"+", // BOX DRAWINGS UP LIGHT AND LEFT DOWN HEAVY - "\u252B":"+", // BOX DRAWINGS HEAVY VERTICAL AND LEFT - "\u252C":"+", // BOX DRAWINGS LIGHT DOWN AND HORIZONTAL - "\u252D":"+", // BOX DRAWINGS LEFT HEAVY AND RIGHT DOWN LIGHT - "\u252E":"+", // BOX DRAWINGS RIGHT HEAVY AND LEFT DOWN LIGHT - "\u252F":"+", // BOX DRAWINGS DOWN LIGHT AND HORIZONTAL HEAVY - "\u2530":"+", // BOX DRAWINGS DOWN HEAVY AND HORIZONTAL LIGHT - "\u2531":"+", // BOX DRAWINGS RIGHT LIGHT AND LEFT DOWN HEAVY - "\u2532":"+", // BOX DRAWINGS LEFT LIGHT AND RIGHT DOWN HEAVY - "\u2533":"+", // BOX DRAWINGS HEAVY DOWN AND HORIZONTAL - "\u2534":"+", // BOX DRAWINGS LIGHT UP AND HORIZONTAL - "\u2535":"+", // BOX DRAWINGS LEFT HEAVY AND RIGHT UP LIGHT - "\u2536":"+", // BOX DRAWINGS RIGHT HEAVY AND LEFT UP LIGHT - "\u2537":"+", // BOX DRAWINGS UP LIGHT AND HORIZONTAL HEAVY - "\u2538":"+", // BOX DRAWINGS UP HEAVY AND HORIZONTAL LIGHT - "\u2539":"+", // BOX DRAWINGS RIGHT LIGHT AND LEFT UP HEAVY - "\u253A":"+", // BOX DRAWINGS LEFT LIGHT AND RIGHT UP HEAVY - "\u253B":"+", // BOX DRAWINGS HEAVY UP AND HORIZONTAL - "\u253C":"+", // BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL - "\u253D":"+", // BOX DRAWINGS LEFT HEAVY AND RIGHT VERTICAL LIGHT - "\u253E":"+", // BOX DRAWINGS RIGHT HEAVY AND LEFT VERTICAL LIGHT - "\u253F":"+", // BOX DRAWINGS VERTICAL LIGHT AND HORIZONTAL HEAVY - "\u2540":"+", // BOX DRAWINGS UP HEAVY AND DOWN HORIZONTAL LIGHT - "\u2541":"+", // BOX DRAWINGS DOWN HEAVY AND UP HORIZONTAL LIGHT - "\u2542":"+", // BOX DRAWINGS VERTICAL HEAVY AND HORIZONTAL LIGHT - "\u2543":"+", // BOX DRAWINGS LEFT UP HEAVY AND RIGHT DOWN LIGHT - "\u2544":"+", // BOX DRAWINGS RIGHT UP HEAVY AND LEFT DOWN LIGHT - "\u2545":"+", // BOX DRAWINGS LEFT DOWN HEAVY AND RIGHT UP LIGHT - "\u2546":"+", // BOX DRAWINGS RIGHT DOWN HEAVY AND LEFT UP LIGHT - "\u2547":"+", // BOX DRAWINGS DOWN LIGHT AND UP HORIZONTAL HEAVY - "\u2548":"+", // BOX DRAWINGS UP LIGHT AND DOWN HORIZONTAL HEAVY - "\u2549":"+", // BOX DRAWINGS RIGHT LIGHT AND LEFT VERTICAL HEAVY - "\u254A":"+", // BOX DRAWINGS LEFT LIGHT AND RIGHT VERTICAL HEAVY - "\u254B":"+", // BOX DRAWINGS HEAVY VERTICAL AND HORIZONTAL - "\u254C":"-", // BOX DRAWINGS LIGHT DOUBLE DASH HORIZONTAL - "\u254D":"=", // BOX DRAWINGS HEAVY DOUBLE DASH HORIZONTAL - "\u254E":"|", // BOX DRAWINGS LIGHT DOUBLE DASH VERTICAL - "\u254F":"|", // BOX DRAWINGS HEAVY DOUBLE DASH VERTICAL - "\u2550":"=", // BOX DRAWINGS DOUBLE HORIZONTAL - "\u2551":"|", // BOX DRAWINGS DOUBLE VERTICAL - "\u2552":"+", // BOX DRAWINGS DOWN SINGLE AND RIGHT DOUBLE - "\u2553":"+", // BOX DRAWINGS DOWN DOUBLE AND RIGHT SINGLE - "\u2554":"+", // BOX DRAWINGS DOUBLE DOWN AND RIGHT - "\u2555":"+", // BOX DRAWINGS DOWN SINGLE AND LEFT DOUBLE - "\u2556":"+", // BOX DRAWINGS DOWN DOUBLE AND LEFT SINGLE - "\u2557":"+", // BOX DRAWINGS DOUBLE DOWN AND LEFT - "\u2558":"+", // BOX DRAWINGS UP SINGLE AND RIGHT DOUBLE - "\u2559":"+", // BOX DRAWINGS UP DOUBLE AND RIGHT SINGLE - "\u255A":"+", // BOX DRAWINGS DOUBLE UP AND RIGHT - "\u255B":"+", // BOX DRAWINGS UP SINGLE AND LEFT DOUBLE - "\u255C":"+", // BOX DRAWINGS UP DOUBLE AND LEFT SINGLE - "\u255D":"+", // BOX DRAWINGS DOUBLE UP AND LEFT - "\u255E":"+", // BOX DRAWINGS VERTICAL SINGLE AND RIGHT DOUBLE - "\u255F":"+", // BOX DRAWINGS VERTICAL DOUBLE AND RIGHT SINGLE - "\u2560":"+", // BOX DRAWINGS DOUBLE VERTICAL AND RIGHT - "\u2561":"+", // BOX DRAWINGS VERTICAL SINGLE AND LEFT DOUBLE - "\u2562":"+", // BOX DRAWINGS VERTICAL DOUBLE AND LEFT SINGLE - "\u2563":"+", // BOX DRAWINGS DOUBLE VERTICAL AND LEFT - "\u2564":"+", // BOX DRAWINGS DOWN SINGLE AND HORIZONTAL DOUBLE - "\u2565":"+", // BOX DRAWINGS DOWN DOUBLE AND HORIZONTAL SINGLE - "\u2566":"+", // BOX DRAWINGS DOUBLE DOWN AND HORIZONTAL - "\u2567":"+", // BOX DRAWINGS UP SINGLE AND HORIZONTAL DOUBLE - "\u2568":"+", // BOX DRAWINGS UP DOUBLE AND HORIZONTAL SINGLE - "\u2569":"+", // BOX DRAWINGS DOUBLE UP AND HORIZONTAL - "\u256A":"+", // BOX DRAWINGS VERTICAL SINGLE AND HORIZONTAL DOUBLE - "\u256B":"+", // BOX DRAWINGS VERTICAL DOUBLE AND HORIZONTAL SINGLE - "\u256C":"+", // BOX DRAWINGS DOUBLE VERTICAL AND HORIZONTAL - "\u256D":"+", // BOX DRAWINGS LIGHT ARC DOWN AND RIGHT - "\u256E":"+", // BOX DRAWINGS LIGHT ARC DOWN AND LEFT - "\u256F":"+", // BOX DRAWINGS LIGHT ARC UP AND LEFT - "\u2570":"+", // BOX DRAWINGS LIGHT ARC UP AND RIGHT - "\u2571":"/", // BOX DRAWINGS LIGHT DIAGONAL UPPER RIGHT TO LOWER LEFT - "\u2572":"\\", // BOX DRAWINGS LIGHT DIAGONAL UPPER LEFT TO LOWER RIGHT - "\u2573":"X", // BOX DRAWINGS LIGHT DIAGONAL CROSS - "\u257C":"-", // BOX DRAWINGS LIGHT LEFT AND HEAVY RIGHT - "\u257D":"|", // BOX DRAWINGS LIGHT UP AND HEAVY DOWN - "\u257E":"-", // BOX DRAWINGS HEAVY LEFT AND LIGHT RIGHT - "\u257F":"|", // BOX DRAWINGS HEAVY UP AND LIGHT DOWN - "\u25CB":"o", // WHITE CIRCLE - "\u25E6":"{\\textopenbullet}", // WHITE BULLET - "\u2605":"*", // BLACK STAR - "\u2606":"*", // WHITE STAR - "\u2612":"X", // BALLOT BOX WITH X - "\u2613":"X", // SALTIRE - "\u2639":":-(", // WHITE FROWNING FACE - "\u263A":":-)", // WHITE SMILING FACE - "\u263B":"(-:", // BLACK SMILING FACE - "\u266D":"b", // MUSIC FLAT SIGN - "\u266F":"$\\#$", // MUSIC SHARP SIGN - "\u2701":"$\\%<$", // UPPER BLADE SCISSORS - "\u2702":"$\\%<$", // BLACK SCISSORS - "\u2703":"$\\%<$", // LOWER BLADE SCISSORS - "\u2704":"$\\%<$", // WHITE SCISSORS - "\u270C":"V", // VICTORY HAND - "\u2713":"v", // CHECK MARK - "\u2714":"V", // HEAVY CHECK MARK - "\u2715":"x", // MULTIPLICATION X - "\u2716":"x", // HEAVY MULTIPLICATION X - "\u2717":"X", // BALLOT X - "\u2718":"X", // HEAVY BALLOT X - "\u2719":"+", // OUTLINED GREEK CROSS - "\u271A":"+", // HEAVY GREEK CROSS - "\u271B":"+", // OPEN CENTRE CROSS - "\u271C":"+", // HEAVY OPEN CENTRE CROSS - "\u271D":"+", // LATIN CROSS - "\u271E":"+", // SHADOWED WHITE LATIN CROSS - "\u271F":"+", // OUTLINED LATIN CROSS - "\u2720":"+", // MALTESE CROSS - "\u2721":"*", // STAR OF DAVID - "\u2722":"+", // FOUR TEARDROP-SPOKED ASTERISK - "\u2723":"+", // FOUR BALLOON-SPOKED ASTERISK - "\u2724":"+", // HEAVY FOUR BALLOON-SPOKED ASTERISK - "\u2725":"+", // FOUR CLUB-SPOKED ASTERISK - "\u2726":"+", // BLACK FOUR POINTED STAR - "\u2727":"+", // WHITE FOUR POINTED STAR - "\u2729":"*", // STRESS OUTLINED WHITE STAR - "\u272A":"*", // CIRCLED WHITE STAR - "\u272B":"*", // OPEN CENTRE BLACK STAR - "\u272C":"*", // BLACK CENTRE WHITE STAR - "\u272D":"*", // OUTLINED BLACK STAR - "\u272E":"*", // HEAVY OUTLINED BLACK STAR - "\u272F":"*", // PINWHEEL STAR - "\u2730":"*", // SHADOWED WHITE STAR - "\u2731":"*", // HEAVY ASTERISK - "\u2732":"*", // OPEN CENTRE ASTERISK - "\u2733":"*", // EIGHT SPOKED ASTERISK - "\u2734":"*", // EIGHT POINTED BLACK STAR - "\u2735":"*", // EIGHT POINTED PINWHEEL STAR - "\u2736":"*", // SIX POINTED BLACK STAR - "\u2737":"*", // EIGHT POINTED RECTILINEAR BLACK STAR - "\u2738":"*", // HEAVY EIGHT POINTED RECTILINEAR BLACK STAR - "\u2739":"*", // TWELVE POINTED BLACK STAR - "\u273A":"*", // SIXTEEN POINTED ASTERISK - "\u273B":"*", // TEARDROP-SPOKED ASTERISK - "\u273C":"*", // OPEN CENTRE TEARDROP-SPOKED ASTERISK - "\u273D":"*", // HEAVY TEARDROP-SPOKED ASTERISK - "\u273E":"*", // SIX PETALLED BLACK AND WHITE FLORETTE - "\u273F":"*", // BLACK FLORETTE - "\u2740":"*", // WHITE FLORETTE - "\u2741":"*", // EIGHT PETALLED OUTLINED BLACK FLORETTE - "\u2742":"*", // CIRCLED OPEN CENTRE EIGHT POINTED STAR - "\u2743":"*", // HEAVY TEARDROP-SPOKED PINWHEEL ASTERISK - "\u2744":"*", // SNOWFLAKE - "\u2745":"*", // TIGHT TRIFOLIATE SNOWFLAKE - "\u2746":"*", // HEAVY CHEVRON SNOWFLAKE - "\u2747":"*", // SPARKLE - "\u2748":"*", // HEAVY SPARKLE - "\u2749":"*", // BALLOON-SPOKED ASTERISK - "\u274A":"*", // EIGHT TEARDROP-SPOKED PROPELLER ASTERISK - "\u274B":"*", // HEAVY EIGHT TEARDROP-SPOKED PROPELLER ASTERISK - "\uFB00":"ff", // LATIN SMALL LIGATURE FF - "\uFB01":"fi", // LATIN SMALL LIGATURE FI - "\uFB02":"fl", // LATIN SMALL LIGATURE FL - "\uFB03":"ffi", // LATIN SMALL LIGATURE FFI - "\uFB04":"ffl", // LATIN SMALL LIGATURE FFL - "\uFB05":"st", // LATIN SMALL LIGATURE LONG S T - "\uFB06":"st", // LATIN SMALL LIGATURE ST -/* Derived accented characters */ - "\u00C0":"\\`{A}", // LATIN CAPITAL LETTER A WITH GRAVE - "\u00C1":"\\'{A}", // LATIN CAPITAL LETTER A WITH ACUTE - "\u00C2":"\\^{A}", // LATIN CAPITAL LETTER A WITH CIRCUMFLEX - "\u00C3":"\\~{A}", // LATIN CAPITAL LETTER A WITH TILDE - "\u00C4":"\\\"{A}", // LATIN CAPITAL LETTER A WITH DIAERESIS - "\u00C5":"\\r{A}", // LATIN CAPITAL LETTER A WITH RING ABOVE - "\u00C7":"\\c{C}", // LATIN CAPITAL LETTER C WITH CEDILLA - "\u00C8":"\\`{E}", // LATIN CAPITAL LETTER E WITH GRAVE - "\u00C9":"\\'{E}", // LATIN CAPITAL LETTER E WITH ACUTE - "\u00CA":"\\^{E}", // LATIN CAPITAL LETTER E WITH CIRCUMFLEX - "\u00CB":"\\\"{E}", // LATIN CAPITAL LETTER E WITH DIAERESIS - "\u00CC":"\\`{I}", // LATIN CAPITAL LETTER I WITH GRAVE - "\u00CD":"\\'{I}", // LATIN CAPITAL LETTER I WITH ACUTE - "\u00CE":"\\^{I}", // LATIN CAPITAL LETTER I WITH CIRCUMFLEX - "\u00CF":"\\\"{I}", // LATIN CAPITAL LETTER I WITH DIAERESIS - "\u00D1":"\\~{N}", // LATIN CAPITAL LETTER N WITH TILDE - "\u00D2":"\\`{O}", // LATIN CAPITAL LETTER O WITH GRAVE - "\u00D3":"\\'{O}", // LATIN CAPITAL LETTER O WITH ACUTE - "\u00D4":"\\^{O}", // LATIN CAPITAL LETTER O WITH CIRCUMFLEX - "\u00D5":"\\~{O}", // LATIN CAPITAL LETTER O WITH TILDE - "\u00D6":"\\\"{O}", // LATIN CAPITAL LETTER O WITH DIAERESIS - "\u00D9":"\\`{U}", // LATIN CAPITAL LETTER U WITH GRAVE - "\u00DA":"\\'{U}", // LATIN CAPITAL LETTER U WITH ACUTE - "\u00DB":"\\^{U}", // LATIN CAPITAL LETTER U WITH CIRCUMFLEX - "\u00DC":"\\\"{U}", // LATIN CAPITAL LETTER U WITH DIAERESIS - "\u00DD":"\\'{Y}", // LATIN CAPITAL LETTER Y WITH ACUTE - "\u00E0":"\\`{a}", // LATIN SMALL LETTER A WITH GRAVE - "\u00E1":"\\'{a}", // LATIN SMALL LETTER A WITH ACUTE - "\u00E2":"\\^{a}", // LATIN SMALL LETTER A WITH CIRCUMFLEX - "\u00E3":"\\~{a}", // LATIN SMALL LETTER A WITH TILDE - "\u00E4":"\\\"{a}", // LATIN SMALL LETTER A WITH DIAERESIS - "\u00E5":"\\r{a}", // LATIN SMALL LETTER A WITH RING ABOVE - "\u00E7":"\\c{c}", // LATIN SMALL LETTER C WITH CEDILLA - "\u00E8":"\\`{e}", // LATIN SMALL LETTER E WITH GRAVE - "\u00E9":"\\'{e}", // LATIN SMALL LETTER E WITH ACUTE - "\u00EA":"\\^{e}", // LATIN SMALL LETTER E WITH CIRCUMFLEX - "\u00EB":"\\\"{e}", // LATIN SMALL LETTER E WITH DIAERESIS - "\u00EC":"\\`{i}", // LATIN SMALL LETTER I WITH GRAVE - "\u00ED":"\\'{i}", // LATIN SMALL LETTER I WITH ACUTE - "\u00EE":"\\^{i}", // LATIN SMALL LETTER I WITH CIRCUMFLEX - "\u00EF":"\\\"{i}", // LATIN SMALL LETTER I WITH DIAERESIS - "\u00F1":"\\~{n}", // LATIN SMALL LETTER N WITH TILDE - "\u00F2":"\\`{o}", // LATIN SMALL LETTER O WITH GRAVE - "\u00F3":"\\'{o}", // LATIN SMALL LETTER O WITH ACUTE - "\u00F4":"\\^{o}", // LATIN SMALL LETTER O WITH CIRCUMFLEX - "\u00F5":"\\~{o}", // LATIN SMALL LETTER O WITH TILDE - "\u00F6":"\\\"{o}", // LATIN SMALL LETTER O WITH DIAERESIS - "\u00F9":"\\`{u}", // LATIN SMALL LETTER U WITH GRAVE - "\u00FA":"\\'{u}", // LATIN SMALL LETTER U WITH ACUTE - "\u00FB":"\\^{u}", // LATIN SMALL LETTER U WITH CIRCUMFLEX - "\u00FC":"\\\"{u}", // LATIN SMALL LETTER U WITH DIAERESIS - "\u00FD":"\\'{y}", // LATIN SMALL LETTER Y WITH ACUTE - "\u00FF":"\\\"{y}", // LATIN SMALL LETTER Y WITH DIAERESIS - "\u0100":"\\={A}", // LATIN CAPITAL LETTER A WITH MACRON - "\u0101":"\\={a}", // LATIN SMALL LETTER A WITH MACRON - "\u0102":"\\u{A}", // LATIN CAPITAL LETTER A WITH BREVE - "\u0103":"\\u{a}", // LATIN SMALL LETTER A WITH BREVE - "\u0104":"\\k{A}", // LATIN CAPITAL LETTER A WITH OGONEK - "\u0105":"\\k{a}", // LATIN SMALL LETTER A WITH OGONEK - "\u0106":"\\'{C}", // LATIN CAPITAL LETTER C WITH ACUTE - "\u0107":"\\'{c}", // LATIN SMALL LETTER C WITH ACUTE - "\u0108":"\\^{C}", // LATIN CAPITAL LETTER C WITH CIRCUMFLEX - "\u0109":"\\^{c}", // LATIN SMALL LETTER C WITH CIRCUMFLEX - "\u010A":"\\.{C}", // LATIN CAPITAL LETTER C WITH DOT ABOVE - "\u010B":"\\.{c}", // LATIN SMALL LETTER C WITH DOT ABOVE - "\u010C":"\\v{C}", // LATIN CAPITAL LETTER C WITH CARON - "\u010D":"\\v{c}", // LATIN SMALL LETTER C WITH CARON - "\u010E":"\\v{D}", // LATIN CAPITAL LETTER D WITH CARON - "\u010F":"\\v{d}", // LATIN SMALL LETTER D WITH CARON - "\u0112":"\\={E}", // LATIN CAPITAL LETTER E WITH MACRON - "\u0113":"\\={e}", // LATIN SMALL LETTER E WITH MACRON - "\u0114":"\\u{E}", // LATIN CAPITAL LETTER E WITH BREVE - "\u0115":"\\u{e}", // LATIN SMALL LETTER E WITH BREVE - "\u0116":"\\.{E}", // LATIN CAPITAL LETTER E WITH DOT ABOVE - "\u0117":"\\.{e}", // LATIN SMALL LETTER E WITH DOT ABOVE - "\u0118":"\\k{E}", // LATIN CAPITAL LETTER E WITH OGONEK - "\u0119":"\\k{e}", // LATIN SMALL LETTER E WITH OGONEK - "\u011A":"\\v{E}", // LATIN CAPITAL LETTER E WITH CARON - "\u011B":"\\v{e}", // LATIN SMALL LETTER E WITH CARON - "\u011C":"\\^{G}", // LATIN CAPITAL LETTER G WITH CIRCUMFLEX - "\u011D":"\\^{g}", // LATIN SMALL LETTER G WITH CIRCUMFLEX - "\u011E":"\\u{G}", // LATIN CAPITAL LETTER G WITH BREVE - "\u011F":"\\u{g}", // LATIN SMALL LETTER G WITH BREVE - "\u0120":"\\.{G}", // LATIN CAPITAL LETTER G WITH DOT ABOVE - "\u0121":"\\.{g}", // LATIN SMALL LETTER G WITH DOT ABOVE - "\u0122":"\\c{G}", // LATIN CAPITAL LETTER G WITH CEDILLA - "\u0123":"\\c{g}", // LATIN SMALL LETTER G WITH CEDILLA - "\u0124":"\\^{H}", // LATIN CAPITAL LETTER H WITH CIRCUMFLEX - "\u0125":"\\^{h}", // LATIN SMALL LETTER H WITH CIRCUMFLEX - "\u0128":"\\~{I}", // LATIN CAPITAL LETTER I WITH TILDE - "\u0129":"\\~{i}", // LATIN SMALL LETTER I WITH TILDE - "\u012A":"\\={I}", // LATIN CAPITAL LETTER I WITH MACRON - "\u012B":"\\={i}", // LATIN SMALL LETTER I WITH MACRON - "\u012C":"\\u{I}", // LATIN CAPITAL LETTER I WITH BREVE - "\u012D":"\\u{i}", // LATIN SMALL LETTER I WITH BREVE - "\u012E":"\\k{I}", // LATIN CAPITAL LETTER I WITH OGONEK - "\u012F":"\\k{i}", // LATIN SMALL LETTER I WITH OGONEK - "\u0130":"\\.{I}", // LATIN CAPITAL LETTER I WITH DOT ABOVE - "\u0134":"\\^{J}", // LATIN CAPITAL LETTER J WITH CIRCUMFLEX - "\u0135":"\\^{j}", // LATIN SMALL LETTER J WITH CIRCUMFLEX - "\u0136":"\\c{K}", // LATIN CAPITAL LETTER K WITH CEDILLA - "\u0137":"\\c{k}", // LATIN SMALL LETTER K WITH CEDILLA - "\u0139":"\\'{L}", // LATIN CAPITAL LETTER L WITH ACUTE - "\u013A":"\\'{l}", // LATIN SMALL LETTER L WITH ACUTE - "\u013B":"\\c{L}", // LATIN CAPITAL LETTER L WITH CEDILLA - "\u013C":"\\c{l}", // LATIN SMALL LETTER L WITH CEDILLA - "\u013D":"\\v{L}", // LATIN CAPITAL LETTER L WITH CARON - "\u013E":"\\v{l}", // LATIN SMALL LETTER L WITH CARON - "\u0141":"\\L{}", //LATIN CAPITAL LETTER L WITH STROKE - "\u0142":"\\l{}", //LATIN SMALL LETTER L WITH STROKE - "\u0143":"\\'{N}", // LATIN CAPITAL LETTER N WITH ACUTE - "\u0144":"\\'{n}", // LATIN SMALL LETTER N WITH ACUTE - "\u0145":"\\c{N}", // LATIN CAPITAL LETTER N WITH CEDILLA - "\u0146":"\\c{n}", // LATIN SMALL LETTER N WITH CEDILLA - "\u0147":"\\v{N}", // LATIN CAPITAL LETTER N WITH CARON - "\u0148":"\\v{n}", // LATIN SMALL LETTER N WITH CARON - "\u014C":"\\={O}", // LATIN CAPITAL LETTER O WITH MACRON - "\u014D":"\\={o}", // LATIN SMALL LETTER O WITH MACRON - "\u014E":"\\u{O}", // LATIN CAPITAL LETTER O WITH BREVE - "\u014F":"\\u{o}", // LATIN SMALL LETTER O WITH BREVE - "\u0150":"\\H{O}", // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE - "\u0151":"\\H{o}", // LATIN SMALL LETTER O WITH DOUBLE ACUTE - "\u0154":"\\'{R}", // LATIN CAPITAL LETTER R WITH ACUTE - "\u0155":"\\'{r}", // LATIN SMALL LETTER R WITH ACUTE - "\u0156":"\\c{R}", // LATIN CAPITAL LETTER R WITH CEDILLA - "\u0157":"\\c{r}", // LATIN SMALL LETTER R WITH CEDILLA - "\u0158":"\\v{R}", // LATIN CAPITAL LETTER R WITH CARON - "\u0159":"\\v{r}", // LATIN SMALL LETTER R WITH CARON - "\u015A":"\\'{S}", // LATIN CAPITAL LETTER S WITH ACUTE - "\u015B":"\\'{s}", // LATIN SMALL LETTER S WITH ACUTE - "\u015C":"\\^{S}", // LATIN CAPITAL LETTER S WITH CIRCUMFLEX - "\u015D":"\\^{s}", // LATIN SMALL LETTER S WITH CIRCUMFLEX - "\u015E":"\\c{S}", // LATIN CAPITAL LETTER S WITH CEDILLA - "\u015F":"\\c{s}", // LATIN SMALL LETTER S WITH CEDILLA - "\u0160":"\\v{S}", // LATIN CAPITAL LETTER S WITH CARON - "\u0161":"\\v{s}", // LATIN SMALL LETTER S WITH CARON - "\u0162":"\\c{T}", // LATIN CAPITAL LETTER T WITH CEDILLA - "\u0163":"\\c{t}", // LATIN SMALL LETTER T WITH CEDILLA - "\u0164":"\\v{T}", // LATIN CAPITAL LETTER T WITH CARON - "\u0165":"\\v{t}", // LATIN SMALL LETTER T WITH CARON - "\u0168":"\\~{U}", // LATIN CAPITAL LETTER U WITH TILDE - "\u0169":"\\~{u}", // LATIN SMALL LETTER U WITH TILDE - "\u016A":"\\={U}", // LATIN CAPITAL LETTER U WITH MACRON - "\u016B":"\\={u}", // LATIN SMALL LETTER U WITH MACRON - "\u016C":"\\u{U}", // LATIN CAPITAL LETTER U WITH BREVE - "\u016D":"\\u{u}", // LATIN SMALL LETTER U WITH BREVE - "\u0170":"\\H{U}", // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE - "\u0171":"\\H{u}", // LATIN SMALL LETTER U WITH DOUBLE ACUTE - "\u0172":"\\k{U}", // LATIN CAPITAL LETTER U WITH OGONEK - "\u0173":"\\k{u}", // LATIN SMALL LETTER U WITH OGONEK - "\u0174":"\\^{W}", // LATIN CAPITAL LETTER W WITH CIRCUMFLEX - "\u0175":"\\^{w}", // LATIN SMALL LETTER W WITH CIRCUMFLEX - "\u0176":"\\^{Y}", // LATIN CAPITAL LETTER Y WITH CIRCUMFLEX - "\u0177":"\\^{y}", // LATIN SMALL LETTER Y WITH CIRCUMFLEX - "\u0178":"\\\"{Y}", // LATIN CAPITAL LETTER Y WITH DIAERESIS - "\u0179":"\\'{Z}", // LATIN CAPITAL LETTER Z WITH ACUTE - "\u017A":"\\'{z}", // LATIN SMALL LETTER Z WITH ACUTE - "\u017B":"\\.{Z}", // LATIN CAPITAL LETTER Z WITH DOT ABOVE - "\u017C":"\\.{z}", // LATIN SMALL LETTER Z WITH DOT ABOVE - "\u017D":"\\v{Z}", // LATIN CAPITAL LETTER Z WITH CARON - "\u017E":"\\v{z}", // LATIN SMALL LETTER Z WITH CARON - "\u01CD":"\\v{A}", // LATIN CAPITAL LETTER A WITH CARON - "\u01CE":"\\v{a}", // LATIN SMALL LETTER A WITH CARON - "\u01CF":"\\v{I}", // LATIN CAPITAL LETTER I WITH CARON - "\u01D0":"\\v{i}", // LATIN SMALL LETTER I WITH CARON - "\u01D1":"\\v{O}", // LATIN CAPITAL LETTER O WITH CARON - "\u01D2":"\\v{o}", // LATIN SMALL LETTER O WITH CARON - "\u01D3":"\\v{U}", // LATIN CAPITAL LETTER U WITH CARON - "\u01D4":"\\v{u}", // LATIN SMALL LETTER U WITH CARON - "\u01E6":"\\v{G}", // LATIN CAPITAL LETTER G WITH CARON - "\u01E7":"\\v{g}", // LATIN SMALL LETTER G WITH CARON - "\u01E8":"\\v{K}", // LATIN CAPITAL LETTER K WITH CARON - "\u01E9":"\\v{k}", // LATIN SMALL LETTER K WITH CARON - "\u01EA":"\\k{O}", // LATIN CAPITAL LETTER O WITH OGONEK - "\u01EB":"\\k{o}", // LATIN SMALL LETTER O WITH OGONEK - "\u01F0":"\\v{j}", // LATIN SMALL LETTER J WITH CARON - "\u01F4":"\\'{G}", // LATIN CAPITAL LETTER G WITH ACUTE - "\u01F5":"\\'{g}", // LATIN SMALL LETTER G WITH ACUTE - "\u1E02":"\\.{B}", // LATIN CAPITAL LETTER B WITH DOT ABOVE - "\u1E03":"\\.{b}", // LATIN SMALL LETTER B WITH DOT ABOVE - "\u1E04":"\\d{B}", // LATIN CAPITAL LETTER B WITH DOT BELOW - "\u1E05":"\\d{b}", // LATIN SMALL LETTER B WITH DOT BELOW - "\u1E06":"\\b{B}", // LATIN CAPITAL LETTER B WITH LINE BELOW - "\u1E07":"\\b{b}", // LATIN SMALL LETTER B WITH LINE BELOW - "\u1E0A":"\\.{D}", // LATIN CAPITAL LETTER D WITH DOT ABOVE - "\u1E0B":"\\.{d}", // LATIN SMALL LETTER D WITH DOT ABOVE - "\u1E0C":"\\d{D}", // LATIN CAPITAL LETTER D WITH DOT BELOW - "\u1E0D":"\\d{d}", // LATIN SMALL LETTER D WITH DOT BELOW - "\u1E0E":"\\b{D}", // LATIN CAPITAL LETTER D WITH LINE BELOW - "\u1E0F":"\\b{d}", // LATIN SMALL LETTER D WITH LINE BELOW - "\u1E10":"\\c{D}", // LATIN CAPITAL LETTER D WITH CEDILLA - "\u1E11":"\\c{d}", // LATIN SMALL LETTER D WITH CEDILLA - "\u1E1E":"\\.{F}", // LATIN CAPITAL LETTER F WITH DOT ABOVE - "\u1E1F":"\\.{f}", // LATIN SMALL LETTER F WITH DOT ABOVE - "\u1E20":"\\={G}", // LATIN CAPITAL LETTER G WITH MACRON - "\u1E21":"\\={g}", // LATIN SMALL LETTER G WITH MACRON - "\u1E22":"\\.{H}", // LATIN CAPITAL LETTER H WITH DOT ABOVE - "\u1E23":"\\.{h}", // LATIN SMALL LETTER H WITH DOT ABOVE - "\u1E24":"\\d{H}", // LATIN CAPITAL LETTER H WITH DOT BELOW - "\u1E25":"\\d{h}", // LATIN SMALL LETTER H WITH DOT BELOW - "\u1E26":"\\\"{H}", // LATIN CAPITAL LETTER H WITH DIAERESIS - "\u1E27":"\\\"{h}", // LATIN SMALL LETTER H WITH DIAERESIS - "\u1E28":"\\c{H}", // LATIN CAPITAL LETTER H WITH CEDILLA - "\u1E29":"\\c{h}", // LATIN SMALL LETTER H WITH CEDILLA - "\u1E30":"\\'{K}", // LATIN CAPITAL LETTER K WITH ACUTE - "\u1E31":"\\'{k}", // LATIN SMALL LETTER K WITH ACUTE - "\u1E32":"\\d{K}", // LATIN CAPITAL LETTER K WITH DOT BELOW - "\u1E33":"\\d{k}", // LATIN SMALL LETTER K WITH DOT BELOW - "\u1E34":"\\b{K}", // LATIN CAPITAL LETTER K WITH LINE BELOW - "\u1E35":"\\b{k}", // LATIN SMALL LETTER K WITH LINE BELOW - "\u1E36":"\\d{L}", // LATIN CAPITAL LETTER L WITH DOT BELOW - "\u1E37":"\\d{l}", // LATIN SMALL LETTER L WITH DOT BELOW - "\u1E3A":"\\b{L}", // LATIN CAPITAL LETTER L WITH LINE BELOW - "\u1E3B":"\\b{l}", // LATIN SMALL LETTER L WITH LINE BELOW - "\u1E3E":"\\'{M}", // LATIN CAPITAL LETTER M WITH ACUTE - "\u1E3F":"\\'{m}", // LATIN SMALL LETTER M WITH ACUTE - "\u1E40":"\\.{M}", // LATIN CAPITAL LETTER M WITH DOT ABOVE - "\u1E41":"\\.{m}", // LATIN SMALL LETTER M WITH DOT ABOVE - "\u1E42":"\\d{M}", // LATIN CAPITAL LETTER M WITH DOT BELOW - "\u1E43":"\\d{m}", // LATIN SMALL LETTER M WITH DOT BELOW - "\u1E44":"\\.{N}", // LATIN CAPITAL LETTER N WITH DOT ABOVE - "\u1E45":"\\.{n}", // LATIN SMALL LETTER N WITH DOT ABOVE - "\u1E46":"\\d{N}", // LATIN CAPITAL LETTER N WITH DOT BELOW - "\u1E47":"\\d{n}", // LATIN SMALL LETTER N WITH DOT BELOW - "\u1E48":"\\b{N}", // LATIN CAPITAL LETTER N WITH LINE BELOW - "\u1E49":"\\b{n}", // LATIN SMALL LETTER N WITH LINE BELOW - "\u1E54":"\\'{P}", // LATIN CAPITAL LETTER P WITH ACUTE - "\u1E55":"\\'{p}", // LATIN SMALL LETTER P WITH ACUTE - "\u1E56":"\\.{P}", // LATIN CAPITAL LETTER P WITH DOT ABOVE - "\u1E57":"\\.{p}", // LATIN SMALL LETTER P WITH DOT ABOVE - "\u1E58":"\\.{R}", // LATIN CAPITAL LETTER R WITH DOT ABOVE - "\u1E59":"\\.{r}", // LATIN SMALL LETTER R WITH DOT ABOVE - "\u1E5A":"\\d{R}", // LATIN CAPITAL LETTER R WITH DOT BELOW - "\u1E5B":"\\d{r}", // LATIN SMALL LETTER R WITH DOT BELOW - "\u1E5E":"\\b{R}", // LATIN CAPITAL LETTER R WITH LINE BELOW - "\u1E5F":"\\b{r}", // LATIN SMALL LETTER R WITH LINE BELOW - "\u1E60":"\\.{S}", // LATIN CAPITAL LETTER S WITH DOT ABOVE - "\u1E61":"\\.{s}", // LATIN SMALL LETTER S WITH DOT ABOVE - "\u1E62":"\\d{S}", // LATIN CAPITAL LETTER S WITH DOT BELOW - "\u1E63":"\\d{s}", // LATIN SMALL LETTER S WITH DOT BELOW - "\u1E6A":"\\.{T}", // LATIN CAPITAL LETTER T WITH DOT ABOVE - "\u1E6B":"\\.{t}", // LATIN SMALL LETTER T WITH DOT ABOVE - "\u1E6C":"\\d{T}", // LATIN CAPITAL LETTER T WITH DOT BELOW - "\u1E6D":"\\d{t}", // LATIN SMALL LETTER T WITH DOT BELOW - "\u1E6E":"\\b{T}", // LATIN CAPITAL LETTER T WITH LINE BELOW - "\u1E6F":"\\b{t}", // LATIN SMALL LETTER T WITH LINE BELOW - "\u1E7C":"\\~{V}", // LATIN CAPITAL LETTER V WITH TILDE - "\u1E7D":"\\~{v}", // LATIN SMALL LETTER V WITH TILDE - "\u1E7E":"\\d{V}", // LATIN CAPITAL LETTER V WITH DOT BELOW - "\u1E7F":"\\d{v}", // LATIN SMALL LETTER V WITH DOT BELOW - "\u1E80":"\\`{W}", // LATIN CAPITAL LETTER W WITH GRAVE - "\u1E81":"\\`{w}", // LATIN SMALL LETTER W WITH GRAVE - "\u1E82":"\\'{W}", // LATIN CAPITAL LETTER W WITH ACUTE - "\u1E83":"\\'{w}", // LATIN SMALL LETTER W WITH ACUTE - "\u1E84":"\\\"{W}", // LATIN CAPITAL LETTER W WITH DIAERESIS - "\u1E85":"\\\"{w}", // LATIN SMALL LETTER W WITH DIAERESIS - "\u1E86":"\\.{W}", // LATIN CAPITAL LETTER W WITH DOT ABOVE - "\u1E87":"\\.{w}", // LATIN SMALL LETTER W WITH DOT ABOVE - "\u1E88":"\\d{W}", // LATIN CAPITAL LETTER W WITH DOT BELOW - "\u1E89":"\\d{w}", // LATIN SMALL LETTER W WITH DOT BELOW - "\u1E8A":"\\.{X}", // LATIN CAPITAL LETTER X WITH DOT ABOVE - "\u1E8B":"\\.{x}", // LATIN SMALL LETTER X WITH DOT ABOVE - "\u1E8C":"\\\"{X}", // LATIN CAPITAL LETTER X WITH DIAERESIS - "\u1E8D":"\\\"{x}", // LATIN SMALL LETTER X WITH DIAERESIS - "\u1E8E":"\\.{Y}", // LATIN CAPITAL LETTER Y WITH DOT ABOVE - "\u1E8F":"\\.{y}", // LATIN SMALL LETTER Y WITH DOT ABOVE - "\u1E90":"\\^{Z}", // LATIN CAPITAL LETTER Z WITH CIRCUMFLEX - "\u1E91":"\\^{z}", // LATIN SMALL LETTER Z WITH CIRCUMFLEX - "\u1E92":"\\d{Z}", // LATIN CAPITAL LETTER Z WITH DOT BELOW - "\u1E93":"\\d{z}", // LATIN SMALL LETTER Z WITH DOT BELOW - "\u1E94":"\\b{Z}", // LATIN CAPITAL LETTER Z WITH LINE BELOW - "\u1E95":"\\b{z}", // LATIN SMALL LETTER Z WITH LINE BELOW - "\u1E96":"\\b{h}", // LATIN SMALL LETTER H WITH LINE BELOW - "\u1E97":"\\\"{t}", // LATIN SMALL LETTER T WITH DIAERESIS - "\u1EA0":"\\d{A}", // LATIN CAPITAL LETTER A WITH DOT BELOW - "\u1EA1":"\\d{a}", // LATIN SMALL LETTER A WITH DOT BELOW - "\u1EB8":"\\d{E}", // LATIN CAPITAL LETTER E WITH DOT BELOW - "\u1EB9":"\\d{e}", // LATIN SMALL LETTER E WITH DOT BELOW - "\u1EBC":"\\~{E}", // LATIN CAPITAL LETTER E WITH TILDE - "\u1EBD":"\\~{e}", // LATIN SMALL LETTER E WITH TILDE - "\u1ECA":"\\d{I}", // LATIN CAPITAL LETTER I WITH DOT BELOW - "\u1ECB":"\\d{i}", // LATIN SMALL LETTER I WITH DOT BELOW - "\u1ECC":"\\d{O}", // LATIN CAPITAL LETTER O WITH DOT BELOW - "\u1ECD":"\\d{o}", // LATIN SMALL LETTER O WITH DOT BELOW - "\u1EE4":"\\d{U}", // LATIN CAPITAL LETTER U WITH DOT BELOW - "\u1EE5":"\\d{u}", // LATIN SMALL LETTER U WITH DOT BELOW - "\u1EF2":"\\`{Y}", // LATIN CAPITAL LETTER Y WITH GRAVE - "\u1EF3":"\\`{y}", // LATIN SMALL LETTER Y WITH GRAVE - "\u1EF4":"\\d{Y}", // LATIN CAPITAL LETTER Y WITH DOT BELOW - "\u1EF5":"\\d{y}", // LATIN SMALL LETTER Y WITH DOT BELOW - "\u1EF8":"\\~{Y}", // LATIN CAPITAL LETTER Y WITH TILDE - "\u1EF9":"\\~{y}" // LATIN SMALL LETTER Y WITH TILDE -}; - -/* unfortunately the mapping isn't reversible - hence this second table - sigh! */ -var reversemappingTable = { - "\\url" : "", // strip 'url' - "\\href" : "", // strip 'href' - "{\\textexclamdown}" : "\u00A1", // INVERTED EXCLAMATION MARK - "{\\textcent}" : "\u00A2", // CENT SIGN - "{\\textsterling}" : "\u00A3", // POUND SIGN - "{\\textyen}" : "\u00A5", // YEN SIGN - "{\\textbrokenbar}" : "\u00A6", // BROKEN BAR - "{\\textsection}" : "\u00A7", // SECTION SIGN - "{\\textasciidieresis}" : "\u00A8", // DIAERESIS - "{\\textcopyright}" : "\u00A9", // COPYRIGHT SIGN - "{\\textordfeminine}" : "\u00AA", // FEMININE ORDINAL INDICATOR - "{\\guillemotleft}" : "\u00AB", // LEFT-POINTING DOUBLE ANGLE QUOTATION MARK - "{\\textlnot}" : "\u00AC", // NOT SIGN - "{\\textregistered}" : "\u00AE", // REGISTERED SIGN - "{\\textasciimacron}" : "\u00AF", // MACRON - "{\\textdegree}" : "\u00B0", // DEGREE SIGN - "{\\textpm}" : "\u00B1", // PLUS-MINUS SIGN - "{\\texttwosuperior}" : "\u00B2", // SUPERSCRIPT TWO - "{\\textthreesuperior}" : "\u00B3", // SUPERSCRIPT THREE - "{\\textasciiacute}" : "\u00B4", // ACUTE ACCENT - "{\\textmu}" : "\u00B5", // MICRO SIGN - "{\\textparagraph}" : "\u00B6", // PILCROW SIGN - "{\\textperiodcentered}" : "\u00B7", // MIDDLE DOT - "{\\c\\ }" : "\u00B8", // CEDILLA - "{\\textonesuperior}" : "\u00B9", // SUPERSCRIPT ONE - "{\\textordmasculine}" : "\u00BA", // MASCULINE ORDINAL INDICATOR - "{\\guillemotright}" : "\u00BB", // RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK - "{\\textonequarter}" : "\u00BC", // VULGAR FRACTION ONE QUARTER - "{\\textonehalf}" : "\u00BD", // VULGAR FRACTION ONE HALF - "{\\textthreequarters}" : "\u00BE", // VULGAR FRACTION THREE QUARTERS - "{\\textquestiondown}" : "\u00BF", // INVERTED QUESTION MARK - "{\\AE}" : "\u00C6", // LATIN CAPITAL LETTER AE - "{\\DH}" : "\u00D0", // LATIN CAPITAL LETTER ETH - "{\\texttimes}" : "\u00D7", // MULTIPLICATION SIGN - "{\\O}" : "\U00D8", // LATIN SMALL LETTER O WITH STROKE - "{\\TH}" : "\u00DE", // LATIN CAPITAL LETTER THORN - "{\\ss}" : "\u00DF", // LATIN SMALL LETTER SHARP S - "{\\ae}" : "\u00E6", // LATIN SMALL LETTER AE - "{\\dh}" : "\u00F0", // LATIN SMALL LETTER ETH - "{\\textdiv}" : "\u00F7", // DIVISION SIGN - "{\\o}" : "\U00F8", // LATIN SMALL LETTER O WITH STROKE - "{\\th}" : "\u00FE", // LATIN SMALL LETTER THORN - "{\\i}" : "\u0131", // LATIN SMALL LETTER DOTLESS I - "'n" : "\u0149", // LATIN SMALL LETTER N PRECEDED BY APOSTROPHE - "{\\NG}" : "\u014A", // LATIN CAPITAL LETTER ENG - "{\\ng}" : "\u014B", // LATIN SMALL LETTER ENG - "{\\OE}" : "\u0152", // LATIN CAPITAL LIGATURE OE - "{\\oe}" : "\u0153", // LATIN SMALL LIGATURE OE - "{\\textasciicircum}" : "\u02C6", // MODIFIER LETTER CIRCUMFLEX ACCENT -// "\\~{}" : "\u02DC", // SMALL TILDE - "{\\textacutedbl}" : "\u02DD", // DOUBLE ACUTE ACCENT - "{\\textendash}" : "\u2013", // EN DASH - "{\\textemdash}" : "\u2014", // EM DASH - "---" : "\u2014", // EM DASH - "--" : "\u2013", // EN DASH - "{\\textbardbl}" : "\u2016", // DOUBLE VERTICAL LINE - "{\\textunderscore}" : "\u2017", // DOUBLE LOW LINE - "{\\textquoteleft}" : "\u2018", // LEFT SINGLE QUOTATION MARK - "{\\textquoteright}" : "\u2019", // RIGHT SINGLE QUOTATION MARK - "{\\quotesinglbase}" : "\u201A", // SINGLE LOW-9 QUOTATION MARK - "{\\textquotedblleft}" : "\u201C", // LEFT DOUBLE QUOTATION MARK - "{\\textquotedblright}" : "\u201D", // RIGHT DOUBLE QUOTATION MARK - "{\\quotedblbase}" : "\u201E", // DOUBLE LOW-9 QUOTATION MARK -// "{\\quotedblbase}" : "\u201F", // DOUBLE HIGH-REVERSED-9 QUOTATION MARK - "{\\textdagger}" : "\u2020", // DAGGER - "{\\textdaggerdbl}" : "\u2021", // DOUBLE DAGGER - "{\\textbullet}" : "\u2022", // BULLET - "{\\textellipsis}" : "\u2026", // HORIZONTAL ELLIPSIS - "{\\textperthousand}" : "\u2030", // PER MILLE SIGN - "'''" : "\u2034", // TRIPLE PRIME - "''" : "\u201D", // RIGHT DOUBLE QUOTATION MARK (could be a double prime) - "``" : "\u201C", // LEFT DOUBLE QUOTATION MARK (could be a reversed double prime) - "```" : "\u2037", // REVERSED TRIPLE PRIME - "{\\guilsinglleft}" : "\u2039", // SINGLE LEFT-POINTING ANGLE QUOTATION MARK - "{\\guilsinglright}" : "\u203A", // SINGLE RIGHT-POINTING ANGLE QUOTATION MARK - "!!" : "\u203C", // DOUBLE EXCLAMATION MARK - "{\\textfractionsolidus}" : "\u2044", // FRACTION SLASH - "?!" : "\u2048", // QUESTION EXCLAMATION MARK - "!?" : "\u2049", // EXCLAMATION QUESTION MARK - "$^{0}$" : "\u2070", // SUPERSCRIPT ZERO - "$^{4}$" : "\u2074", // SUPERSCRIPT FOUR - "$^{5}$" : "\u2075", // SUPERSCRIPT FIVE - "$^{6}$" : "\u2076", // SUPERSCRIPT SIX - "$^{7}$" : "\u2077", // SUPERSCRIPT SEVEN - "$^{8}$" : "\u2078", // SUPERSCRIPT EIGHT - "$^{9}$" : "\u2079", // SUPERSCRIPT NINE - "$^{+}$" : "\u207A", // SUPERSCRIPT PLUS SIGN - "$^{-}$" : "\u207B", // SUPERSCRIPT MINUS - "$^{=}$" : "\u207C", // SUPERSCRIPT EQUALS SIGN - "$^{(}$" : "\u207D", // SUPERSCRIPT LEFT PARENTHESIS - "$^{)}$" : "\u207E", // SUPERSCRIPT RIGHT PARENTHESIS - "$^{n}$" : "\u207F", // SUPERSCRIPT LATIN SMALL LETTER N - "$_{0}$" : "\u2080", // SUBSCRIPT ZERO - "$_{1}$" : "\u2081", // SUBSCRIPT ONE - "$_{2}$" : "\u2082", // SUBSCRIPT TWO - "$_{3}$" : "\u2083", // SUBSCRIPT THREE - "$_{4}$" : "\u2084", // SUBSCRIPT FOUR - "$_{5}$" : "\u2085", // SUBSCRIPT FIVE - "$_{6}$" : "\u2086", // SUBSCRIPT SIX - "$_{7}$" : "\u2087", // SUBSCRIPT SEVEN - "$_{8}$" : "\u2088", // SUBSCRIPT EIGHT - "$_{9}$" : "\u2089", // SUBSCRIPT NINE - "$_{+}$" : "\u208A", // SUBSCRIPT PLUS SIGN - "$_{-}$" : "\u208B", // SUBSCRIPT MINUS - "$_{=}$" : "\u208C", // SUBSCRIPT EQUALS SIGN - "$_{(}$" : "\u208D", // SUBSCRIPT LEFT PARENTHESIS - "$_{)}$" : "\u208E", // SUBSCRIPT RIGHT PARENTHESIS - "{\\texteuro}" : "\u20AC", // EURO SIGN - "a/c" : "\u2100", // ACCOUNT OF - "a/s" : "\u2101", // ADDRESSED TO THE SUBJECT - "{\\textcelsius}" : "\u2103", // DEGREE CELSIUS - "c/o" : "\u2105", // CARE OF - "c/u" : "\u2106", // CADA UNA - "{\\textnumero}" : "\u2116", // NUMERO SIGN - "{\\textcircledP}" : "\u2117", // SOUND RECORDING COPYRIGHT - "{\\textservicemark}" : "\u2120", // SERVICE MARK - "{TEL}" : "\u2121", // TELEPHONE SIGN - "{\\texttrademark}" : "\u2122", // TRADE MARK SIGN - "{\\textohm}" : "\u2126", // OHM SIGN - "{\\textestimated}" : "\u212E", // ESTIMATED SYMBOL - " 1/3" : "\u2153", // VULGAR FRACTION ONE THIRD - " 2/3" : "\u2154", // VULGAR FRACTION TWO THIRDS - " 1/5" : "\u2155", // VULGAR FRACTION ONE FIFTH - " 2/5" : "\u2156", // VULGAR FRACTION TWO FIFTHS - " 3/5" : "\u2157", // VULGAR FRACTION THREE FIFTHS - " 4/5" : "\u2158", // VULGAR FRACTION FOUR FIFTHS - " 1/6" : "\u2159", // VULGAR FRACTION ONE SIXTH - " 5/6" : "\u215A", // VULGAR FRACTION FIVE SIXTHS - " 1/8" : "\u215B", // VULGAR FRACTION ONE EIGHTH - " 3/8" : "\u215C", // VULGAR FRACTION THREE EIGHTHS - " 5/8" : "\u215D", // VULGAR FRACTION FIVE EIGHTHS - " 7/8" : "\u215E", // VULGAR FRACTION SEVEN EIGHTHS - " 1/" : "\u215F", // FRACTION NUMERATOR ONE - "{\\textleftarrow}" : "\u2190", // LEFTWARDS ARROW - "{\\textuparrow}" : "\u2191", // UPWARDS ARROW - "{\\textrightarrow}" : "\u2192", // RIGHTWARDS ARROW - "{\\textdownarrow}" : "\u2193", // DOWNWARDS ARROW - "<->" : "\u2194", // LEFT RIGHT ARROW - "<=" : "\u21D0", // LEFTWARDS DOUBLE ARROW - "=>" : "\u21D2", // RIGHTWARDS DOUBLE ARROW - "<=>" : "\u21D4", // LEFT RIGHT DOUBLE ARROW - "$\\infty$" : "\u221E", // INFINITY - "||" : "\u2225", // PARALLEL TO - "/=" : "\u2260", // NOT EQUAL TO -// "<=" : "\u2264", // LESS-THAN OR EQUAL TO - ">=" : "\u2265", // GREATER-THAN OR EQUAL TO - "<<" : "\u226A", // MUCH LESS-THAN - ">>" : "\u226B", // MUCH GREATER-THAN - "(+)" : "\u2295", // CIRCLED PLUS - "(-)" : "\u2296", // CIRCLED MINUS - "(x)" : "\u2297", // CIRCLED TIMES - "(/)" : "\u2298", // CIRCLED DIVISION SLASH - "|-" : "\u22A2", // RIGHT TACK - "-|" : "\u22A3", // LEFT TACK -// "|-" : "\u22A6", // ASSERTION - "|=" : "\u22A7", // MODELS -// "|=" : "\u22A8", // TRUE - "||-" : "\u22A9", // FORCES - "$\\#$" : "\u22D5", // EQUAL AND PARALLEL TO - "<<<" : "\u22D8", // VERY MUCH LESS-THAN - ">>>" : "\u22D9", // VERY MUCH GREATER-THAN - "{\\textlangle}" : "\u2329", // LEFT-POINTING ANGLE BRACKET - "{\\textrangle}" : "\u232A", // RIGHT-POINTING ANGLE BRACKET - "{\\textvisiblespace}" : "\u2423", // OPEN BOX - "///" : "\u2425", // SYMBOL FOR DELETE FORM TWO - "{\\textopenbullet}" : "\u25E6", // WHITE BULLET - ":-(" : "\u2639", // WHITE FROWNING FACE - ":-)" : "\u263A", // WHITE SMILING FACE - "(-: " : "\u263B", // BLACK SMILING FACE -// "$\\#$" : "\u266F", // MUSIC SHARP SIGN - "$\\%<$" : "\u2701", // UPPER BLADE SCISSORS -/* "$\\%<$" : "\u2702", // BLACK SCISSORS - "$\\%<$" : "\u2703", // LOWER BLADE SCISSORS - "$\\%<$" : "\u2704", // WHITE SCISSORS */ -/* Derived accented characters */ - "\\`{A}" : "\u00C0", // LATIN CAPITAL LETTER A WITH GRAVE - "\\'{A}" : "\u00C1", // LATIN CAPITAL LETTER A WITH ACUTE - "\\^{A}" : "\u00C2", // LATIN CAPITAL LETTER A WITH CIRCUMFLEX - "\\~{A}" : "\u00C3", // LATIN CAPITAL LETTER A WITH TILDE - "\\\"{A}" : "\u00C4", // LATIN CAPITAL LETTER A WITH DIAERESIS - "\\r{A}" : "\u00C5", // LATIN CAPITAL LETTER A WITH RING ABOVE - "\\c{C}" : "\u00C7", // LATIN CAPITAL LETTER C WITH CEDILLA - "\\`{E}" : "\u00C8", // LATIN CAPITAL LETTER E WITH GRAVE - "\\'{E}" : "\u00C9", // LATIN CAPITAL LETTER E WITH ACUTE - "\\^{E}" : "\u00CA", // LATIN CAPITAL LETTER E WITH CIRCUMFLEX - "\\\"{E}" : "\u00CB", // LATIN CAPITAL LETTER E WITH DIAERESIS - "\\`{I}" : "\u00CC", // LATIN CAPITAL LETTER I WITH GRAVE - "\\'{I}" : "\u00CD", // LATIN CAPITAL LETTER I WITH ACUTE - "\\^{I}" : "\u00CE", // LATIN CAPITAL LETTER I WITH CIRCUMFLEX - "\\\"{I}" : "\u00CF", // LATIN CAPITAL LETTER I WITH DIAERESIS - "\\~{N}" : "\u00D1", // LATIN CAPITAL LETTER N WITH TILDE - "\\`{O}" : "\u00D2", // LATIN CAPITAL LETTER O WITH GRAVE - "\\'{O}" : "\u00D3", // LATIN CAPITAL LETTER O WITH ACUTE - "\\^{O}" : "\u00D4", // LATIN CAPITAL LETTER O WITH CIRCUMFLEX - "\\~{O}" : "\u00D5", // LATIN CAPITAL LETTER O WITH TILDE - "\\\"{O}" : "\u00D6", // LATIN CAPITAL LETTER O WITH DIAERESIS - "\\`{U}" : "\u00D9", // LATIN CAPITAL LETTER U WITH GRAVE - "\\'{U}" : "\u00DA", // LATIN CAPITAL LETTER U WITH ACUTE - "\\^{U}" : "\u00DB", // LATIN CAPITAL LETTER U WITH CIRCUMFLEX - "\\\"{U}" : "\u00DC", // LATIN CAPITAL LETTER U WITH DIAERESIS - "\\'{Y}" : "\u00DD", // LATIN CAPITAL LETTER Y WITH ACUTE - "\\`{a}" : "\u00E0", // LATIN SMALL LETTER A WITH GRAVE - "\\'{a}" : "\u00E1", // LATIN SMALL LETTER A WITH ACUTE - "\\^{a}" : "\u00E2", // LATIN SMALL LETTER A WITH CIRCUMFLEX - "\\~{a}" : "\u00E3", // LATIN SMALL LETTER A WITH TILDE - "\\\"{a}" : "\u00E4", // LATIN SMALL LETTER A WITH DIAERESIS - "\\r{a}" : "\u00E5", // LATIN SMALL LETTER A WITH RING ABOVE - "\\c{c}" : "\u00E7", // LATIN SMALL LETTER C WITH CEDILLA - "\\`{e}" : "\u00E8", // LATIN SMALL LETTER E WITH GRAVE - "\\'{e}" : "\u00E9", // LATIN SMALL LETTER E WITH ACUTE - "\\^{e}" : "\u00EA", // LATIN SMALL LETTER E WITH CIRCUMFLEX - "\\\"{e}" : "\u00EB", // LATIN SMALL LETTER E WITH DIAERESIS - "\\`{i}" : "\u00EC", // LATIN SMALL LETTER I WITH GRAVE - "\\'{i}" : "\u00ED", // LATIN SMALL LETTER I WITH ACUTE - "\\^{i}" : "\u00EE", // LATIN SMALL LETTER I WITH CIRCUMFLEX - "\\\"{i}" : "\u00EF", // LATIN SMALL LETTER I WITH DIAERESIS - "\\~{n}" : "\u00F1", // LATIN SMALL LETTER N WITH TILDE - "\\`{o}" : "\u00F2", // LATIN SMALL LETTER O WITH GRAVE - "\\'{o}" : "\u00F3", // LATIN SMALL LETTER O WITH ACUTE - "\\^{o}" : "\u00F4", // LATIN SMALL LETTER O WITH CIRCUMFLEX - "\\~{o}" : "\u00F5", // LATIN SMALL LETTER O WITH TILDE - "\\\"{o}" : "\u00F6", // LATIN SMALL LETTER O WITH DIAERESIS - "\\`{u}" : "\u00F9", // LATIN SMALL LETTER U WITH GRAVE - "\\'{u}" : "\u00FA", // LATIN SMALL LETTER U WITH ACUTE - "\\^{u}" : "\u00FB", // LATIN SMALL LETTER U WITH CIRCUMFLEX - "\\\"{u}" : "\u00FC", // LATIN SMALL LETTER U WITH DIAERESIS - "\\'{y}" : "\u00FD", // LATIN SMALL LETTER Y WITH ACUTE - "\\\"{y}" : "\u00FF", // LATIN SMALL LETTER Y WITH DIAERESIS - "\\={A}" : "\u0100", // LATIN CAPITAL LETTER A WITH MACRON - "\\={a}" : "\u0101", // LATIN SMALL LETTER A WITH MACRON - "\\u{A}" : "\u0102", // LATIN CAPITAL LETTER A WITH BREVE - "\\u{a}" : "\u0103", // LATIN SMALL LETTER A WITH BREVE - "\\k{A}" : "\u0104", // LATIN CAPITAL LETTER A WITH OGONEK - "\\k{a}" : "\u0105", // LATIN SMALL LETTER A WITH OGONEK - "\\'{C}" : "\u0106", // LATIN CAPITAL LETTER C WITH ACUTE - "\\'{c}" : "\u0107", // LATIN SMALL LETTER C WITH ACUTE - "\\^{C}" : "\u0108", // LATIN CAPITAL LETTER C WITH CIRCUMFLEX - "\\^{c}" : "\u0109", // LATIN SMALL LETTER C WITH CIRCUMFLEX - "\\.{C}" : "\u010A", // LATIN CAPITAL LETTER C WITH DOT ABOVE - "\\.{c}" : "\u010B", // LATIN SMALL LETTER C WITH DOT ABOVE - "\\v{C}" : "\u010C", // LATIN CAPITAL LETTER C WITH CARON - "\\v{c}" : "\u010D", // LATIN SMALL LETTER C WITH CARON - "\\v{D}" : "\u010E", // LATIN CAPITAL LETTER D WITH CARON - "\\v{d}" : "\u010F", // LATIN SMALL LETTER D WITH CARON - "\\={E}" : "\u0112", // LATIN CAPITAL LETTER E WITH MACRON - "\\={e}" : "\u0113", // LATIN SMALL LETTER E WITH MACRON - "\\u{E}" : "\u0114", // LATIN CAPITAL LETTER E WITH BREVE - "\\u{e}" : "\u0115", // LATIN SMALL LETTER E WITH BREVE - "\\.{E}" : "\u0116", // LATIN CAPITAL LETTER E WITH DOT ABOVE - "\\.{e}" : "\u0117", // LATIN SMALL LETTER E WITH DOT ABOVE - "\\k{E}" : "\u0118", // LATIN CAPITAL LETTER E WITH OGONEK - "\\k{e}" : "\u0119", // LATIN SMALL LETTER E WITH OGONEK - "\\v{E}" : "\u011A", // LATIN CAPITAL LETTER E WITH CARON - "\\v{e}" : "\u011B", // LATIN SMALL LETTER E WITH CARON - "\\^{G}" : "\u011C", // LATIN CAPITAL LETTER G WITH CIRCUMFLEX - "\\^{g}" : "\u011D", // LATIN SMALL LETTER G WITH CIRCUMFLEX - "\\u{G}" : "\u011E", // LATIN CAPITAL LETTER G WITH BREVE - "\\u{g}" : "\u011F", // LATIN SMALL LETTER G WITH BREVE - "\\.{G}" : "\u0120", // LATIN CAPITAL LETTER G WITH DOT ABOVE - "\\.{g}" : "\u0121", // LATIN SMALL LETTER G WITH DOT ABOVE - "\\c{G}" : "\u0122", // LATIN CAPITAL LETTER G WITH CEDILLA - "\\c{g}" : "\u0123", // LATIN SMALL LETTER G WITH CEDILLA - "\\^{H}" : "\u0124", // LATIN CAPITAL LETTER H WITH CIRCUMFLEX - "\\^{h}" : "\u0125", // LATIN SMALL LETTER H WITH CIRCUMFLEX - "\\~{I}" : "\u0128", // LATIN CAPITAL LETTER I WITH TILDE - "\\~{i}" : "\u0129", // LATIN SMALL LETTER I WITH TILDE - "\\={I}" : "\u012A", // LATIN CAPITAL LETTER I WITH MACRON - "\\={i}" : "\u012B", // LATIN SMALL LETTER I WITH MACRON - "\\u{I}" : "\u012C", // LATIN CAPITAL LETTER I WITH BREVE - "\\u{i}" : "\u012D", // LATIN SMALL LETTER I WITH BREVE - "\\k{I}" : "\u012E", // LATIN CAPITAL LETTER I WITH OGONEK - "\\k{i}" : "\u012F", // LATIN SMALL LETTER I WITH OGONEK - "\\.{I}" : "\u0130", // LATIN CAPITAL LETTER I WITH DOT ABOVE - "\\^{J}" : "\u0134", // LATIN CAPITAL LETTER J WITH CIRCUMFLEX - "\\^{j}" : "\u0135", // LATIN SMALL LETTER J WITH CIRCUMFLEX - "\\c{K}" : "\u0136", // LATIN CAPITAL LETTER K WITH CEDILLA - "\\c{k}" : "\u0137", // LATIN SMALL LETTER K WITH CEDILLA - "\\'{L}" : "\u0139", // LATIN CAPITAL LETTER L WITH ACUTE - "\\'{l}" : "\u013A", // LATIN SMALL LETTER L WITH ACUTE - "\\c{L}" : "\u013B", // LATIN CAPITAL LETTER L WITH CEDILLA - "\\c{l}" : "\u013C", // LATIN SMALL LETTER L WITH CEDILLA - "\\v{L}" : "\u013D", // LATIN CAPITAL LETTER L WITH CARON - "\\v{l}" : "\u013E", // LATIN SMALL LETTER L WITH CARON - "\\L{}" : "\u0141", //LATIN CAPITAL LETTER L WITH STROKE - "\\l{}" : "\u0142", //LATIN SMALL LETTER L WITH STROKE - "\\'{N}" : "\u0143", // LATIN CAPITAL LETTER N WITH ACUTE - "\\'{n}" : "\u0144", // LATIN SMALL LETTER N WITH ACUTE - "\\c{N}" : "\u0145", // LATIN CAPITAL LETTER N WITH CEDILLA - "\\c{n}" : "\u0146", // LATIN SMALL LETTER N WITH CEDILLA - "\\v{N}" : "\u0147", // LATIN CAPITAL LETTER N WITH CARON - "\\v{n}" : "\u0148", // LATIN SMALL LETTER N WITH CARON - "\\={O}" : "\u014C", // LATIN CAPITAL LETTER O WITH MACRON - "\\={o}" : "\u014D", // LATIN SMALL LETTER O WITH MACRON - "\\u{O}" : "\u014E", // LATIN CAPITAL LETTER O WITH BREVE - "\\u{o}" : "\u014F", // LATIN SMALL LETTER O WITH BREVE - "\\H{O}" : "\u0150", // LATIN CAPITAL LETTER O WITH DOUBLE ACUTE - "\\H{o}" : "\u0151", // LATIN SMALL LETTER O WITH DOUBLE ACUTE - "\\'{R}" : "\u0154", // LATIN CAPITAL LETTER R WITH ACUTE - "\\'{r}" : "\u0155", // LATIN SMALL LETTER R WITH ACUTE - "\\c{R}" : "\u0156", // LATIN CAPITAL LETTER R WITH CEDILLA - "\\c{r}" : "\u0157", // LATIN SMALL LETTER R WITH CEDILLA - "\\v{R}" : "\u0158", // LATIN CAPITAL LETTER R WITH CARON - "\\v{r}" : "\u0159", // LATIN SMALL LETTER R WITH CARON - "\\'{S}" : "\u015A", // LATIN CAPITAL LETTER S WITH ACUTE - "\\'{s}" : "\u015B", // LATIN SMALL LETTER S WITH ACUTE - "\\^{S}" : "\u015C", // LATIN CAPITAL LETTER S WITH CIRCUMFLEX - "\\^{s}" : "\u015D", // LATIN SMALL LETTER S WITH CIRCUMFLEX - "\\c{S}" : "\u015E", // LATIN CAPITAL LETTER S WITH CEDILLA - "\\c{s}" : "\u015F", // LATIN SMALL LETTER S WITH CEDILLA - "\\v{S}" : "\u0160", // LATIN CAPITAL LETTER S WITH CARON - "\\v{s}" : "\u0161", // LATIN SMALL LETTER S WITH CARON - "\\c{T}" : "\u0162", // LATIN CAPITAL LETTER T WITH CEDILLA - "\\c{t}" : "\u0163", // LATIN SMALL LETTER T WITH CEDILLA - "\\v{T}" : "\u0164", // LATIN CAPITAL LETTER T WITH CARON - "\\v{t}" : "\u0165", // LATIN SMALL LETTER T WITH CARON - "\\~{U}" : "\u0168", // LATIN CAPITAL LETTER U WITH TILDE - "\\~{u}" : "\u0169", // LATIN SMALL LETTER U WITH TILDE - "\\={U}" : "\u016A", // LATIN CAPITAL LETTER U WITH MACRON - "\\={u}" : "\u016B", // LATIN SMALL LETTER U WITH MACRON - "\\u{U}" : "\u016C", // LATIN CAPITAL LETTER U WITH BREVE - "\\u{u}" : "\u016D", // LATIN SMALL LETTER U WITH BREVE - "\\H{U}" : "\u0170", // LATIN CAPITAL LETTER U WITH DOUBLE ACUTE - "\\H{u}" : "\u0171", // LATIN SMALL LETTER U WITH DOUBLE ACUTE - "\\k{U}" : "\u0172", // LATIN CAPITAL LETTER U WITH OGONEK - "\\k{u}" : "\u0173", // LATIN SMALL LETTER U WITH OGONEK - "\\^{W}" : "\u0174", // LATIN CAPITAL LETTER W WITH CIRCUMFLEX - "\\^{w}" : "\u0175", // LATIN SMALL LETTER W WITH CIRCUMFLEX - "\\^{Y}" : "\u0176", // LATIN CAPITAL LETTER Y WITH CIRCUMFLEX - "\\^{y}" : "\u0177", // LATIN SMALL LETTER Y WITH CIRCUMFLEX - "\\\"{Y}" : "\u0178", // LATIN CAPITAL LETTER Y WITH DIAERESIS - "\\'{Z}" : "\u0179", // LATIN CAPITAL LETTER Z WITH ACUTE - "\\'{z}" : "\u017A", // LATIN SMALL LETTER Z WITH ACUTE - "\\.{Z}" : "\u017B", // LATIN CAPITAL LETTER Z WITH DOT ABOVE - "\\.{z}" : "\u017C", // LATIN SMALL LETTER Z WITH DOT ABOVE - "\\v{Z}" : "\u017D", // LATIN CAPITAL LETTER Z WITH CARON - "\\v{z}" : "\u017E", // LATIN SMALL LETTER Z WITH CARON - "\\v{A}" : "\u01CD", // LATIN CAPITAL LETTER A WITH CARON - "\\v{a}" : "\u01CE", // LATIN SMALL LETTER A WITH CARON - "\\v{I}" : "\u01CF", // LATIN CAPITAL LETTER I WITH CARON - "\\v{i}" : "\u01D0", // LATIN SMALL LETTER I WITH CARON - "\\v{O}" : "\u01D1", // LATIN CAPITAL LETTER O WITH CARON - "\\v{o}" : "\u01D2", // LATIN SMALL LETTER O WITH CARON - "\\v{U}" : "\u01D3", // LATIN CAPITAL LETTER U WITH CARON - "\\v{u}" : "\u01D4", // LATIN SMALL LETTER U WITH CARON - "\\v{G}" : "\u01E6", // LATIN CAPITAL LETTER G WITH CARON - "\\v{g}" : "\u01E7", // LATIN SMALL LETTER G WITH CARON - "\\v{K}" : "\u01E8", // LATIN CAPITAL LETTER K WITH CARON - "\\v{k}" : "\u01E9", // LATIN SMALL LETTER K WITH CARON - "\\k{O}" : "\u01EA", // LATIN CAPITAL LETTER O WITH OGONEK - "\\k{o}" : "\u01EB", // LATIN SMALL LETTER O WITH OGONEK - "\\v{j}" : "\u01F0", // LATIN SMALL LETTER J WITH CARON - "\\'{G}" : "\u01F4", // LATIN CAPITAL LETTER G WITH ACUTE - "\\'{g}" : "\u01F5", // LATIN SMALL LETTER G WITH ACUTE - "\\.{B}" : "\u1E02", // LATIN CAPITAL LETTER B WITH DOT ABOVE - "\\.{b}" : "\u1E03", // LATIN SMALL LETTER B WITH DOT ABOVE - "\\d{B}" : "\u1E04", // LATIN CAPITAL LETTER B WITH DOT BELOW - "\\d{b}" : "\u1E05", // LATIN SMALL LETTER B WITH DOT BELOW - "\\b{B}" : "\u1E06", // LATIN CAPITAL LETTER B WITH LINE BELOW - "\\b{b}" : "\u1E07", // LATIN SMALL LETTER B WITH LINE BELOW - "\\.{D}" : "\u1E0A", // LATIN CAPITAL LETTER D WITH DOT ABOVE - "\\.{d}" : "\u1E0B", // LATIN SMALL LETTER D WITH DOT ABOVE - "\\d{D}" : "\u1E0C", // LATIN CAPITAL LETTER D WITH DOT BELOW - "\\d{d}" : "\u1E0D", // LATIN SMALL LETTER D WITH DOT BELOW - "\\b{D}" : "\u1E0E", // LATIN CAPITAL LETTER D WITH LINE BELOW - "\\b{d}" : "\u1E0F", // LATIN SMALL LETTER D WITH LINE BELOW - "\\c{D}" : "\u1E10", // LATIN CAPITAL LETTER D WITH CEDILLA - "\\c{d}" : "\u1E11", // LATIN SMALL LETTER D WITH CEDILLA - "\\.{F}" : "\u1E1E", // LATIN CAPITAL LETTER F WITH DOT ABOVE - "\\.{f}" : "\u1E1F", // LATIN SMALL LETTER F WITH DOT ABOVE - "\\={G}" : "\u1E20", // LATIN CAPITAL LETTER G WITH MACRON - "\\={g}" : "\u1E21", // LATIN SMALL LETTER G WITH MACRON - "\\.{H}" : "\u1E22", // LATIN CAPITAL LETTER H WITH DOT ABOVE - "\\.{h}" : "\u1E23", // LATIN SMALL LETTER H WITH DOT ABOVE - "\\d{H}" : "\u1E24", // LATIN CAPITAL LETTER H WITH DOT BELOW - "\\d{h}" : "\u1E25", // LATIN SMALL LETTER H WITH DOT BELOW - "\\\"{H}" : "\u1E26", // LATIN CAPITAL LETTER H WITH DIAERESIS - "\\\"{h}" : "\u1E27", // LATIN SMALL LETTER H WITH DIAERESIS - "\\c{H}" : "\u1E28", // LATIN CAPITAL LETTER H WITH CEDILLA - "\\c{h}" : "\u1E29", // LATIN SMALL LETTER H WITH CEDILLA - "\\'{K}" : "\u1E30", // LATIN CAPITAL LETTER K WITH ACUTE - "\\'{k}" : "\u1E31", // LATIN SMALL LETTER K WITH ACUTE - "\\d{K}" : "\u1E32", // LATIN CAPITAL LETTER K WITH DOT BELOW - "\\d{k}" : "\u1E33", // LATIN SMALL LETTER K WITH DOT BELOW - "\\b{K}" : "\u1E34", // LATIN CAPITAL LETTER K WITH LINE BELOW - "\\b{k}" : "\u1E35", // LATIN SMALL LETTER K WITH LINE BELOW - "\\d{L}" : "\u1E36", // LATIN CAPITAL LETTER L WITH DOT BELOW - "\\d{l}" : "\u1E37", // LATIN SMALL LETTER L WITH DOT BELOW - "\\b{L}" : "\u1E3A", // LATIN CAPITAL LETTER L WITH LINE BELOW - "\\b{l}" : "\u1E3B", // LATIN SMALL LETTER L WITH LINE BELOW - "\\'{M}" : "\u1E3E", // LATIN CAPITAL LETTER M WITH ACUTE - "\\'{m}" : "\u1E3F", // LATIN SMALL LETTER M WITH ACUTE - "\\.{M}" : "\u1E40", // LATIN CAPITAL LETTER M WITH DOT ABOVE - "\\.{m}" : "\u1E41", // LATIN SMALL LETTER M WITH DOT ABOVE - "\\d{M}" : "\u1E42", // LATIN CAPITAL LETTER M WITH DOT BELOW - "\\d{m}" : "\u1E43", // LATIN SMALL LETTER M WITH DOT BELOW - "\\.{N}" : "\u1E44", // LATIN CAPITAL LETTER N WITH DOT ABOVE - "\\.{n}" : "\u1E45", // LATIN SMALL LETTER N WITH DOT ABOVE - "\\d{N}" : "\u1E46", // LATIN CAPITAL LETTER N WITH DOT BELOW - "\\d{n}" : "\u1E47", // LATIN SMALL LETTER N WITH DOT BELOW - "\\b{N}" : "\u1E48", // LATIN CAPITAL LETTER N WITH LINE BELOW - "\\b{n}" : "\u1E49", // LATIN SMALL LETTER N WITH LINE BELOW - "\\'{P}" : "\u1E54", // LATIN CAPITAL LETTER P WITH ACUTE - "\\'{p}" : "\u1E55", // LATIN SMALL LETTER P WITH ACUTE - "\\.{P}" : "\u1E56", // LATIN CAPITAL LETTER P WITH DOT ABOVE - "\\.{p}" : "\u1E57", // LATIN SMALL LETTER P WITH DOT ABOVE - "\\.{R}" : "\u1E58", // LATIN CAPITAL LETTER R WITH DOT ABOVE - "\\.{r}" : "\u1E59", // LATIN SMALL LETTER R WITH DOT ABOVE - "\\d{R}" : "\u1E5A", // LATIN CAPITAL LETTER R WITH DOT BELOW - "\\d{r}" : "\u1E5B", // LATIN SMALL LETTER R WITH DOT BELOW - "\\b{R}" : "\u1E5E", // LATIN CAPITAL LETTER R WITH LINE BELOW - "\\b{r}" : "\u1E5F", // LATIN SMALL LETTER R WITH LINE BELOW - "\\.{S}" : "\u1E60", // LATIN CAPITAL LETTER S WITH DOT ABOVE - "\\.{s}" : "\u1E61", // LATIN SMALL LETTER S WITH DOT ABOVE - "\\d{S}" : "\u1E62", // LATIN CAPITAL LETTER S WITH DOT BELOW - "\\d{s}" : "\u1E63", // LATIN SMALL LETTER S WITH DOT BELOW - "\\.{T}" : "\u1E6A", // LATIN CAPITAL LETTER T WITH DOT ABOVE - "\\.{t}" : "\u1E6B", // LATIN SMALL LETTER T WITH DOT ABOVE - "\\d{T}" : "\u1E6C", // LATIN CAPITAL LETTER T WITH DOT BELOW - "\\d{t}" : "\u1E6D", // LATIN SMALL LETTER T WITH DOT BELOW - "\\b{T}" : "\u1E6E", // LATIN CAPITAL LETTER T WITH LINE BELOW - "\\b{t}" : "\u1E6F", // LATIN SMALL LETTER T WITH LINE BELOW - "\\~{V}" : "\u1E7C", // LATIN CAPITAL LETTER V WITH TILDE - "\\~{v}" : "\u1E7D", // LATIN SMALL LETTER V WITH TILDE - "\\d{V}" : "\u1E7E", // LATIN CAPITAL LETTER V WITH DOT BELOW - "\\d{v}" : "\u1E7F", // LATIN SMALL LETTER V WITH DOT BELOW - "\\`{W}" : "\u1E80", // LATIN CAPITAL LETTER W WITH GRAVE - "\\`{w}" : "\u1E81", // LATIN SMALL LETTER W WITH GRAVE - "\\'{W}" : "\u1E82", // LATIN CAPITAL LETTER W WITH ACUTE - "\\'{w}" : "\u1E83", // LATIN SMALL LETTER W WITH ACUTE - "\\\"{W}" : "\u1E84", // LATIN CAPITAL LETTER W WITH DIAERESIS - "\\\"{w}" : "\u1E85", // LATIN SMALL LETTER W WITH DIAERESIS - "\\.{W}" : "\u1E86", // LATIN CAPITAL LETTER W WITH DOT ABOVE - "\\.{w}" : "\u1E87", // LATIN SMALL LETTER W WITH DOT ABOVE - "\\d{W}" : "\u1E88", // LATIN CAPITAL LETTER W WITH DOT BELOW - "\\d{w}" : "\u1E89", // LATIN SMALL LETTER W WITH DOT BELOW - "\\.{X}" : "\u1E8A", // LATIN CAPITAL LETTER X WITH DOT ABOVE - "\\.{x}" : "\u1E8B", // LATIN SMALL LETTER X WITH DOT ABOVE - "\\\"{X}" : "\u1E8C", // LATIN CAPITAL LETTER X WITH DIAERESIS - "\\\"{x}" : "\u1E8D", // LATIN SMALL LETTER X WITH DIAERESIS - "\\.{Y}" : "\u1E8E", // LATIN CAPITAL LETTER Y WITH DOT ABOVE - "\\.{y}" : "\u1E8F", // LATIN SMALL LETTER Y WITH DOT ABOVE - "\\^{Z}" : "\u1E90", // LATIN CAPITAL LETTER Z WITH CIRCUMFLEX - "\\^{z}" : "\u1E91", // LATIN SMALL LETTER Z WITH CIRCUMFLEX - "\\d{Z}" : "\u1E92", // LATIN CAPITAL LETTER Z WITH DOT BELOW - "\\d{z}" : "\u1E93", // LATIN SMALL LETTER Z WITH DOT BELOW - "\\b{Z}" : "\u1E94", // LATIN CAPITAL LETTER Z WITH LINE BELOW - "\\b{z}" : "\u1E95", // LATIN SMALL LETTER Z WITH LINE BELOW - "\\b{h}" : "\u1E96", // LATIN SMALL LETTER H WITH LINE BELOW - "\\\"{t}" : "\u1E97", // LATIN SMALL LETTER T WITH DIAERESIS - "\\d{A}" : "\u1EA0", // LATIN CAPITAL LETTER A WITH DOT BELOW - "\\d{a}" : "\u1EA1", // LATIN SMALL LETTER A WITH DOT BELOW - "\\d{E}" : "\u1EB8", // LATIN CAPITAL LETTER E WITH DOT BELOW - "\\d{e}" : "\u1EB9", // LATIN SMALL LETTER E WITH DOT BELOW - "\\~{E}" : "\u1EBC", // LATIN CAPITAL LETTER E WITH TILDE - "\\~{e}" : "\u1EBD", // LATIN SMALL LETTER E WITH TILDE - "\\d{I}" : "\u1ECA", // LATIN CAPITAL LETTER I WITH DOT BELOW - "\\d{i}" : "\u1ECB", // LATIN SMALL LETTER I WITH DOT BELOW - "\\d{O}" : "\u1ECC", // LATIN CAPITAL LETTER O WITH DOT BELOW - "\\d{o}" : "\u1ECD", // LATIN SMALL LETTER O WITH DOT BELOW - "\\d{U}" : "\u1EE4", // LATIN CAPITAL LETTER U WITH DOT BELOW - "\\d{u}" : "\u1EE5", // LATIN SMALL LETTER U WITH DOT BELOW - "\\`{Y}" : "\u1EF2", // LATIN CAPITAL LETTER Y WITH GRAVE - "\\`{y}" : "\u1EF3", // LATIN SMALL LETTER Y WITH GRAVE - "\\d{Y}" : "\u1EF4", // LATIN CAPITAL LETTER Y WITH DOT BELOW - "\\d{y}" : "\u1EF5", // LATIN SMALL LETTER Y WITH DOT BELOW - "\\~{Y}" : "\u1EF8", // LATIN CAPITAL LETTER Y WITH TILDE - "\\~{y}" : "\u1EF9", // LATIN SMALL LETTER Y WITH TILDE - "\\~{}" : "\u223C", // TILDE OPERATOR - "~" : "\u00A0" // NO-BREAK SPACE -}; - -var alwaysMap = { - "|":"{\\textbar}", - "<":"{\\textless}", - ">":"{\\textgreater}", - "~":"{\\textasciitilde}", - "^":"{\\textasciicircum}", - "\\":"{\\textbackslash}" -}; - -var strings = {}; -var keyRe = /[a-zA-Z0-9\-]/; - -function processField(item, field, value) { - if(Zotero.Utilities.trim(value) == '') return null; - if(fieldMap[field]) { - item[fieldMap[field]] = value; - } else if(inputFieldMap[field]) { - item[inputFieldMap[field]] = value; - } else if(field == "journal") { - if(item.publicationTitle) { - item.journalAbbreviation = value; - } else { - item.publicationTitle = value; - } - } else if(field == "fjournal") { - if(item.publicationTitle) { - // move publicationTitle to abbreviation - item.journalAbbreviation = value; - } - item.publicationTitle = value; - } else if(field == "author" || field == "editor" || field == "translator") { - // parse authors/editors/translators - var names = value.split(/ and /i); // now case insensitive - for(var i in names) { - var name = names[i]; - // skip empty names - if (name.trim() == '') { - continue; - } - // Names in BibTeX can have three commas - pieces = name.split(','); - var creator = {}; - if (pieces.length > 1) { - creator.firstName = pieces.pop().trim(); - creator.lastName = pieces.join(',').trim(); - creator.creatorType = field; - } else { - creator = Zotero.Utilities.cleanAuthor(name, field, false); - } - item.creators.push(creator); - } - } else if(field == "institution" || field == "organization") { - item.backupPublisher = value; - } else if(field == "number"){ // fix for techreport - if (item.itemType == "report") { - item.reportNumber = value; - } else if (item.itemType == "book" || item.itemType == "bookSection") { - item.seriesNumber = value; - } else { - item.issue = value; - } - } else if(field == "month") { - var monthIndex = months.indexOf(value.toLowerCase()); - if(monthIndex != -1) { - value = Zotero.Utilities.formatDate({month:monthIndex}); - } else { - value += " "; - } - - if(item.date) { - if(value.indexOf(item.date) != -1) { - // value contains year and more - item.date = value; - } else { - item.date = value+item.date; - } - } else { - item.date = value; - } - } else if(field == "year") { - if(item.date) { - if(item.date.indexOf(value) == -1) { - // date does not already contain year - item.date += value; - } - } else { - item.date = value; - } - } else if(field == "pages") { - if (item.itemType == "book" || item.itemType == "thesis" || item.itemType == "manuscript") { - item.numPages = value; - } - else { - item.pages = value.replace(/--/g, "-"); - } - } else if(field == "note") { - item.extra += "\n"+value; - } else if(field == "howpublished") { - if(value.length >= 7) { - var str = value.substr(0, 7); - if(str == "http://" || str == "https:/" || str == "mailto:") { - item.url = value; - } else { - item.extra += "\nPublished: "+value; - } - } - } else if(field == "keywords") { - if(value.indexOf(",") == -1) { - // keywords/tags - item.tags = value.split(" "); - } else { - item.tags = value.split(/, ?/g); - } - } else if (field == "comment" || field == "annote" || field == "review") { - item.notes.push({note:Zotero.Utilities.text2html(value)}); - } else if (field == "pdf") { - if (/:\/\//.test(value)) { // a full uri is given - item.attachments = [{url:value, mimeType:"application/pdf", downloadable:true}]; - } else { // if no uri is given, assume that it is an absolute path to the PDF - item.attachments = [{url:"file://"+value, mimeType:"application/pdf"}]; - } - } else if (field == "sentelink") { // the reference manager 'Sente' has a unique file scheme in exported BibTeX - item.attachments = [{url:value.split(",")[0], mimeType:"application/pdf", downloadable:true}]; - } else if (field == "file") { - var attachments = value.split(";"); - for(var i in attachments){ - var attachment = attachments[i]; - var parts = attachment.split(":"); - var filetitle = parts[0]; - var filepath = parts[1]; - if (filepath.trim() === '') continue; // skip empty entries - var filetype = parts[2]; - if (filetitle.length == 0) { - filetitle = "Attachment"; - } - if (filetype.match(/pdf/i)) { - item.attachments.push({url:"file://"+filepath, mimeType:"application/pdf", title:filetitle, downloadable:true}); - } else { - item.attachments.push({url:"file://"+filepath, title:filetitle, downloadable:true}); - } - } - } -} - -function getFieldValue(read) { - var value = ""; - // now, we have the first character of the field - if(read == "{") { - // character is a brace - var openBraces = 1; - while(read = Zotero.read(1)) { - if(read == "{" && value[value.length-1] != "\\") { - openBraces++; - value += "{"; - } else if(read == "}" && value[value.length-1] != "\\") { - openBraces--; - if(openBraces == 0) { - break; - } else { - value += "}"; - } - } else { - value += read; - } - } - } else if(read == '"') { - var openBraces = 0; - while(read = Zotero.read(1)) { - if(read == "{" && value[value.length-1] != "\\") { - openBraces++; - value += "{"; - } else if(read == "}" && value[value.length-1] != "\\") { - openBraces--; - value += "}"; - } else if(read == '"' && openBraces == 0) { - break; - } else { - value += read; - } - } - } - - if(value.length > 1) { - // replace accented characters (yucky slow) - value = value.replace(/{?(\\[`"'^~=a-z]){?\\?([A-Za-z])}/g, "$1{$2}"); - for (var mapped in reversemappingTable) { // really really slow! - var unicode = reversemappingTable[mapped]; - if (value.indexOf(mapped) != -1) { - Zotero.debug("Replace " + mapped + " in " + value + " with " + unicode); - value = value.replace(mapped, unicode, "g"); - } - mapped = mapped.replace(/[{}]/g, ""); - if (value.indexOf(mapped) != -1) { - Zotero.debug("Replace(2) " + mapped + " in " + value + " with " + unicode); - value = value.replace(mapped, unicode, "g"); - } - } - - // kill braces - value = value.replace(/([^\\])[{}]+/g, "$1"); - if(value[0] == "{") { - value = value.substr(1); - } - - // chop off backslashes - value = value.replace(/([^\\])\\([#$%&~_^\\{}])/g, "$1$2"); - value = value.replace(/([^\\])\\([#$%&~_^\\{}])/g, "$1$2"); - if(value[0] == "\\" && "#$%&~_^\\{}".indexOf(value[1]) != -1) { - value = value.substr(1); - } - if(value[value.length-1] == "\\" && "#$%&~_^\\{}".indexOf(value[value.length-2]) != -1) { - value = value.substr(0, value.length-1); - } - value = value.replace(/\\\\/g, "\\"); - value = value.replace(/\s+/g, " "); - } - - return value; -} - -function beginRecord(type, closeChar) { - type = Zotero.Utilities.trimInternal(type.toLowerCase()); - if(type != "string") { - var zoteroType = bibtex2zoteroTypeMap[type]; - if (!zoteroType) { - Zotero.debug("discarded item from BibTeX; type was "+type); - } - var item = new Zotero.Item(zoteroType); - - item.extra = ""; - } - - var field = ""; - - // by setting dontRead to true, we can skip a read on the next iteration - // of this loop. this is useful after we read past the end of a string. - var dontRead = false; - - while(dontRead || (read = Zotero.read(1))) { - dontRead = false; - - if(read == "=") { // equals begin a field - // read whitespace - var read = Zotero.read(1); - while(" \n\r\t".indexOf(read) != -1) { - read = Zotero.read(1); - } - - if(keyRe.test(read)) { - // read numeric data here, since we might get an end bracket - // that we should care about - value = ""; - value += read; - - // character is a number - while((read = Zotero.read(1)) && keyRe.test(read)) { - value += read; - } - - // don't read the next char; instead, process the character - // we already read past the end of the string - dontRead = true; - - // see if there's a defined string - if(strings[value]) value = strings[value]; - } else { - var value = getFieldValue(read); - } - - if(item) { - processField(item, field.toLowerCase(), value); - } else if(type == "string") { - strings[field] = value; - } - field = ""; - } else if(read == ",") { // commas reset - field = ""; - } else if(read == closeChar) { - if(item) { - if(item.extra) item.extra = item.extra.substr(1); // chop \n - item.complete(); - } - return; - } else if(" \n\r\t".indexOf(read) == -1) { // skip whitespace - field += read; - } - } -} - -function doImport() { - var read = "", text = "", recordCloseElement = false; - var type = false; - - while(read = Zotero.read(1)) { - if(read == "@") { - type = ""; - } else if(type !== false) { - if(type == "comment") { - type = false; - } else if(read == "{") { // possible open character - beginRecord(type, "}"); - type = false; - } else if(read == "(") { // possible open character - beginRecord(type, ")"); - type = false; - } else { - type += read; - } - } - } -} - -// some fields are, in fact, macros. If that is the case then we should not put the -// data in the braces as it will cause the macros to not expand properly -function writeField(field, value, isMacro) { - if(!value && typeof value != "number") return; - value = value + ""; // convert integers to strings - Zotero.write(",\n\t"+field+" = "); - if(!isMacro) Zotero.write("{"); - // url field is preserved, for use with \href and \url - // Other fields (DOI?) may need similar treatment - if(!((field == "url") || (field == "doi") | (field == "file"))) { - // I hope these are all the escape characters! - value = value.replace(/[|\<\>\~\^\\]/g, mapEscape).replace(/([\#\$\%\&\_])/g, "\\$1"); - // Case of words with uppercase characters in non-initial positions is preserved with braces. - if(!isMacro&&field != "pages") value = value.replace(/([^\s]+[A-Z][^\s,]*)/g, "{$1}"); - } - if (Zotero.getOption("exportCharset") != "UTF-8") { - value = value.replace(/[\u0080-\uFFFF]/g, mapAccent); - } - Zotero.write(value); - if(!isMacro) Zotero.write("}"); -} - -function mapEscape(character) { - return alwaysMap[character]; -} - -function mapAccent(character) { - return (mappingTable[character] ? mappingTable[character] : "?"); -} - -// a little substitution function for BibTeX keys, where we don't want LaTeX -// escaping, but we do want to preserve the base characters - -function tidyAccents(s) { - var r=s.toLowerCase(); - r = r.replace(new RegExp("[ä]", 'g'),"ae"); - r = r.replace(new RegExp("[ö]", 'g'),"oe"); - r = r.replace(new RegExp("[ü]", 'g'),"ue"); - r = r.replace(new RegExp("[àáâãå]", 'g'),"a"); - r = r.replace(new RegExp("æ", 'g'),"ae"); - r = r.replace(new RegExp("ç", 'g'),"c"); - r = r.replace(new RegExp("[èéêë]", 'g'),"e"); - r = r.replace(new RegExp("[ìíîï]", 'g'),"i"); - r = r.replace(new RegExp("ñ", 'g'),"n"); - r = r.replace(new RegExp("[òóôõ]", 'g'),"o"); - r = r.replace(new RegExp("œ", 'g'),"oe"); - r = r.replace(new RegExp("[ùúû]", 'g'),"u"); - r = r.replace(new RegExp("[ýÿ]", 'g'),"y"); - return r; - }; - -var numberRe = /^[0-9]+/; -// Below is a list of words that should not appear as part of the citation key -// in includes the indefinite articles of English, German, French and Spanish, as well as a small set of English prepositions whose -// force is more grammatical than lexical, i.e. which are likely to strike many as 'insignificant'. -// The assumption is that most who want a title word in their key would prefer the first word of significance. -var citeKeyTitleBannedRe = /\b(a|an|the|some|from|on|in|to|of|do|with|der|die|das|ein|eine|einer|eines|einem|einen|un|une|la|le|l\'|el|las|los|al|uno|una|unos|unas|de|des|del|d\')(\s+|\b)/g; -var citeKeyConversionsRe = /%([a-zA-Z])/; -var citeKeyCleanRe = /[^a-z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+/g; - -var citeKeyConversions = { - "a":function (flags, item) { - if(item.creators && item.creators[0] && item.creators[0].lastName) { - return item.creators[0].lastName.toLowerCase().replace(/ /g,"_").replace(/,/g,""); - } - return ""; - }, - "t":function (flags, item) { - if (item["title"]) { - return item["title"].toLowerCase().replace(citeKeyTitleBannedRe, "").split(/\s+/g)[0]; - } - return ""; - }, - "y":function (flags, item) { - if(item.date) { - var date = Zotero.Utilities.strToDate(item.date); - if(date.year && numberRe.test(date.year)) { - return date.year; - } - } - return "????"; - } -} - - -function buildCiteKey (item,citekeys) { - var basekey = ""; - var counter = 0; - citeKeyFormatRemaining = citeKeyFormat; - while (citeKeyConversionsRe.test(citeKeyFormatRemaining)) { - if (counter > 100) { - Zotero.debug("Pathological BibTeX format: " + citeKeyFormat); - break; - } - var m = citeKeyFormatRemaining.match(citeKeyConversionsRe); - if (m.index > 0) { - //add data before the conversion match to basekey - basekey = basekey + citeKeyFormatRemaining.substr(0, m.index); - } - var flags = ""; // for now - var f = citeKeyConversions[m[1]]; - if (typeof(f) == "function") { - var value = f(flags, item); - Zotero.debug("Got value " + value + " for %" + m[1]); - //add conversion to basekey - basekey = basekey + value; - } - citeKeyFormatRemaining = citeKeyFormatRemaining.substr(m.index + m.length); - counter++; - } - if (citeKeyFormatRemaining.length > 0) { - basekey = basekey + citeKeyFormatRemaining; - } - - // for now, remove any characters not explicitly known to be allowed; - // we might want to allow UTF-8 citation keys in the future, depending - // on implementation support. - // - // no matter what, we want to make sure we exclude - // " # % ' ( ) , = { } ~ and backslash - // however, we want to keep the base characters - - basekey = tidyAccents(basekey); - basekey = basekey.replace(citeKeyCleanRe, ""); - var citekey = basekey; - var i = 0; - while(citekeys[citekey]) { - i++; - citekey = basekey + "-" + i; - } - citekeys[citekey] = true; - return citekey; -} - -function doExport() { - //Zotero.write("% BibTeX export generated by Zotero "+Zotero.Utilities.getVersion()); - // to make sure the BOM gets ignored - Zotero.write("\n"); - - var first = true; - var citekeys = new Object(); - var item; - while(item = Zotero.nextItem()) { - // determine type - var type = zotero2bibtexTypeMap[item.itemType]; - if (typeof(type) == "function") { type = type(item); } - if(!type) type = "misc"; - - // create a unique citation key - var citekey = buildCiteKey(item, citekeys); - - // write citation key - Zotero.write((first ? "" : ",\n\n") + "@"+type+"{"+citekey); - first = false; - - for(var field in fieldMap) { - if(item[fieldMap[field]]) { - writeField(field, item[fieldMap[field]]); - } - } - - if(item.reportNumber || item.issue || item.seriesNumber) { - writeField("number", item.reportNumber || item.issue || item.seriesNumber); - } - - if(item.publicationTitle) { - if(item.itemType == "bookSection" || item.itemType == "conferencePaper") { - writeField("booktitle", item.publicationTitle); - } else { - writeField("journal", item.publicationTitle); - } - } - - if(item.publisher) { - if(item.itemType == "thesis") { - writeField("school", item.publisher); - } else if(item.itemType =="report") { - writeField("institution", item.publisher); - } else { - writeField("publisher", item.publisher); - } - } - - if(item.creators && item.creators.length) { - // split creators into subcategories - var author = ""; - var editor = ""; - var translator = ""; - for(var i in item.creators) { - var creator = item.creators[i]; - var creatorString = creator.lastName; - - if (creator.firstName) { - creatorString = creator.lastName + ", " + creator.firstName; - } - - if (creator.creatorType == "editor") { - editor += " and "+creatorString; - } else if (creator.creatorType == "translator") { - translator += " and "+creatorString; - } else { - author += " and "+creatorString; - } - } - - if(author) { - writeField("author", author.substr(5)); - } - if(editor) { - writeField("editor", editor.substr(5)); - } - if(translator) { - writeField("translator", translator.substr(5)); - } - } - - if(item.date) { - var date = Zotero.Utilities.strToDate(item.date); - // need to use non-localized abbreviation - if(typeof date.month == "number") { - writeField("month", months[date.month], true); - } - if(date.year) { - writeField("year", date.year); - } - } - - if(item.extra) { - writeField("note", item.extra); - } - - if(item.tags && item.tags.length) { - var tagString = ""; - for(var i in item.tags) { - var tag = item.tags[i]; - tagString += ", "+tag.tag; - } - writeField("keywords", tagString.substr(2)); - } - - if(item.pages) { - writeField("pages", item.pages.replace("-","--")); - } - - // Commented out, because we don't want a books number of pages in the BibTeX "pages" field for books. - //if(item.numPages) { - // writeField("pages", item.numPages); - //} - - if(item.itemType == "webpage") { - writeField("howpublished", item.url); - } - if (item.notes && Zotero.getOption("exportNotes")) { - for(var i in item.notes) { - var note = item.notes[i]; - writeField("annote", Zotero.Utilities.unescapeHTML(note["note"])); - } - } - - if(Zotero.getOption("exportFileData")) { - if(item.attachments) { - var attachmentString = ""; - - for(var i in item.attachments) { - var attachment = item.attachments[i]; - if(attachment.defaultPath) { // For Zotero 3.0 - attachment.saveFile(attachment.defaultPath, true); - attachmentString += ";" + attachment.title + ":" + attachment.defaultPath + ":" + attachment.mimeType; - } else if(attachment.path) { // For Zotero 2.1 - attachmentString += ";" + attachment.title + ":" + attachment.path + ":" + attachment.mimeType; - } - } - - if(attachmentString) { - writeField("file", attachmentString.substr(1)); - } - } - } - - Zotero.write("\n}"); - } -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "import", - "input": "@article{Adams2001,\u000aauthor = {Adams, Nancy K and DeSilva, Shanaka L and Self, Steven and Salas, Guido and Schubring, Steven and Permenter, Jason L and Arbesman, Kendra},\u000afile = {:Users/heatherwright/Documents/Scientific Papers/Adams\\_Huaynaputina.pdf:pdf;::},\u000ajournal = {Bulletin of Volcanology},\u000akeywords = {Vulcanian eruptions,breadcrust,plinian},\u000apages = {493--518},\u000atitle = {{The physical volcanology of the 1600 eruption of Huaynaputina, southern Peru}},\u000avolume = {62},\u000ayear = {2001}\u000a}", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Nancy K", - "lastName": "Adams", - "creatorType": "author" - }, - { - "firstName": "Shanaka L", - "lastName": "DeSilva", - "creatorType": "author" - }, - { - "firstName": "Steven", - "lastName": "Self", - "creatorType": "author" - }, - { - "firstName": "Guido", - "lastName": "Salas", - "creatorType": "author" - }, - { - "firstName": "Steven", - "lastName": "Schubring", - "creatorType": "author" - }, - { - "firstName": "Jason L", - "lastName": "Permenter", - "creatorType": "author" - }, - { - "firstName": "Kendra", - "lastName": "Arbesman", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Vulcanian eruptions", - "breadcrust", - "plinian" - ], - "seeAlso": [], - "attachments": [ - { - "url": "file://Users/heatherwright/Documents/Scientific Papers/Adams_Huaynaputina.pdf", - "mimeType": "application/pdf", - "title": "Attachment", - "downloadable": true - }, - { - "url": "file://", - "title": "Attachment", - "downloadable": true - } - ], - "publicationTitle": "Bulletin of Volcanology", - "pages": "493–518", - "title": "The physical volcanology of the 1600 eruption of Huaynaputina, southern Peru", - "volume": "62", - "date": "2001" - } - ] - }, - { - "type": "import", - "input": "@Book{abramowitz+stegun,\u000a author = \"Milton {Abramowitz} and Irene A. {Stegun}\",\u000a title = \"Handbook of Mathematical Functions with\u000a Formulas, Graphs, and Mathematical Tables\",\u000a publisher = \"Dover\",\u000a year = 1964,\u000a address = \"New York\",\u000a edition = \"ninth Dover printing, tenth GPO printing\"\u000a}\u000a\u000a@Book{Torre2008,\u000a author = \"Joe Torre and Tom Verducci\",\u000a publisher = \"Doubleday\",\u000a title = \"The Yankee Years\",\u000a year = 2008,\u000a isbn = \"0385527403\"\u000a}\u000a", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Milton", - "lastName": "Abramowitz", - "creatorType": "author" - }, - { - "firstName": "Irene A.", - "lastName": "Stegun", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "title": "Handbook of Mathematical Functions with Formulas, Graphs, and Mathematical Tables", - "publisher": "Dover", - "date": "1964", - "place": "New York", - "edition": "ninth Dover printing, tenth GPO printing" - }, - { - "itemType": "book", - "creators": [ - { - "firstName": "Joe", - "lastName": "Torre", - "creatorType": "author" - }, - { - "firstName": "Tom", - "lastName": "Verducci", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "publisher": "Doubleday", - "title": "The Yankee Years", - "date": "2008", - "ISBN": "0385527403" - } - ] - }, - { - "type": "import", - "input": "@INPROCEEDINGS {author:06,\u000a title = {Some publication title},\u000a author = {First Author and Second Author},\u000a crossref = {conference:06},\u000a pages = {330—331},\u000a}\u000a@PROCEEDINGS {conference:06,\u000a editor = {First Editor and Second Editor},\u000a title = {Proceedings of the Xth Conference on XYZ},\u000a booktitle = {Proceedings of the Xth Conference on XYZ},\u000a year = {2006},\u000a month = oct,\u000a}", - "items": [ - { - "itemType": "conferencePaper", - "creators": [ - { - "firstName": "First", - "lastName": "Author", - "creatorType": "author" - }, - { - "firstName": "Second", - "lastName": "Author", - "creatorType": "author" - }, - { - "firstName": "First", - "lastName": "Editor", - "creatorType": "editor" - }, - { - "firstName": "Second", - "lastName": "Editor", - "creatorType": "editor" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "title": "Some publication title", - "date": "October 2006", - "proceedingsTitle": "Proceedings of the Xth Conference on XYZ", - "pages": "330—331" - }, - { - "itemType": "book", - "creators": [ - { - "firstName": "First", - "lastName": "Editor", - "creatorType": "editor" - }, - { - "firstName": "Second", - "lastName": "Editor", - "creatorType": "editor" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "title": "Proceedings of the Xth Conference on XYZ", - "publicationTitle": "Proceedings of the Xth Conference on XYZ", - "date": "October 2006" - } - ] - }, - { - "type": "import", - "input": "@Book{hicks2001,\u000a author = \"von Hicks, III, Michael\",\u000a title = \"Design of a Carbon Fiber Composite Grid Structure for the GLAST\u000a Spacecraft Using a Novel Manufacturing Technique\",\u000a publisher = \"Stanford Press\",\u000a year = 2001,\u000a address = \"Palo Alto\",\u000a edition = \"1st,\",\u000a isbn = \"0-69-697269-4\"\u000a}", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Michael", - "lastName": "von Hicks, III", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "title": "Design of a Carbon Fiber Composite Grid Structure for the GLAST Spacecraft Using a Novel Manufacturing Technique", - "publisher": "Stanford Press", - "date": "2001", - "place": "Palo Alto", - "edition": "1st,", - "ISBN": "0-69-697269-4" - } - ] - }, - { - "type": "import", - "input": "@article{Oliveira_2009, title={USGS monitoring ecological impacts}, volume={107}, number={29}, journal={Oil & Gas Journal}, author={Oliveira, A}, year={2009}, pages={29}}", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "A", - "lastName": "Oliveira", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "title": "USGS monitoring ecological impacts", - "volume": "107", - "issue": "29", - "publicationTitle": "Oil & Gas Journal", - "date": "2009", - "pages": "29" - } - ] - }, - { - "type": "import", - "input": "@article{test-ticket1661,\u000atitle={non-braking space: ~; accented characters: {\\~n} and \\~{n}; tilde operator: \\~},\u000a} ", - "items": [ - { - "itemType": "journalArticle", - "creators": [], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "title": "non-braking space: ; accented characters: ñ and ñ; tilde operator: ∼" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Biblio.com.js b/translators/Biblio.com.js @@ -1,125 +0,0 @@ -{ - "translatorID":"9932d1a7-cc6d-4d83-8462-8f6658b13dc0", - "translatorType":4, - "label":"Biblio.com", - "creator":"Adam Crymble and Michael Berkowitz", - "target":"http://www.biblio.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-07 14:50:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("bookseller_search") || doc.location.href.match("bookstores") || doc.location.href.match("textbooks")) { - - } else if (doc.location.href.match("search")) { - return "multiple"; - } else if (doc.location.href.match("books")) { - return "book"; - } -} - -//Biblio.com translator. Code by Adam Crymble. - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var contents = new Array(); - var multiAuthors = new Array(); - var fieldTitle; - var author1; - - var newItem = new Zotero.Item("book"); - - var content = doc.evaluate('//div[@class="smalltext1"][@id="infobox"]/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//div[@class="smalltext1"][@id="infobox"]/ul/li)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue; i++) { - - contents = content.iterateNext().textContent.split(": "); - fieldTitle = contents[0].replace(/\s*/g, ''); - dataTags[fieldTitle] = contents[1].replace(/^\s*|\s*$/g, ''); - } - - //Authors - if (doc.evaluate('//td[2]/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var authors = doc.evaluate('//td[2]/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (authors.match(/\w/)) { - if (authors.match(/^ by/)) { - authors = authors.substr(4); - if (authors.match(/;/)) { - multiAuthors = authors.split(";"); - Zotero.debug(multiAuthors); - for each (var aut in multiAuthors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true)); - } - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "author", true)); - } - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "author")); - } - } - - } - - //extra - if (dataTags["Quantityavailable"]) { - newItem.extra = "Quantity Available: " + dataTags["Quantityavailable"]; - } - - associateData (newItem, dataTags, "Publisher", "publisher"); - associateData (newItem, dataTags, "Place", "place"); - associateData (newItem, dataTags, "Datepublished", "date"); - associateData (newItem, dataTags, "ISBN10", "ISBN"); - associateData (newItem, dataTags, "ISBN13", "ISBN"); - associateData (newItem, dataTags, "Pages", "pages"); - associateData (newItem, dataTags, "Edition", "edition"); - - newItem.title = doc.evaluate('//tbody/tr[1]/td[2]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s&+/g, ''); - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//table[@class="search-result"]/tbody/tr/td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.textContent.match(/\w/)) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Bibliontology RDF.js b/translators/Bibliontology RDF.js @@ -1,1059 +0,0 @@ -{ - "translatorID":"14763d25-8ba0-45df-8f52-b8d1108e7ac9", - "translatorType":3, - "label":"Bibliontology RDF", - "creator":"Simon Kornblith", - "target":"rdf", - "minVersion":"2.0", - "maxVersion":"", - "priority":50, - "browserSupport":"gcs", - "configOptions":{"getCollections":"true", "dataMode":"rdf/xml"}, - "displayOptions":{"exportNotes":true, "exportFileData":false}, - "inRepository":false, - "lastUpdated":"2011-07-08 04:50:39" -} - -var n = { - address:"http://schemas.talis.com/2005/address/schema#", // could also use vcard? - bibo:"http://purl.org/ontology/bibo/", - ctag:"http://commontag.org/ns#", - dcterms:"http://purl.org/dc/terms/", - doap:"http://usefulinc.com/ns/doap#", - foaf:"http://xmlns.com/foaf/0.1/", - link:"http://purl.org/rss/1.0/modules/link/", - po:"http://purl.org/ontology/po/", - rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#", - rel:"http://www.loc.gov/loc.terms/relators/", - res:"http://purl.org/vocab/resourcelist/schema#", - sc:"http://umbel.org/umbel/sc/", - sioct:"http://rdfs.org/sioc/types#", - z:"http://www.zotero.org/namespaces/export#" -}; - -/** - Types should be in the form - - <ZOTERO_TYPE>: [<ITEM_CLASS>, <SUBCONTAINER_CLASS>, <CONTAINER_CLASS>] - - Item classes should be in the form - - [[<PREDICATE>, <OBJECT>]+] - - This generates the triples - - (ITEM <PREDICATE> <OBJECT>)+ - - Subcontainer and container classes should be in the form - - [<ALWAYS_INCLUDE>, <ITEM_PREDICATE>, [<CONTAINER_PREDICATE>, <CONTAINER_OBJECT>]*] | null - - If there is a property to be applied to the container, or if <ALWAYS_INCLUDE> is true, then this - generates - - ITEM <ITEM_PREDICATE> CONTAINER - (CONTAINER <CONTAINER_PREDICATE> <CONTAINER_OBJECT>)* - **/ - -// ZOTERO TYPE ITEM CLASS SUBCONTAINER CLASS CONTAINER CLASS -var TYPES = { - "artwork": [[[n.rdf+"type", n.bibo+"Image"]], null, null], - "attachment": [[[n.rdf+"type", n.z+"Attachment"]], null, null], - "audioRecording": [[[n.rdf+"type", n.bibo+"AudioDocument"]], null, null], - "bill": [[[n.rdf+"type", n.bibo+"Bill"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"Code"]]]], - "blogPost": [[[n.rdf+"type", n.sioct+"BlogPost"], - [n.rdf+"type", n.bibo+"Article"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.sioct+"Weblog"], - [n.rdf+"type", n.bibo+"Website"]]]], - "book": [[[n.rdf+"type", n.bibo+"Book"]], null, null], - "bookSection": [[[n.rdf+"type", n.bibo+"BookSection"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"EditedBook"]]]], - "case": [[[n.rdf+"type", n.bibo+"LegalCaseDocument"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"CourtReporter"]]]], - "computerProgram": [[[n.rdf+"type", n.sc+"ComputerProgram_CW"], - [n.rdf+"type", n.bibo+"Document"]], null, null], - "conferencePaper": [[[n.rdf+"type", n.bibo+"Article"]], null, [true, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"Proceedings"]]]], - "dictionaryEntry": [[[n.rdf+"type", n.bibo+"Article"]], null, [true, n.dcterms+"isPartOf", [[n.rdf+"type", n.sc+"Dictionary"], - [n.rdf+"type", n.bibo+"ReferenceSource"]]]], - "document": [[[n.rdf+"type", n.bibo+"Document"]], null, null], - "email": [[[n.rdf+"type", n.bibo+"Email"]], null, null], - "encyclopediaArticle": [[[n.rdf+"type", n.bibo+"Article"]], null, [true, n.dcterms+"isPartOf", [[n.rdf+"type", n.sc+"Encyclopedia"], - [n.rdf+"type", n.bibo+"ReferenceSource"]]]], - "forumPost": [[[n.rdf+"type", n.sioct+"BoardPost"], - [n.rdf+"type", n.bibo+"Article"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.sioct+"MessageBoard"], - [n.rdf+"type", n.bibo+"Website"]]]], - "film": [[[n.rdf+"type", n.bibo+"Film"]], null, null], - "hearing": [[[n.rdf+"type", n.bibo+"Hearing"]], null, null], - "instantMessage": [[[n.rdf+"type", n.sioct+"InstantMessage"], - [n.rdf+"type", n.bibo+"PersonalCommunication"]], null, null], - "interview": [[[n.rdf+"type", n.bibo+"Interview"]], null, null], - "journalArticle": [[[n.rdf+"type", n.bibo+"AcademicArticle"]], [true, n.dcterms+"isPartOf", - [[n.rdf+"type", n.bibo+"Issue"]]], [true, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"Journal"]]]], - "letter": [[[n.rdf+"type", n.bibo+"Letter"]], null, null], - "magazineArticle": [[[n.rdf+"type", n.bibo+"Article"]], [true, n.dcterms+"isPartOf", - [[n.rdf+"type", n.bibo+"Issue"]]], [true, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"Magazine"]]]], - "manuscript": [[[n.rdf+"type", n.bibo+"Manuscript"]], null, null], - "map": [[[n.rdf+"type", n.bibo+"Map"]], null, null], - "newspaperArticle": [[[n.rdf+"type", n.bibo+"Article"]], [true, n.dcterms+"isPartOf", - [[n.rdf+"type", n.bibo+"Issue"]]], [true, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"Newspaper"]]]], - "note": [[[n.rdf+"type", n.bibo+"Note"]], null, null], - "patent": [[[n.rdf+"type", n.bibo+"Patent"]], null, null], - "podcast": [[[n.rdf+"type", n.z+"Podcast"], - [n.rdf+"type", n.bibo+"AudioDocument"]], null, null], - "presentation": [[[n.rdf+"type", n.bibo+"Slideshow"]], null, null], - "radioBroadcast": [[[n.rdf+"type", n.po+"AudioDocument"], - [n.rdf+"type", n.po+"Episode"], - [n.po+"broadcast_on", n.po+"Radio"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.po+"Programme"]]]], - "report": [[[n.rdf+"type", n.bibo+"Report"]], null, null], - "statute": [[[n.rdf+"type", n.bibo+"Statute"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"Code"]]]], - "thesis": [[[n.rdf+"type", n.bibo+"Thesis"]], null, null], - "tvBroadcast": [[[n.rdf+"type", n.bibo+"AudioVisualDocument"], - [n.rdf+"type", n.po+"Episode"], - [n.po+"broadcast_on", n.po+"TV"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.po+"Programme"]]]], - "videoRecording": [[[n.rdf+"type", n.bibo+"AudioVisualDocument"]], null, null], - "webpage": [[[n.rdf+"type", n.bibo+"Webpage"]], null, [false, n.dcterms+"isPartOf", [[n.rdf+"type", n.bibo+"Website"]]]] -}; - -/** - * This is just a map of un-namespaced BIBO item types to Zotero item types - */ -var BIBO_TYPES = { - "Article": "magazineArticle", - "Brief": "case", - "Chapter": "bookSection", - "CollectedDocument": "document", - "DocumentPart": "document", - "EditedBook": "book", - "Excerpt": "note", - "Quote": "note", - "Film": "videoRecording", - "LegalDecision": "case", - "LegalDocument": "case", - "Legislation": "bill", - "Manual": "book", - "Performance": "presentation", - "PersonalCommunication": "letter", - "PersonalCommunicationDocument": "letter", - "Slide": "presentation", - "Standard": "report", - "Website": "webpage" -}; - -var USERITEM = 1; -var ITEM = 2; -var SUBCONTAINER = 3; -var CONTAINER = 4; -var ITEM_SERIES = 5; -var SUBCONTAINER_SERIES = 6; // not used -var CONTAINER_SERIES = 7; - -/** - Fields should be in the form - - <ZOTERO_FIELD>: ([<SUBJECT>, <PREDICATE>] | <FUNCTION>) - - If a <FUNCTION> is specified, then it is passed the item and should return a set of triples in - the form - - [[<SUBJECT>, <PREDICATE>, <OBJECT>, <LITERAL>]*] - - where <SUBJECT> refers to one of the constants defined above. If <LITERAL> is true, then - <OBJECT> is treated as a literal. - - If a <FUNCTION> is not used and <PREDICATE> is a string, then the parameters generate a triple - in the form - - <SUBJECT> <PREDICATE> FIELD_CONTENT - - where <SUBJECT> refers to one of the constants defined above. Alternatively, <PREDICATE> may be - an array in the form - - [<ITEM_PREDICATE>, [<BLANK_NODE_PREDICATE>, <BLANK_NODE_OBJECT>]*, <PREDICATE>] - - This generates the triples - - <SUBJECT> <ITEM_PREDICATE> <BLANK_NODE> - (<BLANK_NODE> <BLANK_NODE_PREDICATE> <BLANK_NODE_OBJECT>)* - <BLANK_NODE> <PREDICATE> FIELD_CONTENT -**/ -var FIELDS = { - "url": [ITEM, n.bibo+"uri"], - "rights": [USERITEM, n.dcterms+"rights"], - "series": [CONTAINER_SERIES, n.dcterms+"title"], - "volume": [SUBCONTAINER, n.bibo+"volume"], - "issue": [SUBCONTAINER, n.bibo+"issue"], - "edition": [SUBCONTAINER, n.bibo+"edition"], - "place": [CONTAINER, [n.dcterms+"publisher", [[n.rdf+"type", n.foaf+"Organization"]], n.address+"localityName"]], - "country": [CONTAINER, [n.dcterms+"publisher", [[n.rdf+"type", n.foaf+"Organization"]], n.address+"countryName"]], - "publisher": [CONTAINER, [n.dcterms+"publisher", [[n.rdf+"type", n.foaf+"Organization"]], n.foaf+"name"]], - "pages": [ITEM, n.bibo+"pages"], - "firstPage": [ITEM, n.bibo+"pageStart"], - "ISBN": [function(item) { - var isbns = item.ISBN.split(/, ?| /g); - var triples = []; - for each(var isbn in isbns) { - if(isbn.length == 10) { - triples.push([CONTAINER, n.bibo+"isbn10", isbn, true]); - } else { - triples.push([CONTAINER, n.bibo+"isbn13", isbn, true]); - } - } - return triples; - }, function(nodes) { - var isbns = []; - for each(var prop in [n.bibo+"isbn13", n.bibo+"isbn10"]) { - var statements = Zotero.RDF.getStatementsMatching(nodes[CONTAINER], prop, null); - if(statements) { - for each(var statement in statements) { - isbns.push(statement[2]); - } - } - } - if(!isbns.length) return false; - return isbns.join(", "); - }], - "publicationTitle": [CONTAINER, n.dcterms+"title"], - "ISSN": [CONTAINER, n.bibo+"issn"], - "date": [SUBCONTAINER, n.dcterms+"date"], - "section": [ITEM, n.bibo+"section"], - "callNumber": [SUBCONTAINER, n.bibo+"lccn"], - "archiveLocation": [ITEM, n.dcterms+"source"], - "distributor": [SUBCONTAINER, n.bibo+"distributor"], - "extra": [ITEM, n.z+"extra"], - "journalAbbreviation": [CONTAINER, n.bibo+"shortTitle"], - "DOI": [ITEM, n.bibo+"doi"], - "accessDate": [USERITEM, n.z+"accessDate"], - "seriesTitle": [ITEM_SERIES, n.dcterms+"title"], - "seriesText": [ITEM_SERIES, n.dcterms+"description"], - "seriesNumber": [CONTAINER_SERIES, n.bibo+"number"], - "code": [CONTAINER, n.dcterms+"title"], - "session": [ITEM, [n.bibo+"presentedAt", [[n.rdf+"type", n.bibo+"Conference"]], n.dcterms+"title"]], - "legislativeBody": [ITEM, [n.bibo+"organizer", [[n.rdf+"type", n.sc+"LegalGovernmentOrganization"], [n.rdf+"type", n.foaf+"Organization"]], n.foaf+"name"]], - "history": [ITEM, n.z+"history"], - "reporter": [CONTAINER, n.dcterms+"title"], - "court": [CONTAINER, n.bibo+"court"], - "numberOfVolumes": [CONTAINER_SERIES, n.bibo+"numberOfVolumes"], - "committee": [ITEM, [n.bibo+"organizer", [[n.rdf+"type", n.sc+"Committee_Organization"], [n.rdf+"type", n.foaf+"Organization"]], n.foaf+"name"]], - "assignee": [ITEM, n.z+"assignee"], // TODO - "priorityNumbers": [function(item) { // TODO - var priorityNumbers = item.priorityNumbers.split(/, ?| /g); - var returnNumbers = []; - for each(var number in priorityNumbers) { - returnNumbers.push([ITEM, n.z+"priorityNumber", number, true]); - } - return returnNumbers; - }, function(nodes) { - var statements = Zotero.RDF.getStatementsMatching(nodes[ITEM], n.z+"priorityNumber", null); - if(!statements) return false; - var predicates = []; - for each(var statement in statements) { - predicates.push(statement[2]); - } - return predicates.join(", "); - }], - "references": [ITEM, n.z+"references"], - "legalStatus": [ITEM, n.bibo+"status"], - "codeNumber": [CONTAINER, n.bibo+"number"], - "number": [ITEM, n.bibo+"number"], - "artworkSize": [ITEM, n.dcterms+"extent"], - "libraryCatalog": [USERITEM, n.z+"repository"], - "archive": [ITEM, n.z+"repository"], - "scale": [ITEM, n.z+"scale"], - "meetingName": [ITEM, [n.bibo+"presentedAt", [[n.rdf+"type", n.bibo+"Conference"]], n.dcterms+"title"]], - "runningTime": [ITEM, n.po+"duration"], - "version": [ITEM, n.doap+"revision"], - "system": [ITEM, n.doap+"os"], - "conferenceName": [ITEM, [n.bibo+"presentedAt", [[n.rdf+"type", n.bibo+"Conference"]], n.dcterms+"title"]], - "language": [ITEM, n.dcterms+"language"], - "programmingLanguage": [ITEM, n.doap+"programming-language"], - "abstractNote": [ITEM, n.dcterms+"abstract"], - "type": [ITEM, n.dcterms+"type"], - "medium": [ITEM, n.dcterms+"medium"], - "title": [ITEM, n.dcterms+"title"], - "shortTitle": [ITEM, n.bibo+"shortTitle"], - "numPages": [ITEM, n.bibo+"numPages"], - "applicationNumber": [ITEM, n.z+"applicationNumber"], - "issuingAuthority": [ITEM, [n.bibo+"issuer", [[n.rdf+"type", n.foaf+"Organization"]], n.foaf+"name"]], - "filingDate": [ITEM, n.dcterms+"dateSubmitted"] -}; - -var AUTHOR_LIST = 1; -var EDITOR_LIST = 2; -var CONTRIBUTOR_LIST = 3; -var CREATOR_LISTS = { - 1:n.bibo+"authorList", - 2:n.bibo+"editorList", - 3:n.bibo+"contributorList" -}; - -var CREATORS = { - "author": [ITEM, AUTHOR_LIST, n.dcterms+"creator"], - "attorneyAgent": [ITEM, CONTRIBUTOR_LIST, n.z+"attorneyAgent"], - "bookAuthor": [CONTAINER, AUTHOR_LIST, n.dcterms+"creator"], - "castMember": [ITEM, CONTRIBUTOR_LIST, n.rel+"ACT"], - "commenter": [ITEM, CONTRIBUTOR_LIST, [n.sioct+"has_reply", [[n.rdf+"type", n.sioct+"Comment"]], n.dcterms+"creator"]], - "composer": [ITEM, CONTRIBUTOR_LIST, n.rel+"CMP"], - "contributor": [ITEM, CONTRIBUTOR_LIST, n.dcterms+"contributor"], - "cosponsor": [ITEM, CONTRIBUTOR_LIST, n.rel+"SPN"], - "counsel": [ITEM, CONTRIBUTOR_LIST, n.z+"counsel"], - "director": [ITEM, CONTRIBUTOR_LIST, n.bibo+"director"], - "editor": [SUBCONTAINER, EDITOR_LIST, n.bibo+"editor"], - "guest": [ITEM, CONTRIBUTOR_LIST, n.po+"participant"], - "interviewer": [ITEM, CONTRIBUTOR_LIST, n.bibo+"interviewer"], - "interviewee": [ITEM, CONTRIBUTOR_LIST, n.bibo+"interviewee"], - "performer": [ITEM, CONTRIBUTOR_LIST, n.bibo+"performer"], - "producer": [ITEM, CONTRIBUTOR_LIST, n.bibo+"producer"], - "recipient": [ITEM, CONTRIBUTOR_LIST, n.bibo+"recipient"], - "reviewedAuthor": [ITEM, CONTRIBUTOR_LIST, [n.bibo+"reviewOf", [], n.dcterms+"creator"]], - "scriptwriter": [ITEM, CONTRIBUTOR_LIST, n.rel+"AUS"], - "seriesEditor": [CONTAINER_SERIES, EDITOR_LIST, n.bibo+"editor"], - "translator": [SUBCONTAINER, CONTRIBUTOR_LIST, n.bibo+"translator"], - "wordsBy": [ITEM, CONTRIBUTOR_LIST, n.rel+"LYR"] -}; - -var SAME_ITEM_RELATIONS = [n.dcterms+"isPartOf", n.dcterms+"isVersionOf", n.bibo+"affirmedBy", - n.bibo+"presentedAt", n.bibo+"presents", n.bibo+"reproducedIn", - n.bibo+"reviewOf", n.bibo+"translationOf", n.bibo+"transcriptOf"]; - -/** COMMON FUNCTIONS **/ - -var BIBO_NS_LENGTH = n.bibo.length; -var RDF_TYPE = n.rdf+"type"; - -function getBlankNode(attachToNode, itemPredicate, blankNodePairs, create) { - // check if a node with the same relation and properties already exists - var blankNode = null; - // look for blank node - var statements1 = Zotero.RDF.getStatementsMatching(attachToNode, itemPredicate, undefined); - for each(var statement1 in statements1) { - // look for appropriate statements on the blank node - var testNode = statement1[2]; - var statements2 = true; - for each(var pair in blankNodePairs) { - statements2 = Zotero.RDF.getStatementsMatching(testNode, pair[0], pair[1], false, true); - if(!statements2) break; - } - if(statements2) { - // if statements are good, then this is our node - blankNode = testNode; - break; - } - } - - // if no suitable node exists, generate a new one and add blank node statements - if(!blankNode && create) { - blankNode = Zotero.RDF.newResource(); - Zotero.RDF.addStatement(attachToNode, itemPredicate, blankNode, false); - for each(var pair in blankNodePairs) { - Zotero.RDF.addStatement(blankNode, pair[0], pair[1], false); - } - } - - return blankNode; -} - -/** - * A class representing a Zotero-to-BIBO type mapping - * @property zoteroType {String} The corresponding Zotero type name - */ -Type = function(type, typeDefinition) { - this.zoteroType = type; - this[ITEM] = {"pairs":typeDefinition[0]}; - this[SUBCONTAINER] = typeDefinition[1] ? {"alwaysAdd":typeDefinition[1][0], - "predicate":typeDefinition[1][1], - "pairs":typeDefinition[1][2]} : null; - this[CONTAINER] = typeDefinition[2] ? {"alwaysAdd":typeDefinition[2][0], - "predicate":typeDefinition[2][1], - "pairs":typeDefinition[2][2]} : null; -} - -/** - * Score a node to determine how well it matches our type definition - * @returns {[Integer, Object]} The score, and an object containing ITEM, SUBCONTAINER, and - * CONTAINER nodes - */ -Type.prototype.getMatchScore = function(node) { - var nodes = {2:node}; - - // check item (+2 for each match, -1 for each nonmatch) - var score = -this[ITEM].pairs.length; - for each(var pair in this[ITEM].pairs) { - if(Zotero.RDF.getStatementsMatching(node, pair[0], pair[1])) score += 3; - } - - // check subcontainer - [score, nodes[SUBCONTAINER]] = this._scoreNodeRelationship(node, this[SUBCONTAINER], score); - // check container - [score, nodes[CONTAINER]] = this._scoreNodeRelationship( - (nodes[SUBCONTAINER] ? nodes[SUBCONTAINER] : nodes[ITEM]), this[CONTAINER], score); - - if(!nodes[CONTAINER]) nodes[CONTAINER] = nodes[ITEM]; - if(!nodes[SUBCONTAINER]) nodes[SUBCONTAINER] = nodes[CONTAINER]; - - return [score, nodes]; -} - -/** - * Score a CONTAINER/SUBCONTAINTER node - * @returns {[Integer, Object]} The score, and the node (if it existed) - */ -Type.prototype._scoreNodeRelationship = function(node, definition, score) { - var subNode = null; - if(definition) { - statements = Zotero.RDF.getStatementsMatching(node, definition.predicate, null); - if(statements) { - var bestScore = -9999; - for each(var statement in statements) { - // +2 for each match, -1 for each nonmatch - var testScore = -definition.pairs.length; - for each(var pair in definition.pairs) { - if(Zotero.RDF.getStatementsMatching(statement[2], pair[0], pair[1])) score += 3; - } - - if(testScore > bestScore) { - subNode = statement[2]; - bestScore = testScore; - } - } - score += bestScore; - } else if(definition.alwaysAdd) { - score -= definition.pairs.length; - } - } - return [score, subNode]; -} - -/** - * Get USERITEM and SERIES nodes for this type - */ -Type.prototype.getItemSeriesNodes = function(nodes) { - const seriesDefinition = {"alwaysAdd":true, "predicate":n.dcterms+"isPartOf", "pairs":[[n.rdf+"type", n.bibo+"Series"]]}; - - // get user item node - var stmt = Zotero.RDF.getStatementsMatching(null, n.res+"resource", nodes[ITEM]); - nodes[USERITEM] = stmt ? stmt[0][0] : nodes[ITEM]; - - // get ITEM_SERIES node - var score, subNode; - [score, subNode] = this._scoreNodeRelationship(nodes[ITEM], seriesDefinition, 0); - //Zotero.debug("got itemSeries with score "+score); - if(score >= 1) nodes[ITEM_SERIES] = subNode; - - // get SUBCONTAINER_SERIES node - [score, subNode] = this._scoreNodeRelationship(nodes[SUBCONTAINER], seriesDefinition, 0); - //Zotero.debug("got subcontainerSeries with score "+score); - if(score >= 1) nodes[CONTAINER_SERIES] = subNode; - - // get CONTAINER_SERIES node - [score, subNode] = this._scoreNodeRelationship(nodes[CONTAINER], seriesDefinition, 0); - //Zotero.debug("got containerSeries with score "+score); - if(score >= 1) nodes[CONTAINER_SERIES] = subNode; -} - -/** - * Add triples to relate nodes. Called after all properties have been added, so we know which nodes - * need to be related. - */ -Type.prototype.addNodeRelations = function(nodes) { - // add node relations - for each(var i in [ITEM_SERIES, SUBCONTAINER_SERIES, CONTAINER_SERIES]) { - // don't add duplicate nodes - if(!this[i-3]) continue; - // don't add nodes with no arcs - if(!Zotero.RDF.getArcsOut(nodes[i])) continue; - Zotero.RDF.addStatement(nodes[i], RDF_TYPE, n.bibo+"Series", false); - Zotero.RDF.addStatement(nodes[i-3], n.dcterms+"isPartOf", nodes[i], false); - } - - for each(var i in [ITEM, SUBCONTAINER, CONTAINER]) { - if(nodes[i]) { - // find predicate - if(i == ITEM) { - var j = 1; - var predicate = n.res+"resource"; - } else if(i == SUBCONTAINER || i == CONTAINER) { - // don't add duplicate nodes - if(!this[i]) continue; - // don't add nodes with no arcs - if(!this[i][0] && !Zotero.RDF.getArcsOut(nodes[i])) { - nodes[i] = nodes[i-1]; - continue; - } - - var predicate = this[i].predicate; - } - - // add type - for each(var pair in this[i].pairs) { - Zotero.RDF.addStatement(nodes[i], pair[0], pair[1], false) - } - - // add relation to parent - for(var j = i-1; j>1; j--) { - if(nodes[j] != nodes[i]) { - Zotero.RDF.addStatement(nodes[j], predicate, nodes[i], false); - break; - } - } - } - } -} - -/** - * Create USERITEM/ITEM/CONTAINER/SUBCONTAINER nodes for this type - * @returns {Object} The created nodes - */ -Type.prototype.createNodes = function(item) { - var nodes = {}; - nodes[USERITEM] = (item.uri ? item.uri : "#item_"+item.itemID); - - // come up with an item node URI - nodes[ITEM] = null; - // try the URL as URI - if(item.url) { - nodes[ITEM] = encodeURI(item.url); - if(usedURIs[nodes[ITEM]]) nodes[ITEM] = null; - } - // try the DOI as URI - if(!nodes[ITEM] && item.DOI) { - var doi = item.DOI; - if(doi.substr(0, 4) == "doi:") { - doi = doi.substr(4); - } else if(doi.substr(0, 8) == "urn:doi:") { - doi = doi.substr(8); - } else if(doi.substr(0, 9) == "info:doi/") { - doi = doi.substr(9); - } else if(doi.substr(0, 18) == "http://dx.doi.org/") { - doi = doi.substr(18); - } - nodes[ITEM] = "info:doi/"+encodeURI(doi); - if(usedURIs[nodes[ITEM]]) nodes[ITEM] = null; - } - // try the ISBN as URI - if(!nodes[ITEM] && item.ISBN) { - var isbn = item.ISBN.split(/, ?| /g)[0]; - nodes[ITEM] = "urn:isbn:"+encodeURI(isbn); - if(usedURIs[nodes[ITEM]]) nodes[ITEM] = null; - } - // no suitable item URI; fall back to a blank node - if(!nodes[ITEM]) nodes[ITEM] = Zotero.RDF.newResource(); - usedURIs[Zotero.RDF.getResourceURI(nodes[ITEM])] = true; - - // attach item node to user item node - Zotero.RDF.addStatement(nodes[USERITEM], RDF_TYPE, n.z+"UserItem", false); - Zotero.RDF.addStatement(nodes[USERITEM], n.res+"resource", nodes[ITEM], false); - - // container node - nodes[CONTAINER] = (this[CONTAINER] ? Zotero.RDF.newResource() : nodes[ITEM]); - - // subcontainer node - nodes[SUBCONTAINER] = (this[SUBCONTAINER] ? Zotero.RDF.newResource() : nodes[CONTAINER]); - - // series nodes - nodes[ITEM_SERIES] = Zotero.RDF.newResource(); - nodes[CONTAINER_SERIES] = (this[CONTAINER] ? Zotero.RDF.newResource() : nodes[ITEM_SERIES]); - nodes[SUBCONTAINER_SERIES] = (this[SUBCONTAINER] ? Zotero.RDF.newResource() : nodes[CONTAINER_SERIES]); - - return nodes; -} - -/** - * A class representing a BIBO-to-Zotero literal property mapping - */ -LiteralProperty = function(field) { - this.field = field; - this.mapping = FIELDS[field]; - if(!this.mapping) { - //Zotero.debug("WARNING: unrecognized field "+field+" in Bibliontology RDF; mapping to Zotero namespace"); - this.mapping = [ITEM, n.z+field]; - } -} - -/** - * Maps property from a set of RDF nodes to an item - */ -LiteralProperty.prototype.mapToItem = function(newItem, nodes) { - if(typeof this.mapping[0] == "function") { // function case: triples returned - // check function case - var content = this.mapping[1](nodes); - if(!content) return false; - newItem[this.field] = content; - } else { - var node = nodes[this.mapping[0]]; - if(!node) return false; - var statements = getStatementsByDefinition(this.mapping[1], node); - if(!statements) return false; - - var content = []; - for each(var stmt in statements) { - content.push(stmt[2].toString()); - } - newItem[this.field] = content.join(","); - } - return true; -} - -/** - * Maps property from an item to a set of RDF nodes - */ -LiteralProperty.prototype.mapFromItem = function(item, nodes) { - if(typeof this.mapping[0] == "function") { // function case: triples returned - // check function case - for each(var triple in this.mapping[0](item)) { - Zotero.RDF.addStatement(nodes[triple[0]], triple[1], triple[2], triple[3]) - } - } else if(typeof this.mapping[1] == "string") { // string case: simple predicate - Zotero.RDF.addStatement(nodes[this.mapping[0]], - this.mapping[1], item.uniqueFields[this.field], true); - } else { // array case: complex predicate - var blankNode = getBlankNode(nodes[this.mapping[0]], - this.mapping[1][0], this.mapping[1][1], true); - Zotero.RDF.addStatement(blankNode, this.mapping[1][2], item.uniqueFields[this.field], true); - } -} - -/** - * A class representing a BIBO-to-Zotero creator mapping - */ -CreatorProperty = function(field) { - this.field = field; - this.mapping = CREATORS[field]; -} - -/** - * Maps creator from an foaf:Agent - */ -CreatorProperty.prototype.mapToCreator = function(creatorNode, zoteroType) { - //Zotero.debug("mapping "+Zotero.RDF.getResourceURI(creatorNode)+" to a creator"); - var lastNameStmt = Zotero.RDF.getStatementsMatching(creatorNode, n.foaf+"surname", null); - if(lastNameStmt) { // look for a person with a last name - creator = {lastName:lastNameStmt[0][2].toString()}; - var firstNameStmt = Zotero.RDF.getStatementsMatching(creatorNode, n.foaf+"givenname", null); - if(firstNameStmt) creator.firstName = firstNameStmt[0][2].toString(); - } else { - var nameStmt = Zotero.RDF.getStatementsMatching(creatorNode, n.foaf+"name", null); - if(nameStmt) { // an organization - creator = {lastName:nameStmt[0][2].toString(), fieldMode:1}; - } else { // an unnamed entity; ignore it - //Zotero.debug("Dropping unnamed creator "+creatorNode.toString()); - return false; - } - } - - // birthYear and shortName - var birthStmt = Zotero.RDF.getStatementsMatching(creatorNode, n.foaf+"birthday", null, true); - if(birthStmt) creator.birthYear = birthStmt[2].toString(); - var nickStmt = Zotero.RDF.getStatementsMatching(creatorNode, n.foaf+"nick", null, true); - if(nickStmt) creator.shortName = nickStmt[2].toString(); - - if(this.field == "author") { - // could be another primary creator - var creatorsForType = Zotero.Utilities.getCreatorsForType(zoteroType); - if(creatorsForType.indexOf("author") == -1) { - creator.creatorType = creatorsForType[0]; - } - } else { - creator.creatorType = this.field; - } - return creator; -} - -/** - * Maps creators from a top-level (ITEM/SUBCONTAINER/CONTAINER/SERIES) node to a list - */ -CreatorProperty.prototype.mapToCreators = function(node, zoteroType) { - var creators = []; - var creatorNodes = []; - var statements = getStatementsByDefinition(this.mapping[2], node); - if(statements) { - for each(var stmt in statements) { - var creator = this.mapToCreator(stmt[2], zoteroType); - if(creator) { - creators.push(creator); - creatorNodes.push(stmt[2]); - } - } - } - return [creators, creatorNodes]; -} - -/** - * Maps property from a Zotero creator array to a set of RDF nodes - */ -CreatorProperty.prototype.mapFromCreator = function(item, creator, nodes) { - var creatorsForType = Zotero.Utilities.getCreatorsForType(item.itemType); - var isPrimary = creatorsForType[0] == this.field; - if(this.mapping) { - var mapping = this.mapping; - } else { - if(isPrimary && creatorsForType.indexOf("author") == -1) { - // treat other primary creators as dcterms:creators - var mapping = CREATORS["author"]; - } else { - //Zotero.debug("WARNING: unrecognized creator type "+this.field+" in Bibliontology RDF; mapping to Zotero namespace"); - var mapping = [ITEM, AUTHOR_LIST, n.z+this.field]; - } - } - - var creatorNode = Zotero.RDF.newResource(); - if(creator.fieldMode == 1) { - Zotero.RDF.addStatement(creatorNode, RDF_TYPE, n.foaf+"Organization"); - if(creator.lastName) Zotero.RDF.addStatement(creatorNode, n.foaf+"name", creator.lastName, true); - } else { - Zotero.RDF.addStatement(creatorNode, RDF_TYPE, n.foaf+"Person"); - if(creator.firstName) Zotero.RDF.addStatement(creatorNode, n.foaf+"givenname", creator.firstName, true); - if(creator.lastName) Zotero.RDF.addStatement(creatorNode, n.foaf+"surname", creator.lastName, true); - } - if(creator.birthYear) Zotero.RDF.addStatement(creatorNode, n.foaf+"birthday", creator.birthYear, true); - if(creator.shortName) Zotero.RDF.addStatement(creatorNode, n.foaf+"nick", creator.shortName, true); - - // attach creator node - var attachTo = nodes[mapping[0]]; - if(typeof mapping[2] == "string") { - var relation = mapping[2]; - } else { - var relation = mapping[2][2]; - var attachTo = getBlankNode(attachTo, mapping[2][0], mapping[2][1], true); - } - Zotero.RDF.addStatement(attachTo, relation, creatorNode, false); - - // get appropriate creator list - var list = mapping[1]; - if(list == CONTRIBUTOR_LIST && isPrimary) { - // always attach primary to author list instead of contributor list - list = AUTHOR_LIST; - } - - // add to creator list - var creatorList = Zotero.RDF.getStatementsMatching(nodes[mapping[0]], CREATOR_LISTS[list], null); - if(creatorList) { - var creatorList = creatorList[0][2]; - } else { - var creatorList = Zotero.RDF.newResource(); - Zotero.RDF.newContainer("seq", creatorList); - Zotero.RDF.addStatement(nodes[mapping[0]], CREATOR_LISTS[list], creatorList, false); - } - Zotero.RDF.addContainerElement(creatorList, creatorNode, false); -} - -/** IMPORT FUNCTIONS **/ - -/** - * Gets statements matching a statement definition, if it exists - */ -function getStatementsByDefinition(definition, node) { - var statements = null; - if(typeof definition == "string") { // string case: simple predicate - statements = Zotero.RDF.getStatementsMatching(node, definition, null); - } else { // array case: complex - var blankNode = getBlankNode(node, definition[0], definition[1], false); - if(blankNode) { - statements = Zotero.RDF.getStatementsMatching(blankNode, definition[2], null); - } - } - return statements; -} - -function detectImport() { - // look for a bibo item type - var rdfTypes = Zotero.RDF.getStatementsMatching(null, RDF_TYPE, null); - if(rdfTypes) { - for each(var rdfType in rdfTypes) { - if(rdfType[2].uri && rdfType[2].uri.substr(0, BIBO_NS_LENGTH) == n.bibo) return true; - } - } - return false; -} - -function doImport() { - // collapse list of BIBO-only types - var collapsedTypes = {}; - for(var unprefixedBiboType in BIBO_TYPES) { - var biboType = n.bibo+unprefixedBiboType; - var type = new Type(BIBO_TYPES[unprefixedBiboType], [[[RDF_TYPE, n.bibo+biboType]], null, null]); - if(!collapsedTypes[biboType]) { - collapsedTypes[biboType] = [type]; - } else { - collapsedTypes[biboType].push(type); - } - } - - // collapse Zotero-to-BIBO type mappings - for(var zoteroType in TYPES) { - var type = new Type(zoteroType, TYPES[zoteroType]); - for each(var pair in TYPES[zoteroType][0]) { - if(!collapsedTypes[pair[1]]) { - collapsedTypes[pair[1]] = [type]; - } else { - collapsedTypes[pair[1]].push(type); - } - } - } - - // collapse list of field mappings - var collapsedProperties = {1:{}, 2:{}, 3:{}, 4:{}, 5:{}, 6:{}, 7:{}}; - var functionProperties = {}; - for(var zoteroField in FIELDS) { - if(typeof FIELDS[zoteroField][0] == "function") { - functionProperties[zoteroField] = new LiteralProperty(zoteroField); - } else { - var domain = FIELDS[zoteroField][0]; - var predicate = FIELDS[zoteroField][1]; - if(typeof predicate == "object") predicate = predicate[0]; - var prop = new LiteralProperty(zoteroField); - - if(collapsedProperties[domain][predicate]) { - collapsedProperties[domain][predicate].push(prop); - } else { - collapsedProperties[domain][predicate] = [prop]; - } - } - } - - // collapse list of creators - for(var creatorType in CREATORS) { - var domain = CREATORS[creatorType][0]; - var predicate = CREATORS[creatorType][2]; - if(typeof predicate == "object") predicate = predicate[0]; - var prop = new CreatorProperty(creatorType); - - if(collapsedProperties[domain][predicate]) { - collapsedProperties[domain][predicate].unshift(prop); - } else { - collapsedProperties[domain][predicate] = [prop]; - } - } - - // Go through all type arcs to find items - var itemNode, predicateNode, objectNode; - var rdfTypes = Zotero.RDF.getStatementsMatching(null, RDF_TYPE, null); - var itemNodes = {}; - for each(var rdfType in rdfTypes) { - [itemNode, predicateNode, objectNode] = rdfType; - if(!objectNode.uri || !collapsedTypes[objectNode.uri]) continue; - itemNodes[Zotero.RDF.getResourceURI(itemNode)] = itemNode; - } - - // Look through found items to see if their rdf:type matches a Zotero item type URI, and if so, - // subject to further processing - for each(var itemNode in itemNodes) { - // check whether the relationship to another item precludes us from extracting this as - // top-level - var skip = false; - for each(var arc in Zotero.RDF.getArcsIn(itemNode)) { - if(SAME_ITEM_RELATIONS.indexOf(arc) !== -1) { - skip = true; - break; - } - } - if(skip) continue; - - var itemRDFTypes = Zotero.RDF.getStatementsMatching(itemNode, RDF_TYPE, null); - - // score types by the number of triples they share with our types - var bestTypeScore = -9999; - var bestType, score, nodes, bestNodes; - for each(var rdfType in itemRDFTypes) { - if(!rdfType[2].uri) continue; - - for each(var type in collapsedTypes[rdfType[2].uri]) { - [score, nodes] = type.getMatchScore(itemNode); - //Zotero.debug("Type "+type.zoteroType+" has score "+score); - - // check if this is the best we can do - if(score > bestTypeScore) { - bestTypeScore = score; - bestType = type; - bestNodes = nodes; - } - } - } - - // skip if this doesn't fit any type very well - if(bestTypeScore < 1) { - //Zotero.debug("No good type mapping; best type was "+bestType.zoteroType+" with score "+bestTypeScore); - continue; - } - - //Zotero.debug("Got item of type "+bestType.zoteroType+" with score "+bestTypeScore); - nodes = bestNodes; - bestType.getItemSeriesNodes(nodes); - - // create item - var zoteroType = bestType.zoteroType; - var newItem = new Zotero.Item(zoteroType); - - // handle ordinary properties - var allCreators = {} - for(var i in nodes) { - var propertiesHandled = {}; - var properties = Zotero.RDF.getArcsOut(nodes[i]); - for each(var property in properties) { - // only handle each property once - if(propertiesHandled[property]) continue; - propertiesHandled[property] = true; - //Zotero.debug("handling "+property); - - var propertyMappings = collapsedProperties[i][property]; - if(propertyMappings) { - for each(var propertyMapping in propertyMappings) { - if(propertyMapping.mapToItem) { // LiteralProperty - propertyMapping.mapToItem(newItem, nodes); - } else if(propertyMapping.mapToCreator) { // CreatorProperty - var creators, creatorNodes; - [creators, creatorNodes] = propertyMapping.mapToCreators(nodes[i], zoteroType); - if(creators.length) { - for(var j in creators) { - var creatorNodeURI = Zotero.RDF.getResourceURI(creatorNodes[j]); - if(!allCreators[creatorNodeURI]) { - allCreators[creatorNodeURI] = creators[j]; - } - } - } - } - } - } - } - } - - // handle function properties - for each(var functionProperty in functionProperties) { - functionProperty.mapToItem(newItem, nodes); - } - - // handle creators and tags - var creatorLists = {}; - var creatorsAdded = {}; - for(var i in nodes) { - // take DC subjects as tags - var statements = Zotero.RDF.getStatementsMatching(nodes[i], n.dcterms+"subject", null); - for each(var stmt in statements) { - // if attached to the user item, it's a user tag; otherwise, an automatic tag - newItem.tags.push({tag:stmt[2], type:(i == USERITEM ? 0 : 1)}); - } - - // also take ctags as tags - var statements = Zotero.RDF.getStatementsMatching(nodes[i], n.ctag+"tagged", null); - for each(var stmt in statements) { - var tag = {type:0}; - - // AutoTags are automatic tags - var types = Zotero.RDF.getStatementsMatching(stmt[2], n.rdf+"type", null); - for each(var type in types) { - var uri = Zotero.RDF.getResourceURI(type[2]); - if([n.ctag+"AutoTag", n.ctag+"AuthorTag"].indexOf(uri) != -1) tag.type = 1; - break; - } - - // labels are tag content - var labels = Zotero.RDF.getStatementsMatching(stmt[2], n.ctag+"label", null); - if(labels.length) { - tag.tag = labels[0][2]; - newItem.tags.push(tag); - } - } - - for(var j in CREATOR_LISTS) { - var statements = Zotero.RDF.getStatementsMatching(nodes[i], CREATOR_LISTS[j], null); - for each(var stmt in statements) { - var creatorListURI = Zotero.RDF.getResourceURI(stmt[2]); - if(creatorLists[creatorListURI]) continue; - creatorLists[creatorListURI] = true; - var creatorNodes = Zotero.RDF.getContainerElements(stmt[2]); - for each(var creatorNode in creatorNodes) { - var creatorNodeURI = Zotero.RDF.getResourceURI(creatorNode); - if(!creatorsAdded[creatorNodeURI]) { - creatorsAdded[creatorNodeURI] = true; - if(allCreators[creatorNodeURI]) { - // just add to creators list - newItem.creators.push(allCreators[creatorNodeURI]); - } else { - // creator not already processed, use default for this list type - if(j == AUTHOR_LIST) { - //Zotero.debug("WARNING: creator in authorList lacks relationship to item in Bibliontology RDF; treating as primary creator"); - var prop = new CreatorProperty("author"); - } else if(j == EDITOR_LIST) { - //Zotero.debug("WARNING: creator in editorList lacks relationship to item in Bibliontology RDF; treating as editor"); - var prop = new CreatorProperty("editor"); - } else { - //Zotero.debug("WARNING: creator in contributorList lacks relationship to item in Bibliontology RDF; treating as contributor"); - var prop = new CreatorProperty("contributor"); - } - var creator = prop.mapToCreator(creatorNode, zoteroType); - if(creator) newItem.creators.push(creator); - } - } - } - } - } - } - - for(var creatorNodeURI in allCreators) { - if(!creatorsAdded[creatorNodeURI]) { - newItem.creators.push(allCreators[creatorNodeURI]); - } - } - - newItem.complete(); - } -} - -/** EXPORT FUNCTIONS **/ - -var usedURIs = {}; - -function doExport() { - // add namespaces - for(var i in n) Zotero.RDF.addNamespace(i, n[i]); - - // compile references and create URIs - var item; - var items = {}; - while(item = Zotero.nextItem()) { - items[item.itemID] = item; - } - var autoTags = {}; - var userTags = {}; - - // now that we've collected our items, start building the RDF - for each(var item in items) { - // set type on item node - var type = new Type(item.itemType, TYPES[item.itemType]); - var nodes = type.createNodes(item); - - // add fields - for(var field in item.uniqueFields) { - if(item.uniqueFields[field] == "") continue; - - var property = new LiteralProperty(field); - property.mapFromItem(item, nodes); - } - //Zotero.debug("fields added"); - - // add creators - var creatorLists = []; - for each(var creator in item.creators) { - // create creator - var property = new CreatorProperty(creator.creatorType); - property.mapFromCreator(item, creator, nodes); - } - //Zotero.debug("creators added"); - - // add tags - for each(var tag in item.tags) { - var tagCollection = tag.type == 0 ? userTags : autoTags; - - if(tagCollection[tag.tag]) { - var tagNode = tagCollection[tag.tag]; - } else { - var tagNode = Zotero.RDF.newResource(); - Zotero.RDF.addStatement(tagNode, n.rdf+"type", - (tag.type == 0 ? n.ctag+"UserTag" : n.ctag+"AutoTag"), false); - Zotero.RDF.addStatement(tagNode, n.ctag+"label", tag.tag, true); - tagCollection[tag.tag] = tagNode; - } - - Zotero.RDF.addStatement(nodes[USERITEM], n.ctag+"tagged", tagNode, false); - } - - type.addNodeRelations(nodes); - //Zotero.debug("relations added"); - } -} -\ No newline at end of file diff --git a/translators/Bibliotheque UQAM.js b/translators/Bibliotheque UQAM.js @@ -1,234 +0,0 @@ -{ - "translatorID":"39ea814e-8fdb-486c-a88d-59479f341066", - "translatorType":4, - "label":"Bibliotheque UQAM", - "creator":"Adam Crymble", - "target":"http://www.manitou.uqam.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-24 05:15:00" -} - -function detectWeb(doc, url) { - - if (doc.evaluate('//center/table/tbody/tr[1]/td/input', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.title.match("détails")) { - return "book"; - } -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -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("book"); - - var dataTags = new Object(); - var tagsContent = new Array(); - var contents; - var newItemAuthors1 = new Array(); - var newItemAuthors2 = new Array(); - - var xPathHeadings = doc.evaluate('//p/table/tbody/tr/td[1]/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathContents = doc.evaluate('//p/table/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//p/table/tbody/tr/td[1]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var dump = xPathHeadings.iterateNext(); - - for (i=0; i<xPathCount.numberValue-1; i++) { - - fieldTitle=xPathHeadings.iterateNext().textContent.replace(/\s+/g, ''); - contents = xPathContents.iterateNext().textContent; - - if (fieldTitle == "Titres:") { - fieldTitle = "Titre:"; - } - - //determines media type - if (fieldTitle == "Titre:") { - - dataTags[fieldTitle] = contents.replace(/^\s*|\s*$/g, ''); - - if (contents.match("enregistrement sonore")) { - var newItem = new Zotero.Item("audioRecording"); - } else if (contents.match("musique")) { - var newItem = new Zotero.Item("audioRecording"); - } else if (contents.match("enregistrement vidéo")) { - var newItem = new Zotero.Item("videoRecording"); - } else { - var newItem = new Zotero.Item("book"); - } - } - - //gets author(s). - if (fieldTitle == "Auteur:") { - fieldTitle = "author"; - - dataTags[fieldTitle] = contents; - if (dataTags[fieldTitle].match(",")) { - var authorName = dataTags["author"].split(","); - authorName[0] = authorName[0].replace(/^\s*|\s*$/g, ''); - dataTags["author"] = (authorName[1] + (" ") + authorName[0]); - } else { - var parenthesis = dataTags["author"].indexOf("("); - if (parenthesis > 0) { - dataTags["author"] = dataTags["author"].substr(0, parenthesis); - } - dataTags["author"] = dataTags["author"].replace(/^\s*|\s*$/g, ''); - } - - } else if (fieldTitle == "Auteurs:") { - - dataTags[fieldTitle] = contents; - - var multiAuthors = dataTags["Auteurs:"].split(/\n/); - for (var j = 0; j < multiAuthors.length; j++) { - var parenthesis = multiAuthors[j].indexOf("("); - - if (parenthesis > 0) { - multiAuthors[j] = multiAuthors[j].substr(0, parenthesis); - } - - if (multiAuthors[j] != "" && multiAuthors[j] != ' ') { - if (multiAuthors[j].match(", ")) { - var authorName = multiAuthors[j].split(","); - newItemAuthors1.push(authorName[1] + (" ") + authorName[0]); - } else { - newItemAuthors2.push(multiAuthors[j]); - } - } - } - - } else if (fieldTitle == "Éditeur:") { - dataTags[fieldTitle] = contents; - var imprintSplit = dataTags["Éditeur:"].split(": "); - if (imprintSplit.length > 1) { - newItem.place = imprintSplit[0].replace(/^\s*|\s*$/g, ''); - var publisherDate = imprintSplit[1].split(", "); - - newItem.publisher = publisherDate[0].replace(/^\s*|\s*$/g, ''); - - if (publisherDate.length > 1) { - - newItem.date = publisherDate[1].replace(/^\s*|\s*$/g, ''); - } - } else { - newItem.publisher = dataTags["Éditeur:"]; - } - - } else if (fieldTitle == "Sujet:") { - dataTags[fieldTitle] = contents; - - if (dataTags["Sujet:"].match("\n")) { - - tagsContent = (dataTags["Sujet:"].split(/\n/)); - - } - - } else { - - dataTags[fieldTitle] = contents.replace(/^\s*|\s*$/g, ''); - } - } - -//pushes tags - - for (var y = 0; y < tagsContent.length; y++) { - if (tagsContent[y]!='' && tagsContent[y]!= " ") { - var parenthesis = tagsContent[y].indexOf("("); - if (parenthesis > 0) { - tagsContent[y] = tagsContent[y].substr(0, parenthesis); - } - newItem.tags[y] = tagsContent[y]; - } - } - -//because newItem is not defined until after the authors have, authors must be put into Zotero outside the main for loop. - if (dataTags["author"]) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["author"], "author")); - } - - for (var i = 0; i < newItemAuthors1.length; i++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(newItemAuthors1[i], "author")); - } - - for (var i = 0; i < newItemAuthors2.length; i++) { - newItem.creators.push({lastName: newItemAuthors2[i], creatorType: "creator"}); - } - -//trims title as best as possible - if (dataTags["Titre:"].match(/\[/)) { - var splitter = dataTags["Titre:"].indexOf("["); - } - - if (dataTags["Titre:"].match("/")) { - var splitter1 = dataTags["Titre:"].indexOf("/"); - } - - if (splitter1 > -1 && splitter > -1) { - if (splitter1 > splitter) { - dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter); - } else { - dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter1); - } - } else if (splitter1 > -1) { - dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter1); - } else if (splitter > -1) { - dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter); - } - - associateData (newItem, dataTags, "Titre:", "title"); - associateData (newItem, dataTags, "Numéro:", "ISBN"); - associateData (newItem, dataTags, "Description:", "pages"); - associateData (newItem, dataTags, "Banque:", "repository"); - associateData (newItem, dataTags, "Langue:", "language"); - associateData (newItem, dataTags, "Localisation:", "Loc. in Archive"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('/html/body/table/tbody/tr/td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (var i = 0; i < 4; i++) { - var dump = titles.iterateNext(); - } - - var next_title; - - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - Zotero.debug(next_title.href); - Zotero.debug(next_title.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(); -} -\ No newline at end of file diff --git a/translators/Bibliotheque et Archives Nationale du Quebec (Pistard).js b/translators/Bibliotheque et Archives Nationale du Quebec (Pistard).js @@ -1,151 +0,0 @@ -{ - "translatorID":"1eb5eb03-26ab-4015-bd0d-65487734744a", - "translatorType":4, - "label":"Bibliotheque et Archives Nationale du Quebec (Pistard)", - "creator":"Adam Crymble", - "target":"http://pistard.banq.qc.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-06 17:00:00" -} - -function detectWeb (doc, url) { - - if (doc.title.match("Liste détaillée des fonds")) { - return "multiple"; - } else if (doc.title.match("Description fonds")) { - return "book"; - } -} - -//Bibliotheque et Archives National du Quebec. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - var tagsContent= new Array(); - - var newItem = new Zotero.Item("book"); - - var headers = doc.evaluate('//strong', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//strong)', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//div[@id="Content"]/div/table', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var headersArray = new Array(); - var oneHeader = ''; - - if (xPathCount.numberValue > 1) { - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent; - headersArray.push(fieldTitle); - } - } else { - oneHeader = (headers.iterateNext().textContent); - } - - var contentsArray = new Array(); - var j = 0; - - if (oneHeader.length<1) { - - for (var i = headersArray.length-1; i> -1; i--) { - - var fieldIndex = contents.indexOf(headersArray[i]); - var removeHeader = headersArray[i].length; - - contentsArray.push(contents.substr(fieldIndex)); - contents = contents.substr(0, fieldIndex); - fieldTitle = headersArray[i].replace(/\s+/g, ''); - - dataTags[fieldTitle] = contentsArray[j].substr(removeHeader).replace(/^\s*|\s+$/g, ''); - j++; - } - } - Zotero.debug(dataTags); - - if (dataTags["Titre,Dates,Quantité"]) { - if (dataTags["Titre,Dates,Quantité"].match(/\n/)) { - var splitTitle = dataTags["Titre,Dates,Quantité"].split(/\n/); - if (splitTitle[0].match(/\w/)) { - newItem.title = splitTitle[0].replace(/^\s*|\s+$/g, ''); - } - for (var i = 0; i < splitTitle.length; i++) { - if (splitTitle[i].match("/ ")) { - var author = splitTitle[i].replace(/^\s*|\s+$/g, '').substr(2); - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - } - } else { - newItem.title = doc.title; - } - - - var k = 0; - if (dataTags["Termesrattachés"]) { - - if (dataTags["Termesrattachés"].match(/\n/)) { - tagsContent = dataTags["Termesrattachés"].split(/\n/); - for (var i in tagsContent) { - if (tagsContent[i].match(/\w/)) { - newItem.tags[k] = tagsContent[i].replace(/^\s+|\s*$/g, ''); - k++; - } - } - } else { - newItem.tags[0] = dataTags["Termesrattachés"]; - } - } - - associateData (newItem, dataTags, "Languedesdocuments", "language"); - associateData (newItem, dataTags, "Cote:", "callNumber"); - associateData (newItem, dataTags, "Collation", "pages"); - associateData (newItem, dataTags, "Centre:", "place"); - associateData (newItem, dataTags, "Portéeetcontenu", "abstractNote"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.href.match("description_fonds")) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Bibliothèque et Archives nationales du Québec.js b/translators/Bibliothèque et Archives nationales du Québec.js @@ -1,264 +0,0 @@ -{ - "translatorID":"59cce211-9d77-4cdd-876d-6229ea20367f", - "translatorType":4, - "label":"Bibliothèque et Archives nationales du Québec", - "creator":"Adam Crymble", - "target":"http://catalogue.banq.qc.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-12-12 12:35:00" -} - -function detectWeb(doc, url) { - if (doc.title.match("Search")) { - return "multiple"; - } else if (doc.title.match("Recherche")) { - return "multiple"; - - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("book")) { - return "book"; - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mmusic")) { - return "book"; - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("manalytic")) { - return "book"; - - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("msdisc")) { - return "audioRecording"; - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("msound")) { - return "audioRecording"; - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mscas")) { - return "audioRecording"; - - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mvdisc")) { - return "videoRecording"; - - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mpaint")) { - return "artwork"; - - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mserial")) { - return "report"; - - } else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mcomponent")) { - return "newspaperArticle"; - } -} - - - -//Bibliotheque et Archives National du Quebec. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - var contents; - var descriptionField; - var tagsContent= new Array(); - var inField = 0; - - //determines media type - if (detectWeb(doc, url) == "book") { - var newItem = new Zotero.Item("book"); - descriptionField = "pages"; - } else if (detectWeb(doc, url) == "audioRecording") { - var newItem = new Zotero.Item("audioRecording"); - descriptionField = "runningTime"; - } else if (detectWeb(doc, url) == "videoRecording") { - var newItem = new Zotero.Item("videoRecording"); - descriptionField = "runningTime"; - } else if (detectWeb(doc, url) == "artwork") { - var newItem = new Zotero.Item("artwork"); - descriptionField = "artworkSize"; - } else if (detectWeb(doc, url) == "report") { - var newItem = new Zotero.Item("report"); - descriptionField = "pages"; - } else if (detectWeb(doc, url) == "newspaperArticle") { - var newItem = new Zotero.Item("newspaperArticle"); - descriptionField = "pages" - } - -//determines language - var lang = doc.evaluate('//td[2]/a/img', doc, nsResolver, XPathResult.ANY_TYPE, null); - var langCount = doc.evaluate('count (//td[2]/a/img)', doc, nsResolver, XPathResult.ANY_TYPE, null); - var lang1 = lang.iterateNext().src; - - if (langCount.numberValue > 1) { - lang1 = lang.iterateNext().src; - - if (lang1.match("lfre")) { - newItem.language = "French"; - } else if (lang1.match("leng")) { - newItem.language = "English"; - } - } - -//scraping XPaths - var xPathHeadings = doc.evaluate('//td/table/tbody/tr/td[2]/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathContents = doc.evaluate('//td[2]/table/tbody/tr/td/table/tbody/tr/td[4]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//td/table/tbody/tr/td[2]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - if (doc.evaluate('//td/table/tbody/tr/td[2]/b', doc, nsResolver, XPathResult.ANY_TYPE, null)) { - - for (i=0; i<xPathCount.numberValue; i++) { - - fieldTitle = xPathHeadings.iterateNext().textContent.replace(/\s+/g, ''); - contents = xPathContents.iterateNext().textContent; - - if (contents.match("[*]") && fieldTitle!= "Publisher" && fieldTitle!= "Éditeur") { - var removeTagExcess = contents.indexOf("["); - contents = contents.substr(0, removeTagExcess); - } - - if (fieldTitle == "Author" | fieldTitle == "Auteur") { - fieldTitle = "Author"; - dataTags[fieldTitle] = (contents); - var authorName = dataTags["Author"].split(","); - authorName[0] = authorName[0].replace(/\s+/g, ''); - - dataTags["Author"] = (authorName[1] + (" ") + authorName[0]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Author"], "author")); - - //publishing info - } else if (fieldTitle == "Publisher" | fieldTitle == "Éditeur") { - fieldTitle = "Publisher"; - - dataTags["Publisher"] = (contents); - - if (dataTags["Publisher"].match(":")) { - - var place1 = dataTags["Publisher"].split(":"); - dataTags["Place"] = place1[0].replace(/^\s*|\[|\]/g,''); - - var publish = place1[1].split(","); - dataTags["Publish"] = (publish[0].replace(/^\s*|\[|\]/g,'')); - - place1[1] = place1[1].replace(/^\s*|\s*$|\[|\]/g, ''); - if (place1[1].match("/?")) { - var dateLength = place1[1].length-5; - } else { - var dateLength = place1[1].length-4; - } - dataTags["Date"] = place1[1].substr(dateLength); - } else { - dataTags["Date"] = (contents); - } - - //tags - } else if (fieldTitle == "Subjects" | fieldTitle == "Sujets") { - fieldTitle = "Subjects"; - tagsContent = contents.split("\n"); - - //source - } else if (fieldTitle == "Source") { - dataTags[fieldTitle] = (contents.replace(/^\s*|\s*$/g, '')); - dataTags["Source"] = ("Source: " + dataTags["Source"]); - Zotero.debug(doc.title); - //normal - } else { - dataTags[fieldTitle] = (contents.replace(/^\s*|\s*$/g, '')); - } - } - - //series - if (fieldTitle == "Series" | fieldTitle == "Collection") { - fieldTitle = "Series"; - dataTags[fieldTitle] = (contents.replace(/\s\s\s*/g, '')); - } - - //makes tags - for (i = 0; i < tagsContent.length; i++) { - if (tagsContent[i] != ("") && tagsContent[i] !=(" ")) { - newItem.tags[i] = tagsContent[i]; - } - } - - associateData (newItem, dataTags, "Description", descriptionField); - - associateData (newItem, dataTags, "Title", "title"); - associateData (newItem, dataTags, "Place", "place"); - associateData (newItem, dataTags, "Publish", "publisher"); - associateData (newItem, dataTags, "Date", "date"); - associateData (newItem, dataTags, "Source", "extra"); - associateData (newItem, dataTags, "ISBN", "ISBN"); - associateData (newItem, dataTags, "Localinf.", "rights"); - associateData (newItem, dataTags, "Series", "series"); - associateData (newItem, dataTags, "Notes", "abstractNote"); - associateData (newItem, dataTags, "Numbering", "reportNumber"); - - associateData (newItem, dataTags, "Titre", "title"); - associateData (newItem, dataTags, "Numérotation", "reportNumber"); - - } - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var next_title = new Array(); - var links1 = new Array(); - var y = 0; - var next_title1 = new Array(); - - var titlesCount = doc.evaluate('count (//p/table/tbody/tr/td/b)', doc, nsResolver, XPathResult.ANY_TYPE, null); - var numAndTitle= doc.evaluate('//p/table/tbody/tr/td/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//p/table/tbody/tr/td/a[img]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var multipleTest = 0; - - for (j=0; j < titlesCount.numberValue; j++) { - - next_title[j] = numAndTitle.iterateNext().textContent; - next_title[j] = next_title[j].substr(0, next_title[j].length-1); - - if (/^\d*$/.test(next_title[j])) { - multipleTest = 0; - } else if (multipleTest < 1) { - multipleTest++; - next_title1[y] = next_title[j]; - y++; - Zotero.debug(next_title1[0]); - - } else if (multipleTest > 1) { - multipleTest = 0; - } - } - - for (j = 0; j < 10; j++) { - links1[j] = links.iterateNext().href; - //Zotero.debug(links1[0]); - items[links1] = next_title1[j]; - } - - - 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(); - -} -\ No newline at end of file diff --git a/translators/Bibliothèque nationale de France.js b/translators/Bibliothèque nationale de France.js @@ -1,736 +0,0 @@ -{ - "translatorID":"47533cd7-ccaa-47a7-81bb-71c45e68a74d", - "label":"Bibliothèque nationale de France", - "creator":"Florian Ziche", - "target":"^https?://[^/]*catalogue\\.bnf\\.fr", - "minVersion":"2.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "translatorType":4, - "lastUpdated":"2011-02-22 09:55:00" -} - -/* - * Bibliothèque nationale de France Translator - * Copyright (C) 2010 Florian Ziche, ziche@noos.fr - * - * 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/>. -*/ - - -/* Bnf namespace. */ -var BnfClass = function() { - //Private members - - /* MARC translator. */ - var marc; - - var that = this; - - /* Load MARC translator. */ - function loadMarcTranslator() { - if(!marc) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - marc = translator.getTranslatorObject(); - } - return marc; - }; - - /* Map MARC responsibility roles to Zotero creator types. - See http://archive.ifla.org/VI/3/p1996-1/appx-c.htm. - */ - function getCreatorType(aut) { - switch(aut['4']) { - case "005": - case "250": - case "275": - case "590": //performer - case "755": //vocalist - return "performer"; - case "040": - case "130": //book designer - case "740": //type designer - case "750": //typographer - case "350": //engraver - case "360": //etcher - case "430": //illuminator - case "440": //illustrator - case "510": //lithographer - case "530": //metal engraver - case "600": //photographer - case "705": //sculptor - case "760": //wood engraver - return "artist"; - case "070": - case "305": - case "330": - case undefined: - return "author"; - case "020": - case "210": - case "212": - return "commenter"; - case "180": - return "cartographer"; - case "220": - case "340": - return "editor"; - case "230": - return "composer"; - case "245": - return "inventor"; - case "255": - case "695": //scientific advisor - case "727": //thesis advisor - return "counsel"; - case "300": - return "director"; - case "400": //funder - case "723": //sponsor - return "sponsor"; - case "460": - return "interviewee"; - case "470": - return "interviewer"; - case "480": //librettist - case "520": //lyricist - return "wordsBy"; - case "605": - return "presenter"; - case "630": - return "producer"; - case "635": - return "programmer"; - case "660": - return "recipient"; - case "090": //author of dialog - case "690": //scenarist - return "scriptwriter"; - case "730": - return "translator"; - //Ignore (no matching Zotero creatorType): - case "320": //donor - case "610": //printer - case "650": //publisher - return undefined; - //Default - case "205": - default: - return "contributor"; - } - }; - - /* Fix creators (MARC translator is not perfect). */ - function getCreators(record, item) { - //Clear creators - item.creators = new Array(); - // Extract creators (700, 701 & 702) - for (var i = 700; i < 703; i++) { - var authorTag = record.getFieldSubfields(i); - for (var j in authorTag) { - var aut = authorTag[j]; - var authorText = ""; - if (aut.b) { - authorText = aut['a'] + ", " + aut['b']; - } else { - authorText = aut['a']; - } - var type = getCreatorType(aut); - if(type) { - item.creators.push(Zotero.Utilities.cleanAuthor(authorText, type, true)); - } - } - } - // Extract corporate creators (710, 711 & 712) - for (var i = 710; i < 713; i++) { - var authorTag = record.getFieldSubfields(i); - for (var j in authorTag) { - if (authorTag[j]['a']) { - var type = getCreatorType(authorTag[j]); - if(type) { - item.creators.push({ - lastName: authorTag[j]['a'], - creatorType: type, - fieldMode: true}); - } - } - } - } - }; - - - //Translate BnF types to Zotero item types. - function getItemType(type) { - switch(type) { - case "Enregistrement sonore": - return "audioRecording"; - case "Image fixe": - case "Image fixe numérisée": - return "artwork"; - case "Images animées": - return "film"; - case "Ressource électronique": - return "computerProgram"; - case "Document cartographique": - return "map"; - case "Document d'archives": - return "document"; - case "Texte manuscrit": - return "manuscript"; - case "Multimédia multisupport": - case "Musique imprimé": - case "Texte imprimé": - default: - return "book"; - } - }; - - //Add tag, if not present yet - function addTag(item, tag) { - for(var t in item.tags) { - if(item.tags[t] == tag) { - return; - } - } - item.tags.push(tag); - }; - - //Tagging - function getTags(record, item) { - var pTag = record.getFieldSubfields("600"); - if(pTag) { - for(var j in pTag) { - var tagText = false; - var person = pTag[j]; - tagText = person.a; - if(person.b) { - tagText += ", " + person.b; - } - if(person.f) { - tagText += " (" + person.f + ")"; - } - addTag(item, tagText); - } - } - pTag = record.getFieldSubfields("601"); - if(pTag) { - for(var j in pTag) { - var tagText = false; - var person = pTag[j]; - tagText = person.a; - addTag(item, tagText); - } - } - pTag = record.getFieldSubfields("605"); - if(pTag) { - for(var j in pTag) { - var tagText = false; - var person = pTag[j]; - tagText = person.a; - addTag(item, tagText); - } - } - pTag = record.getFieldSubfields("606"); - if(pTag) { - for(var j in pTag) { - var tagText = false; - var person = pTag[j]; - tagText = person.a; - addTag(item, tagText); - } - } - pTag = record.getFieldSubfields("607"); - if(pTag) { - for(var j in pTag) { - var tagText = false; - var person = pTag[j]; - tagText = person.a; - addTag(item, tagText); - } - } - pTag = record.getFieldSubfields("602"); - if(pTag) { - for(var j in pTag) { - var tagText = false; - var person = pTag[j]; - tagText = person.a; - if(person.f) { - tagText += " (" + person.f + ")"; - } - addTag(item, tagText); - } - } - pTag = record.getFieldSubfields("604"); - if(pTag) { - for(var j in pTag) { - var tagText = false; - var person = pTag[j]; - tagText = person.a; - if(person.b) { - tagText += ", " + person.b; - } - if(person.f) { - tagText += " (" + person.f + ")"; - } - if(person.t) { - tagText += ", " + person.t; - } - addTag(item, tagText); - } - } - }; - - //Get series (repeatable) - function getSeries(record, item) { - var seriesText = false; - var seriesTag = record.getFieldSubfields("225"); - if(seriesTag && seriesTag.length > 1) { - for(var j in seriesTag) { - var series = seriesTag[j]; - if(seriesText) { - seriesText += "; "; - } - else { - seriesText = ""; - } - seriesText += series.a; - if(series.v) { - seriesText += ", " + series.v; - } - } - if(seriesText) { - delete item.seriesNumber; - item.series = seriesText; - } - } - //Try 461 - if(!item.series) { - seriesTag = record.getFieldSubfields("461"); - if(seriesTag) { - for(var j in seriesTag) { - var series = seriesTag[j]; - if(seriesText) { - seriesText += "; "; - } - else { - seriesText = ""; - } - seriesText += series.t; - } - } - if(seriesText) { - delete item.seriesNumber; - item.series = seriesText; - } - } - }; - - //Add extra text - function addExtra(noteText, extra) { - if(extra) { - if(noteText) { - if(!/\.$/.exec(noteText)) { - noteText += ". "; - } - else { - noteText += " "; - } - } - else { - noteText = ""; - } - noteText += Zotero.Utilities.trim(extra); - } - return noteText; - } - - //Assemble extra information - function getExtra(record, item) { - var noteText = false; - //Material description - var noteTag = record.getFieldSubfields("215"); - if(noteTag) { - for(var j in noteTag) { - var note = noteTag[j]; - noteText = addExtra(noteText, note.c); - noteText = addExtra(noteText, note.d); - noteText = addExtra(noteText, note.e); - } - } - //Note - noteTag = record.getFieldSubfields("300"); - if(noteTag) { - for(var j in noteTag) { - var note = noteTag[j]; - noteText = addExtra(noteText, note.a); - } - } - //Edition history notes - noteTag = record.getFieldSubfields("305"); - if(noteTag) { - for(var j in noteTag) { - var note = noteTag[j]; - noteText = addExtra(noteText, note.a); - } - } - if(noteText) { - if(!/\.$/.exec(noteText)) { - noteText += "."; - } - item.extra = noteText; - } - }; - - - //Get title from 200 - function getTitle(record, item) { - var titleTag = record.getFieldSubfields("200"); - if(titleTag) { - titleTag = titleTag[0]; - var titleText = titleTag.a; - if(titleTag.e) { - if(!/^[,\.:;-]/.exec(titleTag.e)) { - titleText += ": "; - } - titleText += titleTag.e; - } - if(titleTag.h) { - titleText += ", " + titleTag.h; - if(titleTag.i) { - titleText += ": " + titleTag.i; - } - } - else if(titleTag.i) { - titleText += ", " + titleTag.i; - } - item.title = titleText; - } - }; - - - //Do BnF specific Unimarc postprocessing - function postprocessMarc(record, newItem) { - //Type - var t = record.getFieldSubfields("200"); - if(t && t[0].b) { - newItem.itemType = getItemType(t[0].b); - } - - //Title - getTitle(record, newItem); - - //Fix creators - getCreators(record, newItem); - - //Store perennial url from 009 as attachment and accession number - var url = record.getField("009"); - if(url && url.length > 0 && url[0][1]) { - newItem.accessionNumber = url[0][1]; - newItem.attachments = [ - { - url: url[0][1], - title: "Bnf catalogue entry", - mimeType: "text/html", - snapshot:false - } - ]; - } - - //Country (102a) - record._associateDBField(newItem, "102", "a", "country"); - - //Try to retrieve volumes/pages from 215d - if(!newItem.pages) { - var dimTag = record.getFieldSubfields("215"); - for (var j in dimTag) { - var dim = dimTag[j]; - if(dim.a) { - var pages = /[^\d]*(\d+)\s+p\..*/.exec(dim.a); - if(pages) { - newItem.numPages = pages[1]; - } - var vols= /[^\d]*(\d+)\s+vol\..*/.exec(dim.a); - if(vols) { - newItem.numberOfVolumes = vols[1]; - } - } - } - } - - //Series - getSeries(record, newItem); - - //Extra - getExtra(record, newItem); - - //Tagging - getTags(record, newItem); - - //Repository - newItem.libraryCatalog = "French National Library Online Catalog (http://catalogue.bnf.fr)"; - }; - - - //Public members - - /* Get the UNIMARC URL for a given single result page. */ - this.reformURL = function(url) { - return url.replace(/&FormatAffichage=[^&]*/, "") - .replace(/&idNoeud=[^&]*/, "") + "&FormatAffichage=4"; - }; - - - /* Get the results table from a list page, if any. Looks for //table[@class="ListeNotice"]. */ - this.getResultsTable = function(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - try { - var xPath = '//table[@class="ListeNotice"]'; - var xPathObject = doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - return xPathObject; - } catch(x) { - Zotero.debug(x.lineNumber + " " + x.message); - } - return undefined; - }; - - /* Get the DC type from the web page. Returns the first DC.type from meta tags. - 2010-10-01: No DC meta tags any more... simply test for //td[@class="texteNotice"] cells and return "printed text". - */ - this.getDCType = function(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - try { -// var xPath = '//head/meta[@name="DC.type" and @lang="eng"]/@content'; - var xPath = '//td[@class="texteNotice"]'; - var xPathObject = doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();; - return xPathObject ? "printed text" : undefined; - } catch(x) { - Zotero.debug(x.lineNumber + " " + x.message); - } - return undefined; - }; - - /* Translate a DC type to a corresponding Zotero item type. Currently obsolete. */ - this.translateDCType = function(type) { - switch(type) { - case "printed text": - case "text": - return "book"; - case "sound recording": - return "audioRecording"; - default: - return type; - } - }; - - - /* Get selectable search items from a list page. - Loops through //td[@class="mn_partienoticesynthetique"], extracting the single items URLs from - their onclick attribute, thier titles by assembling the spans for each cell. - */ - this.getSelectedItems = function(doc) { - var items = new Object(); - - var baseUri = /^(https?:\/\/[^\/]+)/.exec(doc.location.href)[1]; - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var cellPath = '//td[@class="mn_partienoticesynthetique"]'; - var spanPath = './/span'; - var cells = doc.evaluate(cellPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var cell = undefined; - var regexLink = /\s*window.location='([^']+)'\s*/; - - //Cell loop - while(cell = cells.iterateNext()) { - //Get link - var link = cell.attributes.item("onclick").textContent; - var url = baseUri + regexLink.exec(link)[1]; - //Get title - var title = ""; - var span = undefined; - var spans = doc.evaluate(spanPath, cell, nsResolver, XPathResult.ANY_TYPE, null); - //Span loop - while(span = spans.iterateNext()) { - if(title.length > 0) { - title += " – "; - } - title += Zotero.Utilities.trim(span.textContent); - } - items[url] = title; - } - - return items; - }; - - - //Check for Gallica URL (digital version available), if found, set item.url - function checkGallica(doc, item) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var url = false; - //Check for links containing the "Visualiser" img - var elmts = doc.evaluate('//a[img[@src="/images/boutons/bouton_visualiser.gif"]]', - doc, nsResolver, XPathResult.ANY_TYPE, null); - if(elmts) { - var link; - while(link = elmts.iterateNext()) { - url = link.href; - break; - } - } - - if(url) { - item.url = url; - } - } - - - /* Process UNIMARC URL. */ - this.processMarcUrl = function(newDoc) { - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - /* Init MARC record. */ - var marc = loadMarcTranslator(); - var record = new marc.record(); - - /* Get table cell containing MARC code. */ - var elmts = newDoc.evaluate('//td[@class="texteNotice"]/text()', - newDoc, nsResolver, XPathResult.ANY_TYPE, null); - /* Line loop. */ - var elmt, tag, content; - var ind = ""; - - while(elmt = elmts.iterateNext()) { - var line = Zotero.Utilities.superCleanString(elmt.nodeValue); - if(line.length == 0) { - continue; - } - if(line.substring(0, 6) == " ") { - content += " "+line.substring(6); - continue; - } else { - if(tag) { - record.addField(tag, ind, content); - } - } - line = line.replace(/[_\t\xA0]/g," "); // nbsp - tag = line.substr(0, 3); - if(tag[0] != "0" || tag[1] != "0") { - ind = line.substr(3, 2); - content = line.substr(5).replace(/\$([a-z]|[0-9])/g, marc.subfieldDelimiter+"$1"); - content = content.replace(/ˆ([^‰]+)‰/g, "$1"); - } else { - if(tag == "000") { - tag = undefined; - record.leader = "00000"+line.substr(8); - } else { - content = line.substr(3); - } - } - } - - //Create item - var newItem = new Zotero.Item(); - record.translate(newItem); - - //Do specific Unimarc postprocessing - postprocessMarc(record, newItem); - - //Check for Gallica URL - checkGallica(newDoc, newItem); - - newItem.complete(); - - }; -}; - -/* Global BnfClass object. */ -var Bnf = new BnfClass(); - - -/* Translator API implementation. */ - - -function detectWeb(doc, url) { - var resultRegexp = /ID=[0-9]+/i; - //Single result ? - if(resultRegexp.test(url)) { - var type = Bnf.getDCType(doc, url); - return Bnf.translateDCType(type); - } - //Muliple result ? - else if(Bnf.getResultsTable(doc)) { - return "multiple"; - } - //No items - return undefined; -} - - -function doWeb(doc, url) { - /* Check type. */ - var type = detectWeb(doc, url); - if(!type) { - return; - } - /* Build array of MARC URLs. */ - var urls = undefined; - switch(type) { - case "multiple": - var items = Bnf.getSelectedItems(doc); - if(!items) { - return true; - } - /* Let user select items. */ - items = Zotero.selectItems(items); - - urls = new Array(); - for(var i in items) { - urls.push(Bnf.reformURL(i)); - } - break; - default: - urls = [Bnf.reformURL(url)]; - } - - /* Loop through URLs. */ - if(urls.length > 0) { - Zotero.Utilities.processDocuments(urls, - function(doc) { - Bnf.processMarcUrl.call(Bnf, doc); - }, - function() { Zotero.done(); }, - null); - - Zotero.wait(); - } -} diff --git a/translators/BioInfoBank.js b/translators/BioInfoBank.js @@ -1,121 +0,0 @@ -{ - "translatorID":"4c9dbe33-e64f-4536-a02f-f347fa1f187d", - "translatorType":4, - "label":"BioInfoBank", - "creator":"Michael Berkowitz", - "target":"http://lib.bioinfo.pl/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-04-03 19:45:00" -} - -function detectWeb(doc, url) { - return "multiple"; -} - -function doWeb(doc, url) { - var pmids = new Array(); - var items = new Object(); - var titles = doc.evaluate('//div[@class="css_pmid"]/div[@class="css_pmid_title"]/a', doc, null, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - items[title.href] = Zotero.Utilities.trimInternal(title.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - pmids.push(i.match(/pmid:(\d+)/)[1]); - } - var newUri = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=PubMed&retmode=xml&rettype=citation&id="+pmids.join(","); - Zotero.Utilities.HTTP.doGet(newUri, function(text) { - // Remove xml parse instruction and doctype - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - - var xml = new XML(text); - for(var i=0; i<xml.PubmedArticle.length(); i++) { - var newItem = new Zotero.Item("journalArticle"); - - var citation = xml.PubmedArticle[i].MedlineCitation; - - var PMID = citation.PMID.text().toString(); - newItem.extra = "PMID: "+PMID; - // add attachments - if(doc) { - newItem.attachments.push({document:doc, title:"PubMed Snapshot"}); - } else { - var url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&cmd=Retrieve&dopt=AbstractPlus&list_uids="+PMID; - newItem.attachments.push({url:url, title:"PubMed Snapshot", - mimeType:"text/html"}); - } - - var article = citation.Article; - if(article.ArticleTitle.length()) { - var title = article.ArticleTitle.text().toString(); - if(title.substr(-1) == ".") { - title = title.substring(0, title.length-1); - } - newItem.title = title; - } - - if (article.Pagination.MedlinePgn.length()){ - newItem.pages = article.Pagination.MedlinePgn.text().toString(); - } - - if(article.Journal.length()) { - var issn = article.Journal.ISSN.text().toString(); - if(issn) { - newItem.ISSN = issn.replace(/[^0-9]/g, ""); - } - - newItem.journalAbbreviation = Zotero.Utilities.superCleanString(citation.MedlineJournalInfo.MedlineTA.text().toString()); - if(article.Journal.Title.length()) { - newItem.publicationTitle = Zotero.Utilities.superCleanString(article.Journal.Title.text().toString()); - } else if(citation.MedlineJournalInfo.MedlineTA.length()) { - newItem.publicationTitle = newItem.journalAbbreviation; - } - - if(article.Journal.JournalIssue.length()) { - newItem.volume = article.Journal.JournalIssue.Volume.text().toString(); - newItem.issue = article.Journal.JournalIssue.Issue.text().toString(); - if(article.Journal.JournalIssue.PubDate.length()) { // try to get the date - if(article.Journal.JournalIssue.PubDate.Day.text().toString() != "") { - newItem.date = article.Journal.JournalIssue.PubDate.Month.text().toString()+" "+article.Journal.JournalIssue.PubDate.Day.text().toString()+", "+article.Journal.JournalIssue.PubDate.Year.text().toString(); - } else if(article.Journal.JournalIssue.PubDate.Month.text().toString() != "") { - newItem.date = article.Journal.JournalIssue.PubDate.Month.text().toString()+" "+article.Journal.JournalIssue.PubDate.Year.text().toString(); - } else if(article.Journal.JournalIssue.PubDate.Year.text().toString() != "") { - newItem.date = article.Journal.JournalIssue.PubDate.Year.text().toString(); - } - } - } - } - - if(article.AuthorList.length() && article.AuthorList.Author.length()) { - var authors = article.AuthorList.Author; - for(var j=0; j<authors.length(); j++) { - var lastName = authors[j].LastName.text().toString(); - var firstName = authors[j].FirstName.text().toString(); - if(firstName == "") { - var firstName = authors[j].ForeName.text().toString(); - } - if(firstName || lastName) { - newItem.creators.push({lastName:lastName, firstName:firstName}); - } - } - } - - - if (citation.MeshHeadingList && citation.MeshHeadingList.MeshHeading) { - var keywords = citation.MeshHeadingList.MeshHeading; - for (var k = 0 ; k < keywords.length() ; k++) { - newItem.tags.push(keywords[k].DescriptorName.text().toString()); - } - } - newItem.abstractNote = article.Abstract.AbstractText.toString() - - newItem.complete(); - } - - Zotero.done(); - }); -} -\ No newline at end of file diff --git a/translators/BioMed Central and More.js b/translators/BioMed Central and More.js @@ -1,140 +0,0 @@ -{ - "translatorID":"1a3e63b2-0adf-4c8e-928b-c58c2594b45d", - "translatorType":4, - "label":"BioMed Central and More", - "creator":"Ben Parr", - "target":"http://[^/]*(jcmr-online|respiratory-research|bio-diglib|nuclear-receptor|medimmunol|kinetoplastids|filariajournal|cellandchromosome|actavetscand|aidsrestherapy|almob|ann-clinmicrob|annals-general-psychiatry|asir-journal|arthritis-research|apfmj|anzhealthpolicy|behavioralandbrainfunctions|biodatamining|biology-direct|biomagres|biomedical-engineering-online|bpsmedicine|biotechnologyforbiofuels|biomedcentral|breast-cancer-research|cancerci|cbmjournal|cardiab|cardiovascularultrasound|casesjournal|lipidsignaling.cbdjournals|biosignaling|celldiv|cerebrospinalfluidresearch|journal.chemistrycentral|capmh|cmjournal|chiroandosteo|clinicalmolecularallergy|cpementalhealth|comparative-hepatology|conflictandhealth|resource-allocation|coughjournal|ccforum|cytojournal|diagnosticpathology|dynamic-med|ete-online|ehjournal|epi-perspectives|epigeneticsandchromatin|fibrogenesis|frontiersinzoology|gvt-journal|genomebiology|genomemedicine|geochemicaltransactions|globalizationandhealth|gutpathogens|harmreductionjournal|head-face-med|hqlo|health-policy-systems|human-resources-health|immunityageing|immunome-research|implementationscience|infectagentscancer|intarchmed|internationalbreastfeedingjournal|equityhealthj|ijbnpa|ij-healthgeographics|ijmhs|issoonline|jautoimdis|jbioleng|jbiol|j-biomed-discovery|jbppni|carcinogenesis|cardiothoracicsurgery|jcmr-online|jcircadianrhythms|ethnobiomed|jexpclinassistreprod|jeccr|jfootankleres|jhoonline|jibtherapies|journal-inflammation|jmedicalcasereports|jmolecularsignaling|jnanobiotechnology|jnrbm|jneuroengrehab|jneuroinflammation|occup-med|josr-online|jissn|translational-medicine|traumamanagement|lipidworld|malariajournal|microbialcellfactories|molecularbrain|molecular-cancer|molecularcytogenetics|molecularneurodegeneration|molecularpain|neuraldevelopment|nonlinearbiomedphys|nutritionandmetabolism|nutritionj|ojrd|om-pc|parasitesandvectors|particleandfibretoxicology|pathogeneticsjournal|pssjournal|ped-rheum|peh-med|plantmethods|pophealthmetrics|proteomesci|ro-journal|rbej|reproductive-health-journal|respiratory-research|retrovirology|salinesystems|the-scientist|scoliosisjournal|scfbm|substanceabusepolicy|tbiomed|thrombosisjournal|thyroidresearchjournal|tobaccoinduceddiseases|trialsjournal|urooncologyjournal|virologyj|wjes|wjso)\\.(com|org|net)", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-15 19:45:00" -} - -function detectWeb(doc,url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var xpath='//meta[@name="citation_fulltext_html_url"]'; - - //Single - if (doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - {return "journalArticle";} - - - //Multiple - xpath='//a[@class="hiddenlink"][span[@class="xcitationtitle"][b]]'; - xpath+=' | //span[@class="xcitationtitle2"]/a[@class="hiddenlink"]'; - xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]'; - xpath+=' | //p[@class="bodytext"]/a[@class="hiddenblack"][b]'; - xpath+=' | //div[@class="bodytext"]/a[@class="hiddenblack"][b]'; - xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]'; - - var rows=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var row; - var link; - while(row=rows.iterateNext()) - { - link=row.href; - if(link.indexOf("pubmed")<0 && link.substr(link.length-4)!=".pdf" && link.indexOf("blogs.")<0) - {return "multiple";} - } - -} - -function parseRIS(getURL) -{ - Zotero.Utilities.HTTP.doGet(getURL, function(text){ - // load translator for RIS - var translator = Zotero.loadTranslator ("import"); - translator.setHandler("itemDone", function(obj, newItem) { - var doi = newItem.DOI; - var splitURL = newItem.url.split('/'); - - if(splitURL.length>=3 && doi){ - var doiSuffix = doi.slice(doi.indexOf('/')+1); - var pdfURL = splitURL[0] + '/' + splitURL[1] + '/' + splitURL[2]; - pdfURL += '/content/pdf/' + doiSuffix + '.pdf'; - var source = splitURL[2].replace(/^www./i,'').replace(/\.[\w]+$/i,''); - newItem.attachments = [ - //{url:newItem.url+'/abstract', title:source + " Abstract Snapshot", mimeType:"text/html"}, - {url:newItem.url, title:source + " Snapshot", mimeType:"text/html"}, - {url:pdfURL, title:source + " PDF", mimeType:"application/pdf"} - ]; - } - newItem.complete(); - }); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - Zotero.done(); - }, function() {}); - - Zotero.wait(); -} - -function doWeb(doc,url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var xpath='//meta[@name="citation_fulltext_html_url"]/@content'; - var rows; - var row=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (row) - { - //Single Article - var url=row.textContent+"/citation/"; - Zotero.Utilities.HTTP.doPost(url, 'include=cit&format=refman&direct=on&submit=Download+references&action=submit', function(text) - {parseRIS(url+'?include=cit&format=refman&direct=on&submit=Download+references&action=submit');}); - - Zotero.wait(); - return true; - } - - - //Multiple - xpath='//a[@class="hiddenlink"][span[@class="xcitationtitle"][b]]'; - xpath+=' | //span[@class="xcitationtitle2"]/a[@class="hiddenlink"]'; - xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]'; - xpath+=' | //p[@class="bodytext"]/a[@class="hiddenblack"][b]'; - xpath+=' | //div[@class="bodytext"]/a[@class="hiddenblack"][b]'; - xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]'; - - rows=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var items=new Array(); - var link; - var t; - while(row=rows.iterateNext()) - { - link=row.href; - if(link.indexOf("pubmed")<0 && link.substr(link.length-4)!=".pdf" && link.indexOf("blogs.")<0) - { - t=link.split('/'); - if(t[t.length-1].indexOf("comments#")>-1) - {link=t.slice(0,t.length-1).join('/');} - items[link.replace("/abstract","")+"/citation"]=row.textContent; - } - } - - items = Zotero.selectItems(items); - var uris=new Array(); - if (!items) - {return true;} - - for (var i in items) - {uris.push(i);} - - Zotero.Utilities.HTTP.doPost(uris, "include=cit&format=refman&direct=on&submit=Download+references&action=submit", function(text) - { - for (var j = 0 ; j < uris.length ; j++) - {parseRIS(uris[j] + "?include=cit&format=refman&direct=on&submit=Download+references&action=submit");} - }); - - Zotero.wait(); -} diff --git a/translators/BioOne.js b/translators/BioOne.js @@ -1,66 +0,0 @@ -{ - "translatorID":"7cb0089b-9551-44b2-abca-eb03cbf586d9", - "translatorType":4, - "label":"BioOne", - "creator":"Michael Berkowitz", - "target":"http://[^/]*www.bioone.org[^/]*/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("searchtype") != -1) { - return "multiple"; - } else if (url.indexOf("get-document") != -1 || url.indexOf("get-abstract") != -1) { - return "journalArticle"; - } -} - -function createCitationURL(str) { - str = str.match(/doi=([^&]+)/)[1]; - return "http://www.bioone.org/perlserv/?request=cite-builder&doi=" + str; -} - -function doWeb(doc, url) { - var host = doc.location.host; - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var results = doc.evaluate('//div[@class="content"]/table/tbody/tr/td[3][@class="group"]', doc, null, XPathResult.ANY_TYPE, null); - var next_result; - while (next_result = results.iterateNext()) { - var title = doc.evaluate('.//span[@class="title"]', next_result, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var link = doc.evaluate('.//tr[4]/td/a[1]', next_result, null, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(createCitationURL(i)); - } - } else { - articles = [createCitationURL(url)]; - } - Zotero.Utilities.processDocuments(articles, function(newDoc) { - var newlink = newDoc.evaluate('//a[contains(@href, "refman")]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - Zotero.Utilities.HTTP.doGet(newlink, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.url = decodeURIComponent(item.url); - item.DOI = item.url.match(/http:\/\/dx\.doi\.org\/(.*)$/)[1]; - var pdfurl = 'http://' + host + '/perlserv/?request=get-pdf&doi=' + item.DOI; - item.attachments = [ - {url:item.url, title:item.title, mimeType:"text/html"}, - {url:pdfurl, title:"BioOne Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }); - translator.translate(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Blackwell Compass.js b/translators/Blackwell Compass.js @@ -1,68 +0,0 @@ -{ - "translatorID":"60d97c99-47f0-4323-98b6-5699faf827b1", - "translatorType":4, - "label":"Blackwell Compass", - "creator":"Michael Berkowitz", - "target":"http://www.blackwell-compass.com/subject/[^/]+/.+", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("search_results") != -1 || url.indexOf("section_home") != -1) { - 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 URIs = new Array(); - var items = new Object(); - if (detectWeb(doc, url) == "multiple") { - - var xpath = '//div[@class="article-holder"]//h4[@class="article"]/a'; - var articles = doc.evaluate(xpath, doc, namespace, XPathResult.ANY_TYPE, null); - var next_art = articles.iterateNext(); - while (next_art) { - items[next_art.href] = next_art.textContent; - next_art = articles.iterateNext(); - } - items = Zotero.selectItems(items); - - for (var i in items) { - URIs.push(i); - } - } else { - URIs.push(url); - } - - Zotero.Utilities.processDocuments(URIs, function(doc, urll) { - var doi = doc.evaluate('//div[@id="content"]/p/span[@class="guide"]/a[substring(@href, 1, 4) = "http"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.match(/doi\/[^/]*\/([^&]*)/)[1]; - Zotero.Utilities.HTTP.doGet('http://www.blackwell-synergy.com/action/downloadCitation?doi=' + doi + '&include=cit&format=refman&direct=on&submit=Download+references', function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.attachments = [ - {url:item.url, title:"Blackwell Compass Snapshot", mimeType:"text/html"}, - {url:item.url.replace("/doi/abs", "/doi/pdf"), title:"Blackwell Compass Full Text PDF", mimeType:"application/pdf"} - ]; - - item.complete(); - - }); - - translator.translate(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Blackwell Synergy.js b/translators/Blackwell Synergy.js @@ -1,91 +0,0 @@ -{ - "translatorID":"cb48083-4d9-4ed-ac95-2e93dceea0ec", - "translatorType":4, - "label":"Blackwell Synergy", - "creator":"Michael Berkowitz", - "target":"https?://www\\.blackwell-synergy\\.com[^/]*/(?:action/doSearch|doi/|links/doi/)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-04-28 17:50:00" -} - -function detectWeb(doc, url) { - if(url.indexOf("doSearch") != -1) { - return "multiple"; - } else { - return "journalArticle"; - } -} - -function titleCase(str) { - var skipWords = ["but", "or", "yet", "so", "for", "and", "nor", "a", "an", "the", "at", "by", "from", "in", "into", "of", "on", "to", "with", "up", "down", "as"]; - var words = str.toLowerCase().split(/\s+/); - var newstr = ""; - for each (var word in words) { - if (skipWords.indexOf(word.replace(/[^a-zA-Z]+/, "")) != -1) { - newstr += " " + word; - } else if (word.indexOf("-") != -1) { - newword = word.split("-"); - newstr += " " + newword[0][0].toUpperCase() + newword[0].substr(1) + "-" + newword[1][0].toUpperCase() + newword[1].substr(1); - } else { - newstr += " " + word[0].toUpperCase() + word.substr(1); - } - } - return Zotero.Utilities.trimInternal(newstr); -} - -function doWeb(doc, url) { - var host = doc.location.host; - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var rows = doc.evaluate('//div[@class="toc_item"]', doc, null, XPathResult.ANY_TYPE, null); - var row; - while (row = rows.iterateNext()) { - var title = Zotero.Utilities.trimInternal(doc.evaluate('.//label', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var id = doc.evaluate('.//input[@name="doi"]', row, null, XPathResult.ANY_TYPE, null).iterateNext().value; - items[id] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [decodeURIComponent(url).match(/doi\/(abs\/)?([^\?]+)(\?|$)/)[2]]; - } - - var post = ""; - for each (var doi in articles) { - post += "doi=" + encodeURIComponent(doi) + "&" - } - post += "include=abs&format=refman&submit=Download+references"; - Zotero.Utilities.HTTP.doPost('http://www.blackwell-synergy.com/action/downloadCitation', post, function(text) { - text = text.replace(/(Y1\s+\-\s+)(\d{4}\/\d{2}).*\n/, "$1$2\n"); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.DOI = Zotero.Utilities.trimInternal(item.notes[0]['note'].substr(4)); - item.notes = new Array(); - item.attachments = [ - {url:item.url, title:"Blackwell Synergy Snapshot", mimeType:"text/html"}, - {url:item.url.replace(/\/\/[^/]*/, "//" + host).replace("/doi/abs", "/doi/pdf"), title:"Blackwell Synergy Full Text PDF", mimeType:"application/pdf"} - ]; - // use fulltext if possible - var oldCreators = item.creators; - item.creators = [] - for each (var author in oldCreators) { - if (author["lastName"] != "") { - item.creators.push({firstName:titleCase(author.firstName), lastName:titleCase(author.lastName), creatorType:"author"}); - } - } - item.title = titleCase(item.title); - item.complete(); - }); - translator.translate(); - - Zotero.done(); - }); -} -\ No newline at end of file diff --git a/translators/Blaetter.js b/translators/Blaetter.js @@ -1,156 +0,0 @@ -{ - "translatorID": "e8e10bd4-fd6f-4297-a060-a8e0a479043f", - "label": "Blaetter fuer deutsche und internationale Politik", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.blaetter\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-31 15:50:04" -} - -/* -Blätter für deutsche und internationale Politik -Copyright (C) 2011 Martin Meyerhoff - -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) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var Blaetter_ArticleTools_XPath = ".//div[contains(@id, 'node')]/h2"; - var Blaetter_Multiple_XPath = ".//div[contains(@class, 'teaser') and not(contains(@class, 'dossier'))]/h3[@class='headline']/a"; - - if (doc.evaluate(Blaetter_ArticleTools_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("magazineArticle"); - return "magazineArticle"; - } else if (doc.evaluate(Blaetter_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - return "multiple"; - } -} - - -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("magazineArticle"); - newItem.url = doc.location.href; - - - // This is for the title - - var title_XPath =".//h2[@class='headline']"; - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = title; - - // Author - var author_XPath = ".//h4[@class='author']/a"; - if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null)){ - var author_obj = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_author; - while (next_author= author_obj.iterateNext()) { - Zotero.debug(next_author.textContent); - newItem.creators.push(Zotero.Utilities.cleanAuthor(next_author.textContent, "author")); - } - } - - // Tags - var tags_XPath = ".//p[@class='credit']/a[@class='rb']"; - if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null)){ - var tags_obj = doc.evaluate(tags_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_tag; - while (next_tag= tags_obj.iterateNext()) { - newItem.tags.push(next_tag.textContent); - } - } - - // Attachment. If there's a PDF available, grab it, otherwise just take the HTML site. - var pdfurl_XPath = "//ul/li[contains(@class, 'download')]/a"; - if (doc.evaluate(pdfurl_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var pdfurl = doc.evaluate(pdfurl_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - newItem.attachments.push({url:pdfurl, title:doc.title, mimeType:"application/pdf"}); - - } else { - newItem.attachments.push({url:doc.location.href, title:doc.title, mimeType:"text/html"}); - - } - - // Publication Title - newItem.publicationTitle = "Blätter für deutsche und internationale Politik"; - // Issue, Year and Date - var credit_XPath = ".//p[@class='credit']"; - if (doc.evaluate(credit_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var credit= doc.evaluate(credit_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.date = credit.replace(/.*(\d+)\/(\d\d\d\d?).*\n.*/g, '$2-$1-00'); // Standard Date Format - newItem.date = newItem.date.replace(/-(\d)-/, '-0$1-'); // If Month is single-digit, add a zero before it. - newItem.pages= credit.replace(/.*,\sSeite\s(\d+-\d+).*\n.*/g, '$1'); - } else if (doc.location.href.match("/dokumente/") ){ - var title2_XPath =".//h3[@class='subtitle']"; - // Zotero doesn't have a field for subtitle, so just add a colon and then the subtitle. - var title2 = doc.evaluate(title2_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = newItem.title + ": " + title2.replace(/(.*)(,\s\d+\.\d+\.\d\d\d\d)$/, '$1'); - // And the date is in there as well... - newItem.date = title2.replace(/(.*,\s)(\d+\.\d+\.\d\d\d\d)$/, '$2'); - } - - var summary_XPath = ".//meta[@name='description']"; - var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.abstractNote = Zotero.Utilities.unescapeHTML(summary); - - newItem.complete(); -} -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var Blaetter_Multiple_XPath = ".//div[contains(@class, 'teaser') and not(contains(@class, 'dossier'))]/h3[@class='headline']/a"; - if (doc.evaluate(Blaetter_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var titles = doc.evaluate(Blaetter_Multiple_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - } - var next_title; - - while (next_title = titles.iterateNext()) { - Zotero.debug(next_title.textContent); - items[next_title.href] = next_title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/Blogger.js b/translators/Blogger.js @@ -1,125 +0,0 @@ -{ - "translatorID": "6f9aa90d-6631-4459-81ef-a0758d2e3921", - "label": "Blogger", - "creator": "Adam Crymble", - "target": "blogspot\\.com", - "minVersion": "1.0.0b4.r5", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-27 20:13:50" -} - -function detectWeb(doc, url) { - var result = doc.evaluate('//h3[contains(@class,"post-title") and contains(@class,"entry-title")]', doc, null, XPathResult.ANY_TYPE, null); - var entry = result.iterateNext(); - if (entry && result.iterateNext()) { - return "multiple"; - } else if (entry) { - return "blogPost"; - } else { - return false; - } -} - -//Blogger translator. Code by Adam Crymble - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var tagsContent = new Array(); - - var newItem = new Zotero.Item("blogPost"); - - //title - if (doc.evaluate('//h3[@class="post-title entry-title"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - newItem.title = doc.evaluate('//h3[@class="post-title entry-title"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - newItem.title = doc.title; - } - - //author, if available - if (doc.evaluate('//span[@class="post-author vcard"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate('//span[@class="post-author vcard"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - var author = author.toLowerCase(); - - if (author.match(/\sby\s/)) { - var shortenAuthor = author.indexOf(" by"); - author = author.substr(shortenAuthor + 3).replace(/^\s*|\s$/g, ''); - } - var words = author.split(/\s/); - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - } - author = words.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - //date, if available - if (doc.evaluate('//h2[@class="date-header"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.date = doc.evaluate('//h2[@class="date-header"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - } - - //tags, if available - if (doc.evaluate('//span[@class="post-labels"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var tags = doc.evaluate('//span[@class="post-labels"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var tags1; - while (tags1 = tags.iterateNext()) { - tagsContent.push(tags1.textContent); - } - - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - } - - var blogTitle1 = doc.title.split(":"); - newItem.blogTitle = blogTitle1[0]; - - newItem.url = doc.location.href; - - newItem.complete(); -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//h3[@class="post-title entry-title"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var titles1 = doc.evaluate('//li[@class="archivedate expanded"]/ul[@class="posts"]/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - - while (next_title = titles1.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Bookmarks.js b/translators/Bookmarks.js @@ -1,169 +0,0 @@ -{ - "translatorID": "4e7119e0-02be-4848-86ef-79a64185aad8", - "label": "Bookmarks", - "creator": "Avram Lyon", - "target": "html", - "minVersion": "2.1b6", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 3, - "browserSupport": "gscn", - "lastUpdated": "2011-07-09 18:52:34" -} - -/* - Browser bookmarks 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/>. - */ - - /* This translator imports and exports browser bookmark files in the standard - * "Netscape Bookmark Format". - * See http://msdn.microsoft.com/en-us/library/aa753582%28VS.85%29.aspx - * This code draws from the CSL style for bookmark export, by Rintze Zelle - * http://www.zotero.org/styles/bookmark-export - * Input looks like: -<!DOCTYPE NETSCAPE-Bookmark-file-1> -<!-- This is an automatically generated file. - It will be read and overwritten. - DO NOT EDIT! --> -<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> -<TITLE>Bookmarks</TITLE> -<H1>Bookmarks Menu</H1> -<DL> - <DT><A HREF="http://www.example.com/">Example Site</A></DT> - <DD>Longer title</DD> -</DL> - */ - -const MAX_DETECT_LINES = 150; - -function detectImport() { - var text = ""; - var line; - var match; - var re = /<DT>\s*<A[^>]*HREF="([^"]+)"[^>]*>([^<\n]+)/gi; - var i = 0; - while((line = Zotero.read()) !== false && (i++ < MAX_DETECT_LINES)) { - text += line; - match = re.exec(text); - if (match) { - Zotero.debug("Found a match with line: "+line); - return true; - } - } - return false; -} - -function doImport() { - var line; - var hits; - var item = false; - var itemIncomplete = false; - var collection = false; - var re = /([A-Za-z_]+)="([^"]+)"/g; - while((line = Zotero.read()) !== false) { - if (line.indexOf("<DT>") !== -1 && line.indexOf("<A") !== -1) { - if (itemIncomplete) item.complete(); - itemIncomplete = true; - //Zotero.debug(line); - item = new Zotero.Item("webpage"); - if (collection) collection.children.push(item); - item.title = line.match(/>([^<]*)<\/A>/)[1]; - //Zotero.debug(item.title); - while(hits = re.exec(line)) { - if (!hits) { - Zotero.debug("RE no match in "+line); - continue; - } - switch (hits[1]) { - case "HREF": item.url = hits[2]; - break; - case "TAGS": item.tags = hits[2].split(','); break; - case "ICON": break; - case "ICON_URI": break; - case "ADD_DATE": - item.accessDate = convertDate(hits[2]); - break; - default: item.extra = item.extra ? item.extra + "; "+ [hits[1], hits[2]].join("=") : - [hits[1], hits[2]].join("="); - } - } - if (item.url.match(/^place:/)) { - item = false; - itemIncomplete = false; - } - } else if (line.indexOf("<DT>") !== -1 && line.indexOf("<H3") !== -1) { - if (collection) { - collection.complete(); - } - collection = new Zotero.Collection(); - collection.name = Zotero.Utilities.unescapeHTML(line.match(/<H3[^>]*>([^<]*)<\/H3>/i)[1]); - Zotero.debug("Starting collection: "+ collection.name); - collection.type = "collection"; - collection.children = new Array(); - } else if (line.substr(0,4) == "<DD>") { - if (itemIncomplete) item.abstractNote = item.abstractNote ? item.abstractNote + " " + line.substr(4) : line.substr(4); - else Zotero.debug("Discarding description line without item: " + line); - } else { - //Zotero.debug("Discarding line: " + line); - } - } - if (item && itemIncomplete) item.complete(); - if (collection) collection.complete(); -} - -function convertDate(timestamp){ - var d = new Date(timestamp*1000); - function pad(n){return n<10 ? '0'+n : n}; - return d.getUTCFullYear()+'-' - + pad(d.getUTCMonth()+1)+'-' - + pad(d.getUTCDate())+' ' - + pad(d.getUTCHours())+':' - + pad(d.getUTCMinutes())+':' - + pad(d.getUTCSeconds())+' UTC'; - } - - - -function doExport() { - var item; - - var header = '<!DOCTYPE NETSCAPE-Bookmark-file-1>\n'+ -'<!-- This is an automatically generated file.\n'+ -' It will be read and overwritten.\n'+ -' DO NOT EDIT! -->\n'+ -'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">\n'+ -'<TITLE>Bookmarks</TITLE>\n'+ -'<H1>Bookmarks Menu</H1>\n'+ -'<DL>\n'; - var footer = '</DL>'; - //var tags = ""; - - Zotero.write(header); - while (item = Zotero.nextItem()) { - // TODO Be more verbose, making an informative title and including more metadata - //tags = item.tags.forEach(function (tag) {return tag.tag}).join(","); - if (item.url) Zotero.write(' <DT><A HREF="'+item.url+'">'+item.title+'</A>\n'); - else Zotero.debug("Skipping item without URL: "+item.title); - } - Zotero.write(footer); -} - - -/** BEGIN TEST CASES **/ -var testCases = [] -/** END TEST CASES **/ diff --git a/translators/Bracero History Archive.js b/translators/Bracero History Archive.js @@ -1,171 +0,0 @@ -{ - "translatorID":"f9373e49-e6ac-46f7-aafe-bb24a2fbc3f0", - "translatorType":4, - "label":"Bracero History Archive", - "creator":"Adam Crymble", - "target":"http://braceroarchive.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:40:00" -} - -function detectWeb(doc, url) { - if (doc.title.match("Item")) { - return "book"; - } else if (doc.evaluate('//div[@class="item-meta"]/h2/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -//Bracero History Archive translator; Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - var contents1; - - var headers = doc.evaluate('//h3', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//div[@class="field"]/div', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//div[@class="field"]/div)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue -1; i++) { - - fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, ''); - contents1 = contents.iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - - if (contents1.match("Empty")) { - contents1 = ''; - } - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents1); - } - - //media type? - if (dataTags["TypeName"]) { - if (dataTags["TypeName"].match("Oral History")) { - Zotero.debug(doc.title); - var newItem = new Zotero.Item("audioRecording"); - } else { - var newItem = new Zotero.Item("book"); - } - } else { - var newItem = new Zotero.Item("book"); - } - - //creators - if (dataTags["Interviewee"] && dataTags["Interviewee"] != '') { - if (dataTags["Interviewee"].match(", ")) { - var authors = dataTags["Interviewee"].split(", "); - authors = authors[1] + ' ' + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "interviewee")); - } else { - newItem.creators.push({lastName: dataTags["Interviewee"], creatorType: "interviewee"}); - } - } - - if (dataTags["Interviewer"] && dataTags["Interviewer"] != '') { - if (dataTags["Interviewer"].match(", ")) { - var authors = dataTags["Interviewer"].split(", "); - authors = authors[1] + ' ' + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "interviewer")); - } else { - newItem.creators.push({lastName: dataTags["Interviewee"], creatorType: "interviewer"}); - } - } - - if (dataTags["Creator"] && dataTags["Creator"] != '') { - if (dataTags["Creator"].match(", ")) { - var authors = dataTags["Creator"].split(", "); - authors = authors[1] + ' ' + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "creator")); - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Creator"], "creator")); - } - } - - if (dataTags["AdditionalCreator"] && dataTags["AdditionalCreator"] != '') { - if (dataTags["AdditionalCreator"].match(", ")) { - var authors = dataTags["AdditionalCreator"].split(", "); - authors = authors[1] + ' ' + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "creator")); - } else { - newItem.creators.push({lastName: dataTags["AdditionalCreator"], creatorType: "creator"}); - } - } - - //associate - associateData (newItem, dataTags, "Description", "abstractNote"); - associateData (newItem, dataTags, "Date", "date"); - associateData (newItem, dataTags, "Publisher", "publisher"); - associateData (newItem, dataTags, "Source", "place"); - associateData (newItem, dataTags, "Location", "place"); - associateData (newItem, dataTags, "RightsHolder", "rights"); - associateData (newItem, dataTags, "Language", "lang"); - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "FileNameIdentifier", "callNumber"); - - //tags - var tags1; - var tagsContent = new Array(); - - if (doc.evaluate('//li[@class="tag"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var xPathTags = doc.evaluate('//li[@class="tag"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (tags1 = xPathTags.iterateNext()) { - tagsContent.push(tags1.textContent); - } - } - - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - - //title - newItem.title = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - newItem.url = doc.location.href; - newItem.complete(); -} - -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 fullRecord = "view=full"; - var extraChar = "?"; - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//div[@class="item-meta"]/h2/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href + extraChar + fullRecord] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Bryn Mawr Classical Review.js b/translators/Bryn Mawr Classical Review.js @@ -1,85 +0,0 @@ -{ - "translatorID":"635c1246-e0c8-40a0-8799-a73a0b013ad8", - "translatorType":4, - "label":"Bryn Mawr Classical Review", - "creator":"Michael Berkowitz", - "target":"http://ccat.sas.upenn.edu/bmcr/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/by_reviewer/) || url.match(/by_author/) || url.match(/recent.html/) || url.match(/\/\d{4}\/$/)) { - return "multiple"; - } else if (url.match(/[\d\-]+\.html$/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var ns = doc.documentElement.namespaceURI; - var nsResolver = ns ? function(prefix) { - if (prefix == 'x') return ns; else return null; - } : null; - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('//table/tbody/tr/td/ul/li/i', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var boxes = doc.evaluate('//table/tbody/tr/td/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var box; - while (box = boxes.iterateNext()) { - var link = doc.evaluate('./a', box, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - var title = doc.evaluate('./i', box, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - items[link] = title; - } - } else if (doc.evaluate('//table/tbody/tr/td/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var title = doc.evaluate('//table/tbody/tr/td/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var next; - while (next = title.iterateNext()) { - items[next.href] = Zotero.Utilities.trimInternal(next.textContent); - } - } else if (url.match(/google\.com/)) { - var titles = doc.evaluate('//h2[@class="r"]/a[@class="l"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - items[title.href] = title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - var title = doc.evaluate('//h3/i', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.title = "Review of: " + Zotero.Utilities.trimInternal(title); - var data = doc.evaluate('//h3[i]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var title = title.replace("(", "\\(").replace(")", "\\)"); - var author = doc.evaluate('//b[contains(text(), "Reviewed")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/Reviewed by\s+([^,]+),/)[1]; - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - var splitRe = new RegExp(title); - var authors = data.split(splitRe)[0].replace(/\([^)]+\)/, "").split(/(,|and)\s+/); - Zotero.debug(authors); - Zotero.debug(authors); - for each (var aut in authors) { - if (aut.match(/\w/) && (aut != "and")) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "reviewedAuthor")); - } - } - item.url = doc.location.href; - item.attachments = [{url:item.url, title:item.title, mimeType:"text/html"}]; - if (doc.evaluate('/html/body/center/table/tbody/tr/td/center/table/tbody/tr/td/center/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - item.date = Zotero.Utilities.trimInternal(doc.evaluate('/html/body/center/table/tbody/tr/td/center/table/tbody/tr/td/center/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("Bryn Mawr Classical Review ", "").replace(/\./g, "/")); - } else { - item.date = Zotero.Utilities.trimInternal(doc.evaluate('/html/body/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("Bryn Mawr Classical Review ", "").replace(/\./g, "/")) - } - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Business Standard.js b/translators/Business Standard.js @@ -1,67 +0,0 @@ -{ - "translatorID":"e8d40f4b-c4c9-41ca-a59f-cf4deb3d3dc5", - "translatorType":4, - "label":"Business Standard", - "creator":"Prashant Iyengar and Michael Berkowitz", - "target":"http://www.business-standard.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/googlesearch/)) { - return "multiple"; - } else if (url.match(/common/)) { - return "newspaperArticle"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var links = doc.evaluate('//a[@class="NewsHead"]', doc, null, XPathResult.ANY_TYPE, null); - var link; - var items = new Object(); - while (link = links.iterateNext()) { - items[link.href] = Zotero.Utilities.cleanTags(link.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "The Business Standard"; - newItem.url = doc.location.href; - newItem.websiteTitle="The Business Standard"; - newItem.edition="Online"; - newItem.title = Zotero.Utilities.cleanTags(doc.title); - - - if (doc.evaluate('//td[@class="author"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var bits = doc.evaluate('//td[@class="author"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\s+\/\s+/); - newItem.creators.push(Zotero.Utilities.cleanAuthor(bits[0], "author")); - extras = Zotero.Utilities.trimInternal(bits[1]).match(/^(.*)(\s\w+\s+\d+,\s*\d+)$/); - newItem.place = extras[1]; - newItem.date = Zotero.Utilities.trimInternal(extras[2]); - newItem.complete(); - } else if (doc.evaluate('//td[@class="NewsSummary"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="NewsSummary"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - var printurl = 'http://www.business-standard.com/general/printpage.php?autono=' + newItem.url.match(/autono=(\d+)/)[1]; - Zotero.debug(printurl); - Zotero.Utilities.HTTP.doGet(printurl, function(text) { - var date = text.match(/<td class=author>([^<]+)</)[1]; - newItem.date = Zotero.Utilities.trimInternal(date.split("&nbsp;")[1]); - newItem.complete(); - }); - } - }, function() {Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/BusinessWeek.js b/translators/BusinessWeek.js @@ -1,58 +0,0 @@ -{ - "translatorID":"fb342bae-7727-483b-a871-c64c663c2fae", - "translatorType":4, - "label":"BusinessWeek", - "creator":"Michael Berkowitz", - "target":"http://(www\\.)?businessweek.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.title == "BusinessWeek Search Results") { - return "multiple"; - } else if (doc.evaluate('//meta[@name="headline"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "magazineArticle"; - } -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var results = doc.evaluate('//div[@class="result"]/h3[@class="story"]/a', doc, null, XPathResult.ANY_TYPE, null); - var result; - var items = new Object(); - while (result = results.iterateNext()) { - items[result.href] = Zotero.Utilities.trimInternal(result.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - Zotero.debug(articles); - Zotero.Utilities.processDocuments(articles, function(newDoc) { - var metaTags = new Object(); - var metas = newDoc.evaluate('//meta', newDoc, null, XPathResult.ANY_TYPE, null); - var meta; - while (meta = metas.iterateNext()) { - metaTags[meta.name] = meta.content; - } - Zotero.debug(metaTags); - var item = new Zotero.Item("magazineArticle"); - item.title = metaTags['headline']; - item.abstractNote = metaTags['abstract']; - item.tags = metaTags['keywords'].split(/\s*,\s*/); - item.creators.push(Zotero.Utilities.cleanAuthor(metaTags['author'], "author")); - item.publicationTitle = "BusinessWeek: " + metaTags['channel']; - item.url = newDoc.location.href; - item.date = metaTags['pub_date'].replace(/(\d{4})(\d{2})(\d{2})/, "$2/$3/$1"); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/CABI - CAB Abstracts.js b/translators/CABI - CAB Abstracts.js @@ -1,132 +0,0 @@ -{ - "translatorID":"a29d22b3-c2e4-4cc0-ace4-6c2326144332", - "translatorType":4, - "label":"CABI - CAB Abstracts", - "creator":"Adam Crymble", - "target":"http://www.cabi.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-29 21:10:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div/table/tbody/tr[1]/td/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//span[@class="PageSubTitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -//CAB Abstracts translator. Code by Adam Crymble -//only designed for "book" entries. People, projects, sites, etc are ignored by Zotero. - -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("book"); - -//authors - if (doc.evaluate('//td[@class="smallwebtext"]/table/tbody/tr/td[1]/span[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var xPathAuthors = doc.evaluate('//td[@class="smallwebtext"]/table/tbody/tr/td[1]/span[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPath1Count = doc.evaluate('count (//td[@class="smallwebtext"]/table/tbody/tr/td[1]/span[@class="MenuBar"])', doc, nsResolver, XPathResult.ANY_TYPE, null); - var nameTest = 0; - - for (var j = 0; j < xPath1Count.numberValue; j++) { - authors = xPathAuthors.iterateNext().textContent - if (authors.match("by ")) { - var shortenAuthor = authors.indexOf("by ")+3; - - authors = authors.substr(shortenAuthor).split("; "); - - for (var i = 0; i < authors.length; i++) { - - shortenAuthor = authors[i].indexOf(","); - authors[i] = (authors[i].substr(0, shortenAuthor)); - var givenName = (authors[i].split(/\s/)); - authors[i] = ''; - - for (var k = 0; k < givenName.length; k++) { - if (givenName[k].length == 1) { - authors[i] = (authors[i] + givenName[k] + "."); - } else { - - authors[i] = (authors[i] + " " + givenName[k]); - } - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } - } - } - -//imprint info - var info = new Array(); - if (doc.evaluate('//td[3]/table/tbody/tr/td[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var xPathImprint = doc.evaluate('//td[3]/table/tbody/tr/td[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var imprint = xPathImprint.iterateNext().textContent.split(/\n/); - - - for (var i = 0; i < imprint.length; i++) { - imprint[i] = imprint[i].replace(/^\s*|\s*$/g, ''); - if (imprint[i].match(/\w/)) { - info.push(imprint[i]); - } - } - - for (var i = 0; i < info.length; i++) { - if (info[i].match("pages")) { - var cutPages = info[i].indexOf("pages"); - newItem.pages = info[i].substr(0, cutPages); - } else if (info[i].match("Date:")) { - newItem.date = info[i].substr(10); - } else if (info[i].match("ISBN: ")) { - newItem.ISBN = info[i].substr(6); - } - } - } - - newItem.title = doc.title; - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//tr[1]/td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var mediaType = doc.evaluate('//strong', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var dump = mediaType.iterateNext(); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = mediaType.iterateNext().textContent; - if (items[next_title.href].match("Book")) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/CARLABRC OAI Harvester.js b/translators/CARLABRC OAI Harvester.js @@ -1,121 +0,0 @@ -{ - "translatorID":"31649d9d-8f7e-4b87-8678-b3e68ee98f39", - "translatorType":4, - "label":"CARL/ABRC OAI Harvester", - "creator":"Adam Crymble", - "target":"http://carl-abrc-oai", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:40:00" -} - -function detectWeb(doc, url) { - if (doc.title.match("Search")) { - return "multiple"; - } else if (doc.title.match("Browse")) { - return "multiple"; - } else if (doc.title.match("Record")) { - return "book"; - } -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var allAuthors = new Array(); - - var newItem = new Zotero.Item("book"); - - var metaTagHTML = doc.getElementsByTagName("meta"); - - for (var i = 0 ; i < metaTagHTML.length ; i++) { - dataTags[metaTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content")); - if (metaTagHTML[i].getAttribute("name") == "DC.Creator") { - allAuthors.push(dataTags["DC.Creator"]); - } - - } - Zotero.debug(allAuthors); - - for (var i = 0; i < allAuthors.length; i++) { - - - if (allAuthors[i].match(",")) { - var authorName = allAuthors[i].split(","); - allAuthors[i] = (authorName[1] + (" ") + authorName[0]); - - if (allAuthors[i].match("; ; ")) { - - allAuthors[i] = allAuthors[i].replace("; ;", ''); - } - - - newItem.creators.push(Zotero.Utilities.cleanAuthor(allAuthors[i], "author")); - } else { - if (allAuthors[i].match("; ; ")) { - - allAuthors[i] = allAuthors[i].replace("; ;", ''); - } - - newItem.creators.push({lastName: allAuthors[i], creatorType: "creator"}); - } - - - } - - - associateData (newItem, dataTags, "DC.Title", "title"); - associateData (newItem, dataTags, "DC.Description", "abstractNote"); - associateData (newItem, dataTags, "DC.Publisher", "publisher"); - associateData (newItem, dataTags, "DC.Contributor", "extra"); - associateData (newItem, dataTags, "DC.Date", "date"); - associateData (newItem, dataTags, "DC.Language", "language"); - - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//span[@class="title"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//div[@class="main"]/div/div/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[links.iterateNext().href] = next_title.textContent; - links.iterateNext(); - } - 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(); -} -\ No newline at end of file diff --git a/translators/CNKI.js b/translators/CNKI.js @@ -1,787 +0,0 @@ -{ - "translatorID":"5c95b67b-41c5-4f55-b71a-48d5d7183063", - "label":"CNKI", - "creator":"Ace Strong <acestrong@gmail.com> and Heromyth <zxpmyth@yahoo.com.cn>", - "target":"^https?://(?:(?:(dlib|epub|acad|apj1|law1|www)\\.cnki\\.net)|(?:[0-9\\.]+))/(?:grid2008|kns50|Kns55|kcms)", - "minVersion":"2.0rc1", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-12-10 14:32:46" -} - -/* - CNKI(China National Knowledge Infrastructure) Translator - Copyright (C) 2009-2010 TAO Cheng, acestrong@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/>. -*/ - -// ####################### -// ##### Sample URLs ##### -// ####################### - -/* - * The starting point for an search is the URL below. - * In testing, I tried the following: - * - * - A search listing of journals - * - A search listing of phd thesis - * - A search listing of master thesis - * - A search listing of conference papers - * - A search listing of newspaper articles - * - A journal paper page - * - A phd thesis page - * - A master thesis page - * - A conference paper page - * - A newspaper article page - */ -// http://epub.cnki.net/grid2008/index/ZKCALD.htm - - -// ################################# -// #### Local utility functions #### -// ################################# - -function detectCode(url) { - var pattern = /(?:dbcode|dbname)=([A-Za-z]{4})/i; - if (pattern.test(url)) { - var code = pattern.exec(url)[1]; - return code; - } else { - // parse from source page - var page = Zotero.Utilities.retrieveSource(url); - pattern = /id="nowdbname"[^>]*?>(.*?)<\/SPAN>/i; - if (pattern.test(page)) { - var dbname = pattern.exec(page)[1]; -// Zotero.debug(dbname); - if (dbname == "中国期刊全文数据库") { - return "CJFD"; - } - } - } - return "NONE"; -} - -function getResolver(doc) { - var namespace, resolver; - namespace = doc.documentElement.namespaceURI; - if (namespace) { - resolver = function(prefix) { - if (prefix == 'x') { - return namespace; - } else { - return null; - } - }; - } else { - resolver = null; - } - return resolver; -} - -function trimTags(text) { - var pattern = /(<.*?>)/g; - text = text.replace(pattern, ""); - return text; -} - -function trimMultiline(text) { - var pattern = /(\s{2,})/g; - text = text.replace(pattern, "\n"); - return text; -} - -// ############################# -// ##### Scraper functions ##### -// ############################# - -// work for journalArticle -function scrapeAndParse1(url) { -// Zotero.debug("journalArticle"); - Zotero.Utilities.doGet(url, function(page) { - var pattern; - - // 类型 & URL - var itemType = "journalArticle"; - var newItem = new Zotero.Item(itemType); -// Zotero.debug(url); - newItem.url = url; - - // 标题/Title - pattern = /<span (?:id="chTitle"|class='datatitle')>(.*?)<\/span>/; - if (pattern.test(page)) { - var title = trimTags(pattern.exec(page)[1]); - newItem.title = title; -// Zotero.debug("title: "+title); - } - - // 作者/Authors - var authorNames; - pattern = /【作者】(?:[\s\S]*?)GetLinkListEx\('(.*?);','/; - if (pattern.test(page)) { - authorNames = pattern.exec(page)[1].split(";"); - } else { - pattern = /【作者】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - authorNames = trimTags(pattern.exec(page)[1]).split(";"); - } - } - if (authorNames) { - for (var i=0; i<authorNames.length; i++) { - var authorName = Zotero.Utilities.trim(authorNames[i]); - if (authorName.length > 0) { - newItem.creators.push( - Zotero.Utilities.cleanAuthor(authorNames[i], - "author", true)); - } - } -// Zotero.debug("authorNames:\n"+authorNames); - } - - // 摘要/Abstract - var abst; - pattern = /【摘要】\s*<[^>]*>(.*?)<\/span>/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } else { - pattern = /【摘要】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } - } - if (abst) { -// Zotero.debug("abstract:\n"+abst); - newItem.abstractNote = Zotero.Utilities.trim(abst); - } - - pattern = /【Abstract】\s*<[^>]*>(.*?)<\/span>/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } else { - pattern = /【英文摘要】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } - } - if (abst) { -// Zotero.debug("abstract:\n"+abst); - if (newItem.abstractNote===undefined) { - newItem.abstractNote = Zotero.Utilities.trim(abst); - } else { - newItem.abstractNote = newItem.abstractNote + "\n" - + Zotero.Utilities.trim(abst); - } - } -// Zotero.debug(newItem.abstractNote); - - // 关键词/Keywords - var tags; - pattern = /【关键词】(?:[\s\S]*?)KeywordFilter\('(.*?)'\),'kw'/; - if (pattern.test(page)) { - tags = pattern.exec(page)[1].split(";"); - } else { - pattern = /【(?:中文)?关键词】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - tags = trimTags(pattern.exec(page)[1]).split(";"); - } - } - if (tags) { - for (var i=0; i<tags.length; i++) { - var tag = Zotero.Utilities.trim(tags[i]); - if (tag.length>0 && newItem.tags.indexOf(tag)<0) { - newItem.tags.push(tag); - } - } -// Zotero.debug("tags:\n"+tags); - } - pattern = /【Key words】(?:[\s\S]*?)GetLinkList\('(.*?)','kw'/; - if (pattern.test(page)) { - tags = pattern.exec(page)[1].split(";"); - } else { - pattern = /【英文关键词】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - tags = trimTags(pattern.exec(page)[1]).split(";"); - } - } - if (tags) { - for (var i=0; i<tags.length; i++) { - var tag = Zotero.Utilities.trim(tags[i]); - if (tag.length>0 && newItem.tags.indexOf(tag)<0) { - newItem.tags.push(tag); - } - } -// Zotero.debug("tags:\n"+tags); - } - - // 文献出处 & DOI & 出版时间 - pattern = /【(?:文献出处|刊名)】([\s\S]*?)<\/a>/; - if (pattern.test(page)) { - var publicationTitle = trimTags(pattern.exec(page)[1]); - newItem.publicationTitle = Zotero.Utilities.trim(publicationTitle); -// Zotero.debug("publicationTitle: "+publicationTitle); - } - var doi; - pattern = /【DOI】(.*?)<\/li>/; - if (pattern.test(page)) { - doi= pattern.exec(page)[1]; - } else { - pattern = /【DOI】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - doi= trimTags(pattern.exec(page)[1]); - } - } - if (doi) { - newItem.DOI = Zotero.Utilities.trim(doi); -// Zotero.debug("doi: "+doi); - } - pattern = /【(?:文献出处|刊名)】(?:[\s\S]*?)(\d{4})年\s*([0-9A-Z]{2})(卷|期)/; - if (pattern.test(page)) { - var date = pattern.exec(page)[1]; - newItem.date = date; - var val = pattern.exec(page)[2]; - var attr = pattern.exec(page)[3]; - if (attr == "卷") { - newItem.volume = val; - } else { - newItem.issue = val; - } -// Zotero.debug("date: "+date); -// Zotero.debug("val: "+val); -// Zotero.debug("attr: "+attr); - } - - newItem.complete(); - }); -} - -// work for thesis -function scrapeAndParse2(url) { -// Zotero.debug("thesis"); - Zotero.Utilities.doGet(url, function(page) { - var pattern; - - // 类型 & URL - var itemType = "thesis"; - var newItem = new Zotero.Item(itemType); -// Zotero.debug(url); - newItem.url = url; - var code = detectCode(url); - if (code == "CDFD") { - newItem.thesisType = "博士论文" - } else { - newItem.thesisType = "硕士论文" - } -// Zotero.debug(newItem.thesisType); - - - // 标题/Title - pattern = /<span (?:id="chTitle"|class='datatitle')>(.*?)<\/span>/; - if (pattern.test(page)) { - var title = pattern.exec(page)[1]; - pattern = /(<.*?>)/g; - title = title.replace(pattern, ""); - newItem.title = title; -// Zotero.debug("title: "+title); - } - - // 作者/Author - pattern = /【作者】([\s\S]*?)<\/a>/; - if (pattern.test(page)) { - var authorNames = trimTags(pattern.exec(page)[1]).split(";"); - for (var i=0; i<authorNames.length; i++) { - newItem.creators.push( - Zotero.Utilities.cleanAuthor(authorNames[i], - "author", true)); - } -// Zotero.debug("authorNames:\n"+authorNames); - } - - // 导师/Tutors - pattern = /【导师】([\s\S]*?)<\/a>/; - if (pattern.test(page)) { - var directors = trimTags(pattern.exec(page)[1]).split(";"); - for (var i=0; i<directors.length; i++) { - newItem.creators.push( - Zotero.Utilities.cleanAuthor(trimTags(directors[i]), - "director", true)); - } -// Zotero.debug("directors: "+directors); - } - - // 摘要/Abstract - var abst; - pattern = /ReplaceFont\('ChDivSummary','(.*?)(?='\);ReplaceFont)/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } else { - pattern = /【中文摘要】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } - } - if (abst) { -// Zotero.debug("abstract:\n"+abst); - newItem.abstractNote = trimMultiline(abst); - } - pattern = /ReplaceFont\('EnDivSummary','(.*?)(?='\);if)/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } else { - pattern = /【英文摘要】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - abst = trimTags(pattern.exec(page)[1]); - } - } - if (abst) { -// Zotero.debug("abstract:\n"+abst); - if (newItem.abstractNote===undefined) { - newItem.abstractNote = Zotero.Utilities.trim(abst); - } else { - newItem.abstractNote = newItem.abstractNote + "\n" - + trimMultiline(abst); - } - } -// Zotero.debug(newItem.abstractNote); - - // 关键词/Keywords - var tags; - pattern = /【关键词】\s*<span[^>]*>(.*?)<\/a>*<\/span>/; - if (pattern.test(page)) { - tags = trimTags(pattern.exec(page)[1]).split(";"); - } else { - pattern = /【关键词】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - tags = trimTags(pattern.exec(page)[1]).split(";"); - } - } - if (tags) { - for (var i=0; i<tags.length; i++) { - var tag = Zotero.Utilities.trim(tags[i]); - if (tag.length>0 && newItem.tags.indexOf(tag)<0) { - newItem.tags.push(tag); - } - } -// Zotero.debug("tags:\n"+tags); - } - pattern = /【Key words】\s*<span[^>]*>(.*?)<\/a>*<\/span>/; - if (pattern.test(page)) { - tags = trimTags(pattern.exec(page)[1]).split(";"); - } else { - pattern = /【英文关键词】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - tags = trimTags(pattern.exec(page)[1]).split(";"); - } - } - if (tags) { - for (var i=0; i<tags.length; i++) { - var tag = Zotero.Utilities.trim(tags[i]); - if (tag.length>0 && newItem.tags.indexOf(tag)<0) { - newItem.tags.push(tag); - } - } -// Zotero.debug("tags:\n"+tags); - } -// Zotero.debug(newItem.tags); - - // 出版学校 & DOI & 出版时间 - var university; - pattern = /【网络出版投稿人】\s*<a[^>]*>(.*?)<\/a>/; - if (pattern.test(page)) { - university = pattern.exec(page)[1]; - } else { - pattern = /【网络出版投稿人】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - university = Zotero.Utilities.trim( - trimTags(pattern.exec(page)[1])); - } - } - if (university) { - pattern = /(.*?)((.*?))/; - if (pattern.test(university)) { - newItem.university = pattern.exec(university)[1]; - newItem.place = pattern.exec(university)[2]; - } else { - newItem.publisher = university; - } -// Zotero.debug("university: "+university); - } - var doi; - pattern = /【DOI】(.*?)<\/li>/; - if (pattern.test(page)) { - doi= pattern.exec(page)[1]; - } else { - pattern = /【DOI】([\s\S]*?)<\/tr>/; - if (pattern.test(page)) { - var doi= trimTags(pattern.exec(page)[1]); - } - } - if (doi) { - newItem.DOI = Zotero.Utilities.trim(doi); -// Zotero.debug("doi: "+doi); - } - var date; - pattern = /【网络出版投稿时间】(.*?)\s*<\/li>/; - if (pattern.test(page)) { - date = pattern.exec(page)[1]; - } else { - pattern = /【网络出版投稿时间】([\s\S]*?)\s*<\/tr>/; - if (pattern.test(page)) { - date = trimTags(pattern.exec(page)[1]); - } - } - if (date) { - newItem.date = Zotero.Utilities.trim(date); -// Zotero.debug("date: "+date); - } - - newItem.complete(); - }); -} - -// work for conferencePaper -function scrapeAndParse3(url) { -// Zotero.debug("conferencePaper"); - Zotero.Utilities.doGet(url, function(page) { - var pattern; - - // 类型 & URL - var itemType = "conferencePaper"; - var newItem = new Zotero.Item(itemType); -// Zotero.debug(url); - newItem.url = url; - - // 标题/Title - pattern = /<span id="chTitle">(.*?)<\/span>/; - if (pattern.test(page)) { - var title = trimTags(pattern.exec(page)[1]); - newItem.title = title; -// Zotero.debug("title: "+title); - } - - // 作者/Authors - pattern = /【作者】(.*?)<\/p>/; - if (pattern.test(page)) { - var authorNames = trimTags(pattern.exec(page)[1]).split(";"); - for (var i=0; i<authorNames.length; i++) { - newItem.creators.push( - Zotero.Utilities.cleanAuthor( - Zotero.Utilities.trim(authorNames[i]), - "author", true)); - } -// Zotero.debug("authorNames:\n"+authorNames); - } - - // 摘要/Abstract - var abst; - pattern = /ReplaceFont\('ChDivSummary','(.*?)(?='\);ReplaceFont)/; - if (pattern.test(page)) { - abst = pattern.exec(page)[1]; -// Zotero.debug("raw:\n"+abst); - pattern = /(<.*?>)/g; - abst = abst.replace(pattern, ""); -// Zotero.debug("after:\n"+abst); - newItem.abstractNote = Zotero.Utilities.trim(abst); - } - - pattern = /ReplaceFont\('EnDivSummary','(.*?)(?='\);if)/; - if (pattern.test(page)) { - abst = pattern.exec(page)[1]; -// Zotero.debug("raw:\n"+abst); - if (abst != undefined && abst != null) { - pattern = /(<.*?>)/g; - abst = abst.replace(pattern, ""); -// Zotero.debug("after:\n"+abst); - - if (newItem.abstractNote===undefined) { - newItem.abstractNote = Zotero.Utilities.trim(abst); - } else { - newItem.abstractNote = newItem.abstractNote + "\n" - + Zotero.Utilities.trim(abst); - } - } - } -// Zotero.debug("abst:\n"+newItem.abstractNote); - - // 关键词/Keywords - pattern = /【关键词】\s*<span[^>]*>(.*?)<\/a>*<\/span>/; - if (pattern.test(page)) { - var tags = trimTags(pattern.exec(page)[1]).split(";"); - for (var i=0; i<tags.length; i++) { - var tag = Zotero.Utilities.trim(tags[i]); - if (tag.length>0 && newItem.tags.indexOf(tag)<0) { - newItem.tags.push(tag); - } - } -// Zotero.debug("tags:\n"+tags); - } - pattern = /【Key words】\s*<span[^>]*>(.*?)<\/a>*<\/span>/; - if (pattern.test(page)) { - var tags = trimTags(pattern.exec(page)[1]).split(";"); - for (var i=0; i<tags.length; i++) { - var tag = Zotero.Utilities.trim(tags[i]); - if (tag.length>0 && newItem.tags.indexOf(tag)<0) { - newItem.tags.push(tag); - } - } -// Zotero.debug("tags:\n"+tags); - } -// Zotero.debug(newItem.tags); - - // 会议名称 & 会议录名称 & 会议地点 & 会议时间 - pattern = /【会议名称】(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var conferenceName = trimTags(pattern.exec(page)[1]); - newItem.conferenceName = conferenceName; -// Zotero.debug("conferenceName: "+conferenceName); - } - pattern = /【会议录名称】(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var proceedingsTitle = trimTags(pattern.exec(page)[1]); - newItem.proceedingsTitle = proceedingsTitle; -// Zotero.debug("proceedingsTitle: "+proceedingsTitle); - } - pattern = /【会议地点】(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var place = trimTags(pattern.exec(page)[1]); - newItem.place = place; -// Zotero.debug("place: "+place); - } - pattern = /【会议时间】(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var date = trimTags(pattern.exec(page)[1]); - newItem.date = date; -// Zotero.debug("date: "+date); - } - - newItem.complete(); - }); -} - -// work for newspaperArticle -function scrapeAndParse4(url) { -// Zotero.debug("newspaperArticle"); - Zotero.Utilities.doGet(url, function(page) { - var pattern; - - // 类型 & URL - var itemType = "newspaperArticle"; - var newItem = new Zotero.Item(itemType); -// Zotero.debug(url); - newItem.url = url; - - // 标题/Title - pattern = /<span id="chTitle">(.*?)<\/span>/; - if (pattern.test(page)) { - var title = trimTags(pattern.exec(page)[1]); - newItem.title = title; -// Zotero.debug("title: "+title); - } - - // 副标题/引题 - var shortTitle; - pattern = /<p>【(?:副标题|引题)】(.*?)(?=<\/p>)/; - if (pattern.test(page)) { - shortTitle = pattern.exec(page)[1]; -// Zotero.debug("shortTitle: "+shortTitle); - newItem.shortTitle = Zotero.Utilities.trimInternal(shortTitle); - } -// Zotero.debug(newItem.shortTitle); - - // 作者/Authors - pattern = /【作\s*者】(.*?)<\/p>/; - if (pattern.test(page)) { - var authorNames = trimTags(pattern.exec(page)[1]).split(";"); - for (var i=0; i<authorNames.length; i++) { - newItem.creators.push( - Zotero.Utilities.cleanAuthor( - Zotero.Utilities.trim(authorNames[i]), - "author", true)); - } -// Zotero.debug("authorNames:\n"+authorNames); - } - - // 正文快照/Abstract - var abst; - pattern = /<p>【正文快照】(.*?)(?=<\/p>)/; - if (pattern.test(page)) { - abst = pattern.exec(page)[1]; -// Zotero.debug("abst:\n"+abst); - newItem.abstractNote = Zotero.Utilities.trimInternal(abst); - } -// Zotero.debug(newItem.abstractNote); - - // 报纸名称 & DOI & 出版时间 & 版名 & 版号 - pattern = /【报纸名称】\s*<[^>]*>(.*?)<\/a>/; - if (pattern.test(page)) { - var publicationTitle = trimTags(pattern.exec(page)[1]); - newItem.publicationTitle = publicationTitle; -// Zotero.debug("publicationTitle: "+publicationTitle); - } - pattern = /【DOI】\s*(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var doi = pattern.exec(page)[1]; - newItem.DOI = doi; -// Zotero.debug("doi: "+doi); - } - pattern = /【报纸日期】\s*(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var date = pattern.exec(page)[1]; - newItem.date = date; -// Zotero.debug("date: "+date); - } - pattern = /【版名】\s*(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var section = pattern.exec(page)[1]; - newItem.section = section; -// Zotero.debug("section: "+section); - } - pattern = /【版号】\s*(.*?)\s*<\/li>/; - if (pattern.test(page)) { - var edition = pattern.exec(page)[1]; - newItem.edition = edition; -// Zotero.debug("edition: "+edition); - } - - newItem.complete(); - }); -} - -// ######################### -// ##### API functions ##### -// ######################### - -function detectWeb(doc, url) { - var pattern = /detail.aspx/; - - if (pattern.test(url)) { - var code = detectCode(url).toUpperCase(); -// Zotero.debug(code); - if (code == "CJFQ" || code == "CJFD") { - return "journalArticle"; - } else if (code == "CDFD") { - return "thesis"; - } else if (code == "CMFD" || code == "CLKM") { - return "thesis"; - } else if (code == "CPFD") { - return "conferencePaper"; - } else if (code == "CCND") { - return "newspaperArticle"; - } else if (code == "NONE") { - Zotero.debug("Not support yet."); - } - } - - pattern = /brief/; - if (pattern.test(url)) { - return "multiple" - } - - return false; -} - -function doWeb(doc, url) { - var nsResolver = getResolver(doc); - var urls, tds, pages; - -// Zotero.debug(url); - - if (detectWeb(doc, url) == "multiple") { -// Zotero.debug("Enter multiple."); - // search page - var items = new Array(); - - var xpath = '//iframe[@id="iframeResult"]'; - var iframe = doc.evaluate(xpath, doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - if (iframe) { - // fetch iframe's element -// Zotero.debug(iframe.src); - pages = Zotero.Utilities.retrieveSource(iframe.src); - } else { - // already in iframe -// Zotero.debug("url:"+url); - pages = Zotero.Utilities.retrieveSource(url); - } - - pattern = /<tr class=["']GTContentTitle["']>[\s\S]*?<\/tr>([\s\S]*?)<table class=["']pageBar_bottom["']/; - var content; - try { - content = pattern.exec(pages)[1]; -// Zotero.debug(content); - pattern = /<\/table>[\s\S]*?<a href=["'](.*?)["'][^>]*?><script[\s\S]*?(?:Replace[^\(]*?\()'(.*?)'\)/g; - } catch (err) { - content = pages; - pattern = /<div class=["']GridTitleDiv["']>.*?<a href=["'](.*?)["'][^>]*?><script[\s\S]*?(?:Replace[^\(]*?\()'(.*?)'\)/g; - } - var res = pattern.exec(content); - if (!res) { - pattern = /<div class=["']GridTitleDiv["']>.*?<a href=["'](.*?)["'][^>]*?>(.*?)<\/a>/g; - res = pattern.exec(content); - if (!res) { - pattern = /<\/table>[\s\S]*?<a href=["'](.*?)["'][^>]*?>(.*?)<\/a>/g; - res = pattern.exec(content); - } - } - var link; - var title; - while (res) { - - title = Zotero.Utilities.cleanTags(res[2]); - link = res[1]; - - patt = /^(http:\/\/.*?)\//; - link = patt.exec(url)[1] + link; - items[link] = trimTags(title); -// Zotero.debug("title:"+title); -// Zotero.debug("link:"+link); - - res = pattern.exec(content); - } -// Zotero.debug(items); - if (items.__count__) { - // 让用户选择要保存哪些文献 - items = Zotero.selectItems(items); - if (!items) return true; - - urls = new Array(); - for (var url in items) { - urls.push(url); - } - } - } else { - urls = [url]; - } - - if (urls) { -// Zotero.debug(urls); - - for (var i=0; i<urls.length; i++) { - var type = detectWeb(null, urls[i]); -// Zotero.debug(type); - if (type == "journalArticle") { - scrapeAndParse1(urls[i]); - } else if (type == "thesis") { - scrapeAndParse2(urls[i]); - } else if (type == "conferencePaper") { - scrapeAndParse3(urls[i]); - } else if (type == "newspaperArticle") { - scrapeAndParse4(urls[i]); - } else { - Zotero.debug("Not supported type."); - } - } - } -} diff --git a/translators/COinS.js b/translators/COinS.js @@ -1,281 +0,0 @@ -{ - "translatorID": "05d07af9-105a-4572-99f6-a8e231c0daef", - "label": "COinS", - "creator": "Simon Kornblith", - "target": "", - "minVersion": "2.1", - "maxVersion": "", - "priority": 300, - "inRepository": true, - "translatorType": 6, - "browserSupport": "gcs", - "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 - // served as application/xhtml+xml - // - // https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript#Implementing_a_default_namespace_for_XML_documents - function nsResolver() { - return 'http://www.w3.org/1999/xhtml'; - } - - var spans = doc.evaluate('//x:span[contains(@class, " Z3988") or contains(@class, "Z3988 ") or @class="Z3988"][@title]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var span; - while(span = spans.iterateNext()) { - // determine if it's a valid type - var item = new Zotero.Item; - var success = Zotero.Utilities.parseContextObject(span.title, item); - - if(item.itemType) { - if(encounteredType) { - return "multiple"; - } else { - encounteredType = item.itemType; - } - } - } - - return encounteredType; -} - -// used to retrieve next COinS object when asynchronously parsing COinS objects -// on a page -function retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc) { - if(needFullItems.length) { - var item = needFullItems.shift(); - - Zotero.debug("looking up contextObject"); - var search = Zotero.loadTranslator("search"); - search.setHandler("itemDone", function(obj, item) { - newItems.push(item); - }); - search.setHandler("done", function() { - retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc); - }); - // look for translators - search.setHandler("translators", function(obj, translators) { - if(translators.length) { - search.setTranslator(translators); - search.translate(); - } else { - retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc); - } - }); - - search.setSearch(item); - search.getTranslators(); - } else { - completeCOinS(newItems, couldUseFullItems, doc); - Zotero.done(); - } -} - -// saves all COinS objects -function completeCOinS(newItems, couldUseFullItems, doc) { - if(newItems.length > 1) { - var selectArray = new Array(newItems.length); - 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); - }); - } else if(newItems.length) { - completeItems(newItems, [0], couldUseFullItems); - } -} - -function completeItems(newItems, useIndices, couldUseFullItems, doc) { - if(!useIndices.length) { - return; - } - var i = useIndices.shift(); - - // grab full item if the COinS was missing an author - if(couldUseFullItems[i]) { - Zotero.debug("looking up contextObject"); - var search = Zotero.loadTranslator("search"); - - var firstItem = false; - search.setHandler("itemDone", function(obj, newItem) { - if(!firstItem) { - // add doc as attachment - newItem.attachments.push({document:doc}); - newItem.complete(); - firstItem = true; - } - }); - search.setHandler("done", function(obj) { - // if we didn't find anything, use what we had before (even if it - // lacks the creator) - if(!firstItem) { - newItems[i].complete(); - } - // call next - completeItems(newItems, useIndices, couldUseFullItems); - }); - search.setHandler("translators", function(obj, translators) { - if(translators.length) { - search.setTranslator(translators); - search.translate(); - } else { - // add doc as attachment - newItems[i].attachments.push({document:doc}); - newItems[i].complete(); - // call next - completeItems(newItems, useIndices, couldUseFullItems); - } - }); - - search.setSearch(newItems[i]); - search.getTranslators(); - } else { - // add doc as attachment - newItems[i].attachments.push({document:doc}); - newItems[i].complete(); - // call next - completeItems(newItems, useIndices, couldUseFullItems); - } -} - -function doWeb(doc, url) { - var newItems = new Array(); - var needFullItems = new Array(); - var couldUseFullItems = new Array(); - - - // See note in detectWeb() - function nsResolver() { - return 'http://www.w3.org/1999/xhtml'; - } - - var spans = doc.evaluate('//x:span[contains(@class, " Z3988") or contains(@class, "Z3988 ") or @class="Z3988"][@title]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var span; - while(span = spans.iterateNext()) { - var spanTitle = span.title; - var newItem = new Zotero.Item(); - newItem.repository = false; // do not save repository - if(Zotero.Utilities.parseContextObject(spanTitle, newItem)) { - if(newItem.title) { - if(!newItem.creators.length) { - // if we have a title but little other identifying - // information, say we'll get full item later - newItem.contextObject = spanTitle; - couldUseFullItems[newItems.length] = true; - } - - // title and creators are minimum data to avoid looking up - newItems.push(newItem); - } else { - // retrieve full item - newItem.contextObject = spanTitle; - needFullItems.push(newItem); - } - } - } - - Zotero.debug(needFullItems); - if(needFullItems.length) { - // retrieve full items asynchronously - Zotero.wait(); - retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc); - } else { - completeCOinS(newItems, couldUseFullItems, doc); - } -} - -function doExport() { - var item; - var co; - - while (item = Zotero.nextItem()) { - co = Zotero.Utilities.createContextObject(item, "1.0"); - Zotero.write("<span class='Z3988' title='"+ Zotero.Utilities.htmlSpecialChars(co) +"'></span>\n"); - } -} -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.husdal.com/2011/06/19/disruptions-in-supply-networks/", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Phil", - "lastName": "Greening", - "creatorType": "author" - }, - { - "firstName": "Christine", - "lastName": "Rutherford", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - {} - ], - "publicationTitle": "International Journal of Logistics Management", - "title": "Disruptions and supply networks: a multi-level, multi-theoretical relational perspective", - "date": "2011", - "volume": "22", - "issue": "1", - "pages": "104-126", - "libraryCatalog": false, - "shortTitle": "Disruptions and supply networks" - } - ] - }, - { - "type": "web", - "url": "http://gamblershouse.wordpress.com/2011/06/19/the-view-from-dolores/", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.hubmed.org/display.cgi?uids=21665052", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "creatorType": "author", - "firstName": "Hui-Wen Vivian", - "lastName": "Tang" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - {} - ], - "publicationTitle": "Evaluation and Program Planning", - "volume": "34", - "ISSN": "01497189", - "date": "11/2011", - "pages": "343-352", - "DOI": "10.1016/j.evalprogplan.2011.04.002", - "url": "http://linkinghub.elsevier.com/retrieve/pii/S0149718911000449", - "title": "Optimizing an immersion ESL curriculum using analytic hierarchy process", - "libraryCatalog": "CrossRef" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/CSIRO Publishing.js b/translators/CSIRO Publishing.js @@ -1,71 +0,0 @@ -{ - "translatorID":"303c2744-ea37-4806-853d-e1ca67be6818", - "translatorType":4, - "label":"CSIRO Publishing", - "creator":"Michael Berkowitz", - "target":"http://(www.)?publish.csiro.au/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-04-23 09:45:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//a[@class="searchBoldBlue"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//a[@class="linkjournal"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("/view/journals/") != -1 || url.indexOf("paper") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var links = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('//a[@class="searchBoldBlue"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var arts = doc.evaluate('//a[@class="searchBoldBlue"]', doc, null, XPathResult.ANY_TYPE, null); - var art = arts.iterateNext(); - while (art) { - items[art.href] = art.textContent; - art = arts.iterateNext(); - } - } else if (doc.evaluate('//a[@class="linkjournal"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var arts = doc.evaluate('//a[@class="linkjournal"]', doc, null, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('//td[3]//td[1]/table/tbody/tr/td/b', doc, null, XPathResult.ANY_TYPE, null); - var art; - var title; - while ((art = arts.iterateNext()) && (title = titles.iterateNext())) { - items[art.href] = title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - links.push(i.match(/([^/=.htm]*)(.htm)?$/)[1]); - } - } else { - links.push(url.match(/([^/=.htm]*)(.htm)?$/)[1]); - } - for (var i in links) { - var newURL = 'http://www.publish.csiro.au/view/journals/dsp_journal_retrieve_citation.cfm?ct=' + links[i] + '.ris'; - var pdfURL = 'http://www.publish.csiro.au/?act=view_file&file_id=' + links[i] + '.pdf'; - Zotero.Utilities.HTTP.doGet(newURL, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.itemType = "journalArticle"; - if (item.notes[0]) { - item.abstractNote = item.notes[0].note; - } - item.attachments = [ - {url:pdfURL, title:"CSIRO Publishing PDF", mimeType:"application/pdf"}, - {url:newURL, title:"CSIRO Publishing Snaphost", mimeType:"text/html"} - ]; - item.complete(); - }); - translator.translate(); - }); - } - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/CTX.js b/translators/CTX.js @@ -1,268 +0,0 @@ -{ - "translatorID":"24d9f058-3eb3-4d70-b78f-1ba1aef2128d", - "translatorType":5, - "label":"CTX", - "creator":"Avram Lyon and Simon Kornblith", - "target":"^http://freecite\\.library\\.brown\\.edu", - "minVersion":"2.0", - "maxVersion":"", - "priority":100, - "configOptions":{"dataMode":"line"}, - "inRepository":false, - "lastUpdated":"2011-01-11 04:31:00" -} - -/* - ContextObjects in XML Translator - Copyright (C) 2010 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 imports OpenURL ContextObjects encapsulated in XML - * documents, as described at: - * http://alcme.oclc.org/openurl/servlet/OAIHandler?verb=GetRecord&metadataPrefix=oai_dc&identifier=info:ofi/fmt:xml:xsd:ctx - * The schema for such XML documents is at: - * http://www.openurl.info/registry/docs/xsd/info:ofi/fmt:xml:xsd:ctx - * - * This format is used in several places online, including Brown University's FreeCite - * Citation parser (http://freecite.library.brown.edu/welcome) and Oslo University's - * X-Port (http://www.ub.uio.no/portal/gs.htm or http://x-port.uio.no/). - - * Our input looks like this: -<ctx:context-objects xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='info:ofi/fmt:xml:xsd:ctx http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:ctx' xmlns:ctx='info:ofi/fmt:xml:xsd:ctx'> -<ctx:context-object timestamp='2010-01-02T16:55:48-05:00' encoding='info:ofi/enc:UTF-8' version='Z39.88-2004' identifier=''> - <ctx:referent> - <ctx:metadata-by-val> - <ctx:format>info:ofi/fmt:xml:xsd:journal</ctx:format> - <ctx:metadata> - <journal xmlns:rft='info:ofi/fmt:xml:xsd:journal' xsi:schemaLocation='info:ofi/fmt:xml:xsd:journal http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:journal'> - <rft:atitle>Acute Myocardial Infarction in the Medicare population: process of care and clinical outcomes</rft:atitle> - <rft:spage>2530</rft:spage> - <rft:date>1992</rft:date> - <rft:stitle>Journal of the American Medical Association</rft:stitle> - <rft:genre>article</rft:genre> - <rft:volume>18</rft:volume> - <rft:epage>2536</rft:epage> - <rft:au>I S Udvarhelyi</rft:au> - <rft:au>C A Gatsonis</rft:au> - <rft:au>A M Epstein</rft:au> - <rft:au>C L Pashos</rft:au> - <rft:au>J P Newhouse</rft:au> - <rft:au>B J McNeil</rft:au> - </journal> - </ctx:metadata> - </ctx:metadata-by-val> - </ctx:referent> -</ctx:context-object> -</ctx:context-objects> - * - * The approach we will take is to convert this into COinS, so that we can - * piggy-back off of the perhaps more robust support in the core Zotero code. - */ - -function detectWeb(doc, url) { - var texts = [], text = ""; - var codes = doc.getElementsByTagName("code"); - for(var i = 0; i < codes.length; i++) { - text = codes[i].textContent; - text.replace(/</g,"&lt;").replace(/>/g,"&gt;"); - texts.push(text); - } - return detectInString(texts); -}; - -function doWeb(doc, url) { - var texts = [], text = ""; - var codes = doc.getElementsByTagName("code"); - for(var i = 0; i < codes.length; i++) { - text = codes[i].textContent; - text.replace(/</g,"&lt;").replace(/>/g,"&gt;"); - texts.push(text); - } - doImportFromText(texts, true); -}; - -function doImport() { - var text = ""; - var line; - while(line = Zotero.read()) { - text += line; - } - return doImportFromText(text, false); -} - -function detectImport() { - var text = ""; - var line; - while(line = Zotero.read()) { - text += line; - } - return detectInString(text) != false; -} - -function detectInString(text) { - var detectedType = false; - - var spans = []; - - // This is because we want to be able to read multiple such CTX elements in a single page - if (typeof text != "string" && text.length >= 1) { - spans = text.map(contextObjectXMLToCOinS).reduce(function(a,b){return a.concat(b);}); - } else { - spans = contextObjectXMLToCOinS(text); - } - - for (var i = 0 ; i < spans.length ; i++) { - var item = new Zotero.Item; - var success = Zotero.Utilities.parseContextObject(spans[i], item); - if(item.itemType) { - Zotero.debug("Found " + item.itemType); - if (detectedType) { - return "multiple"; - } - detectedType = item.itemType; - } else { - Zotero.debug("Type not found"); - } - } - return detectedType; -}; - -/* Takes the string of the ContextObject XML format - * and returns an array of COinS titles of the same, per the COinS - * specification. - */ -function contextObjectXMLToCOinS (text) { - try { - var doc = new XML(text); - } - catch (e) { - return []; - } - - /* Here and elsewhere, we are using the E4X syntax for XML */ - var objects = doc..*::["context-object"]; - - /* Bail out if no object */ - if (objects.length() == 0) { - Zotero.debug("No context object"); - return []; - } - - var titles = []; - - for (var i = 0; i < objects.length(); i++) { - Zotero.debug("Processing object: " + objects[i].text()); - var pieces = []; - - - var version = objects[i].@version; - pieces.push("ctx_ver="+encodeURIComponent(version)); - - var format = objects[i]..*::format; - // Now convert this to the corresponding Key/Encoded-Value format; see note below. - // Check if this is unknown; if it is, skip - if (format.text() == "info:ofi/fmt:xml:xsd:unknown") { - Zotero.debug("Skipping object of type 'unknown'"); - continue; - } - format = mapXMLtoKEV[format.text()]; - - pieces.push("rft_val_fmt=" + encodeURIComponent(format)); - - // Here we disregard the namespaces - var fields = objects[i]..*::metadata.children()[0].*::*; - var field; - - for each (field in fields) { - var name = field.localName(); - // We can hardcode the 'rft' namespace to keep COinS valid - name = "rft."+name; - var value = encodeURIComponent(field.text()); - pieces.push(name + "=" + value); - } - - var title = pieces.join("&"); - var span = "<span title='" + title + "' class='Z3988'></span>\n"; - Zotero.debug("Made span: " + span); - titles.push(title); - } - return titles; -}; - -function doImportFromText(text, showPrompt) { - var spans = [], items = [], zoteroItems = []; - - // This is because we want to be able to read multiple such CTX elements in a single page - if (typeof text != "string" && text.length >= 1) { - spans = text.map(contextObjectXMLToCOinS).reduce(function(a,b){return a.concat(b);}); - } else { - spans = contextObjectXMLToCOinS(text); - } - - for (var i = 0 ; i < spans.length ; i++) { - Zotero.debug("Processing span: "+spans[i]); - var item = new Zotero.Item; - Zotero.Utilities.parseContextObject(spans[i], item); - if(item.itemType) { - Zotero.debug("Found " + item.itemType); - items.push(item.title); - zoteroItems.push(item); - // Set publicationTitle to the short title if only the latter is specified - if (item.journalAbbreviation && !item.publicationTitle) { - item.publicationTitle = item.journalAbbreviation; - } - // If we're in non-prompting mode, save right away - if (showPrompt === false) { - item.complete(); - } - } else { - Zotero.debug("Type not found"); - } - } - // Since we want to prompt, we have to parse twice. - if(showPrompt === true) { - if(items.length == 1) { - item.complete(); - } else { - items = Zotero.selectItems(items); - if(!items) return true; - for(var i in items) { - zoteroItems[i].complete(); - } - } - } -}; - -/* These two arrays are needed because COinS uses Key/Escaped-Value, which has a different - * set of format codes. Codes from "Registry for the OpenURL Framework - ANSI/NISO Z39.88-2004": - * http://alcme.oclc.org/openurl/servlet/OAIHandler?verb=ListRecords&metadataPrefix=oai_dc&set=Core:Metadata+Formats - */ -var mapKEVtoXML = { - 'info:ofi/fmt:kev:mtx:book' : 'info:ofi/fmt:xml:xsd:book', // Books - 'info:ofi/fmt:kev:mtx:dc' : 'info:ofi/fmt:xml:xsd:oai_dc', // Dublin Core - 'info:ofi/fmt:kev:mtx:dissertation' : 'info:ofi/fmt:xml:xsd:dissertation', // Dissertations - 'info:ofi/fmt:kev:mtx:journal' : 'info:ofi/fmt:xml:xsd:journal', // Journals - 'info:ofi/fmt:kev:mtx:patent' : 'info:ofi/fmt:xml:xsd:patent', // Patents - 'info:ofi/fmt:kev:mtx:sch_svc' : 'info:ofi/fmt:xml:xsd:sch_svc' // Scholarly ServiceTypes -}; - -var mapXMLtoKEV = { - 'info:ofi/fmt:xml:xsd:book' : 'info:ofi/fmt:kev:mtx:book', // Books - 'info:ofi/fmt:xml:xsd:oai_dc' : 'info:ofi/fmt:kev:mtx:dc', // Dublin Core - 'info:ofi/fmt:xml:xsd:dissertation' : 'info:ofi/fmt:kev:mtx:dissertation', // Dissertations - 'info:ofi/fmt:xml:xsd:journal' : 'info:ofi/fmt:kev:mtx:journal', // Journals - 'info:ofi/fmt:xml:xsd:patent' : 'info:ofi/fmt:kev:mtx:patent', // Patents - 'info:ofi/fmt:xml:xsd:sch_svc' : 'info:ofi/fmt:kev:mtx:sch_svc' // Scholarly ServiceTypes -}; diff --git a/translators/Cambridge Journals Online.js b/translators/Cambridge Journals Online.js @@ -1,184 +0,0 @@ -{ - "translatorID": "850f4c5f-71fb-4669-b7da-7fb7a95500ef", - "label": "Cambridge Journals Online", - "creator": "Sean Takats, Michael Berkowitz and Avram Lyon", - "target": "^https?://[^/]*journals.cambridge.org[^/]*//?action/(quickSearch|search|displayAbstract|displayFulltext|displayIssue)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:29:49" -} - -function detectWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - var xpath = '//div[@class="tableofcontents-row"][div/input[@type="checkbox"][@name="toView"]]'; - if ((url.indexOf("/action/displayAbstract") != -1) || (url.indexOf("action/displayFulltext") != -1)){ - return "journalArticle"; - } else if (doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } -} - -function doWeb(doc, url){ - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - var host = doc.location.host; - var urlstring="http://" + host + "/action/exportCitation"; - var datastring="format=RIS&emailId=&Download=Download&componentIds="; - var links = new Array(); - if(detectWeb(doc, url) == "multiple"){ - var xpath = '//div[@class="tableofcontents-row"][div/input[@type="checkbox"][@name="toView"]]'; - var tableRows = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var tableRow; - var items=new Array(); - while (tableRow = tableRows.iterateNext()){ - var id = doc.evaluate('./div/input[@type="checkbox"][@name="toView"]/@value', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var title = doc.evaluate('.//h3', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - items['http://' + host + '/action/displayAbstract?aid=' + id.nodeValue] = Zotero.Utilities.capitalizeTitle(title.textContent); - } - Zotero.selectItems(items, function(items) { - for (var i in items) { - links.push(i); - } - Zotero.Utilities.processDocuments(links, scrape, - function() {Zotero.done();}); - }); - } else { - scrape(doc); - } - Zotero.wait(); -} - -function scrape (doc) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - - var host = doc.location.host; - var urlstring="http://" + host + "/action/exportCitation"; - var datastring="format=RIS&emailId=&Download=Download&componentIds="; - - var locURL = doc.location.href; - var abs; - if (abs = doc.evaluate('//p[@class="section-title" and contains(text(),"Abstract")]/following-sibling::p[not(@class) and text() != ""]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - abs = abs.textContent; - } - if (doc.evaluate('//p[@class="KeyWords"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var kws = doc.evaluate('//p[@class="KeyWords"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(11).split('; '); - } - var pdfpath='//div/ul/li/a[contains(text(), "PDF")]'; - if (doc.evaluate(pdfpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var pdflink = doc.evaluate(pdfpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - } - idRe = /aid=([0-9]+)/ - var m = idRe.exec(locURL); - var id = m[1]; - Zotero.Utilities.doGet(urlstring + "?" + datastring+id, function(text) { - text = text.replace(/(^|\n)?([A-Z\d]{2})\s+\-\s+(\n)?/g, "\n$2 - $3"); - var translator = Zotero.loadTranslator("import"); - // Use RIS importer - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.attachments = [{url:locURL, - title:"Cambridge Journals Snapshot", - mimeType:"text/html"}]; - item.title = Zotero.Utilities.capitalizeTitle(item.title); - var authors = item.creators; - item.creators = new Array(); - for each (var aut in authors) { - // correct all-caps, if present - if (aut.firstName && aut.firstName.toUpperCase() == aut.firstName) - aut.firstName=Zotero.Utilities.capitalizeTitle(aut.firstName.toLowerCase(),true); - if (aut.lastName && aut.lastName.toUpperCase() == aut.lastName) - aut.lastName=Zotero.Utilities.capitalizeTitle(aut.lastName.toLowerCase(),true); - item.creators.push({firstName:aut.firstName, - lastName:aut.lastName, - creatorType:"author"}); - } - if (item.tags.length === 1) item.tags = item.tags[0].split(","); - if (abs) item.abstractNote = Zotero.Utilities.trimInternal(abs); - if (pdflink) { - // Some PDFs aren't paywalled, so they don't need the 2nd request - item.attachments.push({ - url: pdflink, - title: "Cambridge Journals PDF", - mimeType:"application/pdf" - }); - Zotero.Utilities.doGet(pdflink, function(text) { - var domain = pdflink.match(/^https?:\/\/[^\/]+\//); - var realpdf = text.match(/<iframe src="\/(action\/displayFulltext[^"]+)"/); - if (realpdf && domain) { - // If we matched the IFRAME, the first attachment must be bad - for (var i in item.attachments) { - if (item.attachments[i].mimeType.indexOf("pdf") !== -1) - item.attachments[i].url = (domain[0]+realpdf[1]).replace(/&amp;/g,"&"); - }; - } - }, function () { - item.complete(); - }); - } else { - item.complete(); - } - }); - translator.translate(); - }); - } - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://journals.cambridge.org/action/quickSearch?quickSearchType=search_combined&inputField1=tatar&fieldStartMonth=01&fieldStartYear=1800&fieldEndMonth=12&fieldEndYear=2011&searchType=ADVANCESEARCH&searchTypeFrom=quickSearch&fieldScjrnl=All&fieldSccats=All&selectField1=%23&jnlId=AMS&issId=02&volId=45&journalSearchType=all", - "items": "multiple" - }, - { - "type": "web", - "url": "http://journals.cambridge.org/action/displayAbstract?fromPage=online&aid=8267699&fulltextType=RA&fileId=S0021875810001738", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Laurie A.", - "lastName": "Rodrigues", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "" - ], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Cambridge Journals Snapshot", - "mimeType": "text/html" - } - ], - "date": "2011", - "title": "“SAMO© as an Escape Clause”: Jean-Michel Basquiat's Engagement with a Commodified American Africanism", - "publicationTitle": "Journal of American Studies", - "pages": "227-243", - "volume": "45", - "issue": "02", - "DOI": "10.1017/S0021875810001738", - "abstractNote": "Heir to the racist configuration of the American art exchange and the delimiting appraisals of blackness in the American mainstream media, Jean-Michel Basquiat appeared on the late 1970s New York City street art scene – then he called himself “SAMO.” Not long thereafter, Basquiat grew into one of the most influential artists of an international movement that began around 1980, marked by a return to figurative painting. Given its rough, seemingly untrained and extreme, conceptual nature, Basquiat's high-art oeuvre might not look so sophisticated to the uninformed viewer. However, Basquiat's work reveals a powerful poetic and visual gift, “heady enough to confound academics and hip enough to capture the attention span of the hip hop nation,” as Greg Tate has remarked. As noted by Richard Marshall, Basquiat's aesthetic strength actually comes from his striving “to achieve a balance between the visual and intellectual attributes” of his artwork. Like Marshall, Tate, and others, I will connect with Basquiat's unique, self-reflexively experimental visual practices of signifying and examine anew Basquiat's active contribution to his self-alienation, as Hebdige has called it. Basquiat's aesthetic makes of his paintings economies of accumulation, building a productive play of contingency from the mainstream's constructions of race. This aesthetic move speaks to a need for escape from the perceived epistemic necessities of blackness. Through these economies of accumulation we see, as Tate has pointed out, Basquiat's “intellectual obsession” with issues such as ancestry/modernity, personhood/property and originality/origins of knowledge, driven by his tireless need to problematize mainstream media's discourses surrounding race – in other words, a commodified American Africanism.", - "libraryCatalog": "Cambridge Journals Online", - "shortTitle": "“SAMO© as an Escape Clause”" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Cambridge Scientific Abstracts.js b/translators/Cambridge Scientific Abstracts.js @@ -1,208 +0,0 @@ -{ - "translatorID":"82174f4f-8c13-403b-99b2-affc7bc7769b", - "translatorType":4, - "label":"Cambridge Scientific Abstracts", - "creator":"Simon Kornblith and Michael Berkowitz", - "target":"https?://[^/]+/ids70/(?:results.php|view_record.php)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-06-14 04:31:00" -} - -/* Provides support for databases of Cambridge Scientific Abstracts - Tested with CSA Illumina, http://www.csa.com/ - CSA does not provide stable URLs - */ - -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.indexOf("/results.php") != -1) { - var type = doc.evaluate('//td[@class="rt_tab_on"]', doc, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().textContent; - - if(type.substr(0, 15) == "Published Works") { - return "multiple"; - } - } else { - // default to journal - var itemType = "journalArticle"; - - var type = doc.evaluate('//tr[td[1][@class="data_heading"]/text() = "Publication Type"]/td[3]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(type) { - type = Zotero.Utilities.trimInternal(type.textContent); - if(type == "Book Chapter") { - return "bookSection"; - } else if(type.substr(0, 4) == "Book") { - return "book"; - } else if(type.substr(0, 12) == "Dissertation") { - return "thesis"; - } else if(type == "Catalog") { - return "magazineArticle"; - } - } - return "journalArticle"; - } - - return false; -} - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var itemType = "journalArticle"; - - var type = doc.evaluate('//tr[td[1][@class="data_heading"]/text() = "Publication Type"]/td[3]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(type) { - type = Zotero.Utilities.trimInternal(type.textContent); - if(type == "Book Chapter") { - itemType = "bookSection"; - } else if(type.substr(0, 4) == "Book") { - itemType = "book"; - } else if(type.substr(0, 12) == "Dissertation") { - itemType = "thesis"; - } else if(type == "Catalog") { - itemType = "magazineArticle"; - } - } - - var newItem = new Zotero.Item(itemType); - - newItem.attachments = [{document:doc, title:"Cambridge Scientific Abstracts Snapshot"}]; - newItem.title = Zotero.Utilities.trimInternal(doc.evaluate('//tr/td[3][@class="data_emphasis"]', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext().textContent); - - var dataRows = doc.evaluate('//tr[td[3][@class="data_content"]]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var dataRow; - while(dataRow = dataRows.iterateNext()) { - var tds = dataRow.getElementsByTagName("td"); - var heading = Zotero.Utilities.trimInternal(tds[0].textContent).toLowerCase(); - var content = Zotero.Utilities.trimInternal(tds[2].textContent); - if(heading == "database") { - newItem.repository = "Cambridge Scientific Abstracts ("+content+")"; - } else if(heading == "author") { - var authors = content.split("; "); - for each(var author in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author.replace(/\d+/g, ""), "author", true)); - } - } else if(heading == "source") { - if(itemType == "journalArticle") { - var parts = content.split(/(,|;)/); - newItem.publicationTitle = parts.shift(); - for each (var i in parts) { - if (i.match(/\d+/)) { - if (i.match(/v(ol)?/)) { - newItem.volume = i.match(/\d+/)[0]; - } else if (i.match(/pp/)) { - newItem.pages = i.match(/[\d\-]+/)[0]; - } else if (i.match(/no?/)) { - newItem.issue = i.match(/\d+/)[0]; - } else if (i.match(/\d{4}/)) { - newItem.date = Zotero.Utilities.trimInternal(i); - } - } - } - } else if(itemType == "book") { - var m = content.match(/^([^:]+): ([^,0-9]+)/); - if(m) { - newItem.place = m[1]; - newItem.publisher = m[2]; - } - } else if(itemType == "bookSection") { - var untitled = !newItem.publicationTitle; - if(untitled || (content.length > newItem.publicationTitle.length - && content.substr(0, newItem.publicationTitle.length) == newItem.publicationTitle) - || content.indexOf(newItem.publicationTitle)) { - if (content.indexOf(newItem.publicationTitle) > 4) { - // This means we probably have a book author or editor first - var m = content.match(/^([^\.]+)\./); - if (m) newItem.creators.push( - Zotero.Utilities.cleanAuthor(m[1], "bookAuthor", true)); - } - var m = content.match(/\)\. ([^:()]+): ([^,0-9]+)/); - if(m) { - if (untitled) { - var n = content.match(/\([0-9]{4}\)([^(]*)/); - if (n) newItem.publicationTitle = n[1]; - } - newItem.place = m[1]; - newItem.publisher = m[2]; - } - m = content.match(/\(pp. ([\-0-9]+)\)/); - if(m) newItem.pages = m[1]; - } - } - } else if(heading == "monograph title") { - newItem.publicationTitle = content; - } else if(heading == "series title") { - newItem.series = content; - } else if(heading == "issn") { - newItem.ISSN = content; - } else if(heading == "isbn") { - newItem.ISBN = content; - } else if(heading == "abstract") { - newItem.abstractNote = content; - } else if(heading == "notes") { - newItem.extra = content; - } else if(heading == "publication year") { - if(!newItem.date) newItem.date = content; - } else if(heading == "information provider") { - if(content.substr(0, 19) == "http://dx.doi.org/") { - newItem.DOI = content.substr(19); - } - } else if(heading == "journal volume") { - newItem.volume = content; - } else if(heading == "journal pages") { - newItem.pages = content; - } else if(heading == "journal issue") { - newItem.issue = content; - } else if(heading == "affiliation") { - if(newItem.itemType == "thesis") { - newItem.publisher = content; - } - } else if(heading == "pages") { // This is for book sections - newItem.pages = content; - } else if(heading == "language") { - newItem.language = content; - } - } - - var terms = doc.evaluate('//input[substring(@name, 1, 4) = "term"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var term; - while(term = terms.iterateNext()) { - newItem.tags.push(term.value.replace(/ [0-9]{3,}$/, "")); - } - - newItem.complete(); -} - -function doWeb(doc, url) { - if(url.indexOf("/results.php") != -1) { - var items = Zotero.Utilities.getItemArray(doc, doc, '/view_record\.php\?', '^(?:View Record|More\.{3})$'); - - items = Zotero.selectItems(items); - if(!items) return true; - - var urls = new Array(); - for(var url in items) { - urls.push(url); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done() }) - Zotero.wait(); - } else { - scrape(doc); - } -} diff --git a/translators/CanLII.js b/translators/CanLII.js @@ -1,112 +0,0 @@ -{ - "translatorID":"84799379-7bc5-4e55-9817-baf297d129fe", - "translatorType":4, - "label":"CanLII", - "creator":"Bill McKinney", - "target":"http:\\/\\/www\\.canlii\\.org\\/en\\/[^\\/]+\\/[^\\/]+\\/doc\\/.+", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-06-18 18:15:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var canLiiRegexp = /http:\/\/www\.canlii\.org\/en\/[^\/]+\/[^\/]+\/doc\/.+/ - if(canLiiRegexp .test(url)) { - return "book"; - } else { - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - if(articleRegexp.test(aTags[i].href)) { - return "multiple"; - } - } - } -} - - -function associateMeta(newItem, metaTags, field, zoteroField) { - var field = metaTags.namedItem(field); - if(field) { - newItem[zoteroField] = field.getAttribute("content"); - } -} - -function scrape(doc) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("case"); - - var metaTags = doc.getElementsByTagName("meta"); - associateMeta(newItem, metaTags, "DC.Title", "title"); - associateMeta(newItem, metaTags, "DC.Date", "dateDecided"); - associateMeta(newItem, metaTags, "DC.Language", "language"); - newItem.url = doc.location.href; - - var field = metaTags.namedItem("DC.Title"); - var tmpText = ""; - if(field) { - tmpText = field.getAttribute("content"); - var capRe = /^(.+),\s+(\d{4})\s+(\w+)\s+(\d+)\s+\(([^\)]+)\)/; - var m = capRe.exec(tmpText); - if(m) { - - newItem.caseName = m[1]+", "+m[2]+" "+m[3]+" "+m[4]; - if (m[3] == 'CanLII') { - newItem.court = m[5]; - } else { - newItem.court = m[3]; - } - - } else { - newItem.caseName = tmpText; - newItem.court = "not found"; - } - } - - - - // attach link to pdf version - // NOTE: not working - don't know why - var pdfRe = /^(.+)\.html$/; - var pdfMatch = pdfRe.exec(doc.location.href); - if (pdfMatch) { - var pdfUrl = pdfMatch[1]+".pdf"; - newItem.attachments = [{url:pdfUrl, title:"PDF version", mimeType:"application/pdf"}]; - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var canLiiRegexp= /http:\/\/www\.canlii\.org\/en\/[^\/]+\/[^\/]+\/doc\/.+/ - if(canLiiRegexp.test(url)) { - scrape(doc); - } else { - - var items = Zotero.Utilities.getItemArray(doc, doc, canLiiRegexp); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/Canada.com.js b/translators/Canada.com.js @@ -1,153 +0,0 @@ -{ - "translatorID":"4da40f07-904b-4472-93b6-9bea1fe7d4df", - "translatorType":4, - "label":"Canada.com", - "creator":"Adam Crymble", - "target":"http://www.canada.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-24 05:30:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("story")) { - return "newspaperArticle"; - } else if (doc.location.href.match("search")) { - return "multiple"; - } -} - - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("newspaperArticle"); - - newItem.title = doc.title; - - if (doc.evaluate('//div[@class="storyheader"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate('//div[@class="storyheader"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//div[@class="storyheader"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstracteNote = doc.evaluate('//div[@class="storyheader"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - if (doc.evaluate('//div[@class="feed_details"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate('//div[@class="feed_details"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - if (author.match(/\n/)) { - author1 = author.split(/\n/); - if (author1[0].match(/ and /)) { - author2 = author1[0].split(/ and /); - for (var i in author2) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author2[i], "author")); - } - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[0], "author")); - } - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - - if (doc.evaluate('//div[@class="feed_details"]/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var date1 = doc.evaluate('//div[@class="feed_details"]/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - if (date1.match("Published:")) { - date1 = date1.substr(11); - newItem.date = date1; - } - } - - if (doc.evaluate('//ul[@class="home"]/li/a/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var pubTitle = doc.evaluate('//ul[@class="home"]/li/a/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (pubTitle.match("Home")) { - newItem.publicationTitle = pubTitle.substr(0, pubTitle.length-5); - } else { - newItem.publicationTitle = pubTitle; - } - } else { - newItem.publicationTitle = "Canada.com"; - } - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var next_title; - - if (doc.evaluate('//div[@class="even"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("AAAAAA"); - var titles0 = doc.evaluate('//div[@class="even"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - while (next_title = titles0.iterateNext()) { - if (next_title.href.match("story") && next_title.href.match("canada.com")) { - items[next_title.href] = next_title.textContent; - } - } - } - - if (doc.evaluate('//div[@class="odd"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("BBBBB"); - var titles1 = doc.evaluate('//div[@class="odd"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - while (next_title = titles1.iterateNext()) { - if (next_title.href.match("story") && next_title.href.match("canada.com")) { - items[next_title.href] = next_title.textContent; - } - } - } - - if (doc.evaluate('//p/b/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("CCCCC"); - var titles2 = doc.evaluate('//p/b/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (next_title = titles2.iterateNext()) { - if (next_title.href.match("story") && next_title.href.match("canada.com")) { - items[next_title.href] = next_title.textContent; - } - } - } - - if (doc.evaluate('//div[@class="name"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - Zotero.debug("DDDD"); - var titles3 = doc.evaluate('//div[@class="name"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (next_title = titles3.iterateNext()) { - if (next_title.href.match("story") && next_title.href.match("canada.com")) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Canadian Letters and Images.js b/translators/Canadian Letters and Images.js @@ -1,124 +0,0 @@ -{ - "translatorID":"a7c8b759-6f8a-4875-9d6e-cc0a99fe8f43", - "translatorType":4, - "label":"Canadian Letters and Images", - "creator":"Adam Crymble", - "target":"http://(www.)?canadianletters.ca/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-20 20:45:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("results")) { - return "multiple"; - } else if (doc.location.href.match("letters.php")) { - return "document"; - } else if (doc.location.href.match("template")) { - return "artwork"; - } - -} - -//Translator for Canadian Letters and Images. Code by Adam Crymble - - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - - var mediaType = (detectWeb(doc, url)); - if (mediaType == "document") { - var newItem = new Zotero.Item("letter"); - var title2; - - //title - if (doc.evaluate('//h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - newItem.title = doc.title; - } - - //letter, diary, memoir, personal item - if (doc.evaluate('//div[@id="collectionCategory_letters"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var xPathType = doc.evaluate('//div[@id="collectionCategory_letters"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.type = xPathType; - } - - //gets date, to and from - if (doc.evaluate('//div[@class="letterInfo_label"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var xPathHeaders = doc.evaluate('//div[@class="letterInfo_label"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathContent = doc.evaluate('//div[@class="letterInfo_title"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//div[@class="letterInfo_label"])', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue; i++) { - fieldTitle=xPathHeaders.iterateNext().textContent.replace(/\s+/g, ''); - dataTags[fieldTitle] = xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - - if (fieldTitle == "To:") { - - newItem.abstractNote = ("To: " + dataTags[fieldTitle]); - - } else if (fieldTitle == "From:") { - - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags[fieldTitle], "author")); - - } else if (fieldTitle == "Date:") { - - newItem.date = dataTags[fieldTitle]; - } - } - } - } else if (mediaType == "artwork") { - - newItem = new Zotero.Item("artwork"); - - if (doc.evaluate('//div[@class="pictureDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//div[@class="pictureDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - newItem.title = doc.title; - } - } - - - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//div[@class="searchResultsDisplay"]/div/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Canadiana.org.js b/translators/Canadiana.org.js @@ -1,180 +0,0 @@ -{ - "translatorID":"2d174277-7651-458f-86dd-20e168d2f1f3", - "translatorType":4, - "label":"Canadiana.org", - "creator":"Adam Crymble", - "target":"http://(www.)?canadiana.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-12 19:30:00" -} - -function detectWeb(doc, url) { - - //checks the title of the webpage. If it matches, then the little blue book symbol appears in the address bar. - //works for English and French versions of the page. - - if(doc.title == "Early Canadiana Online - Item Record"|doc.title == "Notre mémoire en ligne - Notice") { - return "book"; - } else if (doc.evaluate('//div[@id="Content"]/div[@class="NormalRecord"]/h3/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - - - -//Canadiana Translator Coding by Adam Crymble -//because the site uses so many random formats for the "Imprint" field, it's not always perfect. But it works for MOST entries - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - //declaring variables to be used later. - var newItem = new Zotero.Item("book"); - newItem.url = doc.location.href; - - var dataTags = new Object(); - var fieldTitle; - var tagsContent= new Array(); - - //these variables tell the program where to find the data we want in the HTML file we're looking at. - //in this case, the data is found in a table. - var xPath1 = '//tr/td[1][@class="Label"]'; - var xPath2 = '//tr/td[2]'; - - - //at this point, all the data we want has been saved into the following 2 Objects: one for the headings, one for the content. - // The 3rd object tells us how many items we've found. - if (doc.evaluate('//tr/td[1][@class="Label"]', doc, nsResolver, XPathResult.ANY_TYPE, null)) { - var xPath1Results = doc.evaluate(xPath1, doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPath2Results = doc.evaluate(xPath2, doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate( 'count (//tr/td[1][@class="Label"])', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - //At this point we have two lists (xPath1Results and xPath2Results). this loop matches the first item in the first list - //with the first item in the second list, and on until the end. - //If we then ask for the "Principal Author" the program returns "J.K. Rowling" instead of "Principal Author" - if (doc.evaluate('//tr/td[1][@class="Label"]', doc, nsResolver, XPathResult.ANY_TYPE, null)) { - for (i=0; i<xPathCount.numberValue; i++) { - - fieldTitle=xPath1Results.iterateNext().textContent.replace(/\s+/g, ''); - - //gets the author's name without cleaning it away using cleanTags. - if (fieldTitle =="PrincipalAuthor:" || fieldTitle == "Auteurprincipal:") { - - fieldTitle="PrincipalAuthor:"; - dataTags[fieldTitle]=(xPath2Results.iterateNext().textContent); - var authorName =dataTags["PrincipalAuthor:"].split(","); - authorName[0]=authorName[0].replace(/\s+/g, ''); - dataTags["PrincipalAuthor:"]= (authorName[1] + (" ") + authorName[0]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["PrincipalAuthor:"], "author")); - - //Splits Adressebibliographique or Imprint into 3 fields and cleans away any extra whitespace or unwanted characters. - } else if (fieldTitle =="Adressebibliographique:" || fieldTitle == "Imprint:") { - - fieldTitle = "Imprint:"; - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent); - - var separateImprint = dataTags["Imprint:"].split(":"); - separateImprint[0]= separateImprint[0].replace(/^\s*|\[|\]/g,''); - dataTags["Place:"]=separateImprint[0]; - - var justDate = separateImprint[1].replace(/\D/g, ''); - dataTags["Date:"]= justDate; - - separateImprint[1] = separateImprint[1].replace(/\d|\[|\]|\./g, ''); - separateImprint[1] = separateImprint[1].replace(/^\s*|\s*$/g, ''); - dataTags["Publisher:"]= separateImprint[1]; - - // determines how many tags there will be, pushes them into an array and clears away whitespace. - } else if (fieldTitle == "Subject:" || fieldTitle == "Sujet:") { - - tagsContent.push(Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent.replace(/^\s*|\s*$/g, ''))); - while (fieldTitle != "Collection:") { - i=i+1; - tagsContent.push(Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent.replace(/^\s*|\s*$/g, ''))); - fieldTitle=xPath1Results.iterateNext().textContent.replace(/\s+/g, ''); - } - - } else { - - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - - } - } - } - //Adds a string to CIHM no: and ICMH no: so that the resulting number makes sense to the reader. - if (dataTags["CIHMno.:"]) { - - dataTags["CIHMno.:"]=("CIHM Number: " + dataTags["CIHMno.:"]); - } - - if (dataTags["ICMHno:"]) { - - dataTags["ICMHno:"]=("ICMH nombre: " + dataTags["ICMHno:"]); - } - - //makes tags of the items in the "tagsContent" array. - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - - //calls the associateData function to put the data in the correct Zotero field. - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "Place:", "place"); - associateData (newItem, dataTags, "Publisher:", "publisher"); - associateData (newItem, dataTags, "Date:", "date"); - associateData (newItem, dataTags, "PageCount:", "pages"); - associateData (newItem, dataTags, "CIHMno.:", "extra"); - associateData (newItem, dataTags, "DocumentSource:", "rights"); - - associateData (newItem, dataTags, "Titre:", "title" ); - associateData (newItem, dataTags, "Nombredepages:", "pages"); - associateData (newItem, dataTags, "ICMHno:", "extra"); - associateData (newItem, dataTags, "Documentoriginal:", "rights"); - - //Saves everything to Zotero. - newItem.complete(); - -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//div[@id="Content"]/div[@class="NormalRecord"]/h3/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); - - - -} -\ No newline at end of file diff --git a/translators/Cell Press.js b/translators/Cell Press.js @@ -1,139 +0,0 @@ -{ - "translatorID":"f26cfb71-efd7-47ae-a28c-d4d8852096bd", - "translatorType":4, - "label":"Cell Press", - "creator":"Michael Berkowitz", - "target":"http://www.(cancercell|cell|cellhostandmicrobe|cellmetabolism|cellstemcell|chembiol|current-biology|developmentalcell|immunity|molecule|neuron|structure).(org|com)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":99, - "inRepository":true, - "lastUpdated":"2008-07-07 14:50:00" -} - -function detectWeb(doc, url) { - - if (url.indexOf("search/results") != -1) { - return "multiple"; - } else if (url.indexOf("content/article") != -1) { - return "journalArticle"; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - var commaSplit = new Array(); - - var newItem = new Zotero.Item("journalArticle"); - - //title - newItem.title = doc.evaluate('//h1[@class="article_title"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - //publication, volume, pages, date. - var voliss = doc.evaluate('//div[contains(@class, "article_citation")]/p[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var volissSplit = voliss.split("."); - - for (var i = 0; i < volissSplit.length; i++) { - if (volissSplit[i].match(", ")) { - commaSplit = volissSplit[i].split(", "); - } - } - if (commaSplit[0] != '') { - newItem.publicationTitle = commaSplit[0]; - } - if (commaSplit[1] != '') { - newItem.volume = commaSplit[1]; - } - if (commaSplit[2] != '') { - newItem.pages= commaSplit[2]; - } - if (commaSplit[3] != '') { - newItem.date= commaSplit[3]; - } - - //abstract - - var abstractXPath2 = '//div[@class="min_fulltext"][@id="main_content"]/p'; - if (doc.evaluate(abstractXPath2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate(abstractXPath2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - var abstractXPath = '//div[@class="panelcontent article_summary"]/p[contains(text(), " ")]'; - if (doc.evaluate(abstractXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate(abstractXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - //authors - var authors = doc.evaluate('//p[@class="authors"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(","); - for (var i in authors) { - var next_author = authors[i]; - if (next_author.match(/[a-z]/)) { - next_author = Zotero.Utilities.trimInternal(next_author.replace(/\d/g, "")); - if (next_author.substr(0, 3) == "and") { - next_author = next_author.substr(4); - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(next_author, "author")); - } - } - - //url - var newurl = doc.location.href; - if (newurl.indexOf("abstract") != -1) { - newurl = newurl.replace("abstract", "fulltext"); - } - - //attachments - var uid = newurl.match(/uid=([^&]+)/)[1]; - var pdfx = '//a[contains(text(), "PDF")][contains(@href, "' + uid + '")]'; - var pdfurl = doc.evaluate(pdfx, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - newItem.attachments = [ - {url:newurl, title:"Cell Press Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"Cell Press Full Text PDF", mimeType:"application/pdf"} - ]; - - newItem.complete(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - } : null; - - var articles = new Array(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//dd/strong', doc, nsResolver, XPathResult.ANY_TYPE, null); - var link = doc.evaluate('//nobr/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - var next_lilnk; - - while (next_title = titles.iterateNext()) { - next_link = link.iterateNext(); - if (next_link.textContent.match("Summary")) { - items[next_link.href] = next_title.textContent; - } else { - next_link = link.iterateNext(); - items[next_link.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Champlain Society - Collection.js b/translators/Champlain Society - Collection.js @@ -1,167 +0,0 @@ -{ - "translatorID":"50d3ca81-3c4c-406b-afb2-0fe8105b9b38", - "translatorType":4, - "label":"Champlain Society - Collection", - "creator":"Adam Crymble", - "target":"http://link.library.utoronto.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:40:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("search_results")) { - return "multiple"; - } else if (doc.location.href.match("item_record")) { - return "book"; - } -} - -//Champlain Collection translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - - var headers = doc.evaluate('//table[1]/tbody/tr/td[1]/b/font', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//td/table[1]/tbody/tr/td[2]/font', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//table[1]/tbody/tr/td[1]/b/font)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, ''); - if (fieldTitle == "Auteur:" ) { - fieldTitle = "Author:"; - } else if (fieldTitle == "Titre:") { - fieldTitle = "Title:"; - } else if (fieldTitle == "Description:") { - fieldTitle = "Extent:"; - } else if (fieldTitle == "Éditeur:") { - fieldTitle = "Published:"; - } else if (fieldTitle == "Sujet:") { - fieldTitle = "Subjects:"; - } - - dataTags[fieldTitle] = (contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - -//author - var multiAuthors = 0; - if (dataTags["Author:"]) { - var author = dataTags["Author:"]; - if (author.match("; ")) { - var authors = author.split("; "); - multiAuthors = 1; - } - - if (multiAuthors == 1) { - for (var i = 0; i < authors.length; i++) { - if (authors[i].match(", ")) { - var author1 = authors[i].split(", "); - author = author1[1] + " " + author1[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - } else { - if (author.match(", ")) { - var author1 = author.split(", "); - author = author1[1] + " " + author1[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - } - - if (dataTags["Published:"]) { - if (dataTags["Published:"].match(": ")) { - var place1 = dataTags["Published:"].indexOf(": "); - newItem.place = dataTags["Published:"].substr(0, place1); - var publisher1 = dataTags["Published:"].substr(place1 + 2); - - if (publisher1.match(", ")) { - var date1 = publisher1.lastIndexOf(", "); - newItem.date = publisher1.substr(date1 +2); - newItem.publisher = publisher1.substr(0, date1); - } else { - newItem.publisher = publisher1; - } - } else { - newItem.publisher = publisher1; - } - } - -//for Tags - if (dataTags["Subjects:"]) { - tagsContent = dataTags["Subjects:"].split(/\n/); - } - - var j = 0; - for (var i = 0; i < tagsContent.length; i++) { - if (tagsContent[i].match(/\w/)) { - newItem.tags[j] = tagsContent[i].replace(/^\s*|\s+$/g, ''); - j++; - } - } - - associateData (newItem, dataTags, "Extent:", "pages"); - associateData (newItem, dataTags, "ID:", "callNumber"); - associateData (newItem, dataTags, "Notes:", "abstractNote"); - - newItem.title = doc.title; - if (dataTags["Title:"]) { - associateData (newItem, dataTags, "Title:", "title"); - } else { - newItem.title = "No Title Found: Champlain Collection"; - } - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//tr[1]/td[2]/font/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Christian Science Monitor.js b/translators/Christian Science Monitor.js @@ -1,150 +0,0 @@ -{ - "translatorID":"04c0db88-a7fc-4d1a-9cf7-471d0990acb1", - "translatorType":4, - "label":"Christian Science Monitor", - "creator":"Adam Crymble", - "target":"http://(features.csmonitor|www.csmonitor).com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-06 17:00:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("search")) { - return "multiple"; - } else if (doc.location.href.match("features")) { - return "newspaperArticle"; - } else if (doc.evaluate('//div[@id="storyContent"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "newspaperArticle"; - } -} - -//Christian Science Monitor translator. Code by Adam Crymble. - -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("newspaperArticle"); - - - if (doc.location.href.match("features.csmonitor")) { - - newItem.title = doc.title; - - - if (doc.evaluate('//div[@class="story"][@id="main"]/p/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate('//div[@class="story"][@id="main"]/p/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - if (doc.evaluate('//h3/span[@class="time-date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.date = doc.evaluate('//h3/span[@class="time-date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(" edition", ''); - } - - if (doc.evaluate('//h3/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var author = doc.evaluate('//h3/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (author.match("By ")) { - author = author.substr(3); - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - var title1 = doc.title; - - //Some entries do not work for some reason unbeknownst to me; this flag catches the problem and prevents an error, but doesn't save the data properly. - if (title1.match("csmonitor")) { - newItem.title = title1.substr(0, title1.length-15); - } else { - newItem.title = "This Entry Cannot Be Saved"; - newItem.abstractNote = "Entry must be entered manually"; - } - - - - } else { - - //title - if (doc.evaluate('//div[@id="storyContent"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var title1 = doc.evaluate('//div[@id="storyContent"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var words = title1.split(" "); - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - } - title1 = words.join(" "); - newItem.title = title1; - } else { - newItem.title = "no title found"; - } - - //abstract note - if (doc.evaluate('//div[@id="storyContent"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate('//div[@id="storyContent"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - //date - if (doc.evaluate('//div[@id="storyContent"]/p[@class="postdate"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var date1 = doc.evaluate('//div[@id="storyContent"]/p[@class="postdate"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - date1 = date1.replace(/from the /g, ''); - date1 = date1.replace(/ edition/g, ''); - newItem.date = date1; - } - - //author - if (doc.evaluate('//address[@class="byline"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate('//address[@class="byline"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - if (author.match("By ")) { - author = author.substr(3); - } - var words = author.split(" "); - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - } - author = words.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - } - - newItem.publicationTitle = "Christian Science Monitor"; - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//p[@id="searchResultRow"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (!next_title.href.match("features")) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/CiNii.js b/translators/CiNii.js @@ -1,72 +0,0 @@ -{ - "translatorID":"46291dc3-5cbd-47b7-8af4-d009078186f6", - "translatorType":4, - "label":"CiNii", - "creator":"Michael Berkowitz and Mitsuo Yoshida", - "target":"http://ci.nii.ac.jp/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-05-20 04:00:00" -} - -function detectWeb(doc, url) { - if (url.match(/naid/)) { - return "journalArticle"; - } else if (doc.evaluate('//a[contains(@href, "/naid/")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//a[contains(@href, "/naid/")]', doc, ns, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var biblink = 'http://ci.nii.ac.jp/export?fileType=2&docSelect=' + doc.evaluate('//input[@name="docSelect"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value; - var newurl = doc.location.href; - var tags = new Array(); - if (doc.evaluate('//a[@rel="tag"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - var kws = doc.evaluate('//a[@rel="tag"]', doc, ns, XPathResult.ANY_TYPE, null); - var kw; - while (kw = kws.iterateNext()) { - tags.push(Zotero.Utilities.trimInternal(kw.textContent)); - } - } - var abstractNote; - if (doc.evaluate('//div[@class="abstract"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - abstractNote = doc.evaluate('//div[@class="abstract"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - Zotero.Utilities.HTTP.doGet(biblink, function(text) { - var trans = Zotero.loadTranslator("import"); - trans.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - trans.setString(text); - trans.setHandler("itemDone", function(obj, item) { - item.url = newurl; - item.attachments = [{url:item.url, title:item.title + " Snapshot", mimeType:"text/html"}]; - item.tags = tags; - item.abstractNote = abstractNote; - item.complete(); - }); - trans.translate(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/CiteSeer.js b/translators/CiteSeer.js @@ -1,111 +0,0 @@ -{ - "translatorID":"fa396dd4-7d04-4f99-95e1-93d6f355441d", - "translatorType":4, - "label":"CiteSeer", - "creator":"Simon Kornblith", - "target":"^http://(?:citeseer\\.ist\\.psu\\.edu/|citeseer\\.csail\\.mit\\.edu/|citeseer\\.ifi\\.unizh\\.ch/|citeseer\\.comp\\.nus\\.edu\\.sg/)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-02-06 21:00:00" -} - -function detectWeb(doc, url) { - var searchRe = /http:\/\/[^\/]+\/ci?s/; - if(searchRe.test(url)) { - return "multiple"; - } else { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.evaluate('/html/body/span[@class="m"]/pre', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } - } -} - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // figure out what attachments to add - var attachments = new Array(); - var results = doc.evaluate('/html/body/span[@class="m"]/table[@class="h"]/tbody/tr/td[4]/center/font/a', - doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - - var acceptableTypes = ["PDF", "PS", "PS.gz"]; - var mimeTypes = ["application/pdf", "application/postscript", "application/gzip"]; - var resultsArray = []; - while (elmt = results.iterateNext()) { - resultsArray.push(elmt); - } - resultsArray = resultsArray.filter(function (element, index, array) { - return (acceptableTypes.indexOf(element.textContent.toString()) != -1); - }); - resultsArray = resultsArray.sort(function (a,b) { - return (acceptableTypes.indexOf(a.textContent.toString()) - - acceptableTypes.indexOf(b.textContent.toString())); - }); - if (resultsArray.length > 0) { - var elmt = resultsArray[0]; - var kind = elmt.textContent.toString(); - var index = acceptableTypes.indexOf(kind); - var attachment = {url:elmt.href, mimeType:mimeTypes[index], - title:"CiteSeer Full Text "+kind}; - attachments.push(attachment); - } - - var bibtex = doc.evaluate('/html/body/span[@class="m"]/pre/text()', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - if(bibtex) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(bibtex.nodeValue.toString()); - translator.setHandler("itemDone", function(obj, item) { - if(item.url) { // add http to url - item.url = "http://"+item.url; - } - item.attachments = attachments; - - item.complete(); - }); - translator.translate(); - } else { - throw "No BibTeX found!"; - } -} - -function doWeb(doc, url) { - var searchRe = /http:\/\/([^\/]+)\/ci?s/; - var m = searchRe.exec(doc.location.href); - if(m) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var items = Zotero.Utilities.getItemArray(doc, doc, "^http://"+m[1]+"/[^/]+.html"); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } else { - scrape(doc); - } -} -\ No newline at end of file diff --git a/translators/CiteULike.js b/translators/CiteULike.js @@ -1,58 +0,0 @@ -{ - "translatorID":"8917b41c-8527-4ee7-b2dd-bcbc3fa5eabd", - "translatorType":4, - "label":"CiteULike", - "creator":"Sean Takats", - "target":"https?://(?:www\\.)?citeulike.org(?:.*/tag/[^/]*$|/search/|/journal/|/user/|/group/[0-9]+/library$|/\\?page=[0-9]+$|/.*article/[0-9]+$|/$)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-06-13 19:30:00" -} - -function detectWeb(doc, url){ - var articleRe = /\/article\/[0-9]+$/; - var m = url.match(articleRe); - var newUris = new Array(); - - if (m){ - return "journalArticle"; - } else { - return "multiple"; - } -} - -function doWeb(doc, url){ - var articleRe = /\/article\/[0-9]+$/; - var m = url.match(articleRe); - var newUris = new Array(); - - if (m){ - newUris.push(url.replace(/citeulike\.org\//, "citeulike.org/endnote/")); - } else { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var elmt; - var elmts = doc.evaluate('//a[@class="title"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var items = new Object(); - while(elmt = elmts.iterateNext()) { - items[elmt.href] = Zotero.Utilities.trimInternal(elmt.textContent); - } - items = Zotero.selectItems(items); - if(!items) return true; - for(var uri in items) { - newUris.push(uri.replace(/citeulike\.org\//, "citeulike.org/endnote/")); - } - } - Zotero.Utilities.HTTP.doGet(newUris, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - Zotero.done(); - }); - Zotero.wait(); -} diff --git a/translators/Citebase.js b/translators/Citebase.js @@ -1,94 +0,0 @@ -{ - "translatorID":"daa26181-71d4-48ef-8cac-54c06ff4c20e", - "translatorType":12, - "label":"Citebase", - "creator":"Michael Berkowitz", - "target":"^http://www\\.citebase\\.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/\/search/)) { - return "multiple"; - } else if (url.match(/\/abstract/)) { - return "journalArticle"; - } -} - -function detectSearch(item) { - if(item.itemType == "journalArticle") { - return true; - } - return false; -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var links = doc.evaluate('//div[@class="rs_match"]/div/a[@class="abs_title"]', doc, null, XPathResult.ANY_TYPE, null); - var items = new Object(); - var link; - while (link = links.iterateNext()) { - items[link.href] = link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - - Zotero.Utilities.processDocuments(articles, function(doc) { - var biburl = doc.evaluate('//a[contains(text(), "BibTeX")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - if (doc.evaluate('/html/body/div[@class="body"]/div[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) var abs = Zotero.Utilities.trimInternal(doc.evaluate('/html/body/div[@class="body"]/div[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - Zotero.Utilities.HTTP.doGet(biburl, function(text) { - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if (abs) { - if (abs.match(/^Abstract/)) { - item.abstractNote = abs.substr(9); - } else { - item.abstractNote = abs; - } - } - item.attachments = [{url:item.url, title:"Citebase Snapshot", mimeType:"text/html"}]; - item.complete(); - }); - translator.translate(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} - -function doSearch(item) { - if(item.contextObject) { - var co = item.contextObject; - if(co.indexOf("url_ver=") == -1) { - co = "url_ver=Z39.88-2004&"+co; - } - co = co.replace(/(?:&|^)svc_id=[^&]*/, ""); - } else { - var co = Zotero.Utilities.createContextObject(item); - } - - Zotero.Utilities.HTTP.doGet("http://www.citebase.org/openurl?"+co+"&svc_id=bibtex", function(responseText, request) { - if(responseText.substr(0, 6) != "<?xml ") { - // read BibTeX - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(responseText); - translator.translate(); - } - - Zotero.done(); - }); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Civilization.ca.js b/translators/Civilization.ca.js @@ -1,132 +0,0 @@ -{ - "translatorID":"8451431a-895f-4732-8339-79eb6756d2f9", - "translatorType":4, - "label":"Civilization.ca", - "creator":"Adam Crymble", - "target":"http://collections.civilization.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:40:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//tr/td[2]/a/font', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.location.href.match("Display.php")) { - return "artwork"; - } -} - -//Civilization.ca translator. Code by Adam Crymble. - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("artwork"); - - var headers = doc.evaluate('//table[2]/tbody/tr/td[1]/span[@class="textb"]/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//tr[2]/td/table[2]/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//table[2]/tbody/tr/td[1]/span[@class="textb"]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - newItem.title = contents.iterateNext().textContent.replace(/^\s*|\s+$/g, ''); - var dump = contents.iterateNext(); - - for (i=0; i<xPathCount.numberValue; i++) { - - fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, ''); - if (fieldTitle == "Artist/Maker/Manufacturer") { - fieldTitle = " Artiste/Artisan/Fabricant"; - } else if (fieldTitle == "Autreaffiliationculturelle") { - fieldTitle = "OtherCulturalAffiliation"; - } - - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - - if (dataTags["Artist/Maker/Manufacturer"]) { - var author = dataTags["Artist/Maker/Manufacturer"]; - if (author.match(" and ")) { - var authors = author.split(" and "); - for (var i in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - - if (dataTags["OtherCulturalAffiliation"]) { - tagsContent = dataTags["OtherCulturalAffiliation"].split(/\n/); - - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - } - - if (dataTags["Collection"]) { - newItem.extra = "Collection: " + dataTags['Collection']; - } - - associateData (newItem, dataTags, "ArtifactNumber", "callNumber"); - associateData (newItem, dataTags, "Museum", "repository"); - associateData (newItem, dataTags, "Measurements", "artworkSize"); - associateData (newItem, dataTags, "BeginDate", "date"); - associateData (newItem, dataTags, "EndDate", "date"); - associateData (newItem, dataTags, "AdditionalInformation", "abstractNote"); - - associateData (newItem, dataTags, "Numérod'artefact", "callNumber"); - associateData (newItem, dataTags, "Musée", "repository"); - associateData (newItem, dataTags, "Mesures", "artworkSize"); - associateData (newItem, dataTags, "Datededébut", "date"); - associateData (newItem, dataTags, "Datedefin", "date"); - associateData (newItem, dataTags, "Informationsupplémentaire", "abstractNote"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//tr/td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.textContent.match(/\w/)) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Code4Lib Journal.js b/translators/Code4Lib Journal.js @@ -1,68 +0,0 @@ -{ - "translatorID":"a326fc49-60c2-405b-8f44-607e5d18b9ad", - "translatorType":4, - "label":"Code4Lib Journal", - "creator":"Michael Berkowitz", - "target":"http://journal.code4lib.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//h2[@class="articletitle"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//h1[@class="articletitle"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var items = new Object(); - var articles = new Array(); - var xpath = '//div[@class="article"]/h2[@class="articletitle"]/a'; - if (detectWeb(doc, url) == "multiple") { - var xpath = '//div[@class="article"]/h2[@class="articletitle"]/a'; - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_title = titles.iterateNext(); - while (next_title) { - items[next_title.href] = next_title.textContent; - next_title = titles.iterateNext(); - } - - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles.push(url); - } - - Zotero.Utilities.processDocuments(articles, function(newDoc, url) { - var newItem = new Zotero.Item("journalArticle"); - newItem.repository = "Code4Lib Journal"; - newItem.publicationTitle = "The Code4Lib Journal"; - newItem.ISSN = "1940-5758"; - newItem.url = newDoc.location.href; - newItem.title = newDoc.evaluate('//div[@class="article"]/h1[@class="articletitle"]/a', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = newDoc.evaluate('//div[@class="article"]/div[@class="abstract"]/p', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var issdate = newDoc.evaluate('//p[@id="issueDesignation"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.issue = issdate.match(/([^,]*)/)[0].match(/\d+/)[0]; - newItem.date = issdate.match(/,\s+(.*)$/)[1]; - - - var axpath = '//div[@class="article"]/div[@class="entry"]/p[1]/a'; - var authors = newDoc.evaluate(axpath, newDoc, null, XPathResult.ANY_TYPE, null); - var next_author = authors.iterateNext(); - while (next_author) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(next_author.textContent, "author")); - next_author = authors.iterateNext(); - } - - newItem.attachments.push({url:newDoc.location.href, title:"Code4Lib Journal Snapshot", mimeType:"text/html"}); - newItem.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Columbia University Press.js b/translators/Columbia University Press.js @@ -1,69 +0,0 @@ -{ - "translatorID":"a75e0594-a9e8-466e-9ce8-c10560ea59fd", - "translatorType":4, - "label":"Columbia University Press", - "creator":"Michael Berkowitz", - "target":"http://www.cup.columbia.edu/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/book\//)) { - return "book"; - } else if (doc.evaluate('//p[@class="header"]/a/span[@class="_booktitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function addTag(item, tag, xpath) { - item[tag] = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var books = new Array(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//p[@class="header"]/a', doc, ns, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - items[title.href] = title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - books.push(i); - } - } else { - books = [url]; - } - Zotero.Utilities.processDocuments(books, function(doc) { - var item = new Zotero.Item("book"); - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//h1[@id="_booktitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var authors = Zotero.Utilities.trimInternal(doc.evaluate('//p[@id="_authors"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if (authors.match(/Edited/)) { - authors = Zotero.Utilities.trimInternal(authors.replace("Edited by", "")); - var autType = "editor"; - } else { - var autType = "author"; - } - var auts = authors.split(/,|\band\b/); - for each (var aut in auts) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, autType)); - } - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//p[@id="_desc"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.date = Zotero.Utilities.trimInternal(doc.evaluate('//span[@id="_publishDate"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.ISBN = Zotero.Utilities.trimInternal(doc.evaluate('//span[@id="_isbn"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.publisher = Zotero.Utilities.trimInternal(doc.evaluate('//span[@id="_publisher"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Common-Place.js b/translators/Common-Place.js @@ -1,166 +0,0 @@ -{ - "translatorID":"c3edb423-f267-47a1-a8c2-158c247f87c2", - "translatorType":4, - "label":"Common-Place", - "creator":"Frederick Gibbs", - "target":"http://www.common-place\\.|historycooperative\\.org/journals/cp", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-12 19:30:00" -} - -function detectWeb(doc, url) { - if(doc.title.indexOf("Previous Issues") != -1 || doc.title.indexOf("Search Site") != -1 ) { - return "multiple"; - } else { - return "journalArticle"; - } -} - -function scrape(doc) { - - 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"); - newItem.publicationTitle = "Common-Place"; - newItem.url = doc.location.href; - - - //get issue year and month - //these will determine what xpaths we use for title and author - var pubDate; - var dateRe = /<a href="\/vol-[0-9]{2}\/no-[0-9]{2}\/">(.*)<\/a><\/b>/; - var m = dateRe.exec(Zotero.Utilities.trimInternal(doc.getElementsByTagName("body")[0].innerHTML)); - - if(m) { - //newItem.title = Zotero.Utilities.trimInternal(Zotero.Utilities.unescapeHTML(m[1])); - pubDate = m[1]; - } else { - pubDate = doc.evaluate('//div[@id="container"]/div[@id="top"]/p/b/a[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - var d; - //Zotero.debug(pubDate); - pubDateVolRE = /vol. (.*) · no. /; - d = pubDateVolRE.exec(pubDate); - newItem.volume = d[1]; - - pubDateVolRE = /no. (.*) ·/; - d = pubDateVolRE.exec(pubDate); - newItem.issue = d[1]; - - pubDateVolRE = /no. [0-9] · (.*)/; - d = pubDateVolRE.exec(pubDate); - newItem.date = d[1]; - - //usually the page begins with the article title or book title (of reviewed book) - //some pages have an image just before them, so we need to skip it if it's there. - var pLevel; - var m=doc.evaluate('//div[@id="content"]/p[1]/img', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - //if there is an image here, offset the xpath - if (m == null) { - pLevel = '//div[@id="content"]/p[1]'; - } else { - pLevel = '//div[@id="content"]/p[2]'; - } - - //issues before 2004 have a table based layout, so a totally different xpath. - //check to see if we have anything, then try again if we don't. - var author; - var title; - - author = doc.evaluate(pLevel+'/span[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - author = author.iterateNext(); - - if (author != null) { - //Zotero.debug("au"+author+"au"); - var title = doc.evaluate(pLevel+'/span[2]', doc, nsResolver, XPathResult.ANY_TYPE, null); - //Zotero.debug("ti"+title+"ti"); - title = title.iterateNext().textContent; - - //determine if we have a book review - // if so, get the publication information - if (author.textContent.indexOf("Review by") != -1 ) { - newItem.title = String.concat("Review of ", title); - newItem.author = author.textContent.substring(10); - } else { - newItem.author = author.textContent; - newItem.title = title; - } - - } - else { //we have older issue - - //check if we are on a review - var review = doc.evaluate('/html/body/table/tbody/tr/td[2]/p[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var temp = review.textContent; - if (temp.indexOf("Review") != -1) { - title = doc.evaluate('/html/body/table/tbody/tr/td[2]/p/i', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - title = "Review of " + title; - author = review.textContent.substring(10); - } else { //for articles - title = doc.evaluate('/html/body/table/tbody/tr/td[2]/p/b', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - author = doc.evaluate('/html/body/table/tbody/tr/td[2]/p[1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\n/)[1]; - //Zotero.debug(author); - } - newItem.author = author; - newItem.title = title; - } - - newItem.attachments.push({document:doc, title:doc.title}); - - newItem.complete(); -} - -function doWeb(doc, url) { -var type = detectWeb(doc, url); -if (type == "multiple") { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - //create list of items - //what about home page (current issue table of contents?) - //for search result links: /html/body/table[2]/tbody/tr/td[2]/li[3]/a - //for previous issues: //tr/td/p/a/b (but we need to strip out volume links (starts with 'Volume') - - var link; - var title; - var items = new Object(); - var searchLinks = doc.evaluate('/html/body/table[2]/tbody/tr/td[2]/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - while (elmt = searchLinks.iterateNext()) { - Zotero.debug(elmt.textContent); - title = elmt.textContent; - link = elmt.href; - if (title && link){ - items[link] = title; - } - } - - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var uris = new Array(); - for(var i in items) { - uris.push(i); - } - - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, - function() { Zotero.done(); }, null); - - Zotero.wait(); - } else { - scrape(doc); - } -} -\ No newline at end of file diff --git a/translators/Copernicus.js b/translators/Copernicus.js @@ -1,187 +0,0 @@ -{ - "translatorID": "8082115d-5bc6-4517-a4e8-abed1b2a784a", - "label": "Copernicus", - "creator": "Michael Berkowitz", - "target": "http://www.(adv-sci-res|adv-geosci|adv-radio-sci|ann-geophys|astrophys-space-sci-trans|atmos-chem-phys|biogeosciences(-discuss)?|clim-past|electronic-earth|hydrol-earth-syst-sci|nat-hazards-earth-syst-sci|nonlin-processes-geophys|ocean-sci|soc-geogr|surv-perspect-integr-environ-soc|the-cryosphere).net/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-01 07:40:29" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@id="publisher"]/iframe', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//td[*[a[contains(text(), "Abstract")]]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.title.match(/Abstract/)) { - return "journalArticle"; - } -} - -function getRIS(link) { - Zotero.Utilities.HTTP.doGet(link, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.repository = "Copernicus Online Journals"; - item.attachments[0].title = item.publicationTitle + " Snapshot"; - item.attachments[0].mimeType = "text/html"; - item.attachments[1].title = item.publicationTitle + " PDF"; - item.complete(); - }); - translator.translate(); - }); -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('//div[@id="publisher"]/iframe', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var link = doc.evaluate('//div[@id="publisher"]/iframe', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src; - Zotero.Utilities.HTTP.doGet(link, function(text) { - var links = text.match(/<a\s+target=\"_top\"\s+href=\"[^"]+\">[^<]+/g); - for each (var link in links) { - link = link.match(/href=\"([^"]+)\">(.*)/); - items[link[1].replace(/\.[^\.]+$/, ".ris")] = Zotero.Utilities.trimInternal(link[2]) + "..."; - } - items = Zotero.selectItems(items); - for (var i in items) { - getRIS(i); - } - }); - } else { - var titles = doc.evaluate('//td[*[a[contains(text(), "Abstract")]]]/span[@class="pb_toc_article_title"]', doc, null, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//td[*[a[contains(text(), "Abstract")]]]//a[1]', doc, null, XPathResult.ANY_TYPE, null); - var title; - var link; - while ((title = titles.iterateNext()) && (link = links.iterateNext())) { - items[link.href] = title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - getRIS(i.replace(".html", ".ris")); - } - } - } else { - getRIS(url.replace('.html', '.ris')); - } - Zotero.wait(); -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.adv-geosci.net/30/1/2011/adgeo-30-1-2011.html", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Michaelides", - "firstName": "S.", - "creatorType": "author" - }, - { - "lastName": "Athanasatos", - "firstName": "S.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.adv-geosci.net/30/1/2011/", - "title": "Adv. Geosci. Snapshot", - "mimeType": "text/html" - }, - { - "url": "http://www.adv-geosci.net/30/1/2011/adgeo-30-1-2011.pdf", - "mimeType": "application/pdf", - "title": "Adv. Geosci. PDF", - "downloadable": true - } - ], - "title": "Preface ''Precipitation: Measurement, Climatology, Remote Sensing, and Modeling (EGU 2010)''", - "publicationTitle": "Adv. Geosci.", - "volume": "30", - "pages": "1-2", - "date": "May 09, 2011", - "publisher": "Copernicus Publications", - "ISBN": "1680-7359", - "ISSN": "1680-7359", - "url": "http://www.adv-geosci.net/30/1/2011/", - "DOI": "10.5194/adgeo-30-1-2011", - "libraryCatalog": "Copernicus Online Journals", - "accessDate": "CURRENT_TIMESTAMP", - "shortTitle": "Preface ''Precipitation" - } - ] - }, - { - "type": "web", - "url": "http://www.adv-radio-sci.net/6/1/2008/ars-6-1-2008.html", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Will", - "firstName": "B.", - "creatorType": "author" - }, - { - "lastName": "Gerding", - "firstName": "M.", - "creatorType": "author" - }, - { - "lastName": "Schultz", - "firstName": "S.", - "creatorType": "author" - }, - { - "lastName": "Schiek", - "firstName": "B.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.adv-radio-sci.net/6/1/2008/", - "title": "Adv. Radio Sci. Snapshot", - "mimeType": "text/html" - }, - { - "url": "http://www.adv-radio-sci.net/6/1/2008/ars-6-1-2008.pdf", - "mimeType": "application/pdf", - "title": "Adv. Radio Sci. PDF", - "downloadable": true - } - ], - "title": "Time domain reflectrometry measurements using a movable obstacle for the determination of dielectric profiles", - "publicationTitle": "Adv. Radio Sci.", - "volume": "6", - "pages": "1-4", - "date": "May 26, 2008", - "publisher": "Copernicus Publications", - "ISBN": "1684-9965", - "ISSN": "1684-9965", - "url": "http://www.adv-radio-sci.net/6/1/2008/", - "DOI": "10.5194/ars-6-1-2008", - "libraryCatalog": "Copernicus Online Journals", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Cornell LII.js b/translators/Cornell LII.js @@ -1,209 +0,0 @@ -{ - "translatorID":"930d49bc-44a1-4c22-9dde-aa6f72fb11e5", - "translatorType":4, - "label":"Cornell LII", - "creator":"Bill McKinney", - "target":"^http://www\\.law\\.cornell\\.edu/supct/html/.+", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-03-19 17:36:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var liiRegexp = /http:\/\/www\.law\.cornell\.edu\/supct\/html\/.+/ - if(liiRegexp.test(url)) { - return "book"; - } else { - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - if(articleRegexp.test(aTags[i].href)) { - return "multiple"; - } - } - } -} - -function associateMeta(newItem, metaTags, field, zoteroField) { - var field = metaTags.namedItem(field); - if(field) { - newItem[zoteroField] = field.getAttribute("content"); - } -} - -function scrape(doc) { - - var caselawCourt = "U.S. Supreme Court"; - var caselawJurisdiction = "Federal"; - var caselawSourceReporter = "U.S."; - var caselawSourceVolume = "___"; - var caselawSourceStartPage = "___"; - var caselawParallelSourceVolume = "___"; - var caselawParallelSourceStartPage = "___"; - var caselawParallelSourceReporter = "___"; - var caselawDecisionYear = ""; - - var newItem = new Zotero.Item("case"); - newItem.url = doc.location.href; - newItem.language = "en-us"; - newItem.court = "U.S. Supreme Court"; - newItem.reporter = "U.S."; - - // LII provides a bunch of meta tags to harvest - var metaTags = doc.getElementsByTagName("meta"); - associateMeta(newItem, metaTags, "CASENAME", "title"); - associateMeta(newItem, metaTags, "CASENAME", "caseName"); - //associateMeta(newItem, metaTags, "DOCKET", "caselawDocket"); - //associateMeta(newItem, metaTags, "PARTY1", "caselawParty1"); - //associateMeta(newItem, metaTags, "PARTY2", "caselawParty2"); - //associateMeta(newItem, metaTags, "ARGDATE", "caselawArguedDate"); - //associateMeta(newItem, metaTags, "DECDATE", "dateDecided"); - associateMeta(newItem, metaTags, "COURTBELOW", "history"); - //associateMeta(newItem, metaTags, "ACTION", "caselawCourtAction"); - - - var tmpCasename = newItem.caseName; - tmpCasename = Zotero.Utilities.capitalizeTitle(tmpCasename.toLowerCase()); - tmpCasename = tmpCasename.replace("V.", "v."); - newItem.caseName = tmpCasename; - newItem.shortTitle = tmpCasename; - - // judge - var j = metaTags.namedItem("AUTHOR"); - if(j) { - // Some entries the AUTHOR meta tag content is empty, this makes zotero unhappy, adding a default - newItem.creators.push({lastName:j.getAttribute("content") ? j.getAttribute("content") : "Author Not Provided", creatorType:"judge", fieldMode:true}); - } - - // group meta tags - for(var i=0; i<metaTags.length; i++) { - var key = metaTags[i].getAttribute("name"); - var value = metaTags[i].getAttribute("content"); - if (key == "GROUP") { - newItem.tags.push(value); - } - } - - // parse year out of decision date - var decdateField = metaTags.namedItem("DECDATE"); - if(decdateField ) { - var decisionYearRegex = /(\w+)\s+(\d+),\s+(\d+)/ - var decisionDateMatch = decisionYearRegex.exec(decdateField.getAttribute("content")); - var dy; - var dm; - var dd; - if (decisionDateMatch ) { - dm = decisionDateMatch[1]; - dd = decisionDateMatch[2]; - dy = decisionDateMatch [3]; - caselawDecisionYear = dy; - newItem.dateDecided = dy + " " + dm + " " + dd; - } - } - - // create attachment to pdf - var dyRegex = /^(.+)\/html\/(.+)(\.Z\w+)\.html$/; - var dyMatch = dyRegex.exec(newItem.url); - if (dyMatch) { - var pdfUrl = dyMatch[1]+"/pdf/"+dyMatch[2]+"P"+dyMatch[3]; - newItem.attachments.push({url:pdfUrl, title:"PDF version", mimeType:"application/pdf", downloadable:true}); - } - - // parse disposition - var dis = doc.getElementsByTagName("DISPOSITION"); - if (dis.length > 0) { - var tmpDis = dis[0].innerHTML; - tmpDis = tmpDis.replace(/\s+/g, " "); - newItem.title = newItem.title + " (" + tmpDis + ")"; - newItem.caseName= newItem.caseName + " (" + tmpDis + ")"; - - } - - - // parse citation into parts so that bluebook can be constructed - var cite = doc.getElementsByTagName("CASENUMBER"); - if (cite.length > 0) { - var citeRegex = /([0-9]+)\s+U\.S\.\s+([0-9]+)/; - var citeMatch = citeRegex.exec(cite[0].innerHTML); - if (citeMatch) { - caselawSourceVolume = citeMatch[1]; - newItem.reporterVolume = citeMatch[1]; - caselawSourceStartPage = citeMatch[2]; - newItem.firstPage = citeMatch[2]; - } - } - - // look for offcite span element - var spanTags = doc.getElementsByTagName("span"); - if (spanTags.length > 0) { - for(var i=0; i<spanTags.length; i++) { - if(spanTags[i].className == "offcite") { - var citeRegex = /([0-9]+)\s+U\.S\.\s+([0-9]+)/; - var citeMatch = citeRegex.exec(spanTags[i].innerHTML); - if (citeMatch) { - caselawSourceVolume = citeMatch[1]; - newItem.reporterVolume = citeMatch[1]; - caselawSourceStartPage = citeMatch[2]; - newItem.firstPage = citeMatch[2]; - } - break; - } - } - } - - // bluebook citation - var bbCite = newItem.shortTitle + ", " + - caselawSourceVolume + " " + - caselawSourceReporter + " " + - caselawSourceStartPage; - // paralell cite - if (caselawParallelSourceVolume != "___") { - bbCite = bbCite + ", " + caselawParallelSourceVolume + - " " + caselawParallelSourceReporter + " " + - caselawParallelSourceStartPage; - } - // jurisdiction and year - bbCite = bbCite + " (" + caselawDecisionYear + ")"; - // closing period - bbCite = "Bluebook citation: " + bbCite + "."; - newItem.notes.push({note:bbCite}); - - // parse out publication notice - var notice = doc.getElementsByTagName("NOTICE"); - if (notice .length > 0) { - var tmpNotice= notice [0].innerHTML; - tmpNotice= tmpNotice.replace(/\s+/g, " "); - newItem.notes.push({note:tmpNotice}); - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var liiRegexp = /http:\/\/www\.law\.cornell\.edu\/supct\/html\/.+/ - if(liiRegexp.test(url)) { - scrape(doc); - } else { - - var items = Zotero.Utilities.getItemArray(doc, doc, liiRegexp); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/Cornell University Press.js b/translators/Cornell University Press.js @@ -1,64 +0,0 @@ -{ - "translatorID":"4363275e-5cc5-4627-9a7f-951fb58a02c3", - "translatorType":4, - "label":"Cornell University Press", - "creator":"Michael Berkowitz", - "target":"http://www.cornellpress.cornell.edu/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match("detail.taf")) { - return "book"; - } else if (url.match("list.taf") || url.match("listsearch.taf")) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function (prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//tr/td[2]/a', doc, ns, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - if (title.textContent.match(/\w+/)) items[title.href] = Zotero.Utilities.trimInternal(title.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - books.push(i); - } - } else { - books = [url]; - } - Zotero.Utilities.processDocuments(books, function(doc) { - var item = new Zotero.Item("book"); - item.title = Zotero.Utilities.capitalizeTitle(doc.evaluate('//span[@class="bktitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var authors = doc.evaluate('//div[@id="detail"]/table/tbody/tr/td/form/a', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/;/); - Zotero.debug(authors); - for each (var aut in authors) { - if (aut.match(/Translator/)) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut.match(/^(.*)\s+\(/)[1], "translator")); - } else if (aut.match(/Editor/)) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut.match(/^(.*)\s+\(/)[1], "editor")); - } else { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } - var bits = doc.evaluate('//div[@id="detail"]/table/tbody/tr/td/form', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.ISBN = bits.match(/ISBN:\s+([\d\-]+)/)[1]; - item.date = bits.match(/\d{4}/)[0]; - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="description"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/CrossRef.js b/translators/CrossRef.js @@ -1,282 +0,0 @@ -{ - "translatorID":"11645bd1-0420-45c1-badb-53fb41eeb753", - "translatorType":8, - "label":"CrossRef", - "creator":"Simon Kornblith", - "target":"^https?://partneraccess\\.oclc\\.org/", - "minVersion":"2.1.9", - "maxVersion":"", - "priority":90, - "browserSupport":"gcs", - "inRepository":true, - "lastUpdated":"2011-07-29 18:13:47" -} - -/* CrossRef uses unixref; documentation at http://www.crossref.org/schema/documentation/unixref1.0/unixref.html */ -var ns; - -function detectSearch(item) { - // query: should we make this more forgiving? - if(item.itemType === "journalArticle" || item.DOI) { - return true; - } - return false; -} - -function fixAuthorCapitalization(string) { - if(typeof string === "string" && string.toUpperCase() === string) { - string = string.toLowerCase().replace(/\b[a-z]/g, function(m) { return m[0].toUpperCase() }); - } - return string; -} - -function parseCreators(node, item, typeOverrideMap) { - var contributors = ZU.xpath(node, 'c:contributors/c:organization | c:contributors/c:person_name', ns); - for(var i in contributors) { - var creatorXML = contributors[i]; - var creator = {}; - - var role = creatorXML.getAttribute("contributor_role"); - if(typeOverrideMap && typeOverrideMap[role]) { - creator.creatorType = typeOverrideMap[role]; - } else if(role === "author" || role === "editor" || role === "translator") { - creator.creatorType = role; - } else { - creator.creatorType = "contributor"; - } - - if(creatorXML.nodeName === "organization") { - creator.fieldMode = 1; - creator.lastName = creatorXML.textContent; - } else if(creatorXML.nodeName === "person_name") { - creator.firstName = fixAuthorCapitalization(ZU.xpathText(creatorXML, 'c:given_name', ns)); - creator.lastName = fixAuthorCapitalization(ZU.xpathText(creatorXML, 'c:surname', ns)); - } - item.creators.push(creator); - } -} - -function processCrossRef(xmlOutput) { - // XPath does not give us the ability to use the same XPaths regardless of whether or not - // there is a namespace, so we add an element to make sure that there will always be a - // namespace. - xmlOutput = '<xml xmlns="http://www.example.com/">'+xmlOutput.replace(/<\?xml[^>]*\?>/, "")+"</xml>"; - - // parse XML with E4X - try { - var parser = new DOMParser(); - var doc = parser.parseFromString(xmlOutput, "text/xml"); - } catch(e) { - Zotero.debug(e); - return false; - } - - // determine appropriate namespace - ns = {"c":"http://www.crossref.org/xschema/1.1", "x":"http://www.example.com/"}; - var doiRecords = ZU.xpath(doc, '/x:xml/c:doi_records/c:doi_record', ns); - if(!doiRecords.length) { - ns.c = "http://www.crossref.org/xschema/1.0"; - doiRecords = ZU.xpath(doc, '/x:xml/c:doi_records/c:doi_record', ns); - if(!doiRecords.length) { - // this means that the original document was un-namespaced - ns.c = "http://www.example.com/"; - doiRecords = ZU.xpath(doc, '/c:xml/c:doi_records/c:doi_record', ns); - if(!doiRecords.length) { - throw new Error("No records found"); - return; - } - } - } - - var doiRecord = doiRecords[0]; - - // ensure this isn't an error - var errorString = ZU.xpathText(doiRecord, 'c:crossref/c:error', ns); - if(errorString !== null) { - throw errorString; - return false; - } - - var itemXML, item, refXML, metadataXML, seriesXML; - if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:journal', ns)).length) { - item = new Zotero.Item("journalArticle"); - refXML = ZU.xpath(itemXML, 'c:journal_article', ns); - metadataXML = ZU.xpath(itemXML, 'c:journal_metadata', ns); - - item.publicationTitle = ZU.xpathText(metadataXML, 'c:full_title[1]', ns); - item.journalAbbreviation = ZU.xpathText(refXML, 'c:abbrev_title[1]', ns); - item.volume = ZU.xpathText(itemXML, 'c:journal_issue/c:journal_volume/c:volume', ns); - item.issue = ZU.xpathText(itemXML, 'c:journal_issue/c:journal_volume/c:issue', ns); - } else if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:report-paper', ns)).length) { - // Report Paper - // Example: doi: 10.4271/2010-01-0907 - // http://www.crossref.org/openurl/?pid=zter:zter321&url_ver=Z39.88-2004&rft_id=info:doi/10.4271/2010-01-0907&format=unixref&redirect=false - item = new Zotero.Item("report"); - refXML = ZU.xpath(itemXML, 'c:report-paper_metadata', ns); - metadataXML = refXML; - - item.reportNumber = ZU.xpathText(refXML, 'c:publisher_item/c:item_number', ns); - item.institution = ZU.xpathText(refXML, 'c:publisher/c:publisher_name', ns); - item.place = ZU.xpathText(refXML, 'c:publisher/c:publisher_place', ns); - } else if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:book', ns)).length) { - // Book chapter - // Example: doi: 10.1017/CCOL0521858429.016 - // http://www.crossref.org/openurl/?pid=zter:zter321&url_ver=Z39.88-2004&rft_id=info:doi/10.1017/CCOL0521858429.016&format=unixref&redirect=false - // Reference book entry - // Example: doi: 10.1002/14651858.CD002966.pub3 - // http://www.crossref.org/openurl/?pid=zter:zter321&url_ver=Z39.88-2004&rft_id=info:doi/10.1002/14651858.CD002966.pub3&format=unixref&redirect=false - var bookType = itemXML[0].hasAttribute("book_type") ? itemXML[0].getAttribute("book_type") : null; - var componentType = itemXML[0].hasAttribute("component_type") ? itemXML[0].getAttribute("component_type") : null; - - var isReference = ["reference", "other"].indexOf(bookType) !== -1 - && ["chapter", "reference_entry"].indexOf(componentType); - - if(bookType === "edited_book" || isReference) { - item = new Zotero.Item("bookSection"); - refXML = ZU.xpath(itemXML, 'c:content_item', ns); - - if(isReference) { - metadataXML = ZU.xpath(itemXML, 'c:book_metadata', ns); - if(!metadataXML.length) metadataXML = ZU.xpath(itemXML, 'c:book_series_metadata', ns); - - item.bookTitle = ZU.xpathText(metadataXML, 'c:titles[1]/c:title[1]', ns); - } else { - metadataXML = ZU.xpath(itemXML, 'c:book_series_metadata', ns); - if(!metadataXML.length) metadataXML = ZU.xpath(itemXML, 'c:book_metadata', ns); - - item.bookTitle = ZU.xpathText(metadataXML, 'c:series_metadata/c:titles[1]/c:title[1]', ns); - if(!item.bookTitle) item.bookTitle = ZU.xpathText(metadataXML, 'c:titles[1]/c:title[1]', ns); - } - - // Handle book authors - parseCreators(metadataXML, item, {"author":"bookAuthor"}); - // Book - } else { - item = new Zotero.Item("book"); - refXML = ZU.xpath(itemXML, 'c:book_metadata', ns); - metadataXML = refXML; - seriesXML = ZU.xpath(refXML, 'c:series_metadata', ns); - } - - item.place = ZU.xpathText(metadataXML, 'c:publisher/c:publisher_place', ns); - } else if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:conference', ns)).length) { - item = new Zotero.Item("conferencePaper"); - refXML = ZU.xpath(itemXML, 'c:conference_paper', ns); - metadataXML = ZU.xpath(itemXML, 'c:proceedings_metadata', ns); - seriesXML = ZU.xpath(metadataXML, 'c:proceedings_metadata', ns); - - item.publicationTitle = ZU.xpathText(metadataXML, 'c:publisher/c:proceedings_title', ns); - item.place = ZU.xpathText(metadataXML, 'c:event_metadata/c:conference_location', ns); - item.conferenceName = ZU.xpathText(metadataXML, 'c:event_metadata/c:conference_name', ns); - } - - item.ISBN = ZU.xpathText(metadataXML, 'c:isbn', ns); - item.ISSN = ZU.xpathText(metadataXML, 'c:issn', ns); - item.publisher = ZU.xpathText(metadataXML, 'c:publisher/c:publisher_name', ns); - item.edition = ZU.xpathText(metadataXML, 'c:edition_number', ns); - if(!item.volume) item.volume = ZU.xpathText(metadataXML, 'c:volume', ns); - - parseCreators(refXML, item, "author"); - - if(seriesXML && seriesXML.length) { - parseCreators(refXML, item, {"editor":"seriesEditor"}); - item.seriesNumber = ZU.xpathText(seriesXML, 'c:series_number', ns); - } - - var pubDateNode = ZU.xpath(refXML, 'c:publication_date', ns); - if(!pubDateNode) ZU.xpath(metadataXML, 'c:publication_date', ns); - - if(pubDateNode.length) { - var year = ZU.xpathText(pubDateNode[0], 'c:year', ns); - var month = ZU.xpathText(pubDateNode[0], 'c:month', ns); - var day = ZU.xpathText(pubDateNode[0], 'c:day', ns); - - if(year) { - if(month) { - if(day) { - item.date = year+"-"+month+"-"+day; - } else { - item.date = month+"/"+year - } - } else { - item.date = year; - } - } - } - - var pages = ZU.xpath(refXML, 'c:pages[1]', ns); - if(pages.length) { - item.pages = ZU.xpathText(pages, 'c:first_page[1]', ns); - var lastPage = ZU.xpathText(pages, 'c:last_page[1]', ns); - if(lastPage) item.pages += "-"+lastPage; - } - - item.DOI = ZU.xpathText(refXML, 'c:doi_data/c:doi', ns); - item.url = ZU.xpathText(refXML, 'c:doi_data/c:resource', ns); - item.title = ZU.xpathText(refXML, 'c:titles[1]/c:title[1]', ns); - - //Zotero.debug(JSON.stringify(item, null, 4)); - - item.complete(); - return true; -} - -function doSearch(item) { - if(item.contextObject) { - var co = item.contextObject; - if(co.indexOf("url_ver=") == -1) { - co = "url_ver=Z39.88-2004&"+co; - } - } else if(item.DOI) { - var co = "url_ver=Z39.88-2004&&rft_id=info:doi/"+ZU.cleanDOI(item.DOI.toString()); - } else { - var co = Zotero.Utilities.createContextObject(item); - } - - Zotero.Utilities.HTTP.doGet("http://www.crossref.org/openurl/?pid=zter:zter321&"+co+"&noredirect=true&format=unixref", function(responseText) { - processCrossRef(responseText); - Zotero.done(); - }); - - Zotero.wait(); -} -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "search", - "input": { - "DOI":"10.1017/CCOL0521858429.016" - }, - "items": [ - { - "itemType": "bookSection", - "creators": [ - { - "creatorType": "editor", - "firstName": "John", - "lastName": "Rodden" - }, - { - "creatorType": "author", - "firstName": "Christopher", - "lastName": "Hitchens" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "bookTitle": "The Cambridge Companion to George Orwell", - "place": "Cambridge", - "ISBN": "0521858429, 9780521858427, 0521675073, 9780521675079", - "publisher": "Cambridge University Press", - "pages": "201-207", - "DOI": "10.1017/CCOL0521858429.016", - "url": "http://cco.cambridge.org/extract?id=ccol0521858429_CCOL0521858429A016", - "title": "Why Orwell still matters", - "libraryCatalog": "CrossRef" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Cyberpresse.js b/translators/Cyberpresse.js @@ -1,87 +0,0 @@ -{ - "translatorID":"dbfcaa3e-082a-45a4-9619-9892f49399c1", - "translatorType":4, - "label":"Cyberpresse", - "creator":"Adam Crymble", - "target":"http://www.cyberpresse.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-06 17:00:00" -} - -function detectWeb (doc, url) { - if (doc.location.href.match("article")) { - return "newspaperArticle"; - } -} - -//Cyberpresse translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("newspaperArticle"); - - if (doc.title.match("|")) { - - var titleStuff = doc.title.split("|"); - if (titleStuff[0].match(":")) { - var authorTitle = titleStuff[0].split(":"); - newItem.title = authorTitle[1]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorTitle[0], "author")); - - } else { - newItem.title = titleStuff[0]; - } - - } else { - newItem.title = doc.title; - } - - var dataTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < dataTagHTML.length ; i++) { - dataTags[dataTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(dataTagHTML[i].getAttribute("content")); - } - - if (doc.evaluate('//div[@id="nouvelle"]/p[@class="auteur"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate('//div[@id="nouvelle"]/p[@class="auteur"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - if (doc.evaluate('//div[@id="nouvelle"]/p[@class="date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.date = doc.evaluate('//div[@id="nouvelle"]/p[@class="date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - associateData (newItem, dataTags, "summary", "abstractNote"); - associateData (newItem, dataTags, "mediaarticle", "publicationTitle"); - - newItem.url = doc.location.href; - - newItem.complete(); -} - -function doWeb(doc, url) { - - var articles = new Array(); - - articles = [url]; - - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/DBLP Computer Science Bibliography.js b/translators/DBLP Computer Science Bibliography.js @@ -1,170 +0,0 @@ -{ - "translatorID":"625c6435-e235-4402-a48f-3095a9c1a09c", - "translatorType":4, - "label":"DBLP Computer Science Bibliography", - "creator":"Adam Crymble", - "target":"http://(search?|dblp?).mpi-inf", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:40:00" -} - -function detectWeb(doc, url) { - if (doc.title.match("journals")) { - return "journalArticle"; - } else if (doc.title.match("conf")) { - return "conferencePaper"; - } else if (doc.title.match("DBLP entry")) { - return "bookSection"; - } -} - - -//DBLP Computer Science Database Translator. Code by Adam Crymble. -//Doesn't work for multiple entries. Site uses a different URL for the search and single entry. Multiple code attached as comment. - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - } : null; - - var dataTags = new Object(); - - var mediaType = detectWeb(doc, url); - - if (mediaType == "bookSection") { - var newItem = new Zotero.Item("bookSection"); - } else if (mediaType == "conferencePaper") { - var newItem = new Zotero.Item("conferencePaper"); - } else if (mediaType == "journalArticle") { - var newItem = new Zotero.Item("journalArticle"); - } - - var xPathAllData = doc.evaluate('//pre', doc, nsResolver, XPathResult.ANY_TYPE, null); - var allData = xPathAllData.iterateNext().textContent.split("},"); - - var cleanFirstEntry = allData[0].indexOf(","); - allData[0] = allData[0].substr(cleanFirstEntry); - - var headers = new Array(); - var content = new Array(); - var splitAllData; - - for (var i = 0; i < allData.length-2; i++) { - splitAllData = allData[i].split("="); - headers.push(splitAllData[0].replace(/^\s*|\s*$|\W*/g, '')); - content.push(splitAllData[1].replace(/^\s*|\s*$|\{*/g, '')); - - fieldTitle = headers[i].replace(",", ''); - - if (fieldTitle == "author") { - var authors = content[i].split("and"); - - for (var j =0; j<authors.length; j++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j], "author")); - } - } else if (fieldTitle == "editor") { - var editors = content[i].split("and"); - - for (var j =0; j<editors.length; j++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(editors[j], "editor")); - } - } else { - - dataTags[fieldTitle] = content[i]; - } - } - - if (mediaType == "conferencePaper") { - associateData (newItem, dataTags, "booktitle", "conferenceName"); - } else { - associateData (newItem, dataTags, "booktitle", "bookTitle"); - } - - newItem.url = doc.location.href; - - associateData (newItem, dataTags, "year", "date"); - associateData (newItem, dataTags, "pages", "pages"); - associateData (newItem, dataTags, "title", "title"); - associateData (newItem, dataTags, "publisher", "publisher"); - associateData (newItem, dataTags, "volume", "volume"); - associateData (newItem, dataTags, "isbn", "ISBN"); - associateData (newItem, dataTags, "series", "series"); - associateData (newItem, dataTags, "journal", "publicationTitle"); - associateData (newItem, dataTags, "number", "issue"); - - newItem.complete(); - -} - - - -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(); - - /* Multiple code doesn't work due to Permission denied to get property HTMLDocument.documentElement error. - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - //newer interface xPaths - if (doc.title.match("DEMO")) { - - var titles = doc.evaluate('//a/font', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//dt/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[links.iterateNext().href] = next_title.textContent; - } - - //older interface xPaths - } else { - - var titles = doc.evaluate('//td[3]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//td[1]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - var split1; - var split2; - - while (next_title = titles.iterateNext()) { - - split1 = next_title.textContent.indexOf(":"); - var title = next_title.textContent.substr(split1+2); - split2 = title.indexOf("."); - title = title.substr(0, split2); - - items[links.iterateNext().href] = title; - } - - } - - 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(); -} -\ No newline at end of file diff --git a/translators/DOI.js b/translators/DOI.js @@ -1,155 +0,0 @@ -{ - "translatorID":"c159dcfe-8a53-4301-a499-30f6549c340d", - "translatorType":4, - "label":"DOI", - "creator":"Simon Kornblith", - "target":null, - "minVersion":"1.0.10", - "maxVersion":"", - "priority":300, - "browserSupport":"gcs", - "inRepository":true, - "lastUpdated":"2011-06-23 08:58:22" -} - -var items = {}; -var selectArray = {}; - -// builds a list of DOIs -function getDOIs(doc) { - // TODO Detect DOIs more correctly. - // The actual rules for DOIs are very lax-- but we're more strict. - // Specifically, we should allow space characters, and all Unicode - // characters except for control characters. Here, we're cheating - // by not allowing ampersands, to fix an issue with getting DOIs - // out of URLs. - // Description at: http://www.doi.org/handbook_2000/appendix_1.html#A1-4 - const DOIre = /\b(10\.[\w.]+\/[^\s&]+)\.?\b/igm; - const DOIXPath = "//text()[contains(., '10.')]"; - - DOIre.lastMatch = 0; - var DOIs = []; - - var node, m; - var results = doc.evaluate(DOIXPath, doc, null, XPathResult.ANY_TYPE, null); - while(node = results.iterateNext()) { - while(m = DOIre.exec(node.nodeValue)) { - var DOI = m[1]; - if(DOI.substr(-1) == ")" && DOI.indexOf("(") == -1) { - DOI = DOI.substr(0, DOI.length-1); - } - // only add new DOIs - if(DOIs.indexOf(DOI) == -1) { - DOIs.push(DOI); - } - } - } - - return DOIs; -} - -function detectWeb(doc, url) { - const blacklistRe = /^https?:\/\/[^/]*google\.com/i; - - if(!blacklistRe.test(url)) { - var DOIs = getDOIs(doc); - if(DOIs.length) { - return DOIs.length == 1 ? "journalArticle" : "multiple"; - } - } - return false; -} - -function retrieveNextDOI(DOIs, doc) { - if(DOIs.length) { - // retrieve DOI - var DOI = DOIs.shift(); - var translate = Zotero.loadTranslator("search"); - translate.setTranslator("11645bd1-0420-45c1-badb-53fb41eeb753"); - var item = {"itemType":"journalArticle", "DOI":DOI}; - translate.setSearch(item); - // don't save when item is done - translate.setHandler("itemDone", function(translate, item) { - item.repository = "CrossRef"; - items[DOI] = item; - selectArray[DOI] = item.title; - }); - translate.setHandler("done", function(translate) { - retrieveNextDOI(DOIs, doc); - }); - translate.translate(); - } else { - // all DOIs retrieved now - // check to see if there is more than one DOI - var numDOIs = 0; - for(var DOI in selectArray) { - numDOIs++; - if(numDOIs == 2) break; - } - if(numDOIs == 0) { - throw "DOI Translator: could not find DOI"; - } else if(numDOIs == 1) { - // do we want to add URL of the page? - items[DOI].url = doc.location.href; - items[DOI].attachments = [{document:doc}]; - items[DOI].complete(); - } else { - selectArray = Zotero.selectItems(selectArray); - for(var DOI in selectArray) { - items[DOI].complete(); - } - } - Zotero.done(); - } -} - -function doWeb(doc, url) { - var DOIs = getDOIs(doc); - // retrieve full items asynchronously - Zotero.wait(); - retrieveNextDOI(DOIs, doc); -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.crossref.org/help/Content/01_About_DOIs/What_is_a_DOI.htm", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "creatorType": "author", - "firstName": "J", - "lastName": "Mou" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "document": false - } - ], - "publicationTitle": "Journal of Molecular Biology", - "volume": "248", - "ISSN": "00222836", - "date": "1995-5-5", - "pages": "507-512", - "DOI": "10.1006/jmbi.1995.0238", - "url": "http://www.crossref.org/help/Content/01_About_DOIs/What_is_a_DOI.htm", - "title": "Atomic Force Microscopy of Cholera Toxin B-oligomers Bound to Bilayers of Biologically Relevant Lipids", - "libraryCatalog": "CrossRef" - } - ] - }, - { - "type": "web", - "url": "http://blog.apastyle.org/apastyle/digital-object-identifier-doi/", - "items": "multiple" - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/DSpace.js b/translators/DSpace.js @@ -1,101 +0,0 @@ -{ - "translatorID":"0abd577b-ec45-4e9f-9081-448737e2fd34", - "translatorType":4, - "label":"DSpace", - "creator":"Michael Berkowitz", - "target":"(dspace|upcommons.upc.edu)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//table[@class="itemDisplayTable"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "document"; - } else if (doc.evaluate('//table[@class="miscTable"]//td[2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//div[@id="main"]/ul[@class="browselist"]/li/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -var itemTypes = { - "Article":"journalArticle", - "Book":"book", - "Thesis":"thesis", - "Working Paper":"report", - "Technical Report":"report" -} - -function doWeb(doc, url) { - var records = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('//div[@id="main"]/ul[@class="browselist"]/li/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="main"]/ul[@class="browselist"]/li/a'; - } else { - var xpath = '//table[@class="miscTable"]//td[2]//a'; - } - var rows = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var row; - while (row = rows.iterateNext()) { - items[row.href] = row.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - records.push(i + '?mode=full'); - } - } else { - records = [url.match(/^([^?]+)\??/)[1] + "?mode=full"]; - } - Zotero.Utilities.processDocuments(records, function(newDoc) { - var values = new Object(); - var fields = newDoc.evaluate('//table[@class="itemDisplayTable"]/tbody/tr/td[1]', newDoc, null, XPathResult.ANY_TYPE, null); - var data = newDoc.evaluate('//table[@class="itemDisplayTable"]/tbody/tr/td[2]', newDoc, null, XPathResult.ANY_TYPE, null); - var field2; - var datum2; - var newItem = new Zotero.Item(); - while ((field2 = fields.iterateNext()) && (datum2 = data.iterateNext())) { - var field = field2.textContent.replace(/^dc\./, ""); - var datum = datum2.textContent; - if (field == "contributor.author") { - var name = datum.split(","); - newItem.creators.push({firstName:name[1], lastName:name[0], creatorType:"author"}); - } else if (field == "dentifier.uri") { - newItem.url = datum; - } else if (field == "title") { - newItem.title = datum; - } else if (field == "type") { - if (itemTypes[datum]) { - newItem.itemType = itemTypes[datum]; - } else { - newItem.itemType = "document"; - } - } else if (field == "description.abstract") { - newItem.abstractNote = datum; - } else if (field == "date.available") { - newItem.date = datum.replace(/T.*$/, ""); - } else if (field == "subject") { - newItem.tags.push(datum); - } else if (field == "publisher") { - newItem.publisher = datum; - } else if (field == "identifier.issn") { - newItem.ISSN = datum; - } else if (field == "relation.ispartofseries") { - if (datum.match(/Vol/)) { - newItem.volume = datum.match(/\d+/)[0]; - } else if (datum.match(/No/)) { - newItem.issue = datum.match(/\d+/)[0]; - } - } else if (field == "rights") { - newItem.rights = datum; - } - } - if (newDoc.evaluate('//td[@class="standard"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) var pdf = newDoc.evaluate('//td[@class="standard"]/a', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - newItem.attachments = [{url:newDoc.location.href, title:"DSpace Snapshot", mimeType:"text/html"}]; - if (pdf) { - newItem.attachments.push({url:pdf, title:"DSpace PDF", mimeType:"application/pdf"}); - } - newItem.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/DTIC.js b/translators/DTIC.js @@ -1,126 +0,0 @@ -{ - "translatorID":"99be9976-2ff9-40df-96e8-82edfa79d9f3", - "translatorType":4, - "label":"Defense Technical Information Center", - "creator":"Matt Burton", - "target":"http://oai\\.dtic\\.mil/oai/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if(doc.title.indexOf("DTIC OAI Index for") != -1) { - return "multiple"; - } else if (url.indexOf("verb=getRecord") != -1){ - return "report"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newURIs = new Array(); - - if(detectWeb(doc,url) == "multiple"){ - var links = doc.evaluate("//a/@href", doc, nsResolver, XPathResult.Abstract, null); - var titles = doc.evaluate("//a/preceding::text()[1]", doc, nsResolver, XPathResult.Abstract, null); - var items = new Object(); - var link, title; - while( link = links.iterateNext(), title = titles.iterateNext()){ - items[link.textContent.replace(/&metadataPrefix=html/, "&metadataPrefix=oai_dc")] = title.textContent; - } - items = Zotero.selectItems(items); - if(!items) { - return true; - } - for (url in items) { - newURIs.push(url); - Zotero.debug(url); - } - } else { - newURIs.push(url.replace(/&metadataPrefix=html/, "&metadataPrefix=oai_dc")) - } - - // ripped the arXiv.org code, hence the funny var names. - Zotero.Utilities.HTTP.doGet(newURIs, function(text) { - var newItem = new Zotero.Item("report"); - // remove header - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - // fix non-compliant XML tags (colons) - text = text.replace(/<dc:/g, "<dc_").replace(/<\/dc:/g, "</dc_"); - text = text.replace(/<oai_dc:dc/g, "<oai_dc_dc").replace(/<\/oai_dc:dc/g, "</oai_dc_dc"); - text = text.replace(/<OAI-PMH[^>]*>/, "").replace(/<\/OAI-PMH[^>]*>/, ""); - text = "<zotero>" + text + "</zotero>"; - var xml = new XML(text); - var title; - var citation = xml.GetRecord.record.metadata.oai_dc_dc; - var test = xml..responseDate.text().toString(); - - if (citation.dc_title.length()){ - title = Zotero.Utilities.trimInternal(citation.dc_title.text().toString()); - newItem.title = title; - } - Zotero.debug("article title: " + title); - var type = ""; - if(citation.dc_creator.length()) { - var authors = citation.dc_creator; - for(var j=0; j<authors.length(); j++) { - Zotero.debug("author: " + authors[j]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j].text().toString(),type,true)); - } - } - if (citation.dc_date.length()) { - var dates = citation.dc_date; - newItem.date = Zotero.Utilities.trimInternal(dates[0].text().toString()); - } - if (citation.dc_description.length()) { - var descriptions = citation.dc_description; - for (var j=0; j<descriptions.length(); j++) { - var noteStr = Zotero.Utilities.trimInternal(descriptions[j].text().toString()); - newItem.notes.push({note:noteStr}); - } - } - if (citation.dc_subject.length()) { - var subjects = citation.dc_subject; - for (var j=0; j<subjects.length(); j++) { - var subjectValue = Zotero.Utilities.trimInternal(subjects[j].text().toString()); - newItem.tags.push(subjectValue); - } - } - if (citation.dc_identifier.length()) { - var identifiers = citation.dc_identifier; - for (var j=0; j<identifiers.length(); j++) { - var identifier = Zotero.Utilities.trimInternal(identifiers[j].text().toString()); - if (identifier.substr(0, 4) == "doi:") { - newItem.DOI = identifier; - } - else if (identifier.substr(0, 7) == "http://") { - newItem.url = identifier; - } - else { - newItem.extra = identifier; - } - } - } - var articleID = ""; - if (xml.GetRecord.record.header.identifier.length()) { - articleID = xml.GetRecord.record.header.identifier.text().toString(); - articleID = articleID.substr(14); - newItem.publicationTitle = articleID; - } -// TODO add "arXiv.org" to bib data? - newItem.attachments.push({url:newItem.url, title:"DTIC Snapshot", mimeType:"text/html"}); - if (newItem.notes[0]['note']) { - newItem.abstractNote = newItem.notes[0]['note']; - newItem.notes = new Array(); - } - newItem.complete(); - }, function() {Zotero.done();}, null); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Davidson College Library.js b/translators/Davidson College Library.js @@ -1,81 +0,0 @@ -{ - "translatorID":"8b35ab14-f18a-4f69-8472-b2df18c984da", - "translatorType":4, - "label":"Davidson College Library", - "creator":"Michael Berkowitz", - "target":"http://www.lib.davidson.edu/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("log_in") == -1) { - if (url.indexOf("screen=Record") != -1) { - return "book"; - } else { - return "multiple"; - } - } -} - -function doWeb(doc, url) { - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, 'screen=Record.html'); - items = Zotero.selectItems(items); - for (var i in items) { - books.push(i.replace("Record.html", "MARCRecord.html")); - } - } else { - books = [url.replace("Record.html", "MARCRecord.html")]; - } - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.processDocuments(books, function(newDoc) { - var uri = newDoc.location.href; - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var nonstandard = false; - var xpath; - var xpath = '//td[@class="body"]/p/table/tbody/tr[td[3]]'; - var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - var record = new marc.record(); - while(elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.trimInternal(newDoc.evaluate('./td[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if(field) { - var value = newDoc.evaluate('./td[3]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if(field == "LDR") { - record.leader = value; - } else if(field != "FMT") { - value = value.replace(/\$([a-z]) /g, marc.subfieldDelimiter+"$1"); - var code = field.substring(0, 3); - var ind = ""; - if(field.length > 3) { - ind = field[3]; - if(field.length > 4) { - ind += field[4]; - } - } - - record.addField(code, ind, value); - } - } - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^/]+)/); - newItem.repository = "Davidson College Library Catalog"; - newItem.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Der Freitag.js b/translators/Der Freitag.js @@ -1,146 +0,0 @@ -{ - "translatorID": "1ab8b9a4-72b5-4ef4-adc8-4956a50718f7", - "label": "Der Freitag", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.freitag\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": false, - "translatorType": 4, - "lastUpdated": "2011-04-21 01:51:03" -} - -/* -Der Freitag Translator -Copyright (C) 2011 Martin Meyerhoff - -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 site is good, but very, very slow. So when importing multiple Items, be patient! -http://www.freitag.de/search?modus=articles&SearchableText=Gaddafi* -http://www.freitag.de -http://www.freitag.de/guardian-world -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var Freitag_Artikel_XPath = '//div[contains(@class, "artikel_content")]/h2'; - var Freitag_multiple_XPath = ".//h3[contains(@class, 'listing')]/a"; - - if (doc.evaluate(Freitag_Artikel_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ // Diese Zeile verhindert die aus dem Tagesspiegel übernommenen Artikel! - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.evaluate(Freitag_multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ // Diese Zeile verhindert die aus dem Tagesspiegel übernommenen Artikel! - Zotero.debug("multiple"); - return "multiple"; - } -} - -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("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the author and date - - var meta_XPath = "//div[contains(@class, 'article-heading-meta-left')]" - var meta = doc.evaluate(meta_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - meta = meta.split("|"); - for (var i in meta) { - meta[i] = meta[i].replace(/^\s*|\s*$/g, ''); - } - - newItem.date = meta[1].split(/\s/)[0]; - - // author - var author = meta[2].split(/\sund\s|\su\.\s|\,\s|\//); - for (var i in author) { - if (author[i].match(/\s/)) { // only names that contain a space! - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - - // title - var title_XPath = '//title'; - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - title = title.split(/\:|\—/); - for (var i in title) { - title[i] = title[i].replace(/^\s*|\s*$/g, ''); - } - newItem.title = "" - newItem.title = newItem.title.concat(title[0], ": ", title[1]); - newItem.publicationTitle = "Der Freitag"; - - // Summary - var summary_XPath = "//div[@class='artikel_content']/h3"; - var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = Zotero.Utilities.trim(summary); - - // no Tags, because Der Freitag doesn't supply any. - // Section - var section_XPath = "//h1"; - var section= doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.section= section; - - - // Snapshot - var printurl_XPath = ".//a[@id='article-drucken']" - var printurl= doc.evaluate(printurl_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - newItem.attachments.push({url:printurl, title:doc.title, mimeType:"text/html"}); - newItem.complete() - -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate(".//h3[contains(@class, 'listing')]/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} -\ No newline at end of file diff --git a/translators/Die Zeit.js b/translators/Die Zeit.js @@ -1,183 +0,0 @@ -{ - "translatorID": "312bbb0e-bfb6-4563-a33c-085445d391ed", - "label": "Die Zeit", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.zeit\\.de/", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-04-21 02:25:21" -} - -/* -Die Zeit Translator -Copyright (C) 2011 Martin Meyerhoff - -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 works only partially, because zeit.de uses some strange javascript that makes -processDocuments return an error. If I just call scrape(doc, url) on a single document, it works. -The way the translator is programmed now, it only works if JavaScript is turned off in the browser. - -Try it out here: -http://www.zeit.de/wirtschaft/2011-03/schnappauf-ruecktritt-stuttgart -http://www.zeit.de/online/2009/12/arbeitsrecht-urlaub -http://www.zeit.de/suche/index?q=Krise -http://www.zeit.de/2009/11/ -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var Zeit_ArticleTools_XPath = ".//*[@id='informatives']/ul[@class='tools']/li"; - var Zeit_Archive_XPath = "//h4/a|//h2/a"; - - if (doc.evaluate(Zeit_ArticleTools_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.evaluate(Zeit_Archive_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - //return "multiple"; - return false; // TODO Make this not throw javascript errors when using processDocuments - } -} -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("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the title! - - var title_XPath = '//title' - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = Zotero.Utilities.trim(title.split("|")[0]); - - - // Now for the Author - - var author_XPath = '//li[contains(@class, "author first")]'; // I can't get the span selection to work. Help is appreciated. - if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - author = author.replace(/^\s*Von\s|\s*$/g, ''); // remove whitespace around the author and the "Von "at the beginning - } else { - var author = ""; - } - var author = author.split(" | "); // this seems to work even if there's no | - for (var i in author) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - - // Now for the Tags - - var tags_XPath = '//li[contains(@class, "tags")]'; // I can't get the span selection to work. Help is appreciated. - if (doc.evaluate(tags_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var tags = doc.evaluate(tags_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - tags = tags.replace(/^\s*Schlagworte\s|\s*$/g, ''); // remove whitespace around the author and the "Von "at the beginning - } else { - var tags = ""; - } - var tags= tags.split("|"); // this seems to work even if there's no | - for (var i in tags) { - tags[i] = tags[i].replace(/^\s*|\s*$/g, '') // remove whitespace around the tags - newItem.tags.push(tags[i]); - } - - // Date - var date_XPath = '//meta[contains(@name, "date_first_released")]'; - var date2_XPath = ".//li[@class='date']"; - if (doc.evaluate(date_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var date = doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - date = date.split("T")[0]; - newItem.date = date; - } else if (doc.evaluate(date2_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var date = doc.evaluate(date2_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - date = Zotero.Utilities.trim(date.split(/\n/)[1]); - date = date.replace(/Datum\s(\d\d?\.\d\d?\.\d\d\d\d).*/g, '$1'); - newItem.date = date; - } - - - // Summary - - var summary_XPath = ".//p[@class='excerpt']" - if (doc.evaluate(summary_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = Zotero.Utilities.trim(summary); - } - // Produkt (Zeit, Zeit online etc.) - product_XPath = '//meta[contains(@name, "zeit::product-name")]' - if (doc.evaluate(product_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var product = doc.evaluate(product_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.publicationTitle = product; - } else { - var product = "Die Zeit"; - newItem.publicationTitle = product; - } - - - // Section - var section_XPath = '//meta[contains(@name, "zeit::ressort")]' - var section = doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.section= section; - - newItem.attachments.push({url:doc.location.href+"?page=all&print=true", title:doc.title, mimeType:"text/html"}); - newItem.complete() - - -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate("//h4/a|//h2/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.textContent != '') { - items[next_title.href] = next_title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - Zotero.debug(i); - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/Digital Humanities Quarterly.js b/translators/Digital Humanities Quarterly.js @@ -1,61 +0,0 @@ -{ - "translatorID":"bbad0221-134b-495a-aa56-d77cfaa67ab5", - "translatorType":4, - "label":"Digital Humanities Quarterly", - "creator":"Michael Berkowitz", - "target":"http://www.digitalhumanities.org/(dhq)?", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="DHQarticle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } else if (doc.evaluate('//div[@id="mainContent"]/div/p', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function scrape(doc, xpath, xdoc) { - return Zotero.Utilities.trimInternal(doc.evaluate(xpath, xdoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object; - var arts = doc.evaluate('//div[@id="mainContent"]/div/p/a', doc, null, XPathResult.ANY_TYPE, null); - var art; - while (art = arts.iterateNext()) { - items[art.href] = art.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i) - } - } else { - articles = [url]; - } - Zotero.debug(articles); - - Zotero.Utilities.processDocuments(articles, function(newDoc) { - var item = new Zotero.Item("journalArticle"); - item.url = newDoc.location.href; - item.title = scrape(newDoc, '//h1[@class="articleTitle"]', newDoc); - var voliss = scrape(newDoc, '//div[@id="pubInfo"]', newDoc); - voliss = voliss.match(/(.*)Volume\s+(\d+)\s+Number\s+(\d+)/); - item.date = voliss[1]; - item.volume = voliss[2]; - item.issue = voliss[3]; - var authors = newDoc.evaluate('//div[@class="author"]', newDoc, null, XPathResult.ANY_TYPE, null); - var aut; - while (aut = authors.iterateNext()) { - item.creators.push(Zotero.Utilities.cleanAuthor(scrape(newDoc, './a[1]', aut), "author")); - } - item.attachments = [{url:item.url, title:"DHQ Snapshot", mimeType:"text/html"}]; - item.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/Digital Medievalist.js b/translators/Digital Medievalist.js @@ -1,107 +0,0 @@ -{ - "translatorID":"5e684d82-73a3-9a34-095f-19b112d77bbe", - "label":"Digital Medievalist", - "creator":"Fred Gibbs", - "target":"digitalmedievalist\\.org\/(index\\.html)?($|journal\/?$|(journal\/[3-9]))", - "minVersion":"2.0b7", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-01-11 04:31:00" -} - - -function detectWeb(doc, url) { - - if(doc.title == "Digital Medievalist: Journal" || doc.title == "Digital Medievalist") { - return "multiple"; - } else { - return "article"; - } -} - - -function doWeb(doc, url) { - var links =[]; - var articles = []; - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // if on single article - if (detectWeb(doc, url) == "article") { - - // insert 'xml' into URI for location of XML file. - var uri = doc.location.href; - var xmlUri = uri.replace("journal","journal/xml"); - - var d = Zotero.Utilities.retrieveSource(xmlUri); - parseXML(d, uri, doc); - } - - // if multiple, collect article titles - else if (doc.evaluate('//div[@class="issue"]/div/ul/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var titles = doc.evaluate('//div[@class="issue"]/div/ul/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - while (title = titles.iterateNext()) { - links[title.href] = Zotero.Utilities.trimInternal(title.textContent); - } - - var items = Zotero.selectItems(links); - for (var i in items) { - articles.push(i); - } - - Zotero.Utilities.processDocuments(articles, doWeb, function() {Zotero.done();}); - Zotero.wait(); - } -} - - -function parseXML(text, itemUrlBase, doc) { - // Remove xml parse instruction and doctype - text = text.replace(/<\?oxygen[^>]*\?>/, "").replace(/<\?xml[^>]*\?>/, "").replace(/<TEI[^>]*>/, "<TEI>"); - var xml = new XML(text); - - var newItem = new Zotero.Item("journalArticle"); - - var fullTitle = ''; - var title = xml..titleStmt.title; - var len = title.children().length(); - for (i=0; i < len; i++) { - fullTitle += title.children()[i]; - } - - // modify title if review article - if (xml..textClass.keywords.term.(@type == "DMType").text() == "Review") { - fullTitle = "Review of " + fullTitle; - } - - newItem.title = Zotero.Utilities.trimInternal(fullTitle); - - var authors = xml..titleStmt.author.name; - for (var i in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i].toString(), "author")); - } - - newItem.publicationTitle = "Digital Medievalist"; - newItem.volume = xml..seriesStmt.idno.(@type == "volume").toString(); - newItem.issue = xml..seriesStmt.idno.(@type == "issue").toString(); - newItem.date = xml..seriesStmt.idno.(@type == "date").toString(); - newItem.url = itemUrlBase; - - // save keywords - kwords = xml..textClass.keywords.term.(@type == "keyword"); - for (var i = 0; i < kwords.length(); i++) { - Zotero.debug(kwords[i].text()); - newItem.tags[i] = kwords[i]; - } - - //newItem.abstractNote = Zotero.Utilities.trimInternal(xml..text.front.argument.(@n == "abstract").p.text().toString()); - newItem.attachments.push({document:doc, title:doc.title}); - - newItem.complete(); -} diff --git a/translators/Douban.js b/translators/Douban.js @@ -1,347 +0,0 @@ -{ - "translatorID":"fc353b26-8911-4c34-9196-f6f567c93901", - "label":"Douban", - "creator":"Ace Strong<acestrong@gmail.com>", - "target":"^https?://(?:www|book).douban.com/(?:subject|doulist|people/[a-zA-Z._]*/(?:do|wish|collect)|.*?status=(?:do|wish|collect)|group/[0-9]*?/collection|tag)", - "minVersion":"2.0rc1", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-12-19 20:09:43" -} - -/* - Douban Translator - Copyright (C) 2009-2010 TAO Cheng, acestrong@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/>. -*/ - -// ####################### -// ##### Sample URLs ##### -// ####################### - -/* - * The starting point for an search is the URL below. - * In testing, I tried the following: - * - * - A search listing of books - * - A book page - * - A doulist page - * - A do page - * - A wish page - * - A collect page - */ -// http://book.douban.com/ - - -// ################################# -// #### Local utility functions #### -// ################################# - -function trimTags(text) { - return text.replace(/(<.*?>)/g, ""); -} - -function trimMultispace(text) { - return text.replace(/\n\s+/g, "\n"); -} - -// ############################# -// ##### Scraper functions ##### -// ############################# - -function scrapeAndParse(url) { - var page = Zotero.Utilities.retrieveSource(url); - var pattern; - - // 类型 & URL - var itemType = "book"; - var newItem = new Zotero.Item(itemType); -// Zotero.debug(itemType); - newItem.url = url; - - // 标题 - pattern = /<h1>([\s\S]*?)<\/h1>/; - if (pattern.test(page)) { - var title = pattern.exec(page)[1]; - newItem.title = Zotero.Utilities.trim(trimTags(title)); -// Zotero.debug("title: "+title); - } - - // 又名 - pattern = /<span [^>]*?>又名:(.*?)<\/span>/; - if (pattern.test(page)) { - var shortTitle = pattern.exec(page)[1]; - newItem.shortTitle = Zotero.Utilities.trim(shortTitle); -// Zotero.debug("shortTitle: "+shortTitle); - } - - // 作者 - pattern = /<span><span [^>]*?>作者<\/span>:(.*?)<\/span>/; - if (pattern.test(page)) { - var authorNames = trimTags(pattern.exec(page)[1]); - pattern = /(\[.*?\]|\(.*?\)|(.*?))/g; - authorNames = authorNames.replace(pattern, "").split("/"); -// Zotero.debug(authorNames); - for (var i=0; i<authorNames.length; i++) { - var useComma = true; - pattern = /[A-Za-z]/; - if (pattern.test(authorNames[i])) { - // 外文名 - pattern = /,/; - if (!pattern.test(authorNames[i])) { - useComma = false; - } - } - newItem.creators.push(Zotero.Utilities.cleanAuthor( - Zotero.Utilities.trim(authorNames[i]), - "author", useComma)); - } - } - - // 译者 - pattern = /<span><span [^>]*?>译者<\/span>:(.*?)<\/span>/; - if (pattern.test(page)) { - var translatorNames = trimTags(pattern.exec(page)[1]); - pattern = /(\[.*?\])/g; - translatorNames = translatorNames.replace(pattern, "").split("/"); -// Zotero.debug(translatorNames); - for (var i=0; i<translatorNames.length; i++) { - var useComma = true; - pattern = /[A-Za-z]/; - if (pattern.test(translatorNames[i])) { - // 外文名 - useComma = false; - } - newItem.creators.push(Zotero.Utilities.cleanAuthor( - Zotero.Utilities.trim(translatorNames[i]), - "translator", useComma)); - } - } - - // ISBN - pattern = /<span [^>]*?>ISBN:<\/span>(.*?)<br\/>/; - if (pattern.test(page)) { - var isbn = pattern.exec(page)[1]; - newItem.ISBN = Zotero.Utilities.trim(isbn); -// Zotero.debug("isbn: "+isbn); - } - - // 页数 - pattern = /<span [^>]*?>页数:<\/span>(.*?)<br\/>/; - if (pattern.test(page)) { - var numPages = pattern.exec(page)[1]; - newItem.numPages = Zotero.Utilities.trim(numPages); -// Zotero.debug("numPages: "+numPages); - } - - // 出版社 - pattern = /<span [^>]*?>出版社:<\/span>(.*?)<br\/>/; - if (pattern.test(page)) { - var publisher = pattern.exec(page)[1]; - newItem.publisher = Zotero.Utilities.trim(publisher); -// Zotero.debug("publisher: "+publisher); - } - - // 丛书 - pattern = /<span [^>]*?>丛书:<\/span>(.*?)<br\/>/; - if (pattern.test(page)) { - var series = trimTags(pattern.exec(page)[1]); - newItem.series = Zotero.Utilities.trim(series); -// Zotero.debug("series: "+series); - } - - // 出版年 - pattern = /<span [^>]*?>出版年:<\/span>(.*?)<br\/>/; - if (pattern.test(page)) { - var date = pattern.exec(page)[1]; - newItem.date = Zotero.Utilities.trim(date); -// Zotero.debug("date: "+date); - } - - // 简介 - pattern = /<h2[^>]*?>(?:内容)?简介[\s\S]*?<\/h2>([\s\S]*?)<\/div>/; - if (pattern.test(page)) { - var intro = pattern.exec(page)[1]; - intro = trimTags(intro.replace(/(<br\/>)/g, "\n")); - pattern = /\(展开全部\)([\s\S]*)/; - if (pattern.test(intro)) { - intro = pattern.exec(intro)[1]; - } - pattern = /\S/; - if (pattern.test(intro)) { - newItem.abstractNote = "图书简介:\n" - + trimMultispace(intro); - } -// Zotero.debug("abstractNote: "+newItem.abstractNote); - } - - // 作者简介 - pattern = /<h2[^>]*?>作者简介[\s\S]*?<\/h2>([\s\S]*?)<\/div>/; - if (pattern.test(page)) { - var intro = pattern.exec(page)[1]; - intro = trimTags(intro.replace(/(<br\/>)/g, "\n")); - pattern = /\(展开全部\)([\s\S]*)/; - if (pattern.test(intro)) { - intro = pattern.exec(intro)[1]; - } - - if (newItem.abstractNote === undefined) { - newItem.abstractNote = "作者简介:\n" - + trimMultispace(intro); - } else { - newItem.abstractNote += "\n作者简介:\n" - + trimMultispace(intro); - } -// Zotero.debug("abstractNote: "+newItem.abstractNote); - } - - // 丛书信息 - pattern = /<h2>丛书信息<\/h2>([\s\S]*?)<\/div>/; - if (pattern.test(page)) { - var intro = pattern.exec(page)[1]; - intro = Zotero.Utilities.trimInternal(trimTags(intro)); - - if (newItem.abstractNote === undefined) { - newItem.abstractNote = "丛书信息:\n" + intro; - } else { - newItem.abstractNote += "\n丛书信息:\n" + intro; - } -// Zotero.debug("abstractNote: "+newItem.abstractNote); - } - - // 标签 - pattern = /<h2\s*?>豆瓣成员常用的标签([\s\S]*?)<\/div>/; - if (pattern.test(page)) { - var labels = pattern.exec(page)[1]; - pattern = /<a [^>]*?>(.*?)<\/a>/g; - - var result = labels.match(pattern); - for (var i=0; i<result.length; i++) { - var label = trimTags(result[i]); - - if (label) { - newItem.tags.push(label); - } -// Zotero.debug(label); - } - } - - newItem.complete(); -} - -// ######################### -// ##### API functions ##### -// ######################### - -function detectWeb(doc, url) { - var pattern = /subject_search|doulist|people\/[a-zA-Z._]*?\/(?:do|wish|collect)|.*?status=(?:do|wish|collect)|group\/[0-9]*?\/collection|tag/; - - if (pattern.test(url)) { - return "multiple"; - } else { - return "book"; - } - - return false; -} - -function doWeb(doc, url) { - var page = Zotero.Utilities.retrieveSource(url); - var pattern, urls; - - if(detectWeb(doc, url) == "multiple") { -// Zotero.debug("Enter multiple."); - // selected results - var items = new Array(); - - pattern = /doulist/; - if (pattern.test(url)) { - // fetch items from doulist - pattern = /<table ([\s\S]*?)<\/table>/g; - if (pattern.test(page)) { - var result = page.match(pattern); -// Zotero.debug(result.length); -// Zotero.debug(result[1]); - - pattern = /<div (?:[\s\S]*?)<a href="(.*?)">(.*?)<\/a>\s*?<\/div>/; - for (var i=0; i<result.length; i++) { - var res = pattern.exec(result[i]); - if(res[1]) { - items[res[1]] = res[2]; - } - } - } - } else { - pattern = /(?:do|wish|collect)$/; - - if (pattern.test(url)) { - // fetch items from do/wish/collect list - pattern = /<a href="(?:.*?)">\s*<em>(?:.*?)<\/em>\s*<\/a>/g; - if (pattern.test(page)) { - var result = page.match(pattern); -// Zotero.debug(result.length); -// Zotero.debug(result[0]); - - pattern = /<a href="(.*?)">\s*<em>(.*?)<\/em>\s*<\/a>/; - for (var i=0; i<result.length; i++) { - var res = pattern.exec(result[i]); - if(res[1]) { - items[res[1]] = res[2]; - } - } - } - } else { - // fetch items from search result or collection or tag - pattern = /<a class="nbg"\s*([^>]*?)>/g; - if (pattern.test(page)) { - var result = page.match(pattern); -// Zotero.debug(result.length); -// Zotero.debug(result[1]); - - pattern = /href="(.*?)".*?title="(.*?)"/; - for (var i=0; i<result.length; i++) { - var res = pattern.exec(result[i]); - if(res[1]) { - items[res[1]] = res[2]; - } - } - } - } - - - } - - // 让用户选择要保存哪些文献 - items = Zotero.selectItems(items); - if (!items) return true; - - urls = new Array(); - for(var url in items) { - urls.push(url); - } - } else { - urls = [url]; - } - - if (urls) { -// Zotero.debug(urls); - - for (var i=0; i<urls.length; i++) { - scrapeAndParse(urls[i]); - } - } -} diff --git a/translators/EBSCOhost.js b/translators/EBSCOhost.js @@ -1,287 +0,0 @@ -{ - "translatorID": "d0b1914a-11f1-4dd7-8557-b32fe8a3dd47", - "label": "EBSCOhost", - "creator": "Simon Kornblith, Michael Berkowitz, Josh Geller", - "target": "^https?://[^/]+/(?:eds|bsi|ehost)/(?:results|detail|folder)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-07 11:11:54" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') { return namespace; } else { return null; } - } : null; - - // 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(); - if(searchResult) { - return "multiple"; - } - - var xpath = '//a[@class="permalink-link"]'; - var persistentLink = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - if(persistentLink) { - return "journalArticle"; - } -} - -/* - * 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"), - function($0, $1, $2, $3) { queryString[$1] = $3; } - ); - 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]; - } - if (text.match(/^M3\s+-\s*(.*)/m)) { - if (item.DOI == text.match(/^M3\s+\-\s*(.*)/m)[1]) { item.DOI = ""; } - } - if (text.match(/^DO\s+-\s*(.*)/m)) { - item.DOI = text.match(/^DO\s+-\s*(.*)/m)[1]; - } - if (text.match(/^T1\s+-/m)) { - item.title = text.match(/^T1\s+-\s*(.*)/m)[1]; - } - - // 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]; - } - - 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) { - // 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 = []; - // 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].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 () { return true; }); - }); - translator.translate(); -} - -var host; - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') { return namespace; } else { return null; } - } : null; - - var hostRe = new RegExp("^(https?://[^/]+)/"); - var hostMatch = hostRe.exec(url); - host = hostMatch[1]; - - 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) { - /* Get title links and text */ - var titlex = '//a[@class = "title-link color-p4"]'; - var titles = doc.evaluate(titlex, doc, nsResolver, XPathResult.ANY_TYPE, null); - - /* Get folder data for AN, DB, and tag */ - var folderx = '//span[@class = "item add-to-folder"]/input/@value'; - var folderData = doc.evaluate(folderx, doc, nsResolver, XPathResult.ANY_TYPE, null); - - var items = {}; - var folderInfos = {}; - var title, folderInfo; - - /* load up urls, title text and records keys (DB, AN, tag) */ - while (title = titles.iterateNext()) { - items[title.href] = title.textContent; - - folderInfo = folderData.iterateNext(); - folderInfos[title.href] = folderInfo.textContent; - } - - Zotero.selectItems(items, function (items) { - if(!items) { - return true; - } - - /* Get each citation page and pass in record key (db, tag, an) since data does not exist in an easily digestable way on this page */ - var urls = []; - var infos = []; - var i; - for(i in items) { - urls.push(i); - infos.push(folderInfos[i]); - } - - var run = function(urls, infos) { - var url, info; - 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 () { return true; }); - }; - - run(urls, infos); - - Zotero.wait(); - }); - } else { - /* Individual record. Record key exists in attribute for add to folder link in DOM */ - doDelivery(doc, nsResolver, null, function () { Zotero.done(); return true; }); - Zotero.wait(); - } -} -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) { - 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; - } - - var postURL = doc.evaluate('//form[@id="aspnetForm"]/@action', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var queryString = {}; - postURL.replace( - new RegExp("([^?=&]+)(=([^&]*))?", "g"), - function($0, $1, $2, $3) { queryString[$1] = $3; } - ); - - /* ExportFormat = 1 for RIS file */ - 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 = [ - { - "type": "web", - "url": "http://search.ebscohost.com/login.aspx?direct=true&db=a9h&AN=4370815&lang=cs&site=ehost-live", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Warren", - "firstName": "Karen J.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "RECONCILIATION", - "WAR -- Moral & ethical aspects", - "SOCIAL sciences -- Philosophy", - "STERBA, James", - "JUSTICE for Here & Now (Book)" - ], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "EBSCO Record", - "mimeType": "text/html", - "snapshot": false - }, - { - "url": false, - "title": "EBSCO Full Text", - "mimeType": "application/pdf" - } - ], - "title": "Peacemaking and Philosophy: A Critique of Justice for Hero and Now.", - "publicationTitle": "Journal of Social Philosophy", - "date": "Winter 1999", - "volume": "30", - "issue": "3", - "pages": "411-423", - "publisher": "Wiley-Blackwell", - "ISBN": "00472786", - "ISSN": "00472786", - "abstractNote": "This article presents a critical analysis of James Sterba's book, Justice for Here and Now. In the book, Sterba undertakes two distinct but interconnected objects--one primarily methodological and the other primarily ethical. The methodological project is to establish the necessity and desirability of adopting a peacemaking model of doing philosophy, that is, one that is committed to fair-mindedness, openness and self-criticalness in seeking to determine which philosophical views are most justified. Sterba contrasts the peacemaking model with a war-making model of doing philosophy. The ethical project involves establishing two related claims: rationality is required for morality, and it is possible and desirable to reconcile the practical perspectives of alternative positions on justice; welfare liberalism, libertarianism, socialism, feminism, multiculturalism, anthropocentric and nonanthropocentric environmental ethics, and pacifism and just war theory. There is an important and intimate connection between the methodological and ethical projects. In fact, at various places throughout the book Sterba suggests that the relationship is one of logical entailment: not only does appeal to a peacemaking model of doing philosophy establish the two main claims of the ethical project; by showing the rational grounds for reconciling alternative philosophical positions on justice, one establishes that a peacemaking model of philosophy ought to be adopted.", - "libraryCatalog": "EBSCOhost", - "shortTitle": "Peacemaking and Philosophy" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/ERIC.js b/translators/ERIC.js @@ -1,135 +0,0 @@ -{ - "translatorID":"e4660e05-a935-43ec-8eec-df0347362e4c", - "label":"ERIC", - "creator":"Ramesh Srigiriraju, Avram Lyon", - "target":"^http://(?:www\\.)?eric\\.ed\\.gov/", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - // Search results - var searchpath='//div[@id="searchFaceted"]//td[@class="resultHeader"]'; - if(doc.evaluate(searchpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "multiple"; - // Clipboard - if(url.match(/ERICWebPortal\/search\/clipboard\.jsp/)) - return "multiple"; - // folder - if(url.match(/ERICWebPortal\/MyERIC\/clipboard\/viewFolder\.jsp\?folderIndex/)) - return "multiple"; - // Individual record - var singpath='//div[@id="titleBarBlue"]'; - var res = doc.evaluate(singpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(res && res.textContent.indexOf("Record Details") !== -1) { - var typepath='//tr[td/span/a/strong/text()="Pub Types:"]/td[2]/text()'; - var typestr=doc.evaluate(typepath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var typereg=new RegExp("([^;/\-]+)"); - var typearr=typereg.exec(typestr); - if(typearr[1]=="Journal Articles") - return "journalArticle"; - if(typearr[1]=="Information Analyses") - return "journalArticle"; - if(typearr[1]="Machine") - return "computerProgram"; - if(typearr[1]="Computer Programs") - return "computerProgram"; - if(typearr[1]="Dissertations") - return "thesis"; - if(typearr[1]="Reports") - return "report"; - if(typearr[1]="Non") - return "audioRecording"; - if(typearr[1]="Legal") - return "statute"; - else - return "book"; - } -} - -function doWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - if(detectWeb(doc, url) == "multiple") { - var string="http://eric.ed.gov/ERICWebPortal/custom/portlets/clipboard/performExport.jsp"; - var items=new Array(); - if(url.match(/ERICWebPortal\/search\/clipboard\.jsp/) - || url.match(/ERICWebPortal\/MyERIC\/clipboard\/viewFolder\.jsp\?folderIndex/)) { - // We have a clipboard or folder page; structure is the same - var rowpath='//table[@class="tblDataTable"]/tbody/tr[td]'; - var rows = doc.evaluate(rowpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var row, id, title; - while(row = rows.iterateNext()) { - title = doc.evaluate('./td[2]/a', row, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - id = doc.evaluate('./td[6]', row, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - Zotero.debug(title + id); - items[id] = Zotero.Utilities.cleanTags(Zotero.Utilities.trimInternal(title)); - } - } else { - // We have normal search results - var idpath='//a[img[@width="64"]]'; - var ids=doc.evaluate(idpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titlpath='//table[@class="tblSearchResult"]//td[@class="resultHeader"][1]/p/a'; - var titlerows=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var id; - while(id=ids.iterateNext()) - items[id.id]=Zotero.Utilities.cleanTags(Zotero.Utilities.trimInternal(titlerows.iterateNext().textContent)); - } - items=Zotero.selectItems(items); - if (!items) return false; - var string="http://eric.ed.gov/ERICWebPortal/MyERIC/clipboard/performExport.jsp?"; - for(var ids in items) - string+="accno="+ids+"&"; - string+="texttype=endnote&citationtype=brief&Download.x=86&Download.y=14"; - Zotero.debug(string); - Zotero.Utilities.HTTP.doGet(string, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - trans.setString(text); - trans.setHandler("itemDone", function(obj, newItem) { - var linkpath='//tbody[tr/td/a/@id="'+newItem.itemID+'"]/tr/td/p/a[@class="action"]'; - var link=doc.evaluate(linkpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(link) - newItem.attachments.push({url:link.href, title:newItem.title, mimeType:"application/pdf"}); - newItem.complete(); - }); - trans.translate(); - Zotero.done(); - }); - Zotero.wait(); - } - var type = detectWeb(doc, url); - if(type && type != "multiple") { - var idpath='//tr[/td[1]/span/a/strong/contains("ERIC #")]/td[2]'; - var idpath2='//meta[@name="eric #"]/@content'; - var id = url.match(/accno=([^&]+)/)[1]; - var string="http://eric.ed.gov/ERICWebPortal/MyERIC/clipboard/performExport.jsp?"; - string+= "accno="+ id+"&texttype=endnote&citationtype=brief&Download.x=86&Download.y=14"; - Zotero.debug(string); - Zotero.Utilities.HTTP.doGet(string, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - trans.setString(text); - trans.setHandler("itemDone", function(obj, newItem) { - var linkpath='//tr/td/p[img/@alt="PDF"]/a'; - var link=doc.evaluate(linkpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(link) - newItem.attachments.push({url:link.href, title:newItem.title, mimeType:"application/pdf"}); - newItem.complete(); - }); - trans.translate(); - Zotero.done(); - }); - Zotero.wait(); - } -} diff --git a/translators/ESA Journals.js b/translators/ESA Journals.js @@ -1,94 +0,0 @@ -{ - "translatorID":"5af42734-7cd5-4c69-97fc-bc406999bdba", - "translatorType":4, - "label":"ESA Journals", - "creator":"Michael Berkowitz", - "target":"http://www.esajournals.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("get-toc") != -1 || url.indexOf("searchtype") != -1) { - return "multiple"; - } else if (url.indexOf("get-document") != -1 || url.indexOf("get-abstract") != -1) { - return "journalArticle"; - } -} - -function senCase(string) { - var smallwords = Array("AND", "A", "IN", "THE", "BY", "OF"); - var sen = string.split(/\b/); - for (var i = 0 ; i < sen.length; i++) { - if (sen[i].match(/\w+/)) { - if (smallwords.indexOf(sen[i]) != -1 && i != 0) { - sen[i] = sen[i].toLowerCase(); - } else { - sen[i] = sen[i][0] + sen[i].substring(1).toLowerCase(); - } - } - } - return sen.join(""); -} - -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(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var resultItems = doc.evaluate('//div[@class="nocolumn"][@id="content"]/div//*[@class="group"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_item; - while (next_item = resultItems.iterateNext()) { - var link = doc.evaluate('.//a[1]', next_item, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - var title = senCase(doc.evaluate('.//*[@class="title"]', next_item, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles.push(url); - } - Zotero.Utilities.processDocuments(articles, function(newDoc) { - var newlink = newDoc.evaluate('//a[text() = "Create Reference"]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - var itemurl = newDoc.location.href; - if (newDoc.evaluate('//a[text() = "Full Text"]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - itemurl = newDoc.evaluate('//a[text() = "Full Text"]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - } - if (newDoc.evaluate('//div[@class="doc-head"]/p[contains(text(), "DOI")][@class="info"]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var doi = newDoc.evaluate('//div[@class="doc-head"]/p[contains(text(), "DOI")][@class="info"]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - doi = Zotero.Utilities.trimInternal(doi.substr(4)); - } - var issn = newDoc.evaluate('//div[@id="pageTitle"]/p/a', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href.match(/issn=([^&]+)/)[1]; - newlink = newlink.replace('cite-builder', 'download-citation&t=refman&site=esaonline'); - Zotero.Utilities.HTTP.doGet(newlink, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.url = decodeURIComponent(itemurl); - if (doi) item.DOI = decodeURIComponent(doi); - var bits = new Array(issn, item.volume, item.issue); - var pdfurl = 'http://www.esajournals.org/archive/' + bits.join("/") + "/pdf/i" + bits.join("-") + "-" + item.pages.match(/\d+/)[0] + ".pdf"; - item.attachments = [ - {url:item.url, title:"ESA Journals Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"ESA Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }); - translator.translate(); - - Zotero.done(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/ESpacenet.js b/translators/ESpacenet.js @@ -1,176 +0,0 @@ -{ - "translatorID":"176948f7-9df8-4afc-ace7-4c1c7318d426", - "label":"ESpacenet", - "creator":"Gilles Poulain, Rintze Zelle, and Edouard Leroy", - "target":"^https?://worldwide\\.espacenet\\.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if(url.match("searchResults\?")) { - return "multiple"; - } else if (doc.location.href.match("biblio")) { - return "patent"; - } - } - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//span[@class="resNumber"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = Zotero.Utilities.trim(next_title.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - - if(articles.length == 0) return true; - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} - -function getItem(reftext,re) { - var item = reftext.match(re); - return item[1]; -} - -function scrape(doc,url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - //Get title - var xpath = '//div[@id="pagebody"]/h3'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var title = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - - // In the very common case of all-caps, fix them! - if (title == title.toUpperCase()) { - title = Zotero.Utilities.capitalizeTitle(title.toLowerCase(), true); - } - } - - //Get Abstract - var xpath = '//div[@class="application article clearfix"]/p[1]'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var abstract = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Get Applicant - var xpath = '//table[@class="tableType3"]/tbody/tr[5]/td'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var applicantField = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Get application number - var xpath = '//table[@class="tableType3"]/tbody/tr[7]/td'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var anumber = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Get patent number - var xpath = '//table[@class="tableType3"]/tbody/tr[2]/td/a'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var pnumber = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var pnumber= pnumber.split("-"); - pnumber=pnumber[0]; - } - - //Get CIB - var xpath = '//tr[contains(th/text(),"- international:")]/td'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var CIBnumber = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Get ECLA - var xpath = "//tr[contains(th/text(),'- European:')]/td"; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - ECLAnumber = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Get priority number - var xpath = '//table[@class="tableType3"]/tbody/tr[8]/td'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var prnumber = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Get date - var xpath = '//table[@class="tableType3"]/tbody/tr[3]/td'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var date = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Get Creators - var xpath = '//table[@class="tableType3"]/tbody/tr[4]/td'; - if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var inventorField = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - //Create Zotero Ref - var newArticle = new Zotero.Item('patent'); - newArticle.attachments = [{url:doc.location.href, title:"Espacenet patent record"}]; - newArticle.title = title; - newArticle.date = date; - newArticle.abstractNote = abstract; - newArticle.patentNumber = pnumber; - newArticle.priorityNumbers = prnumber; - newArticle.applicationNumber = anumber; - newArticle.extra = "CIB: " + CIBnumber + "\nECLA: " + ECLAnumber; - - if (applicantField) { - newArticle.assignee = reorganizeNames(applicantField).join("; "); - } - - var inventors = reorganizeNames(inventorField); - for (var m = 0; m< inventors.length; m++) { - newArticle.creators.push(Zotero.Utilities.cleanAuthor(inventors[m], "inventor", true)); - } - - newArticle.complete(); -} - -function reorganizeNames(nameField) { - var nameCollection = nameField.split("(")[1].split(")")[0]; - var nameParts = nameCollection.split(" "); - for (var j in nameParts) { - nameParts[j] = nameParts[j][0].toUpperCase() + nameParts[j].substr(1).toLowerCase(); - } - nameCollection = nameParts.join(" "); - - var nameArray = nameCollection.split(", ; "); - - for (var m = 0; m< nameArray.length; m++) { - if (nameArray[m].match(",")) { - var nameParts = ""; - nameParts = nameArray[m].split(", "); - nameParts[0] = nameParts[0].concat(","); - nameArray[m] = nameParts.join(" "); - } else { - nameArray[m] = nameArray[m].replace(" ", ", "); - } - } - - return nameArray; -} diff --git a/translators/Early English Books Online.js b/translators/Early English Books Online.js @@ -1,75 +0,0 @@ -{ - "translatorID":"b86bb082-6310-4772-a93c-913eaa3dfa1b", - "translatorType":4, - "label":"Early English Books Online", - "creator":"Michael Berkowitz", - "target":"^http://[^/]*eebo.chadwyck.com[^/]*/search", - "minVersion":"2.1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-06-14 19:30:00" -} - -function detectWeb(doc, url) { - if (doc.title == "Search Results - EEBO") { - return "multiple"; - } else if (doc.title != "Basic Search - EEBO") { - return "book"; - } -} - -function doWeb(doc, url) { - var eeboIDs = new Array(); - - var hostRegexp = new RegExp("^(https?://[^/]+)/"); - var hMatch = hostRegexp.exec(url); - var host = hMatch[1]; - var IDRegex = /&ID=([^&]+)/ - - if (doc.title == "Search Results - EEBO") { - var items = new Object(); - var IDxpath = '//td/input[@name="EeboId"]/@value'; - var Titlexpath = '//table[tbody/tr/td/input[@name="EeboId"]]/following-sibling::table[1]//i[1]'; - var new_ids = doc.evaluate(IDxpath, doc, null, XPathResult.ANY_TYPE, null); - var new_titles = doc.evaluate(Titlexpath, doc, null, XPathResult.ANY_TYPE, null); - var next_id = new_ids.iterateNext(); - var next_title = new_titles.iterateNext(); - while (next_id) { - items[next_id.textContent.trim()] = next_title.textContent.trim(); - next_id = new_ids.iterateNext(); - next_title = new_titles.iterateNext(); - } - items = Zotero.selectItems(items); - for (var i in items) { - eeboIDs.push(i); - } - } else { - var eeboid = url.match(IDRegex)[1]; - if (eeboid[0] == "D") { - eeboid = eeboid.slice(7, 14); - } - eeboIDs.push(eeboid); - } - Zotero.debug(eeboIDs); - for (var i = 0 ; i < eeboIDs.length ; i++) { - var postString = 'cit_format=RIS&Print=Print&cit_eeboid=' + eeboIDs[i] + '&EeboId=' + eeboIDs[i]; - var new_eeboid = eeboIDs[i] - Zotero.Utilities.HTTP.doPost(host+'/search/print', postString, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text.substring(17)); - translator.setHandler("itemDone", function(obj, item) { - item.attachments.push( - {url : host+'/search/full_rec?SOURCE=pgimages.cfg&ACTION=ByID&ID=' + new_eeboid + '&FILE=../session/1190302085_15129&SEARCHSCREEN=CITATIONS&SEARCHCONFIG=config.cfg&DISPLAY=ALPHA', - title : "EEBO Record", - snapshot : false }); - item.complete(); - }); - translator.translate(); - Zotero.done(); - }); - } - Zotero.wait(); -} diff --git a/translators/Education Week.js b/translators/Education Week.js @@ -1,95 +0,0 @@ -{ - "translatorID":"7e51d3fb-082e-4063-8601-cda08f6004a3", - "translatorType":4, - "label":"Education Week", - "creator":"Ben Parr", - "target":"^https?://(?:www\\.|blogs\\.|www2\\.)?edweek", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc,url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath='//meta[@name="Story_type"]/@content'; - var temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if(temp) - { - if(temp.value=="Blog") - {return "blogPost";} - if(temp.value.indexOf("Story")>-1) - {return "magazineArticle";} - } -} - -function associateMeta(newItem, metaTags, field, zoteroField) { - if(metaTags[field]) { - newItem[zoteroField] = metaTags[field]; - } -} - -function scrape(doc, url) { - - var newItem = new Zotero.Item("magazineArticle"); - if(url&&url.indexOf("blogs.edweek.org")>-1) - {newItem.itemType="blogPost";} - - newItem.url = doc.location.href; - - var metaTags = new Object(); - - var metaTagHTML = doc.getElementsByTagName("meta"); - var i; - for (i = 0 ; i < metaTagHTML.length ; i++) { - metaTags[metaTagHTML[i].getAttribute("name")]=Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content")); - } - associateMeta(newItem, metaTags, "Title", "title"); - associateMeta(newItem, metaTags, "Cover_date", "date"); - associateMeta(newItem, metaTags, "Description", "abstractNote"); - associateMeta(newItem, metaTags, "ArticleID", "accessionNumber"); - associateMeta(newItem,metaTags,"Source","publicationTitle"); - - - if (metaTags["Authors"]) { - var author = Zotero.Utilities.trimInternal(metaTags["Authors"]); - if (author.substr(0,3).toLowerCase() == "by ") { - author = author.substr(3); - } - - var authors = author.split(" and "); - for each(var author in authors) { - var words = author.split(" "); - for (var i in words) { - words[i] = words[i][0].toUpperCase() +words[i].substr(1).toLowerCase(); - } - author = words.join(" "); - - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - - newItem.complete(); -} - -function doWeb(doc,url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath='//meta[@name="Story_type"]/@content'; - var temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if(temp) - { - if(temp.value.indexOf("Story")>-1 || temp.value=="Blog") - {scrape(doc,url);} - } -} -\ No newline at end of file diff --git a/translators/Edutopia.js b/translators/Edutopia.js @@ -1,139 +0,0 @@ -{ - "translatorID":"3f44a651-8b6b-4591-8ca4-4bfb943a13f4", - "translatorType":4, - "label":"Edutopia", - "creator":"Adam Crymble", - "target":"http://www.edutopia.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-20 20:45:00" -} - -function detectWeb(doc, url) { - - var blog1 = 0; - - if (doc.title.match("blog")) { - blog1 = 1; - } - - if (doc.location.href.match("search")) { - return "multiple"; - } else if (blog1 == 0 && doc.evaluate('//h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "newspaperArticle"; - } -} - -//Edutopia.org translator. Code by Adam Crymble - -function associateMeta(newItem, metaTags, field, zoteroField) { - if(metaTags[field]) { - newItem[zoteroField] = metaTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var author; - var authorCheck = 0; - var tagsContent = new Array(); - - var newItem = new Zotero.Item("newspaperArticle"); - -//title - var title1 = doc.title.split("|"); - newItem.title = title1[0]; - -//author - if (doc.evaluate('//div[@id="article"]/h4/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - author = doc.evaluate('//div[@id="article"]/h4/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - authorCheck = 1; - - } else if (doc.evaluate('//div[@id="pollpage"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - author = doc.evaluate('//div[@id="pollpage"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - authorCheck = 1; - - } else if (doc.evaluate('//div[@class="blog"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - author = doc.evaluate('//div[@class="blog"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - authorCheck = 1; - } - - if (authorCheck == 1) { - if (author.toLowerCase().match(/^by /)) { - author = author.substr(3); - } - Zotero.debug(author); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - -//abstract - if (doc.evaluate('//div[@class="dek"]/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = (doc.evaluate('//div[@class="dek"]/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - -//date - if (doc.evaluate('/span[@class="blog_date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.date = doc.evaluate('/span[@class="blog_date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - var metaTags = new Object(); - - var metaTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < metaTagHTML.length ; i++) { - metaTags[metaTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content")); - } - - if (metaTags["keywords"]) { - tagsContent = (metaTags["keywords"].split(', ')); - } - - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - - associateMeta (newItem, metaTags, "description", "abstractNote"); - - newItem.publication = "Edutopia.org" - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//dt[@class="title"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Eighteenth Century Collections Online.js b/translators/Eighteenth Century Collections Online.js @@ -1,160 +0,0 @@ -{ - "translatorID":"00ce0d68-9205-40e6-91f4-c96f7ab296c2", - "translatorType":4, - "label":"Eighteenth Century Collections Online", - "creator":"Adam Crymble", - "target":"http://galenet.galegroup.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:40:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//td[2][@class="stnd"]/a/i/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//td[3]/span[@class="stnd"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "bookSection"; - } else if (doc.evaluate('//span[@class="stnd"]/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - - -//Eighteenth Century Collections Online translator. Code by Adam Crymble - - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - - var headers = doc.evaluate('//td[1][@class="stnd"]/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//td[2][@class="stnd"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - while (fieldTitle = headers.iterateNext()) { - - fieldTitle = fieldTitle.textContent.replace(/\s+/g, ''); - fieldContent = contents.iterateNext().textContent; - - while (fieldContent.length<2) { - if (fieldContent.match(/\d/)) { - break; - } else { - fieldContent = contents.iterateNext().textContent; - } - } - dataTags[fieldTitle] = fieldContent.replace(/^\s*|\s*$/g, ''); - } - - if (dataTags["Author"]) { - if (dataTags["Author"].match(/\n/)) { - var author = dataTags["Author"].split(/\n/); - dataTags["Author"] = author[0]; - - } - if (dataTags["Author"].match(", ")) { - var author = dataTags["Author"].split(", "); - author = author[1] + " " + author[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Author"], "author")); - } - } - - if (dataTags["GaleDocumentNumber"]) { - newItem.extra = "Gale Document Number: " + dataTags["GaleDocumentNumber"]; - } - - if (dataTags["18thCenturyMicrofilmReel#"]) { - newItem.locInArchive = "18th Century Microfilm Reel #: " + dataTags["18thCenturyMicrofilmReel#"]; - } - - if (dataTags["Imprint"]) { - if (dataTags["Imprint"].match(": ")) { - var place1 = dataTags["Imprint"].split(": "); - newItem.place = place1[0]; - if (place1[1].match(", ")) { - var pub1 = place1[1].split(", "); - newItem.publisher = pub1[0]; - newItem.date = pub1[1]; - } else { - newItem.publisher = place1[1]; - } - } else { - newItem.publisher = dataTags["Imprint"]; - } - } - - associateData (newItem, dataTags, "Title", "title"); - associateData (newItem, dataTags, "Language", "language"); - associateData (newItem, dataTags, "Pages", "page"); - associateData (newItem, dataTags, "SourceLibrary", "repository"); - associateData (newItem, dataTags, "Volume", "volume"); - associateData (newItem, dataTags, "Notes", "abstractNote"); - - newItem.url = doc.location.href; - - newItem.complete(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var items = new Object(); - var articles1 = new Array(); - - if (detectWeb(doc, url) == "multiple") { - var titles = doc.evaluate('//td[2][@class="stnd"]/a/i/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//td[2][@class="stnd"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - var link = links.iterateNext(); - - while (link.textContent!="Full Citation") { - link = links.iterateNext(); - } - - items[link.href] = next_title.textContent; - } - - items = Zotero.selectItems(items); - for (var i in items) { - articles1.push(i); - } - - } else if (detectWeb(doc, url) == "bookSection") { - - var links = doc.evaluate('//td[3]/span[@class="stnd"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var articles = links.iterateNext(); - Zotero.debug(articles); - - articles1.push(articles.href); - - } else { - articles1 = [url]; - } - - Zotero.Utilities.processDocuments(articles1, scrape, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Electronic Colloquium on Computational Complexity.js b/translators/Electronic Colloquium on Computational Complexity.js @@ -1,113 +0,0 @@ -{ - "translatorID":"09a9599e-c20e-a405-d10d-35ad4130a426", - "translatorType":4, - "label":"Electronic Colloquium on Computational Complexity", - "creator":"Jonas Schrieb", - "minVersion":"1.0.0b3.r1", - "target":"http://(www.)?eccc.(uni-trier|hpi-web).de/", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2010-03-03 15:00:00" -} - -function detectWeb(doc, url) { - var singleRe = /^http:\/\/(www\.)?eccc\.(uni-trier|hpi-web)\.de\/report\/\d{4}\/\d{3}/; - var multipleRe = /^http:\/\/(www\.)?eccc\.(uni-trier|hpi-web)\.de\/(title|year|keyword)\//; - if(singleRe.test(url)) { - return "report"; - } else if(multipleRe.test(url)) { - return "multiple"; - } -} - -function scrape(doc) { - var newItem = new Zotero.Item("report"); - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - var url = doc.location.href; - var tmp = url.match(/\/(\d{4})\/(\d{3})\/$/); - newItem.date = tmp[1]; - newItem.reportNumber = tmp[2]; - newItem.url = url; - - - - var titleXPath = "id('box')//h4"; - newItem.title = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - - - var authorsXPath = "id('box')//a[contains(@href,'author')]"; - var authors = doc.evaluate(authorsXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextAuthor; - while (nextAuthor = authors.iterateNext()) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(nextAuthor.textContent, "author")); - } - - - - var keywordsXPath = "id('box')//a[contains(@href,'keyword')]"; - var keywords = doc.evaluate(keywordsXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextKeyword; - var i = 0; - while (nextKeyword = keywords.iterateNext()) { - newItem.tags[i++] = nextKeyword.textContent; - } - - - - var abstractXPath = "id('box')/text()"; - var abstractLines = doc.evaluate(abstractXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - newItem.abstractNote = ""; - var nextLine; - while(nextLine = abstractLines.iterateNext()) { - newItem.abstractNote += nextLine.textContent; - } - - - - newItem.attachments = [ - {url:url, title:"ECCC Snapshot", mimeType:"text/html"}, - {url:url+"download", title:"ECCC Full Text PDF", mimeType:"application/pdf"} - ]; - - newItem.complete(); -} - -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") { - var titleXPath = "//a[starts-with(@href,'/report/')]/h4"; - var linkXPath = "//a[starts-with(@href,'/report/')][h4]"; - - var titles = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate(linkXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (nextTitle = titles.iterateNext()) { - nextLink = links.iterateNext(); - items[nextLink.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(); -} diff --git a/translators/Embedded RDF.js b/translators/Embedded RDF.js @@ -1,134 +0,0 @@ -{ - "translatorID": "951c027d-74ac-47d4-a107-9c3069ab7b48", - "label": "Embedded RDF", - "creator": "Simon Kornblith", - "target": "", - "minVersion": "2.1", - "maxVersion": "", - "priority": 400, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-04 00:32:05" -} - -var _prefix; -var _dc = "http://purl.org/dc/elements/1.1/"; - -function getDCPrefix(doc) { - if(_prefix) { - return _prefix; - } - - var links = doc.getElementsByTagName("link"); - for(var i=0; i<links.length; i++) { - if(links[i].getAttribute("href") == _dc) { - var rel = links[i].getAttribute("rel"); - if(rel) { - var matches = rel.match(/^schema\.([a-zA-Z]+)/); - if(matches) { - _prefix = matches[1].toLowerCase() + "."; - } - } - break; - } - } - if(!_prefix) { - _prefix = "dc."; - } - return _prefix; -} - -function detectWeb(doc, url) { - var prefix = getDCPrefix(doc); - - if (url.indexOf("reprint") != -1) return false; - var metaTags = doc.getElementsByTagName("meta"); - for(var i=0; i<metaTags.length; i++) { - var tag = metaTags[i].getAttribute("name"); - if(tag && tag.substr(0, prefix.length).toLowerCase() == prefix) { - return "webpage"; - } - } - - return false; -} - -function doWeb(doc, url) { - var prefix = getDCPrefix(doc); - - // load RDF translator, so that we don't need to replicate import code - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("5e3ad958-ac79-463d-812b-a86a9235c28f"); - translator.setHandler("itemDone", function(obj, newItem) { - // add attachment - newItem.attachments.push({document:doc}); - // add access date and url - newItem.accessDate = 'CURRENT_TIMESTAMP'; - newItem.url = doc.location.href; - newItem.repository = false; - newItem.complete(); - }); - - translator.getTranslatorObject(function(rdf) { - var metaTags = doc.getElementsByTagName("meta"); - var foundTitle = false; // We can use the page title if necessary - for(var i=0; i<metaTags.length; i++) { - var tag = metaTags[i].getAttribute("name"); - var value = metaTags[i].getAttribute("content"); - if(tag && value && tag.substr(0, prefix.length).toLowerCase() == prefix) { - if(tag == "dc.title") { - foundTitle = true; - } - rdf.Zotero.RDF.addStatement(url, _dc + tag.substr(3).toLowerCase(), value, true); - } else if(tag && value && (tag == "author" || tag == "author-personal")) { - rdf.Zotero.RDF.addStatement(url, _dc + "creator", value, true); - } else if(tag && value && tag == "author-corporate") { - rdf.Zotero.RDF.addStatement(url, _dc + "creator", value, true); - } - } - - if (!foundTitle) { - rdf.Zotero.RDF.addStatement(url, _dc + "title", doc.title, true); - } - rdf.defaultUnknownType = "webpage"; - rdf.doImport(); - }); -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://dublincore.org/documents/usageguide/", - "items": [ - { - "itemType": "webpage", - "creators": [ - { - "lastName": "Diane Hillmann", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "document": false - } - ], - "itemID": "http://dublincore.org/documents/usageguide/", - "title": "Using Dublin Core", - "publisher": "Dublin Core Metadata Initiative", - "institution": "Dublin Core Metadata Initiative", - "company": "Dublin Core Metadata Initiative", - "label": "Dublin Core Metadata Initiative", - "distributor": "Dublin Core Metadata Initiative", - "extra": "This document is intended as an entry point for users of Dublin Core. For non-specialists, it will assist them in creating simple descriptive records for information resources (for example, electronic documents). Specialists may find the document a useful point of reference to the documentation of Dublin Core, as it changes and grows.", - "url": "http://dublincore.org/documents/usageguide/" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Emerald Publishing.js b/translators/Emerald Publishing.js @@ -1,84 +0,0 @@ -{ - "translatorID":"79f6f9ed-537a-4d4f-8270-c4fbaafdf327", - "translatorType":4, - "label":"Emerald Publishing", - "creator":"Michael Berkowitz", - "target":"www.emeraldinsight.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match('searchQuickOptions.do')) { - return "multiple" - } else if (url.match('viewContentItem')) { - return "journalArticle"; - } -} - -var tags = { - journal:"publicationTitle", - year:"date", - volume:"volume", - issue:"issue", - page:"pages", - doi:"DOI", -// publisher:"repository", - 'article url':"url", - abstract:"abstractNote" -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//td[3][@class="resultTd"]/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.title = Zotero.Utilities.trimInternal(doc.title.split('-')[1]); - - var data = new Object(); - var values = doc.evaluate('//div[@class="browseBoxGreen"]/div[@class="toc"]/p[@class="inline"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var fields = doc.evaluate('//div[@class="browseBoxGreen"]/div[@class="toc"]/h3', doc, nsResolver, XPathResult.ANY_TYPE, null); - var value; - var field; - while ((field = fields.iterateNext()) && (value = values.iterateNext())) { - data[Zotero.Utilities.trimInternal(field.textContent.toLowerCase()).replace(':', '')] = value.textContent; - } - var values = doc.evaluate('//div[@id="centerLeft"]/p[@class="inline"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var fields = doc.evaluate('//div[@id="centerLeft"]/h3[@class="inline"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - while ((field = fields.iterateNext()) && (value = values.iterateNext())) { - data[Zotero.Utilities.trimInternal(field.textContent.toLowerCase()).replace(':', '')] = value.textContent; - } - for (var tag in data) { - if (tags[tag]) item[tags[tag]] = Zotero.Utilities.trimInternal(data[tag]); - } - item.attachments = [{url:item.url, title:"Emerald Insight Snapshot", mimeType:"text/html"}]; - item.tags = Zotero.Utilities.trimInternal(data['keywords']).split(/,\s+/); - var authors = data['author(s)'].split(/,\s+/); - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Encyclopedia of Chicago.js b/translators/Encyclopedia of Chicago.js @@ -1,164 +0,0 @@ -{ - "translatorID": "0689f3e1-f0b4-4c0c-b795-4aebdfea08e0", - "label": "Encyclopedia of Chicago", - "creator": "Brodie Austin", - "target": "^http://encyclopedia\\.chicagohistory\\.org/pages", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-06 00:45:32" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/*Encyclopedia articles and tables*/ -FW.Scraper({ - itemType : 'encyclopediaArticle', - detect : FW.Xpath('//td[@class="entrynavheader"]').text().match(/Entries|Features/), - title : FW.Xpath('//td[@class="ideEssay"]/span[@class="feature"]').text().trim(), - creators : FW.Xpath('//p[@class="entryauthor"]').text().match(/^ *.* *$/).split(/and/).replace(/,\s*/,"-").cleanAuthor("author"), - date : FW.Xpath('//div[@class="copyright"]').text().match(/\d+/), - encyclopediaTitle : 'Encyclopedia of Chicago', - place : 'Chicago', - publisher : 'Chicago History Museum and the Newberry Library', - /*attachments*/ - attachments : [{url: FW.Url(), - title: 'Encyclopedia of Chicago Entry URL', - type: 'text/html', - }], -}); - -/*Encyclopedia essays [very similar to entries, but different detect target]*/ -FW.Scraper({ - itemType : 'encyclopediaArticle', - detect : FW.Xpath('//div[@class="entryheader"]').text().match(/Essay/), - title : FW.Xpath('//td[@class="ideEssay"]/span[@class="feature"]').text().trim(), - creators : FW.Xpath('//p[@class="entryauthor"]').text().match(/^ *.* *$/).split(/and/).replace(/,\s*/,"-").cleanAuthor("author"), - date : FW.Xpath('//div[@class="copyright"]').text().match(/\d+/), - encyclopediaTitle : 'Encyclopedia of Chicago', - place : 'Chicago', - publisher : 'Chicago History Museum and the Newberry Library', - /*attachments*/ - attachments : [{url: FW.Url(), - title: 'Encyclopedia of Chicago Entry URL', - type: 'text/html', - }], -}); - -/*Primary source documents*/ -FW.Scraper({ - itemType : 'document', - detect : FW.Xpath('//td[@class="entrynavheader"]').text().match(/Sourc(e|es)/), - title : FW.Xpath('//td[@class="ideEssay"]/span[@class="feature"]').text(), - creators : FW.Xpath('//p[@class="entryauthor"]').text().match(/[Artist|Creator|Author|Photographer]s*\:\s+([\w\s.,-|\&amp;|()]+)Source/,1).split(/and/).replace(/,\w*/, "-").cleanAuthor("author"), - date : FW.Xpath('//td[@class="ideEssay"]/span[@class="feature"]').text().match(/\d+/), - archive : FW.Xpath('//p[@class="entryauthor"]').text().match(/Source\:\s+([\w\s\d.,-|\&amp;]+)\s/,1), - archiveLocation : FW.Xpath('//p[@class="entryauthor"]').text().match(/Source\:\s+[\w\s\d.,-|\&amp;]+\s[(]*([\w\d\s-.,]+)/,1), - /*attachments*/ - attachments : [{url: FW.Url(), - title: 'Encyclopedia of Chicago Document URL', - type: 'text/html', - }], -}); - -/*Maps created by the Encyclopedia, not historical maps which are documents*/ -FW.Scraper({ - itemType : 'map', - detect : FW.Xpath('//td[@class="entrynavheader"]').text().match(/Maps|MAPS/), - title : FW.Xpath('//td[@class="ideEssay"]/span[@class="feature"]').text().trim(), - creators : FW.Xpath('//p[@class="entryauthor"]').text().match(/[Artist|Creator|Author|Photographer]s*\:\s+([\w\s.,-|\&amp;]+)(\(|Source)/,1).split(/and/).replace(/,\w*/, "-").cleanAuthor("author"), - date : FW.Xpath('//div[@class="copyright"]').text().match(/\d+/).trim(), - archive : FW.Xpath('//p[@class="entryauthor"]').text().match(/Source\:\s+([\w\s\d.,-|\&amp;]+)\s/,1).trim(), - archiveLocation : FW.Xpath('//p[@class="entryauthor"]').text().match(/Source\:\s+[\w\s\d.,-|\&amp;]+\s[(]*([\w\d\s-.,]+)/,1).trim(), - /*attachments*/ - attachments : [{url: FW.Url(), - title: 'Encyclopedia of Chicago Map URL', - type: 'text/html', - }], -}); - -/*Multi item does not seem to work due to iframes on pages, -but I'm leaving the code here for now -FW.MultiScraper({ - itemType : 'multiple', - detect : FW.Xpath('//div[@class="entryheader"]').text().match(/Index/), - choices : { - titles : FW.Xpath('//iframe/html/body/div[@class="itemtable"]/div[@class="itemalign"]/a').text().trim(), - urls : FW.Xpath('//iframe/html/body/div[@class="itemtable"]/div[@class="itemalign"]/a/@href').text(), - } -});*/ - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://encyclopedia.chicagohistory.org/pages/457.html", - "items": [ - { - "itemType": "encyclopediaArticle", - "creators": [ - { - "firstName": "Robin", - "lastName": "Einhorn", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Encyclopedia of Chicago Entry URL", - "type": "text/html" - } - ], - "url": "http://encyclopedia.chicagohistory.org/pages/457.html", - "date": "2005", - "encyclopediaTitle": "Encyclopedia of Chicago", - "place": "Chicago", - "publisher": "Chicago History Museum and the Newberry Library", - "title": "Fire Limits", - "libraryCatalog": "Encyclopedia of Chicago" - } - ] - }, - { - "type": "web", - "url": "http://encyclopedia.chicagohistory.org/pages/3716.html", - "items": [ - { - "itemType": "map", - "creators": [ - { - "firstName": "Ann Durkin", - "lastName": "Keating", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Encyclopedia of Chicago Map URL", - "type": "text/html" - } - ], - "url": "http://encyclopedia.chicagohistory.org/pages/3716.html", - "archive": "Newberry Library", - "date": "2005", - "title": "Annexations and Additions to the City of Chicago", - "libraryCatalog": "Encyclopedia of Chicago" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Engineering Village.js b/translators/Engineering Village.js @@ -1,125 +0,0 @@ -{ - "translatorID":"1f40baef-eece-43e4-a1cc-27d20c0ce086", - "translatorType":4, - "label":"Engineering Village", - "creator":"Ben Parr", - "target":"^https?://(?:www\\.)?engineeringvillage(2)?\\.(?:com|org)", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-07-31 19:40:00" -} - -function detectWeb(doc, url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath='//a[img/@style="vertical-align: middle;"][@href]'; - if(doc.evaluate(xpath, doc, - nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { return "journalArticle";} - - xpath='//input[@name="cbresult"]/@onclick'; - if(doc.evaluate(xpath, doc, - nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { return "multiple";} - - return null; -} - -function parseRIS(uris) -{ - Zotero.Utilities.HTTP.doGet(uris, function(text){ - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - Zotero.done(); - }, function() {}); - Zotero.wait(); -} - -//creates the link to the RIS file -function createURL(EISESSION,docidlist,curURL) -{ - var milli = (new Date()).getTime(); - var temp = curURL.split('/'); - var url = temp.slice(0,temp.length-1).join('/') + "/Controller?EISESSION="+EISESSION; - url+="&CID=downloadSelectedRecordsris&format=ris&displayformat=fullDoc&timestamp=" - url+=milli; - url+="&docidlist="; - url+=docidlist; - url+="&handlelist=1"; - return 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 url; - var xpath='//a[img/@style="vertical-align: middle;"][@href]'; - if(doc.evaluate(xpath, doc, - nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) - { - xpath='//a[@class="MedBlueLink"][img]/@onclick'; - var temp=doc.evaluate(xpath, doc, - nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - var docidlist=temp.value; - - docidlist=docidlist.split("MID=")[1]; - docidlist=docidlist.split("&")[0]; - - xpath='//a[img/@style="vertical-align: middle;"][@href]'; - temp=doc.evaluate(xpath, doc, - nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - - var EISESSION =temp.href; - EISESSION=EISESSION.split("('")[1]; - EISESSION=EISESSION.split("'")[0]; - url=createURL(EISESSION,docidlist,doc.location.href); - parseRIS(url); - } - else - { - xpath='//input[@NAME="sessionid"]'; - var EISESSION=doc.evaluate(xpath, doc, - nsResolver,XPathResult.ANY_TYPE,null).iterateNext().value; - - xpath='//input[@name="cbresult"]/@onclick'; - - var items=new Array(); - var rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null); - var xpath2='//a[@class="MedBlackText"]/b'; - xpath2=doc.evaluate(xpath2, doc, nsResolver,XPathResult.ANY_TYPE,null); - var title; - var docidlist; - while(row=rows.iterateNext()) - { - docidlist=row.value; - docidlist=docidlist.split("'")[1]; - - url=createURL(EISESSION,docidlist,doc.location.href); - - title=xpath2.iterateNext(); - title=title.textContent; - - items[url]=title; - } - items = Zotero.selectItems(items); - if(!items) return true; - var dois=""; - var theurls= new Array(); - for(var thelink in items) - { - theurls.push(thelink); - } - parseRIS(theurls); - } -} -\ No newline at end of file diff --git a/translators/Epicurious.js b/translators/Epicurious.js @@ -1,150 +0,0 @@ -{ - "translatorID":"aee2323e-ce00-4fcc-a949-06eb1becc98f", - "translatorType":4, - "label":"Epicurious", - "creator":"Sean Takats", - "target":"^https?://www\\.epicurious\\.com/(?:tools/searchresults|recipes/food/views)", - "minVersion":"1.0.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//div[@id="ingredients"]'; - var multxpath = '//table[@class="search-results"]/tbody/tr'; - - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "document"; - } else if (doc.evaluate(multxpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } - -} - -function cleanText(s){ - s = s.replace(/\n+/g, "\n"); - s = s.replace(/(\n|\r)\t+/g, "\n"); - s = s.replace(/\t+/g, " "); - s = s.replace(" ", "", "g"); - return s; -} - -function scrape(doc){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("document"); - - var xpath = '//title'; - var title = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - title = Zotero.Utilities.trimInternal(title); - title = title.substring(0, title.indexOf(" Recipe at Epicurious.com")); - newItem.title = title; - - var elmt; - - xpath = '//p[@class="source"]'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - if (elmt = elmts.iterateNext()){ - var authordate = elmt.textContent; - var authordates = authordate.split("|"); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authordates[0], "contributor", true)); - var datestring = authordates[1].toString(); - datestring = datestring.replace("Copyright", ""); - newItem.date = Zotero.Utilities.formatDate(Zotero.Utilities.strToDate(datestring)); - while (elmt = elmts.iterateNext()){ - Zotero.debug("looping?"); - Zotero.debug(elmt.textContent); - newItem.creators.push(Zotero.Utilities.cleanAuthor(elmt.textContent, "contributor", false)); - } - } - - xpath = '//div[@id="recipe_intro"]/p'; - if (elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var abstract = elmt.textContent; - abstract = Zotero.Utilities.trimInternal(abstract); - newItem.abstractNote = abstract; - } - - xpath = '//div[@id="ingredients"]'; - if (elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var ingredients = elmt.textContent; - ingredients = Zotero.Utilities.superCleanString(ingredients); - ingredients = cleanText(ingredients); - } - xpath = '//div[@id="preparation"]'; - if (elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var prep = elmt.textContent; - prep = Zotero.Utilities.superCleanString(prep); - prep = cleanText(prep); - prep = prep.replace(/\n/g, "\n\n"); - } - xpath = '//div[@id="recipe_summary"]/p'; - if (elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var serving = elmt.textContent; - serving = Zotero.Utilities.superCleanString(serving); - serving = cleanText(serving); - } -// notestring = ingredients + "\n\n" + prep + "\n\n" + serving; -// newItem.notes.push({note:notestring}); - newItem.notes.push({note:ingredients}); - newItem.notes.push({note:prep}); - newItem.notes.push({note:serving}); - - var url = doc.location.href; - - var snapshotURL = url.replace("/views/", "/printerfriendly/"); - newItem.attachments.push({title:"Epicurious.com Snapshot", mimeType:"text/html", url:snapshotURL, snapshot:true}); - newItem.url = url; - newItem.attachments.push({title:"Epicurious.com Link", snapshot:false, mimeType:"text/html", url:url}); - - newItem.complete(); -} - -function doWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var singxpath = '//div[@id="ingredients"]'; - var multxpath = '//table[@class="search-results"]/tbody/tr'; - if(doc.evaluate(singxpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - // single recipe page - scrape(doc, url); - } else if (doc.evaluate(multxpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var items = new Object(); - var elmtxpath = '//div[@id="resultstable"]/table[@class="search-results"]/tbody/tr/td[3][@class="name"]/a[@class="hed"]'; - var elmts = doc.evaluate(elmtxpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - while (elmt = elmts.iterateNext()) { - var title = elmt.textContent; - var link = elmt.href; - if (title && link){ - items[link] = title; - } - } - - var items = Zotero.selectItems(items); - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/Euclid.js b/translators/Euclid.js @@ -1,143 +0,0 @@ -{ - "translatorID":"2e1c09a0-3006-11de-8c30-0800200c9a66", - "label":"Project Euclid", - "creator":"Guy Freeman and Avram Lyon", - "target":"^https?://[^/]*projecteuclid\\.org[^/]*/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-11-10 10:15:00" -} - -function detectWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//div[@class="abstract-text"]'; - Zotero.debug(xpath); - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - 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 = doc.location.host; - var newItem = new Zotero.Item("journalArticle"); - newItem.url = doc.location.href; - Zotero.debug(doc.location.href); - - var items = Object(); - var header; - var contents; - - var titleXPath = '//div[@id="main-text"]/h3'; - var titleitem = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - Zotero.debug(titleitem); - newItem.title = titleitem; - - var authorXPath = '//div[@class="abs-page-text-bold"]/span'; - var authoritem = doc.evaluate(authorXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - if (authoritem.search(/\sand\s/) == -1) { - var authoritem2 = ""; - for (var authornamescount in authoritem.split(/\s/)) { - authoritem2 = authoritem2 + " " + authoritem.split(/\s/)[authornamescount][0] + authoritem.split(/\s/)[authornamescount].substring(1).toLowerCase(); - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(authoritem2, 'author')); - } else { - var authors = authoritem.split(/\sand\s/i); - for (var authorcount in authors) { - var author = ""; - for (var authornames in authors[authorcount].split(/\s/)) { - author = author + " " + authors[authorcount].split(/\s/)[authornames][0] + authors[authorcount].split(/\s/)[authornames].substring(1).toLowerCase(); - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, 'author')); - } - } - - var abstractXPath = '//div[@class="abstract-text"]/p'; - var abstractitem = doc.evaluate(abstractXPath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = abstractitem; - - var journalXPath = '//div[@id="main-image"]/img'; - var journalitem = doc.evaluate(journalXPath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext()["alt"]; - newItem.publicationTitle = journalitem; - - var journalabbXPath = '//div[@class="abs-page-text"]/a'; - var journalabbitem = doc.evaluate(journalabbXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.journalAbbreviation = journalabbitem; - - var idXPath = '//div[@id="identifier"]/p'; - var idresult = doc.evaluate(idXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().innerHTML; - var idrows = idresult.split('<br>'); - var idrow, pieces; - var identifiers = []; - newItem.extra=""; - for each (idrow in idrows) { - pieces = idrow.match(/\s*([^:]+)\s*:\s*(.+)/); - if (pieces && pieces[1] && pieces[2]) { - switch (pieces[1]) { - case "Digital Object Identifier": - newItem.DOI = pieces[2].match(/^\s*doi:(.*)/)[1]; - break; - case "Mathematical Reviews number (MathSciNet)": - case "Zentralblatt MATH identifier": - identifiers.push(pieces[1] + ": " + pieces[2].match(/>(.*?)</)[1]); - break; - case "Permanent link to this document": - newItem.url = pieces[2]; - break; - default: - Zotero.debug("Discarding identifier: " + pieces[1] + ": " + pieces[2] ); - break; - } - pieces = null; - } - newItem.extra = identifiers.join("; "); - } - - var volumeetcXPath = '//div[@class="abs-page-text"]/text()'; - //var volumeetcitem = doc.evaluate(volumeetcXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().childNodes[2].textContent; - var volumeetcitem = doc.evaluate(volumeetcXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - Zotero.debug("volumeetcitem="+volumeetcitem); - var volumeetcitemarray = volumeetcitem.replace(/\s+/g," ").split(/\s/); - if (volumeetcitemarray[3].search(/Number/) == -1) { - var volumeitem = volumeetcitemarray[2].match(/\d+/)[0]; - var yearitem = volumeetcitemarray[3].match(/\d+/)[0]; - var pagesitem = volumeetcitemarray[4].match(/[^\.]+/)[0]; - newItem.volume = volumeitem; - newItem.pages = pagesitem; - newItem.date = yearitem; - } else { - var volumeitem = volumeetcitemarray[2].match(/\d+/)[0]; - var issueitem = volumeetcitemarray[4].match(/\d+/)[0]; - var yearitem = volumeetcitemarray[5].match(/\d+/)[0]; - var pagesitem = volumeetcitemarray[6].match(/[^\.]+/)[0]; - newItem.volume = volumeitem; - newItem.pages = pagesitem; - newItem.issue = issueitem; - newItem.date = yearitem; - } - - // From META tags - newItem.publisher = doc.evaluate('//meta[@name="citation_publisher"]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext().content; - newItem.date = doc.evaluate('//meta[@name="citation_date"]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext().content; - newItem.ISSN = doc.evaluate('//meta[@name="citation_issn"]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext().content; - newItem.language = doc.evaluate('//meta[@name="citation_language"]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext().content; - - var pdfurlxpath = '//meta[@name="citation_pdf_url"]'; - if (doc.evaluate(pdfurlxpath,doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext()) { - var pdfurl = doc.evaluate(pdfurlxpath,doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext().content; - newItem.attachments.push({url:pdfurl, title:"Euclid Project PDF", mimeType:"application/pdf"}); - } - - newItem.complete(); -} diff --git a/translators/EurasiaNet.js b/translators/EurasiaNet.js @@ -1,45 +0,0 @@ -{ - "translatorID": "58ae38d2-80d3-4569-81eb-9cefc43ac5b4", - "label": "EurasiaNet", - "creator": "Avram Lyon", - "target": "^https?://www\\.eurasianet\\.org/", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-23 23:58:49" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'newspaperArticle', -detect : FW.Url().match(/(\/node\/\d+|articles\/[a-zA-Z0-9]+\.shtml)/), -title : FW.Xpath('//h1[@class="title"]').text().trim(), -attachments : [ - { url: FW.Url().replace(/node/,"print"), - title: "EurasiaNet Printable", - type: "text/html" } - // Video? Not yet. -/* { url: FW.Xpath('//object[@id="videofield-embedded_api"]/param[@name="flashvars"]').key("value").match(/"url":"([^"])"/,0), - title: "EurasiaNet Video", - type: "video/x-flv" } */ - ], -// here, we use the replace(..) to break names on &nbsp; -creators : FW.Xpath('//div[@class="submitted"]/span[@class="authors"]/a').text().replace(/\s/," ").cleanAuthor("author"), -date : FW.Xpath('//div[@class="submitted"]/span[@class="timestamp"]').text(), -tags : FW.Xpath('//div[@class="terms terms-inline"]/ul/li/a[@rel="tag"]').text(), -publicationTitle : "EurasiaNet" -}); - -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Url().match(/\/search\/node/), -choices : { - titles : FW.Xpath('//dl[@class="search-results node-results"]/dt[@class="title"]/a').text().trim(), - urls : FW.Xpath('//dl[@class="search-results node-results"]/dt[@class="title"]/a').key("href") -} -}); -\ No newline at end of file diff --git a/translators/European Educational Research Journal.js b/translators/European Educational Research Journal.js @@ -1,87 +0,0 @@ -{ - "translatorID":"2e304579-dd7b-4770-85e9-0d724c9b49a5", - "translatorType":4, - "label":"European Educational Research Journal", - "creator":"Michael Berkowitz", - "target":"http://www.wwwords.co.uk/eerj/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-05 07:45:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@id="maincontent"]/table[*//p[@class="articletitle"]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function titleCase(str) { - var skipWords = ["but", "or", "yet", "so", "for", "and", "nor", "a", "an", "the", "at", "by", "from", "in", "into", "of", "on", "to", "with", "up", "down", "as"]; - var words = str.toLowerCase().split(/\s+/); - var newstr = ""; - for each (var word in words) { - if (skipWords.indexOf(word.replace(/[^a-zA-Z]+/, "")) != -1) { - newstr += " " + word; - } else if (word.indexOf("-") != -1) { - newword = word.split("-"); - newstr += " " + newword[0][0].toUpperCase() + newword[0].substr(1) + "-" + newword[1][0].toUpperCase() + newword[1].substr(1); - } else { - newstr += " " + word[0].toUpperCase() + word.substr(1); - } - } - return Zotero.Utilities.trimInternal(newstr); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return false; - } : null; - var items = new Object(); - var titles = doc.evaluate('//p[@class="articletitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - var text = Zotero.Utilities.trimInternal(title.textContent); - items[text] = text; - } - items = Zotero.selectItems(items); - Zotero.debug(items); - - var articles = doc.evaluate('//div[@id="maincontent"]/table[*//p[@class="articletitle"]]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var art; - while (art = articles.iterateNext()) { - var title = Zotero.Utilities.trimInternal(doc.evaluate('.//p[@class="articletitle"]', art, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if (items[title]) { - var pdfurl = doc.evaluate('.//a[contains(text(), "FULL TEXT")]', art, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - var item = new Zotero.Item("journalArticle"); - item.publicationTitle = "European Educational Research Journal"; - item.ISSN = "1474-9041"; - item.url = url; - item.title = title; - var voliss = doc.title.match(/\-\s+(.*)$/)[1]; - voliss = voliss.match(/Volume\s+(\d+)\s+Issue\s+(\d+)\s+\((\d+)\)/); - item.volume = voliss[1]; - item.issue = voliss[2]; - item.date = voliss[3]; - - var authors = doc.evaluate('.//tr[2]/td', art, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var ibits = doc.evaluate('.//tr[2]/td//i', art, nsResolver, XPathResult.ANY_TYPE, null); - var ibit = ""; - var bit; - while (bit = ibits.iterateNext()) { - authors = authors.replace(bit.textContent, ","); - } - authors = authors.split(/\s*(,|&)\s*/); - for each (var aut in authors) { - if (aut.match(/\w/)) { - aut = titleCase(Zotero.Utilities.trimInternal(aut)); - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } - item.attachments = [{url:pdfurl, title:"EERJ Full Text PDF", mimeType:"application/pdf"}]; - item.complete(); - } - } -} -\ No newline at end of file diff --git a/translators/FAZ.NET.js b/translators/FAZ.NET.js @@ -1,196 +0,0 @@ -{ - "translatorID": "4f0d0c90-5da0-11df-a08a-0800200c9a66", - "label": "FAZ.NET", - "creator": "ibex", - "target": "^http://((www\\.)?faz\\.net/.)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-01 07:38:34" -} - -/* - FAZ Translator - Parses FAZ articles and creates Zotero-based metadata. - Copyright (C) 2010-2011 ibex - - 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/>. -*/ - -/* -Test with the following URLs: -http://www.faz.net/artikel/C30783/wissenschaftsphilosophie-krumme-wege-der-vernunft-30436005.html -http://www.faz.net/f30/common/Suchergebnis.aspx?term=philosophie&x=0&y=0&allchk=1 -*/ - -/* Get the first xpath element from doc, if not found return null. */ -function getXPath(xpath, doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - return doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); -} - -/* Zotero API */ -function detectWeb(doc, url) { - //Zotero.debug("ibex detectWeb URL= "+ url); - if (doc.title == "Suche - FAZ.NET" && getXPath('//div[@class = "SuchPagingModul"]', doc)) { - return "multiple"; - } else if (getXPath('//div[@class = "Article"]', doc)) { - return "newspaperArticle"; - } -} - -/* Zotero API */ -function doWeb(doc, url) { - //Zotero.debug("ibex doWeb URL = "+ url); - var urls = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, - doc.getElementById("MainColumn") - .getElementsByTagName("h1"), - '/artikel/.+\\.html'); - if (!items || countObjectProperties(items) == 0) { - Zotero.debug("no items"); - return true; - } - items = Zotero.selectItems(items); - if (!items) { - return true; - } - - for (var i in items) { - urls.push(i); - } - } else { - urls.push(doc.location.href); - } - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); } ); - Zotero.wait(); -} - -function scrape(doc) { - var newArticle = new Zotero.Item('newspaperArticle'); - newArticle.url = doc.location.href; - newArticle.title = Zotero.Utilities.trimInternal(getXPath('//div[@class = "Article"]/h1', doc).textContent); - var date = getXPath('//div[@class = "Article"]//span[@id = "dateline"][1]', doc).textContent; - newArticle.date = Zotero.Utilities.trimInternal(date.replace(/ .*$/, "")); - - - var subtitle = getXPath('//div[@class = "Article"]/h2', doc); - if (subtitle != null) { - newArticle.shortTitle = newArticle.title; - newArticle.title = Zotero.Utilities.trimInternal(subtitle.textContent) + ": " + newArticle.title; - } - - var teaser = getXPath('//div[@class = "Article"]/h4', doc); - if (teaser != null) { - newArticle.abstractNote = Zotero.Utilities.trimInternal(teaser.textContent); - } - - var authorline = getXPath('//div[@class = "Article"]/p[@class = "Author"]', doc); - if (authorline != null) { - authorline = Zotero.Utilities.trimInternal(authorline.textContent); - //assumption of authorline: "Von name1 [und Name2][, location]" - authorline = authorline.replace(/Von /, ""); - //remove ", location" - authorline = Zotero.Utilities.trim(authorline.replace(/, .*$/, "")); - - var authors = authorline.split(" und "); - for (var i = 0; i < authors.length && authorline.length > 0; i++) { - newArticle.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } - - newArticle.publicationTitle = "FAZ.NET"; - - var section = getXPath('//div[@id="FAZNavMain"]//li[@class = "tabSelected"]/a', doc); - if (section != null) { - newArticle.section = Zotero.Utilities.trimInternal(section.textContent); - } - - var source = getXPath('//div[@id="MainColumn"]/div[@class = "Article"]/p[@class = "ArticleSrc"]', doc); - if (source != null) { - newArticle.extra = Zotero.Utilities.trimInternal(Zotero.Utilities.cleanTags(source.innerHTML)); - } - - //unfortunately a print dialog will be shown due to <script>window.print();</script> if the snapshot is opened. A user must click on cancel afterwards. - var length = newArticle.attachments.push({title:"FAZ.NET Article Snapshot", mimeType:"text/html", url:doc.location.href.replace("~Scontent.html", "~Scontent~Afor~Eprint.html"), snapshot:true}); - - newArticle.complete(); -} - -/* There is no built-in function to count object properties which often are used as associative arrays.*/ -function countObjectProperties(obj) { - var size = 0; - for (var key in obj) { - if (obj.hasOwnProperty(key)) size++; - } - return size; -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.faz.net/artikel/C30783/wissenschaftsphilosophie-krumme-wege-der-vernunft-30436005.html", - "items": [ - { - "itemType": "newspaperArticle", - "creators": [ - { - "firstName": "Fynn Ole", - "lastName": "Engler", - "creatorType": "author" - }, - { - "firstName": "Jürgen", - "lastName": "Renn", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "title": "FAZ.NET Article Snapshot", - "mimeType": "text/html", - "url": false, - "snapshot": true - } - ], - "url": "http://www.faz.net/artikel/C30783/wissenschaftsphilosophie-krumme-wege-der-vernunft-30436005.html", - "title": "Wissenschaftsphilosophie: Krumme Wege der Vernunft", - "date": "2011-06-13", - "shortTitle": "Krumme Wege der Vernunft", - "abstractNote": "Wissenschaft hat eine Geschichte, wie kann sie dann aber rational sein? Im Briefwechsel zwischen Ludwik Fleck und Moritz Schlick deuteten sich bereits Antworten an.", - "publicationTitle": "FAZ.NET", - "extra": "Fynn Ole Engler ist Mitherausgeber der als Langzeitvorhaben der Akademie der Wissenschaften in Hamburg erscheinenden Moritz-Schlick-Gesamtausgabe. Jürgen Renn ist Direktor am Max-Planck-Institut für Wissenschaftsgeschichte in Berlin. Text: F.A.S. Bildmaterial: Foto ETH Zürich, ÖNB Bildarchiv Austria", - "libraryCatalog": "FAZ.NET" - } - ] - }, - { - "type": "web", - "url": "http://www.faz.net/f30/common/Suchergebnis.aspx?term=philosophie&x=0&y=0&allchk=1", - "items": "multiple" - } -] -/** END TEST CASES **/ diff --git a/translators/Factiva.js b/translators/Factiva.js @@ -1,136 +0,0 @@ -{ - "translatorID":"7bdb79e-a47f-4e3d-b317-ccd5a0a74456", - "translatorType":4, - "label":"Factiva", - "creator":"Simon Kornblith", - "target":"https?://[^/]*global\\.factiva\\.com[^/]*/ha/default\\.aspx$", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.evaluate('//tr[@class="headline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - if(doc.body.className == 'articleView') { - return "newspaperArticle"; - } else { - return "multiple"; - } - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var items = new Array(); - var singlePage = doc.body.className == 'articleView'; - - var tableRows = doc.evaluate('//tr[@class="headline"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var tableRow; - while(tableRow = tableRows.iterateNext()) { - var hdl = doc.evaluate('.//input[@name="hdl"]', tableRow, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().value; - if(!singlePage){ - items[hdl] = Zotero.Utilities.trimInternal(tableRow.getElementsByTagName("a")[0].textContent); - } else { - var m = doc.evaluate('.//td[@class="count"]', tableRow, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().textContent.match(/[0-9]+/); - items[m[0]] = hdl; - } - } - - if(!singlePage) { - items = Zotero.selectItems(items); - if(!items) return true; - - var hdls = new Array(); - for(var hdl in items) { - hdls.push(hdl); - } - } else { - var m = doc.evaluate('//div[@class="articleHeader"][@id="artHdr1"]/span[substring(text(), 1, 7) = "Article"]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/[0-9]+/); - var hdls = [items[m[0]]]; - } - - var post = ""; - - var hiddenInputs = doc.evaluate('//form[@name="PageBaseForm"]//input[@type="hidden"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var hiddenInput; - while(hiddenInput = hiddenInputs.iterateNext()) { - // this is some weird shit, but apparently they're very picky - post = post+"&"+hiddenInput.name+"="+escape(hiddenInput.value).replace(/\+/g, "%2B").replace(/\%20/g, "+"); - } - - var selects = doc.evaluate('//form[@name="PageBaseForm"]//select', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var select; - while(select = selects.iterateNext()) { - post = post+"&"+select.name+"="+escape(select.options[select.selectedIndex].value); - } - - for each(var hdl in hdls) { - post += "&hdl="+escape(hdl); - } - post = post.substr(1); - - Zotero.Utilities.HTTP.doPost("http://global.factiva.com/pps/default.aspx?pp=XML", post, function(text) { - // Remove xml parse instruction and doctype - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - // kill the XML namespace, too, because we have no way of knowing what it will be, which presents a problem - text = text.replace(/<ppsArticleResponse xmlns="[^"]+">/, "<ppsArticleResponse>"); - // kill hlt tags; they just make parsing harder - text = text.replace(/<\/?hlt>/g, ""); - var xml = new XML(text); - - // loop through articles - for each(var ppsarticle in xml[0]..ppsarticle) { - var article = ppsarticle.article; - var newItem = new Zotero.Item("newspaperArticle"); - - newItem.title = Zotero.Utilities.trimInternal(article.headline.paragraph.text().toString()); - newItem.publicationTitle = Zotero.Utilities.trimInternal(article.sourceName.text().toString()); - for each(var tag in article..name) { - newItem.tags.push(tag.text().toString()); - } - newItem.date = Zotero.Utilities.formatDate(Zotero.Utilities.strToDate(article.publicationDate.date.text().toString())); - if(article.byline.length()) { - var byline = Zotero.Utilities.trimInternal(article.byline.text().toString().replace(/By/i, "")); - var authors = byline.split(/ (?:\&|and) /i); - for each(var author in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - newItem.section = article.sectionName.text().toString(); - newItem.edition = article.edition.text().toString(); - - if(article.pages.length()) { - newItem.pages = ""; - for each(var page in article.pages.page) { - newItem.pages += ","+page.text().toString(); - } - newItem.pages = newItem.pages.substr(1); - } - - var m = article.volume.text().toString().match(/ISSN[:\s]*([\-0-9]{8,9})/i); - if(m) newItem.ISSN = m[1]; - - newItem.complete(); - } - - Zotero.done(); - }); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Flickr.js b/translators/Flickr.js @@ -1,157 +0,0 @@ -{ - "translatorID":"5dd22e9a-5124-4942-9b9e-6ee779f1023e", - "translatorType":4, - "label":"Flickr", - "creator":"Sean Takats", - "target":"^http://(?:www\\.)?flickr\\.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (elmt = doc.evaluate('//h1[@property="dc:title" and starts-with(@id, "title_div")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "artwork"; - } else if (doc.evaluate('//td[@class="DetailPic"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } else if (doc.evaluate('//div[contains(@class, "StreamView")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } else if (doc.evaluate('//div[@id="setThumbs"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - if (!doc.URL.match('/comments/')) { - return "multiple"; - } - } else if (doc.evaluate('//p[@class="StreamList" or @class="UserTagList"]/span/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var items = new Object(); - var photo_ids = new Array(); - var uris = new Array(); - var key = "3cde2fca0879089abf827c1ec70268b5"; - - var elmts; - var elmt; - -// single result - if (elmt = doc.evaluate('//h1[@property="dc:title" and starts-with(@id, "title_div")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var photo_id = elmt.id; - photo_id = photo_id.substr(9); - photo_ids.push(photo_id); - } else { //multiple results - var photoRe = /\/photos\/[^\/]*\/([0-9]+)\//; -//search results - if (doc.evaluate('//td[@class="DetailPic"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - elmts = doc.evaluate('//td[@class="DetailPic"]//a', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (elmt = elmts.iterateNext()){ - var title = elmt.title; - title = Zotero.Utilities.trimInternal(title); - var link = elmt.href; - var m = photoRe(link); - var photo_id = m[1]; - items[photo_id] = title; - } -// photo stream - } else if (doc.evaluate('//div[contains(@class, "StreamView")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - if (doc.evaluate('//div[contains(@class, "StreamView") and starts-with(@id, "sv_title_")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - elmts = doc.evaluate('//div[contains(@class, "StreamView") and starts-with(@id, "sv_title_")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } else { - elmts = doc.evaluate('//div[contains(@class, "StreamView") and starts-with(@id, "sv_body_")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - while (elmt = elmts.iterateNext()){ - //var title = Zotero.Utilities.trimInternal(elmt.textContent); - var title = elmt.getElementsByTagName("h4")[0].textContent - var photo_id = elmt.id; - photo_id = photo_id.replace(/(sv_body_|sv_title_)/,''); - Zotero.debug("id="+photo_id) - items[photo_id] = title; - } -// photo set - } else if (doc.evaluate('//div[@class="setThumbs-indv"]/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - elmts = doc.evaluate('//div[@class="setThumbs-indv"]/span', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (elmt = elmts.iterateNext()){ - var title = doc.evaluate('./a/@title', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var photo_id = elmt.id.substr(11); - items[photo_id] = title; - } -// tagged with - } else if (doc.evaluate('//p[@class="StreamList" or @class="UserTagList"]/span/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var elmts = doc.evaluate('//p[@class="StreamList" or @class="UserTagList"]//a[img]', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (elmt = elmts.iterateNext()){ - var title = Zotero.Utilities.trimInternal(elmt.title); - var link = elmt.href; - var m = photoRe(link); - var photo_id = m[1]; - items[photo_id] = title; - } - } - items = Zotero.selectItems(items); - if(!items) return true; - for(var i in items) { - photo_ids.push(i); - } - } - for each(var photo_id in photo_ids){ - uris.push("http://api.flickr.com/services/rest/?method=flickr.photos.getInfo&api_key="+key+"&photo_id="+photo_id); - } - Zotero.Utilities.HTTP.doGet(uris, function(text) { - text = text.replace(/<\?xml[^>]*\?>/, ""); - var xml = new XML(text); - var newItem = new Zotero.Item("artwork"); - var title = ""; - if (xml..title.length()){ - var title = Zotero.Utilities.trimInternal(xml..title[0].text().toString()); - if (title == ""){ - title = " "; - } - newItem.title = title; - } - for(var i=0; i<xml..tag.length(); i++) { - newItem.tags.push(Zotero.Utilities.trimInternal(xml..tag[i].text().toString())); - } - if (xml..dates.length()){ - var date = xml..dates[0].@taken.toString(); - newItem.date = date.substr(0, 10); - } - if (xml..owner.length()){ - var author = xml..owner[0].@realname.toString(); - if (author == ""){ - author = xml..owner[0].@username.toString(); - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "artist")); - } - if (xml..url.length()){ - newItem.url = xml..url[0].text().toString(); - } - if (xml..description.length()){ - newItem.abstractNote = xml..description[0].text().toString(); - } - var format = xml..photo[0].@originalformat.toString(); - var photo_id = xml..photo[0].@id.toString(); - -// get attachment code - var uri = "http://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key="+key+"&photo_id="+photo_id; - Zotero.Utilities.HTTP.doGet(uri, function(text) { - text = text.replace(/<\?xml[^>]*\?>/, ""); - var xml = new XML(text); - var last = xml..size.length() - 1; - var attachmentUri = xml..size[last].@source.toString(); - newItem.attachments = [{title:title, url:attachmentUri}]; - newItem.complete(); - }, function(){Zotero.done();}); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Florida University Libraries (Endeca 1).js b/translators/Florida University Libraries (Endeca 1).js @@ -1,104 +0,0 @@ -{ - "translatorID":"a2363670-7040-4cb9-8c48-6b96584e92ee", - "translatorType":4, - "label":"Florida University Libraries (Endeca 1)", - "creator":"Sean Takats", - "target":"^http://[^/]+/[^\\.]+.jsp\\?[^/]*(?:Ntt=|NttWRD=)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//div[starts-with(@id, "briefTitle")]'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } - if (url.indexOf("&V=D")){ - return "book"; - } else if (url.indexOf("&V=M")){ - return "book"; - } else if (url.indexOf("&V=U")){ - return "book"; - } -} - -function doWeb(doc, url){ - var newUris = new Array(); - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var xpath = '//div[starts-with(@id, "briefTitle")]/a[starts-with(@id, "Title")]'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - if(elmt = elmts.iterateNext()) { - // search page - var items = new Array(); - do { - items[elmt.href] = Zotero.Utilities.trimInternal(elmt.textContent); - } while (elmt = elmts.iterateNext()); - - items = Zotero.selectItems(items); - if(!items) { - return true; - } - for(var i in items) { - var newUri = i.replace(/&V=./, "&V=M"); - newUris.push(newUri); - } - } else { - // single page - var newURL = url.replace(/&V=./, "&V=M"); - newUris.push(newURL); - } - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.processDocuments(newUris, function(newDoc) { - var uri = newDoc.location.href; - var xpath = '//tr[@class="trGenContent"][td[3]]'; - var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - - var record = new marc.record(); - while(elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./TD[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var value = newDoc.evaluate('./TD[3]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - if(field == "LDR") { - record.leader = value; - } else if(field != "FMT") { - - value = value.replace(/\|([a-z]) /g, marc.subfieldDelimiter+"$1"); - - var code = field.substring(0, 3); - var ind = ""; - if(field.length > 3) { - ind = field[3]; - if(field.length > 4) { - ind += field[4]; - } - } - - record.addField(code, ind, value); - } - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - }, function() { Zotero.done(); }, null); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Foreign Policy.js b/translators/Foreign Policy.js @@ -1,144 +0,0 @@ -{ - "translatorID": "0e7ab798-bb96-4a3a-9a01-8d1d67153908", - "label": "Foreign Policy", - "creator": "Sebastian Karcher", - "target": "^https?://(.*)foreignpolicy\\.com", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-06-18 00:43:21" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'magazineArticle', -detect : FW.Url().match(/\/articles\//), -title : FW.Xpath('//div[@class="translateHead"]/h1').text().trim(), -abstractNote : FW.Xpath('//div[@class="translateHead"]/h2').text().trim(), -attachments : [{ url: FW.Url().remove(/\?page=full/).append("?page=full"), - title: "Foreign Policy Snapshot", - type: "text/html" }], -creators : FW.Xpath('//h3/span[@id="by-line"]').text().remove(/BY /).capitalizeTitle().split(/,/).cleanAuthor("author"), -date : FW.Xpath('//h3/span[@id="pub-date"]').text().capitalizeTitle(), -tags : FW.Xpath('//div[@id="sub-tags"]/span[@class="fp_red"]/a').text().capitalizeTitle(), -publicationTitle : "Foreign Policy" -}); - -/** Blogs */ -FW.Scraper({ -itemType : 'blogPost', -detect : FW.Url().match(/\/posts\//), -title : FW.Xpath('//div[@class="translateHead"]/h1').text().trim(), -abstractNote : FW.Xpath('//div[@class="translateHead"]/h2').text().trim(), -attachments : [{ url: FW.Url().remove(/\?page=full/).append("?page=full"), - title: "Foreign Policy Snapshot", - type: "text/html" }], -creators : FW.Xpath('//span[@class="post_by"]/a').text().cleanAuthor("author"), -date : FW.Xpath('//span[@class="post_date"]').text().remove(/-.*/), -tags : FW.Xpath('//div[@class="subjects"]/a').text().capitalizeTitle(), -publicationTitle : "Foreign Policy Blogs" -}); - -/** Multiple Blogs */ -/** This fails because of permission issues if any of the listed items are articles instead of blog posts */ -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Xpath('//div[@id="blog-post-2"]'), -choices : { - titles : FW.Xpath('//div[@class="translateHead"]/h1/a').text().trim(), - urls : FW.Xpath('//div[@class="translateHead"]/h1/a').key("href") -} -}); - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://drezner.foreignpolicy.com/posts/2011/06/16/the_real_turn_in_republican_foreign_policy", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "Daniel W.", - "lastName": "Drezner", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "U.s. Foreign Policy", - "2012 Campaign", - "China", - "Republicans", - "Trade Politics", - "Trade Protectionism", - "United States" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://drezner.foreignpolicy.com/posts/2011/06/16/the_real_turn_in_republican_foreign_policy?page=full", - "title": "Foreign Policy Snapshot", - "type": "text/html" - } - ], - "url": "http://drezner.foreignpolicy.com/posts/2011/06/16/the_real_turn_in_republican_foreign_policy", - "abstractNote": false, - "date": "Thursday, June 16, 2011 ", - "publicationTitle": "Foreign Policy Blogs", - "title": "The real turn in Republican foreign policy", - "libraryCatalog": "Foreign Policy", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - }, - { - "type": "web", - "url": "http://www.foreignpolicy.com/articles/2011/04/25/more_than_1_billion_people_are_hungry_in_the_world", - "items": [ - { - "itemType": "magazineArticle", - "creators": [ - { - "firstName": "Abhijit", - "lastName": "Banerjee", - "creatorType": "author" - }, - { - "firstName": "Esther", - "lastName": "Duflo", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Food/Agriculture" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.foreignpolicy.com/articles/2011/04/25/more_than_1_billion_people_are_hungry_in_the_world?page=full", - "title": "Foreign Policy Snapshot", - "type": "text/html" - } - ], - "url": "http://www.foreignpolicy.com/articles/2011/04/25/more_than_1_billion_people_are_hungry_in_the_world", - "abstractNote": "But what if the experts are wrong?", - "date": "May/June 2011", - "publicationTitle": "Foreign Policy", - "title": "More Than 1 Billion People Are Hungry in the World", - "libraryCatalog": "Foreign Policy", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/FreePatentsOnline.js b/translators/FreePatentsOnline.js @@ -1,124 +0,0 @@ -{ - "translatorID":"879d738c-bbdd-4fa0-afce-63295764d3b7", - "translatorType":4, - "label":"FreePatentsOnline", - "creator":"Adam Crymble", - "target":"http://www.freepatentsonline.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-09-02 13:40:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("result.html")) { - return "multiple"; - } else if (doc.evaluate('//div[@class="disp_doc2"]/div', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "patent"; - } -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - var contents; - - var newItem = new Zotero.Item("patent"); - - var pageContent = doc.evaluate('//div[@class="disp_doc2"]/div', doc, null, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//div[@class="disp_doc2"]/div)', doc, null, XPathResult.ANY_TYPE, null); - - - for (i=0; i<xPathCount.numberValue/2; i++) { - - fieldTitle = pageContent.iterateNext().textContent.replace(/\s+/g, ''); - content = pageContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - dataTags[fieldTitle] = (content); - } - - var inventors = new Array(); - var parenthesis; - - if (dataTags["Inventors:"]) { - inventors = dataTags["Inventors:"].split(/\n/); - if (inventors.length>1) { - for (var i = 0; i < inventors.length; i++) { - parenthesis = inventors[i].indexOf("("); - inventors[i] = inventors[i].substr(0, parenthesis).replace(/^\s*|\s*$/g, ''); - if (inventors[i].match(", ")) { - var inventors1 = inventors[i].split(", "); - inventors[i] = inventors1[1] + " " + inventors1[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(inventors[i], "inventor")); - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(inventors[i], "inventor")); - } - } - - } else { - Zotero.debug(doc.title); - parenthesis = dataTags["Inventors:"].indexOf("("); - dataTags["Inventors:"] = dataTags["Inventors:"].substr(0, parenthesis).replace(/^\s*|\s*$/g, ''); - - if (dataTags["Inventors:"].match(", ")) { - var inventors1 = dataTags["Inventors:"].split(", "); - dataTags["Inventors:"] = inventors1[1] + " " + inventors1[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Inventors:"], "inventor")); - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Inventors:"], "inventor")); - } - } - } - - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "Abstract:", "abstract"); - associateData (newItem, dataTags, "DocumentTypeandNumber:", "patentNumber"); - associateData (newItem, dataTags, "ApplicationNumber:", "applicationNumber"); - associateData (newItem, dataTags, "PublicationDate:", "issueDate"); - associateData (newItem, dataTags, "Assignee:", "assignee"); - - newItem.url = doc.location.href; - - newItem.complete(); -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//table[@class="listing_table"]/tbody/tr/td[3]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Frontiers.js b/translators/Frontiers.js @@ -1,283 +0,0 @@ -{ - "translatorID":"cb9e794e-7a65-47cd-90f6-58cdd191e8b0", - "label":"Frontiers", - "creator":"Jason Friedman", - "target":"^https?://www\\.frontiersin\\.org.*/", - "minVersion":"2.0.10", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-01-11 23:21:54" -} - -/* - Frontiers translator - Copyright (C) 2009-2011 Jason Friedman, write.to.jason@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) { - - if (url.indexOf("abstract") != -1) { - return "journalArticle"; - } - else if (url.indexOf("full") != -1) { - return "journalArticle"; - } - else if (url.indexOf("SearchSite") != -1) { - return "multiple"; - } - // other pages on the site may contain articles - else - return "multiple"; - - -} - -function doWeb(doc, url) { - var articles = new Array(); - - // individual article - if (url.indexOf("abstract") != -1) { - // For some strange reason, replacing /abstract with /pdf/abstract will load a document that has a link to the pdf . . . - if (!url.match(/pdf/) && url.match(/abstract$/)) { - url = url.replace('abstract','pdf/abstract'); - } - articles = [url]; - - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } - else if(url.indexOf("full")!= -1) { - // For some strange reason, replacing /abstract with /pdf/abstract will load a document that has a link to the pdf . . . - if (!url.match(/pdf/) && url.match(/full$/)) { - url = url.replace('full','pdf/full'); - } - articles = [url]; - - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } - // search results / other page - else { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var items = new Object(); - var noitems = 1; - - var links = doc.evaluate('//div[@class="ArchiveList"]/div/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (link = links.iterateNext()) { - var url = link.href; - if (url.indexOf("abstract")!= -1) { - if(url.match(/abstract$/)) - url = url.replace('abstract','pdf/abstract'); - items[url] = link.textContent; - noitems=0; - } - else if (url.indexOf("full")!= -1) { - if(url.match(/full$/)) - url = url.replace('full','pdf/full'); - items[url] = link.textContent; - noitems=0; - } - - } - - - var links = doc.evaluate('//div/div/h4/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (link = links.iterateNext()) { - var url = link.href; - if (url.indexOf("abstract")!= -1) { - if(url.match(/abstract$/)) - url = url.replace('abstract','pdf/abstract'); - items[url] = link.textContent; - noitems=0; - } - else if (url.indexOf("full")!= -1) { - if(url.match(/full$/)) - url = url.replace('full','pdf/full'); - items[url] = link.textContent; - noitems=0; - } - } - - if (noitems) - return true; - - items = Zotero.selectItems(items); - - for (var i in items) { - articles.push(i); - } - - if (!items) - return true; - - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - 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"); - - // save the url - newItem.url = doc.location.href; - - //title - var title1 = doc.evaluate('//div[@class="JournalAbstract"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if (title1==null) - title1 = doc.evaluate('//div[@class="JournalAbstract"]/div/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - newItem.title = Zotero.Utilities.trim(title1.textContent); - - // journal name - var docTitle = doc.evaluate('//head/title', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.publicationTitle = Zotero.Utilities.trimInternal(docTitle.split('|')[2]); - - //authors - can be in two ways, depending on which page - var authors = doc.evaluate('//div[@class="authors"]/a', doc, nsResolver, XPathResult.ANY_TYPE,null); - while (author = authors.iterateNext()) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(author.textContent),"author")); - } - - authors = doc.evaluate('//div[@class="paperauthor"]/a',doc,nsResolver,XPathResult.ANY_TYPE,null); - - while (author = authors.iterateNext()) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(author.textContent),"author")); - } - - // abstract - var abstract1; - abstract1 = doc.evaluate('//div[@class="JournalAbstract"]/p',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - - if (abstract1==null) - abstract1 = doc.evaluate('//div[@class="JournalAbstract"]/div[@class="abstracttext"]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - - if (!(abstract1==null)) - newItem.abstractNote = Zotero.Utilities.trim(abstract1.textContent); - - // Get volume, DOI, pages and year from the citation. It can appear in various places - - var citation1 = doc.evaluate('//div[@class="AbstractSummary"]/p[2]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(2); - if (citation1!=null) { - if (!citation1.textContent.match(/Citation:/)) - citation1 = null; - } - - if (citation1==null) { - citation1 = doc.evaluate('//div[@class="AbstractSummary"]/p[1]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if (citation1!=null) { - if (!citation1.textContent.match(/Citation:/)) - citation1 = null; - } - } - - if (citation1==null) { - citation1 = doc.evaluate('//div[@class="metacontainer"]/div[@class="metavalue"][2]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(2); - if (citation1!=null) { - if (!doc.evaluate('//div[@class="metacontainer"]/div[@class="metakey"][2]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(2).textContent.match(/Citation:/)) - citation1 = null; - } - } - - if (citation1==null) - citation1 = doc.evaluate('//div[@class="AbstractSummary"]/p',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(2); - - if (citation1.textContent.match(/Received/)) - citation1 = doc.evaluate('//div[@class="metacontainer"]/div[@class="metavalue"]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - - var citation = citation1.textContent; - - if (!(citation==null)) { - // DOI - var doipart = citation.split('doi:')[1]; - if (doipart!=null) - newItem.DOI = Zotero.Utilities.trim(doipart); - var citation2 = citation.match(/:([0-9]*)\./); - // If it has been recently released, there may be no page number - if (citation2!=null) - newItem.pages = citation2[1]; - var citation3 = citation.match(/\((20[0-9][0-9])\)/); - if(citation3!=null) - newItem.date = citation3[1]; - } - - // Look for keywords - var keywords1 = doc.evaluate('//div[@class="AbstractSummary"]/p[1]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if (keywords1!=null) { - if (!(keywords1.textContent.match(/Keywords/))) - keywords1 = null; - } - var withoutKeywordsColon = 0; - - if (keywords1==null) { - // In these articles, "Keyword:" appears inside a separate div - keywords1 = doc.evaluate('//div[@class="metacontainer"]/div[@class="metavalue"][1]',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - withoutKeywordsColon = 1; - } - - if (keywords1 != null) { - - var keywords = keywords1.textContent; - - if(!(keywords == null)) { - var keywordspart = "a,b"; - if (withoutKeywordsColon) - keywordspart = keywords; - else - keywordspart = Zotero.Utilities.trim(keywords.split('Keywords:')[1]); - var keywordsall = keywordspart.split(','); - for (i=0; i<keywordsall.length; i++) { - newItem.tags[i] = Zotero.Utilities.cleanTags(Zotero.Utilities.trim(keywordsall[i]), ""); - } - } - } - - var abbrev = doc.evaluate('//div[@class="AbstractSummary"]/p[2]/i',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - - if (abbrev==null) - abbrev = doc.evaluate('//div[@class="metacontainer"]/div[@class="metavalue"]/i',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - - if (!(abbrev==null)) - newItem.journalAbbreviation = Zotero.Utilities.trim(abbrev.textContent); - - var vol = doc.evaluate('//div[@class="AbstractSummary"]/p[2]/b',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - if (vol==null) - vol = doc.evaluate('//div[@class="metacontainer"]/div[@class="metavalue"]/b',doc,nsResolver,XPathResult.ANY_TYPE,null).iterateNext(); - - if (!(vol==null)) - newItem.volume = vol.textContent; - - var matches = doc.body.innerHTML.match(/downloadfile.aspx.fileid=([^']*)/); - - if (matches!=null) { - var pdfurl = 'http://www.frontiersin.org/journal/downloadfile.aspx?fileid=' + matches[1]; - newItem.attachments = [ - {url:pdfurl, title:"Full text PDF", mimeType:"application/pdf"} - ]; - } - newItem.complete(); -} diff --git a/translators/GPO Access e-CFR.js b/translators/GPO Access e-CFR.js @@ -1,107 +0,0 @@ -{ - "translatorID":"dede653d-d1f8-411e-911c-44a0219bbdad", - "translatorType":4, - "label":"GPO Access e-CFR", - "creator":"Bill McKinney", - "target":"^http://ecfr\\.gpoaccess\\.gov/cgi/t/text/text-idx.+", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-06-18 18:15:00" -} - -function detectWeb(doc, url) { - var re = new RegExp("^http://ecfr\.gpoaccess\.gov/cgi/t/text/text-idx"); - if(re.test(doc.location.href)) { - return "book"; - } else { - return "multiple"; - } -} - -function get_nextsibling(n) - { - var x=n.nextSibling; - while (x.nodeType!=1) - { - x=x.nextSibling; - } - return x; -} -function scrape(doc) { - - var newItem = new Zotero.Item("statute"); - newItem.url = doc.location.href; - var extraText = new String(); - var tmpSection = ""; - newItem.code = "Electronic Code of Federal Regulations"; - newItem.language = "en-us"; - - var spanTags = doc.getElementsByTagName("span"); - for(var i=0; i<spanTags.length; i++) { - if (spanTags[i].className == "mainheader") { - var tmpStr = spanTags[i].innerHTML; - tmpStr = tmpStr.replace(/\&nbsp;/g, " "); - tmpStr = tmpStr.replace(/\&\#167;/g, "Sec."); - newItem.codeNumber = tmpStr; - newItem.title = "e-CFR: " + tmpStr; - } - if (spanTags[i].className == "div5head") { - var tmpStr = spanTags[i].childNodes[0].innerHTML; - tmpStr = tmpStr.replace(/\&nbsp;/g, " "); - tmpStr = tmpStr.replace(/\&\#167;/g, "Sec."); - tmpSection = tmpStr; - } - } - - var heading5Tags = doc.getElementsByTagName("h5"); - for(var i=0; i<heading5Tags.length; i++) { - var tmpStr = heading5Tags[0].innerHTML; - tmpStr = tmpStr.replace(/\&nbsp;/g, " "); - tmpStr = tmpStr.replace(/\&\#167;/g, "Sec."); - if (tmpSection != "") { - tmpSection = tmpSection + " - "; - } - newItem.section = tmpSection + tmpStr; - break; - } - - // statutory source - var boldTags = doc.getElementsByTagName("b"); - for(var i=0; i<boldTags.length; i++) { - var s = new String(boldTags[i].innerHTML); - if (s.indexOf("Source:") > -1) { - newItem.history = "Source: " + boldTags[i].nextSibling.nodeValue; - } - if (s.indexOf("Authority:") > -1) { - newItem.extra = "Authority: " + boldTags[i].nextSibling.nodeValue; - } - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var re = new RegExp("http://ecfr\.gpoaccess\.gov/cgi/t/text/text-idx.+"); - if(re.test(doc.location.href)) { - scrape(doc); - } else { - var items = Zotero.Utilities.getItemArray(doc, doc,"http://ecfr\.gpoaccess\.gov/cgi/t/text/text-idx.+"); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var uris = new Array(); - for(var i in items) { - uris.push(i); - } - - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, - function() { Zotero.done(); }, null); - - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/GSA Journals Online.js b/translators/GSA Journals Online.js @@ -1,60 +0,0 @@ -{ - "translatorID":"70295509-4c29-460f-81a3-16d4ddbb93f6", - "translatorType":4, - "label":"GSA Journals Online", - "creator":"Michael Berkowitz", - "target":"http://www.gsajournals.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("request=search") != -1 || url.indexOf("request=get-toc") != -1) { - return "multiple"; - } else if (url.indexOf("request=get-abstract") != -1 || url.indexOf("request=get-document") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var results = doc.evaluate('//*[@class="group"]', doc, null, XPathResult.ANY_TYPE, null); - var next; - while (next = results.iterateNext()) { - var title = Zotero.Utilities.trimInternal(doc.evaluate('.//*[@class="title"]', next, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var link = doc.evaluate('.//a[1]', next, null, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i.replace(/get\-(abstract|document)/, "cite-builder")); - } - } else { - arts = [url.replace(/get\-(abstract|document)/, "cite-builder")]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var newurl = doc.evaluate('//a[contains(@href, "refman")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - var oldurl = doc.location.href; - Zotero.Utilities.HTTP.doGet(newurl, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.url = oldurl; - item.DOI = decodeURIComponent(item.url.match(/doi=([^&]+)/)[1]); - var pdfurl = 'http://www.gsajournals.org/perlserv/?request=res-loc&uri=urn:ap:pdf:doi:' + item.DOI; - item.attachments = [ - {url:item.url, title:"GSA Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"GSA Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }); - translator.translate(); - }); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/Gale - Cengage Learning.js b/translators/Gale - Cengage Learning.js @@ -1,141 +0,0 @@ -{ - "translatorID":"4ea89035-3dc4-4ae3-b22d-726bc0d83a64", - "translatorType":4, - "label":"Gale - Cengage Learning", - "creator":"Adam Crymble", - "target":"http://www.gale.cengage.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-24 05:30:00" -} - -function detectWeb(doc, url) { - - if (doc.evaluate('//td[3]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//div[@id="title_main"]/h2', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } - - - -} - -//Gale Cengage Learning - Catalog translator. Code by Adam Crymble. - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var titles1; - - var newItem = new Zotero.Item("book"); - - var credits = doc.evaluate('//div[@id="credits"]/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//div[@id="credits"]/ul/li)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var creditsArray = new Array(); - - for (var i = 0; i < xPathCount.numberValue; i++) { - creditsArray.push(credits.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - - if (doc.evaluate('//div[@id="title_main"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - titles1 = doc.evaluate('//div[@id="title_main"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - } - - if (titles1.match(/\w/) && creditsArray[0].match(/\w/)) { - newItem.title = titles1 + ": " + creditsArray[0]; - } else if (titles1.match(/\w/) && !creditsArray[0].match(/\w/)) { - newItem.title = titles1; - } else { - newItem.title = "No Title Found." - } - - for (var i = 1; i < creditsArray.length; i++) { - - if (creditsArray[i].match("Author ")) { - var author = creditsArray[i].split("Author "); - author = author[1]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else if (creditsArray[i].match("Published by ")) { - var publisher1 = creditsArray[i].split("Published by "); - newItem.publisher = publisher1[1]; - } else if (creditsArray[i].match("Volume")) { - var volume1 = creditsArray[i].split("Volume"); - newItem.volume = volume1[1]; - } - - } - - if (doc.evaluate('//div[@id="description"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate('//div[@id="description"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - var pageContents = doc.evaluate('//div[@id="detail"]/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var allContents = new Array(); - var contents; - var fieldTitle; - - while (contents = pageContents.iterateNext()) { - allContents.push(contents.textContent); - } - - for (i=0; i<allContents.length; i++) { - if (allContents[i].match(":")) { - contents = allContents[i].split(":"); - fieldTitle = contents[0].replace(/\s*/g, ''); - dataTags[fieldTitle] = contents[1]; - } - } - - associateData (newItem, dataTags, "ISBN10", "ISBN"); - if (dataTags["ISBN13"]) { - newItem.extra = "ISBN 13: " + dataTags["ISBN13"]; - } - associateData (newItem, dataTags, "Published/Released", "date"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//td[3]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Gale Literature Resource Center.js b/translators/Gale Literature Resource Center.js @@ -1,173 +0,0 @@ -{ - "translatorID":"84564450-d633-4de2-bbcc-451ea580f0d6", - "translatorType":4, - "label":"Gale Literature Resource Center", - "creator":"Simon Kornblith", - "target":"^https?://[^/]+/servlet/LitRC?(?:|.*&)srchtp=(?:adv)?mla(?:&|$)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.title.length <= 33 || doc.title.substr(0, 33) != "Literature Resource Center -- MLA") return false; - - if(url.indexOf("docNum=") != -1) { // article; - return "journalArticle"; - } else if(doc.evaluate('//tr[td/span[@class="stndxtralead"]]', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } - - return false; -} - -function extractCitation(type, citation) { - type = Zotero.Utilities.trimInternal(type).toLowerCase(); - citation = Zotero.Utilities.trimInternal(citation); - - if(type == "book article") { - var item = new Zotero.Item("bookSection"); - } else if(type == "book" || type == "book collection") { - var item = new Zotero.Item("book"); - } else if(type == "dissertation abstract") { - var item = new Zotero.Item("thesis"); - } else { - var item = new Zotero.Item("journalArticle"); - } - - var m; - if(item.itemType == "journalArticle" || item.itemType == "thesis") { - m = citation.match(/^(.+)\. "([^"]+)" (.+), ([0-9\:]*) ?\(([^\)]+)\)(?:, (?:pp\. ([\-0-9]+)|([\-0-9A-Z]+)))?/); - if(!m) return false; - - item.publicationTitle = m[3]; - var parts = m[4].split(":"); - if(parts.length == 2) { - item.volume = parts[0]; - item.issue = parts[1]; - } else { - item.issue = m[4]; - } - item.date = m[5]; - item.pages = m[6] ? m[6] : m[7]; - } else if(item.itemType == "book") { - m = citation.match(/^(.+)\. "([^"]+)" ([^:]+): ([^,]+), ([0-9]{4})\..*?(?:([0-9]+) pp\.)/); - if(!m) return false; - - item.place = m[3]; - item.publisher = m[4]; - item.date = m[5]; - item.pages = m[6]; - } else if(item.itemType == "bookSection") { - m = citation.match(/^(.+)\. "([^"]+)" pp\. ([\-0-9]+)\. (?:((?:[^\.]*|\([^\)]+\)| [A-Z]\.)*)\.)? ([^\(\)]+). ([^:]+): ([^,]+), ([0-9]{4})/); - if(!m) return false; - - Zotero.debug(m); - - item.pages = m[3]; - var bookAuthors = m[4].split(" and "); - for each(var bookAuthor in bookAuthors) { - var n = bookAuthor.match(/^([^,]+), ([^\(]+)(?: \(([^\)]+)\)?)?$/); - if(n) { - var type = (n[3] && n[3].toLowerCase().indexOf("ed.") != -1) ? "editor" : "author"; - item.creators.push({lastName:n[1], firstName:n[2], creatorType:type}) - } - } - item.publicationTitle = m[5]; - item.place = m[6]; - item.publisher = m[7]; - item.date = m[8]; - } - - // add creators - var creators = m[1].split("; "); - for each(var creator in creators) { - item.creators.push(Zotero.Utilities.cleanAuthor(creator, "author", true)); - } - if(m[2][m[2].length-1] == ".") { - item.title = m[2].substr(0, m[2].length-1); - } else { - item.title = m[2]; - } - - return item; -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var uri = doc.location.href; - if(url.indexOf("docNum=") != -1) { // article; - var citation = doc.evaluate('//td[b/text() = "Source Database:"] | //td[*/b/text() = "Source Database:"]', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext().innerHTML; - - // ugh - var parts = citation.split(/<\/CENTER>/i); - var citation = parts[parts.length-1]; - citation = citation.replace(/<script[^>]*>(?:.|[\r\n])*<\/script>/gi, ""); - citation = citation.replace(/<a[^>]*>(?:.|[\r\n])*<\/a>/gi, ""); - - // big enormous hack, but it works - var span = doc.createElement("span"); - span.innerHTML = citation; - citation = span.textContent; - - var citeM = citation.match(/^\s*([^\n]+)/); - var subjectM = citation.match(/Subject Terms:\s+([^\n]+)/); - var typeM = citation.match(/Document Type:\s+([^\n]+)/); - var issnM = citation.match(/ISSN:\s+([^\n]+)/); - - var item = extractCitation(typeM[1], citeM[1]); - item.tags = subjectM[1].split("; "); - - if(issnM) item.ISSN = issnM[1]; - - item.complete(); - } else { // search results - var items = new Array(); - - var tableRows = doc.evaluate('//tr[td/span[@class="stndxtralead"]]', doc, nsResolver, - XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - // Go through table rows - for(var i=0; i<tableRows.snapshotLength; i++) { - items[i] = doc.evaluate('./td/span[@class="stndxtralead"]//a', tableRows.snapshotItem(i), - nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - items[i] = items[i].substring(1, items[i].length-1); - } - - items = Zotero.selectItems(items); - if(!items) return true - - for(var i in items) { - var tableRow = tableRows.snapshotItem(i); - - var type = doc.evaluate('./td[3]/span[@class="stndxtralead"]', tableRow, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext().textContent; - var citation = doc.evaluate('./td/span[@class="stndxtralead"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var item = extractCitation(type, citation); - if(!item) continue; - - var terms = doc.evaluate('.//span[@class="mlasubjects"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(terms) { - // chop off "[Subject Terms: " and "]" - terms = terms.textContent; - terms = terms.substring(16, terms.length-2); - item.tags = terms.split("; "); - } - - item.complete(); - } - } -} -\ No newline at end of file diff --git a/translators/Gallica.js b/translators/Gallica.js @@ -1,266 +0,0 @@ -{ - "translatorID":"58ab2618-4a25-4b9b-83a7-80cd0259f896", - "translatorType":4, - "label":"Gallica", - "creator":"Sylvain Machefert", - "target":"^http://gallica\\.bnf\\.fr", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-02-20 10:40:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var indexSearch = url.toString().indexOf('http://gallica.bnf.fr/Search'); - var indexArk = url.toString().indexOf('http://gallica.bnf.fr/ark:'); - var indexSNE = url.toString().indexOf('http://gallica.bnf.fr/VisuSNE'); - - if (indexSearch == 0) - { - var errorXpath = '//div[@class="errorMessage"]'; - if (elt = doc.evaluate(errorXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - // We are on a search page result but it can be an empty result page. - // Nothing to return; - } - else - { - return "multiple"; - } - } - else if (indexArk == 0) - { - var iconxpath = '//div[@class="contenu1"]/img'; - if (elt = doc.evaluate(iconxpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - { - var icon = elt.getAttribute('src'); - return getDoctypeGallica(icon); - } - - // For some biblio, the icon picture is located in another div ... - var iconxpath = '//div[@class="titrePeriodiqueGauche"]/img'; - if (elt = doc.evaluate(iconxpath, doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext()) - { - var icon = elt.getAttribute('src'); - return getDoctypeGallica(icon); - } - } - else if (indexSNE == 0) - { - return "book"; - } -} - -// This function takes the name of the icon, and returns the Zotero item name -function getDoctypeGallica(img) -{ - var iconname = img.substring(img.lastIndexOf('/') + 1); - - if (iconname =='livre_a.png') - { - return "book"; - } - else if (iconname == 'carte.png') - { - return "map"; - } - else if (iconname == 'images.png') - { - return "artwork"; - } - else if (iconname == 'docsonore.png') - { - return "audioRecording"; - } - else if (iconname == 'musiquenotee.png') - { - // This icon is for Sheet music type. But no Zotero type matches - // as of today (2010-02) - return "book"; - } - else if ( (iconname == 'picto_type_document1.png') || (iconname == 'perio_vol_ocr.png') ) - { - return "book"; - } - else - { - Zotero.debug("Undefined icon : " + iconname); - return "book"; - } - -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (detectWeb(doc, url) == "multiple") - { - var availableItems = new Array(); - var xpath = '//div[@class="resultats_line"]'; - - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - - var itemsId = new Array(); - - var i = 1; - do { - var id = doc.evaluate('div[@class="resultat_id"]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var this_result = doc.evaluate('div[@class="resultat_desc"]/div[@class="titre"]/a', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - availableItems[i] = Zotero.Utilities.cleanTags(this_result.getAttribute('title')); - - i++; - } while (elmt = elmts.iterateNext()); - - var items = Zotero.selectItems(availableItems); - - for (var i in items) { - // All informations are available on search result page. We don't need to query - // every subpage with scrape. We'are going to call the special Gallica scrape function - // This function (scrapeGallica) is reused in scrape. - var fullpath = '//div[@class="resultats_line"][' + i + ']'; - - var item_element = doc.evaluate(fullpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (item_element != undefined) - { - var detail = doc.evaluate('.//div[@class="notice"]', item_element, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - var iconType = doc.evaluate('.//span[@class="picto"]/img', item_element, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var docType = getDoctypeGallica(iconType.getAttribute('src')); - - var docUrl = doc.evaluate('.//div[@class="liens"]/a', item_element, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - docUrl = docUrl.getAttribute("href"); - - scrapeGallica(doc, nsResolver, detail, docType, docUrl); - } - } - } - else - { - var docType = detectWeb(doc, url); - var xpath = '//div[@class="notice"]'; - var detail = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - scrapeGallica(doc, nsResolver, detail, docType, ""); - } -} - -function scrapeGallica(doc, nsResolver, div, type, direct_url) -{ - var item = new Zotero.Item; - item.itemType = type; - - var elmts = doc.evaluate('p', div, nsResolver, XPathResult.ANY_TYPE, null); - - var elmt = elmts.iterateNext(); - - do { - var text = Zotero.Utilities.trimInternal(elmt.textContent); - var contenu = ''; - if (contenu = text.split(/^(Titre|Title|Título) : /)[2]) - { - item.title = Zotero.Utilities.trimInternal(contenu); - } - else if ( contenu = text.split(/^(Auteur|Author|Autor) : /)[2]) - { - contenu = contenu.replace(/(See only the results matching this author|Ne voir que les résultats de cet auteur)/, ''); - if (type == 'artwork') - { - item.creators.push(Zotero.Utilities.cleanAuthor(contenu, "artist", true)); - } - else - { - item.creators.push(Zotero.Utilities.cleanAuthor(contenu, "author", true)); - } - } - else if ( contenu = text.split(/^(Publisher|Éditeur|Editor) : /)[2]) - { - item.publisher = Zotero.Utilities.trimInternal(contenu); - } - else if ( contenu = text.split(/^(Date of publication|Date d'édition|Data de publicação|Fecha de publicación) : /)[2]) - { - item.date = Zotero.Utilities.trimInternal(contenu); - } - else if ( contenu = text.split(/^(Contributeur|Contributor|Contribuidor) : /)[2]) - { - item.creators.push(Zotero.Utilities.cleanAuthor(contenu, "contributor", true)); - } - else if ( contenu = text.split(/^(Language|Langue|Língua|Idioma) : /)[2]) - { - item.language = Zotero.Utilities.trimInternal(contenu); - } - else if ( contenu = text.split(/^(Format|Formato) : /)[2]) - { - // This field contains : application/pdf for example. - } - else if ( contenu = text.split(/^(Copyright|Droits|Direitos) : /)[2]) - { - item.rights = Zotero.Utilities.trimInternal(contenu); - } - else if (contenu = text.split(/^(Identifier|Identifiant|Senha) : /)[2]) - { - var temp = ''; - if (temp = contenu.split(/^ISSN /)[1]) - { - item.ISSN = temp; - } - else if (contenu.match(/^http:\/\//)) - { - // If identifier starts with http it is the url of the document - item.url = contenu; - } - else if (contenu.match(/^ark:/)) - { - item.url = "http://gallica.bnf.fr/" + contenu; - } - } - else if (contenu = text.split(/^(Description|Descrição) : /)[2]) - { - var temp = ''; - if (temp = contenu.split(/^Variante\(s\) de titre : /)[1]) - { - // Alternative title : no field in zotero ? - // Zotero.debug("Titre : " + temp); - } - else if (temp = contenu.split(/^Collection : /)[1]) - { - item.collection = temp; - } - else - { -// Zotero.debug(contenu); - } - } - else if (contenu = text.split(/^(Sujet|Assunto|Tema|Subject) : /)[2]) - { - - var tagList = contenu.split(/; ?/); - for (var tag in tagList) - { - item.tags.push(Zotero.Utilities.trimInternal(tagList[tag])); - } - } - - } while (elmt = elmts.iterateNext()); - - if ( (item.url == "") || (item.url == undefined) ) - { - if (direct_url != "") - { - item.url = "http://gallica.bnf.fr" + direct_url; - } - else - { - item.url = doc.location.href; - } - } - item.complete(); -} diff --git a/translators/Gasyrlar Awazy.js b/translators/Gasyrlar Awazy.js @@ -1,42 +0,0 @@ -{ - "translatorID": "8afd6209-ef61-4e64-ae6c-3b2d6f71aa50", - "label": "Гасырлар авазы / Эхо веков", - "creator": "Avram Lyon", - "target": "^https?://www\\.archive\\.gov\\.tatarstan\\.ru/magazine/go/anonymous/main/\\?path=mg:/", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-24 00:50:46" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};function detectWeb(doc, url) { -if (url.match(/numbers\/\d{4}[^/]*\/[\d_]+\/[\d_]+\/?$/)) { -return FW.detectWeb(doc, url); -} -return false; // no multi now -} -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ itemType : 'journalArticle', - detect : FW.Xpath('//span[@class="bt1b"]').text(), - title : FW.Xpath('//span[@class="bt1b"]').text().trim(), - attachments : [ { - url : FW.Url(), - type : "text/html", - title : "Echo of the Ages Snapshot" - }], - creators : FW.Xpath('//td[p[@align="justify"]]/p[@align="right"]').text().remove(/,[^,]*(доктор|кандидат|специалист|аспирант)[^,]*/g).split(',').cleanAuthor("author"), - date : FW.Xpath('//td[span[@class="bt1b"]]/a[1]').text().match(/([0-9]{4})/), - issue : FW.Xpath('//td[span[@class="bt1b"]]/a[1]').text().match(/([0-9]{4})(.*)/,2), - section : FW.Xpath('//td[span[@class="bt1b"]]/a[2]').text(), - publicationTitle : "Гасырлар авазы / Эхо веков" }); - -/** Search results -FW.MultiScraper({ itemType : "multiple", -detect : !FW.Url().match(/numbers\/\d{4}[^/]*\/\d+\/\d+\/?$/), -titles : FW.Xpath('//a').text().replace(/numbers\/\d{4}[^/]*\/\d+\/\d+\/?$/), -urls : FW.Xpath('//ul[@class="results-list"]//h3/a').key('href').text() }); -*/ diff --git a/translators/GeneOntology.org.js b/translators/GeneOntology.org.js @@ -1,114 +0,0 @@ -{ - "translatorID":"cee0cca2-e82a-4618-b6cf-16327970169d", - "translatorType":4, - "label":"Gene Ontology", - "creator":"Amelia Ireland", - "target":"^https?:\/\/.*\\.geneontology\\.org", - "minVersion":"2.0", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2011-01-27 21:28:58" -} - -/* - Gene Ontology website translator - Copyright (C) 2010-2011 girlwithglasses, amelia.ireland@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 works on cited PubMed references on the Gene Ontology website. - - It makes use of the code of the existing PubMed translator; thanks to the - authors of that translator for their premium quality code. -*/ - -var items = {}; -var selectArray = {}; - - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var xPath = '//cite//*[@class="pmid"] | //cite//a[contains (@href, "pubmed")]'; - var cites = doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if (cites) - { Zotero.debug("Found some cites!"); - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var myPMID = '//cite//*[@class="pmid"] | //cite//a[contains (@href, "pubmed")]'; - var pmids = doc.evaluate(myPMID, doc, nsResolver, XPathResult.ANY_TYPE, null); - var pmid_list = new Array(); - var unknown_list = new Array(); - var x; - while (x = pmids.iterateNext()) { - if (x.href && x.href.match('pubmed')) { - // get the number - var n = x.href.lastIndexOf("/"); - n++; - pmid_list.push(x.href.substr(n)); -// Zotero.debug("Got a pubmed href! " + x.href.substr(n)); - } - else { - unknown_list.push(x); - } - } - if (unknown_list.length > 0) { -// Zotero.debug("Couldn't work out what to do with these refs: " + unknown_list.join("\n")); - } - if (pmid_list.length > 0) { - Zotero.debug( "Found " + pmid_list.length + " PMIDs!" ); - } - // get the data from the NCBI server - var pmids = pmid_list.join(","); - var url = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&retmode=xml&id=" + pmids; - - Zotero.Utilities.HTTP.doGet(url, function(text) { - // load translator for PubMed - var translator = Zotero.loadTranslator("import"); -// var translator = Zotero.Translate.Import; - translator.setTranslator("fcf41bed-0cbc-3704-85c7-8062a0068a7a"); - translator.setString(text); - - // don't save when item is done - translator.setHandler("itemDone", function(obj, item) { - items[item.extra] = item; - selectArray[item.extra] = item.title; - }); - - translator.translate(); - - // all pmids retrieved now - selectArray = Zotero.selectItems(selectArray); - for(var PMID in selectArray) { - items[PMID].complete(); - } - - Zotero.done(); - }); - Zotero.wait(); -} diff --git a/translators/Getty Research Library Catalog.js b/translators/Getty Research Library Catalog.js @@ -1,255 +0,0 @@ -{ - "translatorID":"f87c10fe-2bdc-4e1e-aedd-7fd20ec4b4c2", - "translatorType":4, - "label":"Getty Research Library Catalog", - "creator":"Adam Crymble", - "target":"http://(opac.pub|library).getty.edu", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-21 15:45:00" -} - -function detectWeb(doc, url) { - - var multiCheck = ''; - - if (doc.evaluate('//table/tbody/tr/td[1]/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - - multiCheck = doc.evaluate('//table/tbody/tr/td[1]/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - var callNumSearch = ''; - if (doc.evaluate('//table/tbody/tr/th[2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - callNumSearch = doc.evaluate('//table/tbody/tr/th[2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - if (callNumSearch.match("Call Number")) { - return "multiple"; - } - - if (multiCheck.match("Sort by:")) { - return "multiple"; - } - - if (doc.evaluate('//table[2]/tbody/tr/th', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.match("Author:")) { - return "book"; - } else if (doc.evaluate('//tr/th/font/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } else if (doc.evaluate('//tr/th/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -//Getty Research Library Catalog translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - - var fieldContent = new Array(); - var fieldExtra = new Array(); - var tagsContent = new Array(); - var multis = new Array(); - - var content1; - var extra1; - var multi1; - - var newItem = new Zotero.Item("book"); - - var multiLineEntry = doc.evaluate('//table[2]/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (multi1 = multiLineEntry.iterateNext()) { - multis.push(multi1.textContent); - } - - //Puts field Content into an array - var contents = doc.evaluate('//table[2]/tbody/tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (content1 = contents.iterateNext()) { - if (content1.textContent.match(/\w/)) { - fieldContent.push(content1.textContent.replace(/^\s*|\s*&/g, '')); - } - } - - //Entries that do not line up perfectly with a field heading are put into an array and these are then removed from the field Content array. - var extraField = doc.evaluate('//table[2]/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (extra1 = extraField.iterateNext()) { - if (extra1.textContent.match(/\w/)) { - fieldExtra.push(extra1.textContent.replace(/^\s*|\s*&/g, '')); - } - } - - var duplicates = new Array(); - for (var i = 0; i < fieldContent.length; i++) { - for (var j = 0; j < fieldExtra.length; j++) { - if (fieldContent[i] == fieldExtra[j]) { - duplicates.push(i); - } - } - } - var cleanContent = new Array(); - - for (var i = duplicates.length-1; i > -1; i --) { - - fieldContent[duplicates[i]-1] = fieldContent[duplicates[i]-1] + "; " + fieldContent[duplicates[i]]; - fieldContent[duplicates[i]] = ''; - } - - for (var i = 0; i < fieldContent.length-1; i++) { - if (fieldContent[i].match(/\w/)) { - cleanContent.push(fieldContent[i]); - } - } - - var headers = doc.evaluate('//form/table/tbody/tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null); - - //field title and cleancontent have the same number of entries; These are then associated and put into dataTags object. - for (var i = 0; i < cleanContent.length; i++) { - fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, ''); - if (fieldTitle.match(/\w/)) { - - } else { - fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, ''); - } - dataTags[fieldTitle] = cleanContent[i]; - - } - - //The data is all now in the dataTags object. It needs only to be formatted and put in the proper Zotero fields. - - //fixing up any content that needs a different format for Zotero and then pushing it into Zotero. - if (dataTags["Notes:"]) { - if (dataTags["Notes:"].match("; ")) { - var notes1 = dataTags["Notes:"].split("; "); - var notes2 = ''; - - for (var i = 0; i < notes1.length; i++) { - - if (notes2.match(/\w/)) { - notes2 = notes2 + "; " + notes1[i]; - } else { - notes2 = notes1[i]; - } - } - dataTags["Notes:"] = notes2; - } - } - - if (dataTags["Subjects:"]) { - if (dataTags["Subjects:"].match("; ")) { - tagsContent = dataTags["Subjects:"].split("; "); - } else { - newItem.tags = dataTags["Subjects:"]; - var noMoreTags = 1; - } - if (noMoreTags != 1) { - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - } - } - - if (dataTags["Author:"]) { - if (dataTags["Author:"].match(", ")) { - var author = dataTags["Author:"].split(', '); - author = author[1].substr(0, author[1].length) + " " + author[0]; - author = author.replace(/\./, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - - if (dataTags["CorporateAuthor:"]) { - newItem.creators.push({lastName: dataTags["CorporateAuthor:"], creatorType: "creator"}); - } - - if (dataTags["Location:"]) { - newItem.extra = "Location in Library: " + " " + dataTags["Location:"]; - } - - if (dataTags["PersistentLinkforthisRecord:"]) { - associateData (newItem, dataTags, "PersistentLinkforthisRecord:", "url"); - } else { - newItem.url = doc.location.href; - } - - //Publishing info is split in a best guess format. - //If not all of Place, Publisher and Date are present, or they are in an unstandard format, the information is stored in Publisher. - if (dataTags["PublicationInformation:"]) { - if (dataTags["PublicationInformation:"].match(": ")) { - var colon = dataTags["PublicationInformation:"].indexOf(":"); - var place1 = dataTags["PublicationInformation:"].substr(0, colon); - newItem.place = place1; - var publisher1 = dataTags["PublicationInformation:"].substr(colon); - if (publisher1.match(", ")) { - var date1 = publisher1.split(", "); - newItem.publisher = date1[0]; - if (date1[1].match(/\d/)) { - newItem.date = date1[1]; - } - } else { - newItem.date = publisher1; - } - } else { - newItem.publisher = dataTags["PublicationInformation:"]; - } - } - - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "Series:", "series"); - associateData (newItem, dataTags, "Description:", "description"); - associateData (newItem, dataTags, "ISBN:", "ISBN"); - associateData (newItem, dataTags, "Notes:", "abstractNote"); - associateData (newItem, dataTags, "CallNumber:", "callNumber"); - associateData (newItem, dataTags, "Edition:", "edition"); - - newItem.notes.push({title:"Title", note:"Site is designed to timeout user. This may prevent Zotero from saving a screen capture."}); - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var typeOfPage = doc.evaluate('//table/tbody/tr/th[3]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - Zotero.debug(typeOfPage); - - if (typeOfPage.match("Title")) { - var titles = doc.evaluate('//table/tbody/tr/td[3]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } else { - var titles = doc.evaluate('//table[2]/tbody/tr/td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Glenbow Library.js b/translators/Glenbow Library.js @@ -1,265 +0,0 @@ -{ - "translatorID":"330f283f-12e9-4421-aa59-e17ec5f4aa37", - "translatorType":4, - "label":"Glenbow Library", - "creator":"Adam Crymble", - "target":"http://ww2.glenbow.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-21 15:45:00" -} - -function detectWeb(doc, url) { - - if (doc.title.match("Library Main Catalogue Search Results") && doc.location.href.match("GET_RECORD")) { - return "book"; - } else if - (doc.title.match("Library Map Collection Search Results") && doc.location.href.match("GET_RECORD")) { - return "map"; - - } else if - (doc.title.match("Library Main Catalogue Search Results") && !(doc.location.href.match("GET_RECORD"))) { - return "multiple"; - } else if - (doc.title.match("Map Collection Search Results") && !(doc.location.href.match("GET_RECORD"))) { - return "multiple"; - } -} - -//Translator for the Glenbow Museum Collection. Code by Adam Crymble -//Only works for Library Main Catalogue and Map Collection. The other categories do not have stable URLs for individual entries. - - -function associateContent (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - } : null; - - var fieldTitle = new Array(); - var tagsContent = new Array(); - - if (detectWeb(doc, url) == "book") { - - newItem = new Zotero.Item("book"); - authorType= "author"; - - } else if (detectWeb(doc, url) == "map") { - - newItem = new Zotero.Item("map"); - authorType= "cartographer"; - } - - var dataTags= new Object(); - var authorType; - var organizeName; - - if (doc.evaluate('//tr/td/p', doc, nsResolver, XPathResult.ANY_TYPE, null)) { - var xPathContent = doc.evaluate('//tr/td/p', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//tr/td/p)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (var i = 0; i < xPathCount.numberValue; i++) { - - fieldTitle= xPathContent.iterateNext().textContent; - - var separate = fieldTitle.indexOf(":"); - var fieldTitle1 = fieldTitle.substr(0, separate); - fieldTitle1 = fieldTitle1.replace(/\s+/g, ''); - - var fieldContent = fieldTitle.substr(separate + 2); - - dataTags[fieldTitle1] = (fieldContent); - - } - - - //names start - if (dataTags["Names"]) { - - //if there are multiple authors: - if (dataTags["Names"].match("\n")) { - var multipleNames = dataTags["Names"].split("\n"); - - for (j = 0; j < multipleNames.length; j++) { - if (detectWeb(doc, url) == "book") { - multipleNames[j] = multipleNames[j].substr(3); - - } else if (detectWeb(doc, url) == "map") { - multipleNames[j] = multipleNames[j]; - } - - if (multipleNames[j].match(/\,/)) { - - organizeName = multipleNames[j].split(","); - organizeName = (organizeName[1] + (" ") + organizeName[0]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(organizeName, authorType)); - - } else { - newItem.creators.push({lastName: multipleNames[j], creatorType: authorType}); - } - - } - - //if there is 1 human author - } else if (dataTags["Names"].match(/\,/)) { - if (detectWeb(doc, url) == "book") { - var organizeName = dataTags["Names"].substr(3).split(","); - - } else if (detectWeb(doc, url) == "map") { - var organizeName = dataTags["Names"].split(","); - } - - organizeName = (organizeName[1] + (" ") + organizeName[0]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(organizeName,authorType)); - - //if there is 1 corporate author - } else { - if (detectWeb(doc, url) == "book") { - newItem.creators.push({lastName: dataTags["Names"].substr(3), creatorType: authorType}); - - } else if (detectWeb(doc, url) == "map") { - newItem.creators.push({lastName: dataTags["Names"], creatorType: authorType}); - - } - } - } - - //tags start - if (dataTags["Subjects"]) { - if (dataTags["Subjects"].match("\n")) { - var multipleSubjects= dataTags["Subjects"].split("\n"); - - for (j = 0; j < multipleSubjects.length; j++) { - multipleSubjects[j] = multipleSubjects[j].substr(3); - tagsContent.push(Zotero.Utilities.cleanTags(multipleSubjects[j])); - } - } else { - dataTags["Subjects"] = dataTags["Subjects"].substr(3); - tagsContent.push(Zotero.Utilities.cleanTags(dataTags["Subjects"])); - } - - for (var y = 0; y < tagsContent.length; y++) { - newItem.tags[y] = tagsContent[y]; - } - } - - //book publisher info start - if (dataTags["PublishingInformation"]) { - dataTags["PublishingInformation"] = dataTags["PublishingInformation"].replace(/\[|\]*/g, ''); - - var pubLoc= dataTags["PublishingInformation"].split(":"); - if (pubLoc[1]) { - dataTags["Place"] = pubLoc[0]; - - var pubAndDate = pubLoc[1].split(","); - dataTags["Publisher"] = pubAndDate[0]; - dataTags["Date"] = pubAndDate[1]; - } else { - associateContent (newItem, dataTags, "PublishingInformation", "date"); - } - } - - //accession number start - if (dataTags["Accessionnumber"]) { - - dataTags["Accessionnumber"] = ("Accession number: " + dataTags["Accessionnumber"]); - } - - if (dataTags["CallNumber"]) { - if (dataTags["CallNumber"] == ' ') { - dataTags["CallNumber"] = "None"; - Zotero.debug(dataTags["CallNumber"]); - } - } - } - associateContent (newItem, dataTags, "CallNumber", "callNumber"); - associateContent (newItem, dataTags, "Title", "title"); - associateContent (newItem, dataTags, "Place", "place"); - associateContent (newItem, dataTags, "Publisher", "publisher"); - associateContent (newItem, dataTags, "Date", "date"); - associateContent (newItem, dataTags, "Description", "pages"); - associateContent (newItem, dataTags, "Edition", "edition"); - associateContent (newItem, dataTags, "Notes", "abstractNote"); - associateContent (newItem, dataTags, "Accessionnumber", "extra"); - associateContent (newItem, dataTags, "Scale", "scale"); - - newItem.url = doc.location.href; - if (!newItem.title) newItem.title = "New Search Terms Suggested" - newItem.complete(); -} - -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 dataTags = new Object(); - var titleList = new Array(); - var uris = new Array(); - var next_title= new Array(); - - if (detectWeb(doc, url) == "multiple") { - - //checks multiple entries for a link to a single entry page. - if (doc.evaluate('//td/div[@class="floatRight"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null)) { - - var items = new Object(); - var titles = doc.evaluate('//td/p', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var xPathMultiCount = doc.evaluate('count (//td/p)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - - for (var i = 0; i < xPathMultiCount.numberValue; i++) { - - articles= titles.iterateNext().textContent; - - var separateMulti = articles.indexOf(":"); - var articles1 = articles.substr(0, separateMulti); - articles1 = articles1.replace(/\s+/g, ''); - - var multiContent = articles.substr(separateMulti + 2); - - dataTags[articles1] = (multiContent); - - if (articles1 == "Title") { - titleList.push(dataTags["Title"]); - } - if (articles1 == "See") { - titleList.push("skip"); - } - } - var links = doc.evaluate('//td/div[@class="floatRight"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathLinksCount = doc.evaluate('count (//td/div[@class="floatRight"]/a)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathLinksCount.numberValue; i++) { - next_title.push(links.iterateNext().href); - if (titleList[i] != "skip") { - items[next_title] = titleList[i]; - } - } - - items = Zotero.selectItems(items); - - for (var i in items) { - uris.push(i); - } - - } - -//code if single entry only. - } else { - uris = [url]; - } - - Zotero.Utilities.processDocuments(uris, scrape, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Gmail.js b/translators/Gmail.js @@ -1,48 +0,0 @@ -{ - "translatorID":"58a778cc-25e2-4884-95b3-6b22d7571183", - "translatorType":4, - "label":"Gmail", - "creator":"Michael Berkowitz", - "target":"http://mail.google.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-17 19:30:00" -} - -function detectWeb(doc, url) { - if (url.match(/#inbox\/[\w\d]+/)) { - return "document"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var scripts = doc.evaluate('//script', doc, ns, XPathResult.ANY_TYPE, null); - var script; - var text = ""; - while (script = scripts.iterateNext()) { - text += script.textContent; - } - var ik = text.match(/ID_KEY:\"([^"]+)\"/)[1] - var th = url.match(/#inbox\/(.*)$/)[1]; - var newurl = 'http://mail.google.com/mail/?ui=2&ik=' + ik + '&view=om&th=' + th; - Zotero.Utilities.HTTP.doGet(newurl, function(text) { - var item = new Zotero.Item("email"); - var to = text.match(/\nTo:\s+([^\n]+)\n/)[1]; - item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(to.replace(/<.*>/g, "")), "recipient")); - var from = text.match(/\nFrom:\s+([^\n]+)\n/)[1]; - item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(from.replace(/<.*>/g, "")), "author")); - item.date = text.match(/\nDate:\s+(.*,\s+\d+\s+\w+\s+\d{4})/)[1]; - item.subject = text.match(/\nSubject:\s+([^\n]+)/)[1]; - if (item.subject == "") item.subject = "<No Subject>"; - item.title = item.subject; - item.complete(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Google Blogs.js b/translators/Google Blogs.js @@ -1,76 +0,0 @@ -{ - "translatorID": "58641ca2-d324-445b-a618-4e7c4631726f", - "label": "Google Blogs", - "creator": "Avram Lyon", - "target": "^https?://www\\.google\\.[^/]+/.*[#&]tbm=blg", - "minVersion": "2.1.8", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "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"; -} - -function doWeb(doc, url) { - if (ZU === undefined) { - var ZU = {}; - ZU.xpath = function (node, xpath, ns) { - var nodes = []; - var i; - var result = doc.evaluate(xpath, node, ns, XPathResult.ANY_TYPE, null); - while (i = result.iterateNext()) nodes.push(i); - if (nodes.length > 0) return nodes; - return null; - } - } - - var list = ZU.xpath(doc, '//div[@id="search"]//ol[@id="rso"]/li/div[@class="vsc"]'); - var i, node; - var items = []; - var names = {}; - for (i in list) { - items[i] = new Zotero.Item("blogPost"); - link = ZU.xpath(list[i], './span/h3/a')[0]; - names[i] = link.textContent; - items[i].title = link.textContent; - items[i].url = link.href; - items[i].attachments.push({url:link.href, - title:"Blog Snapshot", - mimeType:"text/html"}); - items[i].blogTitle = ZU.xpath(list[i], './/cite/a')[0].textContent; - node = ZU.xpath(list[i], './/div[@class="f kb"]')[0].textContent.match(/^(.*) by (.*)$/); - if (node) { - items[i].date = node[1]; - items[i].creators.push(Zotero.Utilities.cleanAuthor(node[2], "author")); - } - } - - Zotero.selectItems(names, function(names) { - var j; - for (j in names) { - items[j].complete(); - } - }); -} diff --git a/translators/Google Books.js b/translators/Google Books.js @@ -1,447 +0,0 @@ -{ - "translatorID": "3e684d82-73a3-9a34-095f-19b112d88bbf", - "label": "Google Books", - "creator": "Simon Kornblith, Michael Berkowitz and Rintze Zelle", - "target": "^http://(books|www)\\.google\\.[a-z]+(\\.[a-z]+)?/books(?:\\/.*)?\\?(.*id=.*|.*q=.*)", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-01 13:31:22" -} - -/* -The various types of Google Books URLs are: - -Search results - List view -http://books.google.com/books?q=asimov&btnG=Search+Books - -Search results - Cover view -http://books.google.com/books?q=asimov&btnG=Search%20Books&rview=1 - -Single item - URL with "id" -http://books.google.com/books?id=skf3LSyV_kEC&source=gbs_navlinks_s -http://books.google.com/books?hl=en&lr=&id=Ct6FKwHhBSQC&oi=fnd&pg=PP9&dq=%22Peggy+Eaton%22&ots=KN-Z0-HAcv&sig=snBNf7bilHi9GFH4-6-3s1ySI9Q#v=onepage&q=%22Peggy%20Eaton%22&f=false - -Single item - URL with "vid" (see http://code.google.com/apis/books/docs/static-links.html) -http://books.google.com/books?printsec=frontcover&vid=ISBN0684181355&vid=ISBN0684183951&vid=LCCN84026715#v=onepage&q&f=false - -*/ - -var singleRe = /^http:\/\/(?:books|www)\.google\.[a-z]+(?:\.[a-z]+)?\/books(?:\/.*)?\?(?:.*&)?(id|vid)=([^&]+)/i; - -function detectWeb(doc, url) { - if(singleRe.test(url)) { - return "book"; - } else { - return "multiple"; - } -} - -var itemUrlBase; -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // get local domain suffix - var psRe = new RegExp("https?://(books|www)\.google\.([^/]+)/"); - var psMatch = psRe.exec(url); - var suffix = psMatch[2]; - var prefix = psMatch[1]; - itemUrlBase = "http://"+prefix+".google."+suffix+"/books?id="; - - var m = singleRe.exec(url); - if(m && m[1] == "id") { - ZU.doGet("http://books.google.com/books/feeds/volumes/"+m[2], parseXML, function() { Z.done() }); - } else if (m && m[1] == "vid") { - var itemLinkWithID = ZU.xpath(doc, '/html/head/link[@rel="canonical"]')[0].href; - var m = singleRe.exec(itemLinkWithID); - ZU.doGet("http://books.google.com/books/feeds/volumes/"+m[2], parseXML, function() { Z.done() }); - } else { - var items = getItemArrayGB(doc, doc, 'google\\.' + suffix + '/books\\?id=([^&]+)', '^(?:All matching pages|About this Book|Table of Contents|Index)'); - // Drop " - Page" thing - //Zotero.debug(items); - for(var i in items) { - items[i] = items[i].replace(/- Page [0-9]+\s*$/, ""); - } - Zotero.selectItems(items, function(items) { - if(!items) Z.done(); - - var newUris = []; - for(var i in items) { - var m = singleRe.exec(i); - newUris.push("http://books.google.com/books/feeds/volumes/"+m[2]); - } - ZU.doGet(newUris, parseXML, function() { Z.done() }); - }); - } - - Z.wait(); -} - -function parseXML(text) { - // Remove xml parse instruction and doctype - var parser = new DOMParser(); - var xml = parser.parseFromString(text, "text/xml").documentElement; - - var ns = {"dc":"http://purl.org/dc/terms", - "atom":"http://www.w3.org/2005/Atom"}; - - var newItem = new Zotero.Item("book"); - - var authors = ZU.xpath(xml, "dc:creator", ns); - for (var i in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i].textContent, "author")); - } - - var pages = ZU.xpathText(xml, "dc:format", ns); - const pagesRe = /(\d+)( pages)/; - var pagesMatch = pagesRe.exec(pages); - if (pagesMatch!=null) { - newItem.numPages = pagesMatch[1]; - } else { - newItem.numPages = pages; - } - - var ISBN; - const ISBN10Re = /(ISBN:)(\w{10})$/; - const ISBN13Re = /(ISBN:)(\w{13})$/; - var identifiers = ZU.xpath(xml, "dc:identifier", ns); - for (var i in identifiers) { - var ISBN10Match = ISBN10Re.exec(identifiers[i].textContent); - var ISBN13Match = ISBN13Re.exec(identifiers[i].textContent); - if (ISBN10Match != null) { - ISBN = ISBN10Match[2]; - } - if (ISBN13Match != null) { - ISBN = ISBN13Match[2]; - } - } - newItem.ISBN = ISBN; - - newItem.publisher = ZU.xpathText(xml, "dc:publisher", ns); - newItem.title = ZU.xpathText(xml, "dc:title", ns, ": "); - newItem.language = ZU.xpathText(xml, 'dc:language', ns); - newItem.abstractNote = ZU.xpathText(xml, 'dc:description', ns); - newItem.date = ZU.xpathText(xml, "dc:date", ns); - - var url = itemUrlBase + identifiers[0].textContent; - newItem.attachments = [{title:"Google Books Link", snapshot:false, mimeType:"text/html", url:url}]; - - var subjects = ZU.xpath(xml, 'dc:subject', ns); - for(var i in subjects) { - newItem.tags.push(subjects[i].textContent); - } - - newItem.complete(); -} - -/** - * Grabs items based on URLs, modified for Google Books - * - * @param {Document} doc DOM document object - * @param {Element|Element[]} inHere DOM element(s) to process - * @param {RegExp} [urlRe] Regexp of URLs to add to list - * @param {RegExp} [urlRe] Regexp of URLs to reject - * @return {Object} Associative array of link => textContent pairs, suitable for passing to - * Zotero.selectItems from within a translator - */ -function getItemArrayGB (doc, inHere, urlRe, rejectRe) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var availableItems = new Object(); // Technically, associative arrays are objects - - // Require link to match this - if(urlRe) { - if(urlRe.exec) { - var urlRegexp = urlRe; - } else { - var urlRegexp = new RegExp(); - urlRegexp.compile(urlRe, "i"); - } - } - // Do not allow text to match this - if(rejectRe) { - if(rejectRe.exec) { - var rejectRegexp = rejectRe; - } else { - var rejectRegexp = new RegExp(); - rejectRegexp.compile(rejectRe, "i"); - } - } - - if(!inHere.length) { - inHere = new Array(inHere); - } - - for(var j=0; j<inHere.length; j++) { - var coverView = doc.evaluate('//div[@class="thumbotron"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();//Detect Cover view - if(coverView){ - var links = inHere[j].getElementsByTagName("a"); - for(var i=0; i<links.length; i++) { - if(!urlRe || urlRegexp.test(links[i].href)) { - var text = links[i].textContent; - if(!text) { - var text = links[i].firstChild.alt; - } - if(text) { - text = Zotero.Utilities.trimInternal(text); - if(!rejectRe || !rejectRegexp.test(text)) { - if(availableItems[links[i].href]) { - if(text != availableItems[links[i].href]) { - availableItems[links[i].href] += " "+text; - } - } else { - availableItems[links[i].href] = text; - } - } - } - } - } - } - else { - var links = inHere[j].getElementsByTagName("img");//search for <img>-elements, scrape title from alt-attribute, href-link from parent <a>-element - for(var i=0; i<links.length; i++) { - if(!urlRe || urlRegexp.test(links[i].parentNode.href)) { - var text = links[i].alt; - if(text) { - text = Zotero.Utilities.trimInternal(text); - if(!rejectRe || !rejectRegexp.test(text)) { - if(availableItems[links[i].href]) { - if(text != availableItems[links[i].href]) { - availableItems[links[i].href] += " "+text; - } - } else { - availableItems[links[i].parentNode.href] = text; - } - } - } - } - } - } - } - - return availableItems; -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://books.google.com/books?q=asimov&btnG=Search+Books", - "items": "multiple" - }, - { - "type": "web", - "url": "http://books.google.com/books?q=asimov&btnG=Search%20Books&rview=1", - "items": "multiple" - }, - { - "type": "web", - "url": "http://books.google.com/books?id=skf3LSyV_kEC&source=gbs_navlinks_s", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Rubén", - "lastName": "Pelayo", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Garcia Marquez, Gabriel - Criticism and interpretation", - "Literary Criticism / Caribbean & Latin American", - "Literary Criticism / European / Spanish & Portuguese", - "Literary Criticism / Caribbean & Latin American" - ], - "seeAlso": [], - "attachments": [ - { - "title": "Google Books Link", - "snapshot": false, - "mimeType": "text/html", - "url": false - } - ], - "numPages": "208", - "ISBN": "9780313312601", - "publisher": "Greenwood Publishing Group", - "title": "Gabriel García Márquez: a critical companion", - "language": "en", - "abstractNote": "Winner of the Nobel Prize for Literature in 1982 for his masterpiece One Hundred Years of Solitude, Gabriel Garcia Marquez had already earned tremendous respect and popularity in the years leading up to that honor, and remains, to date, an active and prolific writer. Readers are introduced to Garcia Marquez with a vivid account of his fascinating life; from his friendships with poets and presidents, to his distinguished career as a journalist, novelist, and chronicler of the quintessential Latin American experience. This companion also helps students situate Garcia Marquez within the canon of Western literature, exploring his contributions to the modern novel in general, and his forging of literary techniques, particularly magic realism, that have come to distinguish Latin American fiction. Full literary analysis is given for One Hundred Years of Solitude, as well as Chronicle of a Death Foretold (1981), Love in the Time of Cholera (1985), two additional novels, and five of Garcia Marquez's best short stories. Students are given guidance in understanding the historical contexts, as well as the characters and themes that recur in these interrelated works. Narrative technique and alternative critical perspectives are also explored for each work, helping readers fully appreciate the literary accomplishments of Gabriel Garcia Marquez.", - "date": "2001", - "libraryCatalog": "Google Books", - "shortTitle": "Gabriel García Márquez" - } - ] - }, - { - "type": "web", - "url": "http://books.google.com/books?hl=en&lr=&id=Ct6FKwHhBSQC&oi=fnd&pg=PP9&dq=%22Peggy+Eaton%22&ots=KN-Z0-HAcv&sig=snBNf7bilHi9GFH4-6-3s1ySI9Q#v=onepage&q=%22Peggy%20Eaton%22&f=false", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Meade", - "lastName": "Minnigerode", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Adams, Abigail", - "Adams, Louisa Catherine", - "Eaton, Peggy", - "Jackson, Rachel", - "Madison, Dolley", - "Monroe, Elizabeth", - "Washington, Martha", - "Women", - "Biography & Autobiography / General", - "Biography & Autobiography / Women", - "Biography & Autobiography / Women" - ], - "seeAlso": [], - "attachments": [ - { - "title": "Google Books Link", - "snapshot": false, - "mimeType": "text/html", - "url": false - } - ], - "numPages": "332", - "ISBN": "9780836913620", - "publisher": "Ayer Publishing", - "title": "Some American ladies: seven informal biographies ...", - "language": "en", - "date": "1926-06", - "libraryCatalog": "Google Books", - "shortTitle": "Some American ladies" - } - ] - }, - { - "type": "web", - "url": "http://books.google.com/books?printsec=frontcover&vid=ISBN0684181355&vid=ISBN0684183951&vid=LCCN84026715#v=onepage&q&f=false", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Thom", - "lastName": "Holmes", - "creatorType": "author" - }, - { - "firstName": "Thomas B.", - "lastName": "Holmes", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Avant-garde (Music)", - "Electronic music History and criticism", - "Electronic music", - "Music / General", - "Music / History & Criticism", - "Music / Genres & Styles / New Age" - ], - "seeAlso": [], - "attachments": [ - { - "title": "Google Books Link", - "snapshot": false, - "mimeType": "text/html", - "url": false - } - ], - "numPages": "340", - "ISBN": "9780415936446", - "publisher": "Routledge", - "title": "Electronic and experimental music: pioneers in technology and composition", - "language": "en", - "abstractNote": "\"Electronic and Experimental Music\" details the history of electronic music throughout the world, and the people who created it. From the theory of sound production to key composers and instrument designers, this is a complete introduction to the genre from its early roots to the present technological explosion. Every major figure is covered including: Thaddeus Cahill, Peire Henry, Gorden Mumma, Pauline Oliveros, Brian Eno, and D.J. Spooky. The vast array of forms and instruments that these innovators introduced and expanded are also included--tape composition, the synthesizer, \"live\" electronic performance, the ONCE festivals, ambient music, and turntablism.This new edition, includes a thoroughly updated and enlarged theoretical and historical sections and includes new material on using home computers (PCs) and the many resources now available in software and the Internet.", - "date": "2002-07-05", - "libraryCatalog": "Google Books", - "shortTitle": "Electronic and experimental music" - } - ] - }, - { - "type": "web", - "url": "http://books.google.com/books/about/The_Cambridge_companion_to_electronic_mu.html?id=AJbdPZv1DjgC", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Nicholas", - "lastName": "Collins", - "creatorType": "author" - }, - { - "firstName": "Nick", - "lastName": "Collins", - "creatorType": "author" - }, - { - "firstName": "Julio", - "lastName": "d'Escriván", - "creatorType": "author" - }, - { - "firstName": "Julio d' Escrivan", - "lastName": "Rincón", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Electronic music", - "Electronic music/ History and criticism", - "Electronic music - History and criticism", - "Music / Genres & Styles / Electronic", - "Music / History & Criticism", - "Music / General", - "Music / General", - "Music / Genres & Styles / Electronic", - "Music / History & Criticism", - "Music / Instruction & Study / General", - "Music / Musical Instruments / General", - "Music / Recording & Reproduction", - "Music / Songbooks" - ], - "seeAlso": [], - "attachments": [ - { - "title": "Google Books Link", - "snapshot": false, - "mimeType": "text/html", - "url": false - } - ], - "numPages": "313", - "ISBN": "9780521868617", - "publisher": "Cambridge University Press", - "title": "The Cambridge companion to electronic music", - "language": "en", - "abstractNote": "Musicians are always quick to adopt and explore new technologies. The fast-paced changes wrought by electrification, from the microphone via the analogue synthesiser to the laptop computer, have led to a wide diversity of new musical styles and techniques. Electronic music has grown to a broad field of investigation, taking in historical movements such as musique concrète and elektronische musik, and contemporary trends such as electronic dance music and electronica. A fascinating array of composers and inventors have contributed to a diverse set of technologies, practices and music. This book brings together some novel threads through this scene, from the viewpoint of researchers at the forefront of the sonic explorations empowered by electronic technology. The chapters provide accessible and insightful overviews of core topic areas and uncover some hitherto less publicised corners of worldwide movements. Recent areas of intense activity such as audiovisuals, live electronic music, interactivity and network music are actively promoted.", - "date": "2007", - "libraryCatalog": "Google Books" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Google Patents.js b/translators/Google Patents.js @@ -1,177 +0,0 @@ -{ - "translatorID": "d71e9b6d-2baa-44ed-acb4-13fe2fe592c0", - "label": "Google Patents", - "creator": "Adam Crymble", - "target": "^http://www\\.google.*/patents", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-16 14:00:40" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.location.href.match(/[?&]q=/)) { - return "multiple"; - } else if(doc.location.href.match(/[?&]id=/)) { - return "patent"; - } -} - -//Google Patents Translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - var dataTags = new Object(); - var newItem = new Zotero.Item("patent"); - - //Grab the patent_bibdata items and the text node directly next to them - var xPathHeadings = doc.evaluate('//div[@class="patent_bibdata"]//b', doc, null, XPathResult.ANY_TYPE, null); - var xPathContents = doc.evaluate('//div[@class="patent_bibdata"]//b/following::text()[1]', doc, null, XPathResult.ANY_TYPE, null); - - // create an associative array of the items and their contents - var heading, content; - while( heading = xPathHeadings.iterateNext(), content = xPathContents.iterateNext()){ - if(heading.textContent == 'Publication number'){ - content = doc.evaluate('//div[@class="patent_bibdata"]//b[text()="Publication number"]/following::nobr[1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - } - dataTags[heading.textContent] = content.textContent.replace(": ", '');; - //Zotero.debug(dataTags); - } - - if (doc.evaluate('//td[3]/p', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = (doc.evaluate('//td[3]/p', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("Abstract", '')); - } - - - /* - for (var i =0; i < xPathCount.numberValue; i++) { - - headings.push(xPathHeadings.iterateNext().textContent); - contents = contents.replace(headings[i], "xxx"); - } - - - var splitContent = new Array(); - splitContent = contents.split(/xxx/); - */ - //associate headings with contents. - - //extra field - newItem.extra = ''; - - for (fieldTitle in dataTags) { - Zotero.debug(fieldTitle); - //fieldTitle = item.replace(/\s+|\W*/g, ''); - /* - if (fieldTitle == "US Classification" | fieldTitle == "International Classification" | fieldTitle == "Abstract") { - dataTags[fieldTitle] = splitContent[i+1]; - } else { - dataTags[fieldTitle] = splitContent[i+1].replace(": ", ''); - } - */ - if (dataTags[fieldTitle].match("About this patent")) { - dataTags[fieldTitle] = dataTags[fieldTitle].replace("About this patent", ''); - } - - //author(s) - if (fieldTitle == "Inventors" | fieldTitle == "Inventor") { - var authors = dataTags[fieldTitle].split(", "); - for (var j = 0; j < authors.length; j++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j], "inventor")); - } - } else if (fieldTitle == "Inventor") { - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Inventor"], "inventor")); - } - - if (fieldTitle == "Current U.S. Classification" ) { - newItem.extra += "U.S. Classification: " + dataTags["Current U.S. Classification"]+"\n"; - } else if (fieldTitle == "International Classification" ) { - newItem.extra += "International Classification: " + dataTags["International Classification"]+"\n"; - } else if (fieldTitle == "Publication number" ) { - newItem.extra += "Publication number: " +dataTags["Publication number"]+"\n"; - } - } - - associateData (newItem, dataTags, "Patent number", "patentNumber"); - associateData (newItem, dataTags, "Issue date", "date"); - associateData (newItem, dataTags, "Filing date", "filingDate"); - associateData (newItem, dataTags, "Assignees", "assignee"); - associateData (newItem, dataTags, "Assignee", "assignee"); - associateData (newItem, dataTags, "Abstract", "abstractNote"); - associateData (newItem, dataTags, "Application number", "applicationNumber"); - - var pdf = doc.evaluate('//div[@class="g-button-basic"]/span/span/a[contains(@href,"/download/)]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (pdf) newItem.attachments.push({url:pdf.href, title:"Google Patents PDF", mimeType:"application/pdf"}); - newItem.title = doc.evaluate('//h1[@class="gb-volume-title"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.url = doc.location.href.replace(/(^[^\?]*\?id=[a-zA-Z0-9]+).*/,"$1"); - - newItem.complete(); -} - -function doWeb(doc, url) { - var host = 'http://' + doc.location.host + "/"; - - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, /\/patents(?:\/about)?\?id=/); - Zotero.selectItems(items, function (items) { - var articles = new Array(); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - }); - } else { - scrape(doc); - } -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.google.com/patents/about?id=j5NSAAAAEBAJ", - "items": [ - { - "itemType": "patent", - "creators": [ - { - "firstName": "T.", - "lastName": "SHOOK", - "creatorType": "inventor" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "U.S. Classification: 215/273", - "patentNumber": "1065211", - "date": "Jun 17, 1913", - "filingDate": "Aug 3, 1912", - "title": "BOTTLE-STOPPER", - "url": "http://www.google.com/patents/about?id=j5NSAAAAEBAJ", - "libraryCatalog": "Google Patents" - } - ] - }, - { - "type": "web", - "url": "http://www.google.com/search?tbm=pts&tbo=1&hl=en&q=book&btnG=Search+Patents", - "items": "multiple" - } -] -/** END TEST CASES **/ diff --git a/translators/Google Scholar.js b/translators/Google Scholar.js @@ -1,540 +0,0 @@ -{ - "translatorID": "57a00950-f0d1-4b41-b6ba-44ff0fc30289", - "label": "Google Scholar", - "creator": "Simon Kornblith, Frank Bennett", - "target": "^https?://scholar\\.google\\.(?:com|com?\\.[a-z]{2}|[a-z]{2}|co\\.[a-z]{2})/scholar(?:_case)*", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-04 13:18:22" -} - -/* - * Test pages - * - * Searches of Google Scholar with the following terms should yield a folder - * icon that works. Check that unlinked ([CITATION]) items that provide - * no BibTeX data (there is currently one under "Marbury v. Madison", - * and "clifford" seems to be a good source of garbage) are - * dropped from the listings: - * - * marbury v madison - * kelo - * smith - * view of the cathedral - * clifford - * - * "How cited" pages should NOT yield a page or folder icon. The - * Urls to these currently look like this: - * - * http://scholar.google.co.jp/scholar_case?about=1101424605047973909&q=kelo&hl=en&as_sdt=2002 - * - * Case pages should present a document icon that works: - * - * http://scholar.google.co.jp/scholar_case?case=18273389148555376997&hl=en&as_sdt=2002&kqfp=13204897074208725174&kql=186&kqpfp=16170611681001262513#kq - */ - - -/* - * ############################### - * ### detectWeb() and doWeb() ### - * ############################### - */ - -var bogusItemID = 1; - -var detectWeb = function (doc, url) { - // Icon shows only for search results and law cases - if (url.match(/scholar_case/)) { - if (url.match(/about=/)) { - return false; - } else { - return "case"; - } - } else { - return "multiple"; - } -}; - -function doWeb(doc, url) { - var haveBibTexLinks, nsResolver; - // Invoke the case or the listing scraper, as appropriate. - // In a listings page, this forces use of bibtex data and English page version - nsResolver = doc.createNSResolver(doc.documentElement); - if (url.match(/scholar_case/)) { - scrapeCase(doc, url); - } else { - haveBibTexLinks = doc.evaluate('//a[contains(@href, "scholar.bib")]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(!haveBibTexLinks) { - url = url.replace (/hl\=[^&]*&?/, ""); - url = url.replace("scholar?", "scholar_setprefs?hl=en&scis=yes&scisf=4&submit=Save+Preferences&"); - Zotero.Utilities.processDocuments(url, function(scisigDoc) { - var scisig = scisigDoc.evaluate('//input[@name="scisig"]', - scisigDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - url = url + "&scisig="+scisig.value; - Zotero.Utilities.processDocuments(url, function(doc) { - scrapeListing(doc); - }, function() {}); - }, function() {}); - } else { - scrapeListing(doc); - } - Zotero.wait(); - } -} - - -/* - * ######################### - * ### Scraper Functions ### - * ######################### - */ -var scrapeListing = function (doc) { - var nsResolver = doc.createNSResolver(doc.documentElement); - - // XML fragment lists - var titleFrags = doc.evaluate('//div[@class="gs_r"]//h3', doc, nsResolver, XPathResult.ANY_TYPE, null); - var citeletFrags = doc.evaluate('//span[@class="gs_a"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var bibtexFrags = doc.evaluate('//a[contains(@href, "scholar.bib")]', - doc, nsResolver, XPathResult.ANY_TYPE, null); - - var labels = []; - var factories = []; - - while (true) { - var titleFrag = titleFrags.iterateNext(); - if (!titleFrag) { - break; - } - // initialize argument values - var titleString = titleFrag.textContent; - var citeletString = citeletFrags.iterateNext().textContent; - var bibtexLink = bibtexFrags.iterateNext().href; - var attachmentFrag = doc.evaluate('.//a', - titleFrag, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (attachmentFrag) { - var attachmentLinks = [attachmentFrag.href]; - } else { - var attachmentLinks = []; - } - - // Instantiate item factory with available data - var factory = new ItemFactory(citeletString, attachmentLinks, titleString, bibtexLink); - - if (!factory.hasUsefulData()) { - continue; - } - // (Feed the array used in the selection list) - if (factory.hyphenSplit.length) { - labels.push(titleString + " (" + factory.trailingInfo + ")"); - } else { - labels.push(titleString); - } - factories.push(factory); - } - - Zotero.selectItems(labels, function(items) { - if(!items) { - return false; - } - - var newFactories = []; - for(var i in items) { - newFactories.push(factories[i]); - } - - processFactories(newFactories); - }); - return true; -}; - -function processFactories(factories) { - if(!factories.length) { - Zotero.done(); - return; - } - - var factory = factories.shift(); - factory.getCourt(); - factory.getVolRepPag(); - if (factory.hasReporter()) { - // If we win here, we get by without fetching the BibTeX object at all. - factory.saveItem(); - processFactories(factories); - } else { - var attachments; - - // The only supplementary translator we use is BibTeX - var bibtexTranslator = Zotero.loadTranslator("import"); - bibtexTranslator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - bibtexTranslator.setHandler("itemDone", function(obj, item) { - item.attachments = attachments; - item.complete(); - }); - - factory.getBibtexData(function(res) { - if (res) { - // Has BibTeX data with title, pass it through to the BibTeX translator - attachments = factory.getAttachments("Page"); - bibtexTranslator.setString(res); - bibtexTranslator.setHandler("done", function() { - processFactories(factories); - }); - bibtexTranslator.translate(); - } else { - // If BibTeX is empty, this is some kind of case, if anything. - // Metadata from the citelet, supplemented by the target - // document for the docket number, if possible. - if (!factory.hasReporter()) { - factory.getDocketNumber(null, function() { - factory.saveItem(); - processFactories(factories); - }); - } else { - factory.saveItem(); - processFactories(factories); - } - } - }); - } -} - -var scrapeCase = function (doc, url) { - // Citelet is identified by - // id="gsl_reference" - var nsResolver = doc.createNSResolver(doc.documentElement); - var refFrag = doc.evaluate('//div[@id="gsl_reference"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (refFrag) { - // citelet looks kind of like this - // Powell v. McCormack, 395 US 486 - Supreme Court 1969 - var item = new Zotero.Item("case"); - var factory = new ItemFactory(refFrag.textContent, [url]); - factory.repairCitelet(); - factory.getDate(); - factory.getCourt(); - factory.getVolRepPag(); - if (!factory.hasReporter()) { - // Look for docket number in the current document - factory.getDocketNumber(doc); - } - factory.getTitle(); - factory.saveItem(); - } -}; - - -/* - * #################### - * ### Item Factory ### - * #################### - */ - -var ItemFactory = function (citeletString, attachmentLinks, titleString, bibtexLink) { - // var strings - this.v = {}; - this.v.title = titleString; - this.v.number = false; - this.v.court = false; - this.v.extra = false; - this.v.date = undefined; - this.v.jurisdiction = false; - this.v.docketNumber = false; - this.vv = {}; - this.vv.volRepPag = []; - // portable array - this.attachmentLinks = attachmentLinks; - // working strings - this.citelet = citeletString; - this.bibtexLink = bibtexLink; - this.bibtexData = undefined; - this.trailingInfo = false; - // simple arrays of strings - this.hyphenSplit = false; - this.commaSplit = false; -}; - - -ItemFactory.prototype.repairCitelet = function () { - if (!this.citelet.match(/\s+-\s+/)) { - this.citelet = this.citelet.replace(/,\s+([A-Z][a-z]+:)/, " - $1"); - } -}; - - -ItemFactory.prototype.repairTitle = function () { - // All-caps words of four or more characters probably need fixing. - if (this.v.title.match(/(?:[^a-z]|^)[A-Z]{4,}(?:[^a-z]|$)/)) { - this.v.title = Zotero.Utilities.capitalizeTitle(this.v.title.toLowerCase()).replace(/([^0-9a-z])V([^0-9a-z])/, "$1v$2"); - } -}; - - -ItemFactory.prototype.hasUsefulData = function () { - if (this.getDate()) { - return true; - } - if (this.hasInitials()) { - return true; - } - return false; -}; - - -ItemFactory.prototype.hasInitials = function () { - if (this.hyphenSplit.length && this.hyphenSplit[0].match(/[A-Z] /)) { - return true; - } - return false; -}; - - -ItemFactory.prototype.hasReporter = function () { - if (this.vv.volRepPag.length > 0) { - return true; - } - return false; -}; - - -ItemFactory.prototype.getDate = function () { - var i, m; - // Citelet parsing, step (1) - if (!this.hyphenSplit) { - this.hyphenSplit = this.citelet.split(/\s+-\s+/); - this.trailingInfo = this.hyphenSplit.slice(-1); - } - if (!this.v.date && this.v.date !== false) { - this.v.date = false; - for (i = this.hyphenSplit.length - 1; i > -1; i += -1) { - m = this.hyphenSplit[i].match(/(?:(.*)\s+)*([0-9]{4})$/); - if (m) { - this.v.date = m[2]; - if (m[1]) { - this.hyphenSplit[i] = m[1]; - } else { - this.hyphenSplit[i] = ""; - } - this.hyphenSplit = this.hyphenSplit.slice(0, i + 1); - break; - } - } - } - return this.v.date; -}; - - -ItemFactory.prototype.getCourt = function () { - var s, m; - // Citelet parsing, step (2) - s = this.hyphenSplit.pop().replace(/,\s*$/, "").replace(/\u2026\s*$/, "Court"); - m = s.match(/(?:([a-zA-Z]+):\s*)*(.*)/); - if (m) { - this.v.court = m[2].replace("_", " ", "g"); - if (m[1]) { - this.v.extra = "{:jurisdiction: " + m[1] + "}"; - } - } - return this.v.court; -}; - - -ItemFactory.prototype.getVolRepPag = function () { - var i, m; - // Citelet parsing, step (3) - if (this.hyphenSplit.length) { - this.commaSplit = this.hyphenSplit.slice(-1)[0].split(/\s*,\s+/); - var gotOne = false; - for (i = this.commaSplit.length - 1; i > -1; i += -1) { - m = this.commaSplit[i].match(/^([0-9]+)\s+(.*)\s+(.*)/); - if (m) { - var volRepPag = {}; - volRepPag.volume = m[1]; - volRepPag.reporter = m[2]; - volRepPag.pages = m[3].replace(/\s*$/, ""); - this.commaSplit.pop(); - if (!volRepPag.pages.match(/[0-9]$/) && (i > 0 || gotOne)) { - continue; - } - gotOne = true; - this.vv.volRepPag.push(volRepPag); - } else { - break; - } - } - } -}; - - -ItemFactory.prototype.getTitle = function () { - // Citelet parsing, step (4) [optional] - if (this.commaSplit) { - this.v.title = this.commaSplit.join(", "); - } -}; - - -ItemFactory.prototype.getDocketNumber = function (doc, callback) { - if (!doc) { - // Needs doc fetch and xpath - var me = this; - Zotero.Utilities.processDocuments(this.attachmentLinks[0], - function(doc) { me.getDocumentNumber(doc, callback) }, function() {}); - return; - } - - var nsResolver = doc.createNSResolver(doc.documentElement); - if (doc) { - var docNumFrag = doc.evaluate('//center[preceding-sibling::center//h3[@id="gsl_case_name"]]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (docNumFrag) { - this.v.docketNumber = docNumFrag.textContent.replace(/^\s*[Nn][Oo](?:.|\s+)\s*/, "").replace(/\.\s*$/, ""); - } - } - - if(callback) callback(); -}; - - -ItemFactory.prototype.getAttachments = function (doctype) { - var i, ilen, attachments; - attachments = []; - for (i = 0, ilen = this.attachmentLinks.length; i < ilen; i += 1) { - attachments.push({title:"Google Scholar Linked " + doctype, type:"text/html", - url:this.attachmentLinks[i]}); - } - return attachments; -}; - - -ItemFactory.prototype.pushAttachments = function (doctype) { - this.item.attachments = this.getAttachments(doctype); -}; - - -ItemFactory.prototype.getBibtexData = function (callback) { - if (!this.bibtexData) { - if (this.bibtexData !== false) { - Zotero.Utilities.doGet(this.bibtexLink, function(bibtexData) { - if (!bibtexData.match(/title={{}}/)) { - this.bibtexData = bibtexData; - } else { - this.bibtexData = false; - } - callback(this.bibtexData); - }); - return; - } - } - callback(this.bibtexData); -}; - - -ItemFactory.prototype.saveItem = function () { - var i, ilen, key; - if (this.v.title) { - this.repairTitle(); - if (this.vv.volRepPag.length) { - var completed_items = []; - for (i = 0, ilen = this.vv.volRepPag.length; i < ilen; i += 1) { - this.item = new Zotero.Item("case"); - for (key in this.vv.volRepPag[i]) { - if (this.vv.volRepPag[i][key]) { - this.item[key] = this.vv.volRepPag[i][key]; - } - } - this.saveItemCommonVars(); - if (i === (this.vv.volRepPag.length - 1)) { - this.pushAttachments("Judgement"); - } - this.item.itemID = "" + bogusItemID; - bogusItemID += 1; - completed_items.push(this.item); - } - for (i = 0, ilen = completed_items.length; i < ilen; i += 1) { - for (j = 0, jlen = completed_items.length; j < jlen; j += 1) { - if (i === j) { - continue; - } - completed_items[i].seeAlso.push(completed_items[j].itemID); - } - completed_items[i].complete(); - } - } else { - this.item = new Zotero.Item("case"); - this.saveItemCommonVars(); - this.pushAttachments("Judgement"); - this.item.complete(); - } - } -}; - - -ItemFactory.prototype.saveItemCommonVars = function () { - for (key in this.v) { - if (this.v[key]) { - this.item[key] = this.v[key]; - } - } -}; - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://scholar.google.com/scholar?q=marbury&hl=en&btnG=Search&as_sdt=1%2C22&as_sdtp=on", - "items": "multiple" - }, - { - "type": "web", - "url": "http://scholar.google.com/scholar?hl=en&q=kelo&btnG=Search&as_sdt=0%2C22&as_ylo=&as_vis=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://scholar.google.com/scholar?hl=en&q=smith&btnG=Search&as_sdt=0%2C22&as_ylo=&as_vis=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://scholar.google.com/scholar?hl=en&q=view+of+the+cathedral&btnG=Search&as_sdt=0%2C22&as_ylo=&as_vis=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://scholar.google.com/scholar?hl=en&q=clifford&btnG=Search&as_sdt=0%2C22&as_ylo=&as_vis=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://scholar.google.com/scholar_case?case=9834052745083343188&q=marbury+v+madison&hl=en&as_sdt=2,5", - "items": [ - { - "itemType": "case", - "creators": [], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "title": "Google Scholar Linked Judgement", - "type": "text/html", - "url": false - } - ], - "volume": "5", - "reporter": "US", - "pages": "137", - "title": "Marbury v. Madison", - "court": "Supreme Court", - "date": "1803", - "itemID": "1", - "libraryCatalog": "Google Scholar" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Gulag Many Days, Many Lives.js b/translators/Gulag Many Days, Many Lives.js @@ -1,142 +0,0 @@ -{ - "translatorID":"c41c9c66-8540-4216-b138-7c00532748c9", - "translatorType":4, - "label":"Gulag: Many Days, Many Lives", - "creator":"Adam Crymble", - "target":"http://gulaghistory.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-04 07:10:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="field"][@id="citation"]/p', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } else if (doc.evaluate('//h3/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -//Gulag: Many Days, Many Lives translator; Code by Adam Crymble - -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("book"); - - if (doc.evaluate('//div[@class="field"][@id="description"]/div', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var abstract1 = doc.evaluate('//div[@class="field"][@id="description"]/div', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = abstract1.replace(/^\s+|\s*$/g, ''); - } - - if (doc.evaluate('//div[@class="field"][@id="source"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var rights1 = doc.evaluate('//div[@class="field"][@id="source"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.rights = rights1.replace(/^\s+|\s*$/g, ''); - } - - var cite = doc.evaluate('//div[@class="field"][@id="citation"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var checkForAuthor = cite.indexOf('"'); - - if (cite.match("Gulag: Many Days, Many Lives")) { - - var split1 = new Array(); - var split2 = new Array(); - var split3 = new Array(); - var split4 = new Array(); - var split5 = new Array(); - - if (checkForAuthor == 0) { - split1[1] = cite; - } else { - //author - split1 = cite.split(', "'); - var authorWords = split1[0].split(/\b\s/); - if (authorWords.length > 3) { - newItem.creators.push({lastName: split1[0], creatorType: "creator"}); - } else { - - newItem.creators.push(Zotero.Utilities.cleanAuthor(split1[0], "author")); - } - } - - //title - split2 = split1[1].split('." '); - newItem.title = split2[0]; - - //repository - split3 = split2[1].split("Lives, "); - - //object number - split4 = split3[1].split(" ("); - newItem.callNumber = split4[0]; - - //date posted and URL - split5 = split4[1].split(")<"); - newItem.date = split5[0]; - - } else { - - var split1 = cite.split(". "); - Zotero.debug(split1); - - //author - var author = split1[0].split(/\, /); - author = author[1] + ' ' + author[0]; - Zotero.debug(author); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - - //title - newItem.title = split1[1]; - - //place - var place1 = split1[2].split(":"); - newItem.place = place1[0]; - - //date - var date1 = split1[2].split (", "); - newItem.date = date1[1]; - - //publisher - newItem.publisher = date1[0].replace(place1[0], '').substr(2); - } - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//h3/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - - while (next_title = titles.iterateNext()) { - - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Hanrei Watch.js b/translators/Hanrei Watch.js @@ -1,90 +0,0 @@ -{ - "translatorID":"8e5f8616-05d0-4d33-8554-dad76b20ecbx", - "translatorType":4, - "label":"Hanrei Watch RSS service", - "creator":"Frank Bennett", - "target":"http://kanz.jp/hanrei/detail.html\\?idx=[0-9]+$", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-10-22 19:00:00" -} - -function detectWeb(doc, url) { - return "case"; -} - -var years = {}; -years["明治"] = 1867; -years["大正"] = 1911; -years["昭和"] = 1925; -years["平成"] = 1988; - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var item = new Zotero.Item("case"); - - // - // For values that require no special post-processing, get Xpath targets in raw list form. - // Values to be extracted are for docket number, case nickname, court, and the abstract - // of the judgment. - // - var values = []; - values.push( doc.evaluate( '//table[@class="detail"]//th[contains(text(),"事件番号")]/following-sibling::td[position()=1]', doc, null, XPathResult.ANY_TYPE, null) ); - values.push( doc.evaluate( '//table[@class="detail"]//th[contains(text(),"事件名")]/following-sibling::td[position()=1]', doc, null, XPathResult.ANY_TYPE, null) ); - values.push( doc.evaluate( '//table[@class="detail"]//th[contains(text(),"裁判所")]/following-sibling::td[position()=1]', doc, null, XPathResult.ANY_TYPE, null) ); - values.push( doc.evaluate( '//table[@class="detail"]//th[contains(text(),"裁判要旨")]/following-sibling::td[position()=1]', doc, null, XPathResult.ANY_TYPE, null) ); - // - // For each variable above, extract its string value, if any. - // - for (var pos in values){ - values[pos] = values[pos].iterateNext(); - if (values[pos]){ - values[pos] = values[pos].textContent; - } - } - - // - // Get the date, and normalize the format and the year - // - var date = doc.evaluate( '//table[@class="detail"]//th[contains(text(),"裁判年月日")]/following-sibling::td[position()=1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (date){ - date = date.textContent; - date = date.replace(/日$/,""); - date = date.replace(/(月|年)/g,"-"); - - var m = date.match(/^(平成|昭和|大正|明治)([0-9]+)(.*)/); - if (m && years[m[1]]){ - date = (years[m[1]] + parseInt(m[2],10)) + m[3]; - } - } - - // - // Get the URL of the PDF attachment. - // - var pdf = doc.evaluate( '//a[contains(text(),"PDF File")]/@href', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (pdf){ - pdf = pdf.textContent; - } - - // - // Assemble the item and declare it complete. - // - item.type = "case"; - item.docketNumber = values[0]; - item.title = values[1]; - item.court = values[2]; - item.abstractNote = values[3]; - item.date = date; - item.url = url; - item.attachments.push( { - url:pdf, - title:"SupCt PDF", - mimeType:"application/pdf"} ); - item.complete(); -} diff --git a/translators/Helsinki University of Technology.js b/translators/Helsinki University of Technology.js @@ -1,81 +0,0 @@ -{ - "translatorID":"2943d7fc-3ce8-401c-afd5-ee1f70b7aae0", - "translatorType":4, - "label":"Helsinki University of Technology", - "creator":"Michael Berkowitz", - "target":"https?://teemu.linneanet.fi/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/v\d+=\d+/)) { - return "book"; - } else if (url.match(/Search_Arg/)) { - return "multiple"; - } -} - -function MARCify(str) { - return str.replace(/v\d+=([^&]+)/, "v3=$1"); -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var titles = doc.evaluate('/html/body/form/table/tbody/tr/td[3]/a', doc, ns, XPathResult.ANY_TYPE, null); - var title; - var items = new Object(); - while (title = titles.iterateNext()) { - items[title.href] = Zotero.Utilities.trimInternal(title.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - books.push(MARCify(i)); - } - } else { - books = [MARCify(url)]; - } - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.processDocuments(books, function(doc) { - var elmts = doc.evaluate('/html/body/form/table/tbody/tr[th]', doc, ns, XPathResult.ANY_TYPE, null); - var record = new marc.record(); - var elmt; - while (elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.superCleanString(doc.evaluate('./th', elmt, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if (field) { - var value = doc.evaluate('./td[1]', elmt, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (value.split(/\n/)[1]) value = Zotero.Utilities.trimInternal(value.split(/\n/)[1]); - if(field == "LDR") { - record.leader = value; - } else if(field != "FMT") { - value = value.replace(/\|([a-z]) /g, marc.subfieldDelimiter+"$1"); - var code = field.substring(0, 3); - var ind = ""; - if(field.length > 3) { - ind = field[3]; - if(field.length > 4) { - ind += field[4]; - } - } - - record.addField(code, ind, value); - } - } - } - var item = new Zotero.Item("book"); - record.translate(item); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/HighWire.js b/translators/HighWire.js @@ -1,259 +0,0 @@ -{ - "translatorID": "5eacdb93-20b9-4c46-a89b-523f62935ae4", - "label": "HighWire", - "creator": "Simon Kornblith", - "target": "^http://[^/]+/(?:cgi/searchresults|cgi/search|cgi/content/(?:abstract|full|short|summary)|current.dtl$|content/vol[0-9]+/issue[0-9]+/(?:index.dtl)?$)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-03 03:58:51" -} - -function detectWeb(doc, url) { - if(doc.title.indexOf(" -- Search Result") !== -1) { - if(doc.evaluate('//table/tbody/tr[td/input[@type="checkbox"][@name="gca"]]', doc, - null, XPathResult.ANY_TYPE, null).iterateNext()) return "multiple"; - } else if(doc.title.indexOf(" -- Table of Contents") != -1) { - if(doc.evaluate('//form/dl', doc, null, XPathResult.ANY_TYPE,null).iterateNext()) return "multiple"; - } else { - if(doc.evaluate('//a[substring(@href, 1, 16) = "/cgi/citmgr?gca="]', doc, null, - XPathResult.ANY_TYPE, null).iterateNext()) return "journalArticle"; - } - - return false; -} - -function handleRequests(requests) { - if(requests.length == 0) { - Zotero.done(); - return; - } - - var request = requests.shift(); - var URL = request.baseURL+request.args; - - Zotero.Utilities.HTTP.doGet(URL, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if(item.notes[0]) { - item.DOI = Zotero.Utilities.unescapeHTML(item.notes[0].note); - item.notes = new Array(); - } - - item.attachments = new Array(); - var snapshot = request.snapshots.shift(); - var pdf = request.pdfs.shift(); - if(snapshot) { - if(typeof(snapshot) == "string") { - // string snapshot (from search) - item.attachments.push({title:"HighWire Snapshot", mimeType:"text/html", url:snapshot}); - } else { - // document object - item.attachments.push({title:"HighWire Snapshot", document:snapshot}); - } - } - if(pdf) { - var m = pdf.match(/^[^?]+/); - item.attachments.push({title:"HighWire Full Text PDF", mimeType:"application/pdf", url:m[0]+".pdf"}); - } - - item.complete(); - }); - translator.translate(); - - handleRequests(requests); - }); -} - -function doWeb(doc, url) { - var requests = new Array(); - var hostRe = /https?:\/\/[^\/]+/; - - var isSearch = doc.title.indexOf("Search Result") != -1 - var isTOC = doc.title.indexOf(" -- Table of Contents") != -1; - var isScience = doc.title.indexOf("Science Magazine Search Results") != -1; - if(isSearch || isTOC) { - // search page - var items = new Object(); - var snapshots = new Object(); - var pdfs = new Object(); - - if(isTOC) { - var gcaRe = /^https?:\/\/[^\/]+\/cgi\/reprint\/([0-9]+\/[0-9]+\/[0-9]+)/; - var tableRows = doc.evaluate('//form/dl', doc, null, XPathResult.ANY_TYPE, null); - } else if(isScience) { - var tableRows = doc.evaluate('//form/dl/dd', doc, null, XPathResult.ANY_TYPE, null); - var tableDTs = doc.evaluate('//form/dl/dt', doc, null, XPathResult.ANY_TYPE, null); - } else { - var tableRows = doc.evaluate('//table/tbody/tr[td/input[@type="checkbox"]][td/font/strong]', doc, - null, XPathResult.ANY_TYPE, null); - } - - var tableRow, link; - while(tableRow = tableRows.iterateNext()) { - var snapshot = undefined; - var pdf = undefined; - - if(isTOC) { - var title = doc.evaluate('.//strong', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var links = doc.evaluate('.//a', tableRow, null, XPathResult.ANY_TYPE, null); - while(link = links.iterateNext()) { - // prefer Full Text snapshots, but take abstracts - if(link.textContent == "[Abstract]") { - if(!snapshot) snapshot = link.href; - } else if (link.textContent == "[Full Text]") { - snapshot = link.href; - } else if(link.textContent == "[PDF]") { - pdf = link.href; - var m = gcaRe.exec(link.href); - var gca = m[1]; - } - } - } else { - if(isScience) { - var tableDT = tableDTs.iterateNext(); - var gca = doc.evaluate('./input[@type="checkbox"]', tableDT, null, XPathResult.ANY_TYPE, null).iterateNext().value; - var title = doc.evaluate('./label', tableDT, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - var gca = doc.evaluate('./td/input[@type="checkbox"]', tableRow, null, XPathResult.ANY_TYPE, null).iterateNext().value; - var title = doc.evaluate('./td/font/strong', tableRow, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - if(title.snapshotItem(0).textContent.toUpperCase() == title.snapshotItem(0).textContent) { - title = title.snapshotItem(1).textContent; - } else { - title = title.snapshotItem(0).textContent; - } - } - - var links = doc.evaluate('.//a', tableRow, null, XPathResult.ANY_TYPE, null); - while(link = links.iterateNext()) { - // prefer Full Text snapshots, but take abstracts - var textContent = Zotero.Utilities.trimInternal(link.textContent); - if((textContent.substr(0, 8) == "Abstract" && !snapshot) || textContent.substr(0, 9) == "Full Text") { - snapshot = link.href; - } else if(textContent.substr(0, 3) == "PDF") { - pdf = link.href; - } - } - } - - snapshots[gca] = snapshot; - pdfs[gca] = pdf; - - items[gca] = Zotero.Utilities.trimInternal(title); - } - - items = Zotero.selectItems(items, function(items) { - if(!items) return true; - - var requests = new Array(); - for(var gca in items) { - var m = hostRe.exec(pdfs[gca]); - var baseURL = 'http://' + doc.location.host + '/cgi/citmgr?type=refman'; - - var thisRequest = null; - for each(var request in requests) { - if(request.baseURL == baseURL) { - thisRequest = request; - break; - } - } - - if(!thisRequest) { - thisRequest = new Object(); - thisRequest.snapshots = new Array(); - thisRequest.pdfs = new Array(); - thisRequest.args = ""; - thisRequest.baseURL = baseURL; - requests.push(thisRequest); - } - - thisRequest.snapshots.push(snapshots[gca]); - thisRequest.pdfs.push(pdfs[gca]); - thisRequest.args += "&gca="+gca; - } - handleRequests(requests); - }); - } else { - var baseURL = doc.evaluate('//a[substring(@href, 1, 16) = "/cgi/citmgr?gca="]', doc, null, - XPathResult.ANY_TYPE, null).iterateNext().href; - var pdf = doc.location.href.replace(/\/content\/[^\/]+\//, "/reprint/"); - Zotero.debug(pdf); - var requests = [{baseURL:baseURL, args:"&type=refman", snapshots:[doc], pdfs:[pdf]}]; - handleRequests(requests); - } - - Zotero.wait(); -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.annfammed.org/cgi/search?fulltext=family+medicine&sendit=Enter&volume=9&issue=2&journalcode=annalsfm", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.annfammed.org/cgi/content/abstract/9/2/165?maxtoshow=&hits=10&RESULTFORMAT=&fulltext=family+medicine&searchid=1&FIRSTINDEX=0&volume=9&issue=2&resourcetype=HWCIT", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Rosser", - "firstName": "Walter W.", - "creatorType": "author" - }, - { - "lastName": "Colwill", - "firstName": "Jack M.", - "creatorType": "author" - }, - { - "lastName": "Kasperski", - "firstName": "Jan", - "creatorType": "author" - }, - { - "lastName": "Wilson", - "firstName": "Lynn", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "title": "HighWire Snapshot", - "document": false - }, - { - "title": "HighWire Full Text PDF", - "mimeType": "application/pdf", - "url": false - } - ], - "title": "Progress of Ontario's Family Health Team Model: A Patient-Centered Medical Home", - "date": "March 1, 2011", - "publicationTitle": "Ann Fam Med", - "pages": "165-171", - "volume": "9", - "issue": "2", - "url": "http://www.annfammed.org/cgi/content/abstract/9/2/165", - "abstractNote": "Ontario's Family Health Team (FHT) model, implemented in 2005, may be North America's largest example of a patient-centered medical home. The model, based on multidisciplinary teams and an innovative incentive-based funding system, has been developed primarily from fee-for-service primary care practices. Nearly 2 million Ontarians are served by 170 FHTs. Preliminary observations suggest high satisfaction among patients, higher income and more gratification for family physicians, and trends for more medical students to select careers in family medicine. Popular demand is resulting in expansion to 200 FHTs. We describe the development, implementation, reimbursement plan, and current status of this multidisciplinary model, relating it to the principles of the patient-centered medical home. We also identify its potential to provide an understanding of many aspects of primary care. ", - "DOI": "10.1370/afm.1228", - "libraryCatalog": "HighWire", - "shortTitle": "Progress of Ontario's Family Health Team Model" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Highwire 2.0.js b/translators/Highwire 2.0.js @@ -1,309 +0,0 @@ -{ - "translatorID": "8c1f42d5-02fa-437b-b2b2-73afc768eb07", - "label": "Highwire 2.0", - "creator": "Matt Burton", - "target": "(content/([0-9]+/[0-9]+|current|firstcite|early)|search\\?submit=|search\\?fulltext=|cgi/collection/.+)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:43:24" -} - -/* - Translator for several Highwire journals. Example URLs: - -1. Ajay Agrawal, Iain Cockburn, and John McHale, “Gone but not forgotten: knowledge flows, labor mobility, and enduring social relationships,” Journal of Economic Geography 6, no. 5 (November 2006): 571-591. - http://joeg.oxfordjournals.org/content/6/5/571 : -2. Gordon L. Clark, Roberto Durán-Fernández, and Kendra Strauss, “‘Being in the market’: the UK house-price bubble and the intended structure of individual pension investment portfolios,” Journal of Economic Geography 10, no. 3 (May 2010): 331-359. - http://joeg.oxfordjournals.org/content/10/3/331.abstract -3. Hans Maes, “Intention, Interpretation, and Contemporary Visual Art,” Brit J Aesthetics 50, no. 2 (April 1, 2010): 121-138. - http://bjaesthetics.oxfordjournals.org/cgi/content/abstract/50/2/121 -4. M L Giger et al., “Pulmonary nodules: computer-aided detection in digital chest images.,” Radiographics 10, no. 1 (January 1990): 41-51. - http://radiographics.rsna.org/content/10/1/41.abstract -5. Mitch Leslie, "CLIP catches enzymes in the act," The Journal of Cell Biology 191, no. 1 (October 4, 2010): 2. - http://jcb.rupress.org/content/191/1/2.2.short -*/ - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var highwiretest = false; - - highwiretest = url.match(/\.pdf+html\?frame=header/); - - if (!highwiretest) { - // lets hope this installations don't tweak this... - highwiretest = doc.evaluate("//link[@href = '/shared/css/hw-global.css']", doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - } - - if(highwiretest) { - - if ( - url.match("search\\?submit=") || - url.match("search\\?fulltext=") || - url.match("content/by/section") || - doc.title.match("Table of Contents") || - doc.title.match("Early Edition") || - url.match("cgi/collection/.+") || - url.match("content/firstcite") - ) { - return "multiple"; - } else if (url.match("content/(early/)?[0-9]+")) { - 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; - - if (!url) url = doc.documentElement.location; - else if (url.match(/\?frame=header/)) { - // recall all this using new url - url = url.replace(/\?.*/,"?frame=sidebar"); - Zotero.Utilities.processDocuments(url, - function(newdoc) { - doWeb(newdoc, url); - }, function() {Zotero.done()}); - Zotero.wait(); - return true; - } - - var host = 'http://' + doc.location.host + "/"; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.title.match("Table of Contents") - || doc.title.match("Early Edition") - || url.match("content/firstcite")) { - var searchx = '//li[contains(@class, "toc-cit") and not(ancestor::div/h2/a/text() = "Correction" or ancestor::div/h2/a/text() = "Corrections")]'; - var titlex = './/h4'; - } else if (url.match("content/by/section") || url.match("cgi/collection/.+")) { - var searchx = '//li[contains(@class, "results-cit cit")]'; - var titlex = './/span[contains(@class, "cit-title")]'; - } - else { - var searchx = '//div[contains(@class,"results-cit cit")]'; - var titlex = './/span[contains(@class,"cit-title")]'; - } - var linkx = './/a[1]'; - var searchres = doc.evaluate(searchx, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_res; - while (next_res = searchres.iterateNext()) { - var title = doc.evaluate(titlex, next_res, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var link = doc.evaluate(linkx, next_res, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - var newurls = new Array(); - for each (var i in arts) { - newurls.push(i); - } - if(arts.length == 0) { - Zotero.debug('no items'); - return false; - } - Zotero.Utilities.HTTP.doGet(arts, function(text) { - var id, match, newurl, pdfurl, get; - /* Here, we have to use three phrasings because they all occur, depending on - the journal. - TODO We should rewrite this to not use regex! */ - match = text.match(/=([^=]+)\">\s*Download (C|c)itation/); - if (!match || match.length < 1) { - match = text.match(/=([^=]+)\">\s*Download to citation manager/); - if (!match || match.length < 1) { - // Journal of Cell Biology - match = text.match(/=([^=]+)\">\s*Add to Citation Manager/); - } - } - id = match[1]; - newurl = newurls.shift(); - if (newurl.match("cgi/content")) { - pdfurl = newurl.replace(/cgi\/content\/abstract/, "content") + ".full.pdf"; - // This is here to catch those pdf+html pages - } else if (newurl.match("\.full\.pdf")) { - pdfurl = newurl.slice(0, newurl.lastIndexOf(".full.pdf")) + ".full.pdf"; - } else { - // This is not ideal...todo: brew a regex that grabs the correct URL - pdfurl = newurl.slice(0, newurl.lastIndexOf(".")) + ".full.pdf"; - } - get = host + 'citmgr?type=refman&gca=' + id; - Zotero.Utilities.HTTP.doGet(get, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - // Sometimes Highwire 2.0 has blank entries for N1 - if (text.match(/N1\s+\-\s+(10\..*)\n/)) { - var doi = text.match(/N1\s+\-\s+(.*)\n/)[1]; - } - translator.setHandler("itemDone", function(obj, item) { - item.attachments = [ - {url:newurl, title:"Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"Full Text PDF", mimeType:"application/pdf"} - ]; - if (doi) item.DOI = doi; - if (item.notes) item.notes = []; - item.complete(); - }); - translator.translate(); - }); - }); - Zotero.wait(); -} -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://rer.sagepub.com/content/52/2/201.abstract", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Hofstein", - "firstName": "Avi", - "creatorType": "author" - }, - { - "lastName": "Lunetta", - "firstName": "Vincent N.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "title": "Full Text PDF", - "mimeType": "application/pdf" - } - ], - "title": "The Role of the Laboratory in Science Teaching: Neglected Aspects of Research", - "date": "Summer 1982", - "publicationTitle": "Review of Educational Research", - "pages": "201 -217", - "volume": "52", - "issue": "2", - "url": "http://rer.sagepub.com/content/52/2/201.abstract", - "abstractNote": "The laboratory has been given a central and distinctive role in science education, and science educators have suggested that there are rich benefits in learning from using laboratory activities. At this time, however, some educators have begun to question seriously the effectiveness and the role of laboratory work, and the case for laboratory teaching is not as self-evident as it once seemed. This paper provides perspectives on these issues through a review of the history, goals, and research findings regarding the laboratory as a medium of instruction in introductory science teaching. The analysis of research culminates with suggestions for researchers who are working to clarify the role of the laboratory in science education.", - "DOI": "10.3102/00346543052002201", - "libraryCatalog": "Highwire 2.0", - "shortTitle": "The Role of the Laboratory in Science Teaching" - } - ] - }, - { - "type": "web", - "url": "http://sag.sagepub.com/content/early/2010/04/23/1046878110366277.abstract", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Owens", - "firstName": "Trevor", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "title": "Full Text PDF", - "mimeType": "application/pdf" - } - ], - "title": "Modding the History of Science: Values at Play in Modder Discussions of Sid Meier’s CIVILIZATION", - "date": "May 27 , 2010", - "publicationTitle": "Simulation & Gaming", - "url": "http://sag.sagepub.com/content/early/2010/04/23/1046878110366277.abstract", - "abstractNote": "Sid Meier’s CIVILIZATION has been promoted as an educational tool, used as a platform for building educational simulations, and maligned as promoting Eurocentrism, bioimperialism, and racial superiority. This article explores the complex issues involved in interpreting a game through analysis of the ways modders (gamers who modify the game) have approached the history of science, technology, and knowledge embodied in the game. Through text analysis of modder discussion, this article explores the assumed values and tone of the community’s discourse. The study offers initial findings that CIVILIZATION modders value a variety of positive discursive practices for developing historical models. Community members value a form of historical authenticity, they prize subtlety and nuance in models for science in the game, and they communicate through civil consensus building. Game theorists, players, and scholars, as well as those interested in modeling the history, sociology, and philosophy of science, will be interested to see the ways in which CIVILIZATION III cultivates an audience of modders who spend their time reimagining how science and technology could work in the game.", - "DOI": "10.1177/1046878110366277", - "libraryCatalog": "Highwire 2.0", - "shortTitle": "Modding the History of Science" - } - ] - }, - { - "type": "web", - "url": "http://scx.sagepub.com/content/30/2/277.abstract", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Mulder", - "firstName": "Henk A. J.", - "creatorType": "author" - }, - { - "lastName": "Longnecker", - "firstName": "Nancy", - "creatorType": "author" - }, - { - "lastName": "Davis", - "firstName": "Lloyd S.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "title": "Full Text PDF", - "mimeType": "application/pdf" - } - ], - "title": "The State of Science Communication Programs at Universities Around the World", - "date": "December 01 , 2008", - "publicationTitle": "Science Communication", - "pages": "277 -287", - "volume": "30", - "issue": "2", - "url": "http://scx.sagepub.com/content/30/2/277.abstract", - "abstractNote": "Building on discussions at two workshops held at the recent 10th International Conference on the Public Communication of Science and Technology during June 2008 in Malmö, Sweden, this article proposes specific steps toward achieving a common understanding of the essential elements for academic programs in science communication. About 40 academics, science communication professionals, and students from at least 16 countries participated in this process.", - "DOI": "10.1177/1075547008324878", - "libraryCatalog": "Highwire 2.0" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/History Cooperative.js b/translators/History Cooperative.js @@ -1,145 +0,0 @@ -{ - "translatorID":"e85a3134-8c1a-8644-6926-584c8565f23e", - "translatorType":4, - "label":"History Cooperative", - "creator":"Simon Kornblith", - "target":"https?://[^/]*historycooperative\\.org[^/]*/(?:journals/.+/.+/.+\\.s?html$|cgi-bin/search.cgi|journals/(?!cp|whc).+/.+/)", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-06 08:15:00" -} - -function detectWeb(doc, url) { - var contents = doc.title.replace("Contents", ""); - if(doc.title != contents || doc.title == "History Cooperative: Search Results") { - return "multiple"; - } else { - return "journalArticle"; - } -} - -function associateMeta(newItem, metaTags, field, zoteroField) { - var field = metaTags.namedItem(field); - if(field) { - newItem[zoteroField] = field.getAttribute("content"); - } -} - -function scrape(doc) { - var newItem = new Zotero.Item("journalArticle"); - newItem.url = doc.location.href; - - var month, year; - var metaTags = doc.getElementsByTagName("meta"); - - associateMeta(newItem, metaTags, "Journal", "publicationTitle"); - associateMeta(newItem, metaTags, "Volume", "volume"); - associateMeta(newItem, metaTags, "Issue", "issue"); - - // grab title without using meta tag, since when titles have quotes History - // Cooperative can't create a proper meta tag - - // 16apr08 - fwg - // as of now, title meta tags are properly escaped, but - // in the case of book reviews, the title field is set to one of many (~10) variations - // of "Book Review", so it's easiest to get the book title from the proprietary tags (below) as originally coded. - - var titleRe = /<!--_title_-->(.*)<!--_\/title_-->/; - - // 16apr08 - fwg - // added trimInteral, since some pages have extraneous line breaks in source code - // added unescapeHTML to make quotes nice - var m = titleRe.exec(Zotero.Utilities.trimInternal(doc.getElementsByTagName("body")[0].innerHTML)); - if(m) { - newItem.title = Zotero.Utilities.trimInternal(Zotero.Utilities.unescapeHTML(m[1])); - } else { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var bookTitle; - - //different journals want their reviewed book titles formatted in different ways (or have bizarre markup) - jNames = new Array ("The Western Historical Quarterly", "Journal of American Ethnic History", "Labour History","Environmental History", - "New York History","Indiana Magazine of History"); - - jXpaths = new Array("//tr[4]/td[3]/table/tbody/tr[1]/td/b/i", - "//[4]/td[3]/table/tbody/tr[1]/td/b/i", - "//tr[4]/td[3]/table/tbody/tr[1]/td/b/b/i", - "//tr[4]/td[3]/table/tbody/tr[1]/td/b[1]", - "//tr[4]/td[3]/p[1]/font/b/i", - "//tr[4]/td[3]/table[1]/tbody/tr[1]/td/h4/font/i" - ); - - // 16apr08 - fwg - // figure out which Xpath to use - // the below Xpath seems to work much of the time, so we default to it - var jXpath ='//tr[4]/td[3]/table/tbody/tr[1]/td/i'; - - for (var i=0; i < jNames.length; i++) { - if (newItem.publicationTitle == jNames[i]) { - //Zotero.debug("using Xpath for: " + jNames[i]); - //Zotero.debug("Xpath is: " + jXpaths[i]); - jXpath = jXpaths[i]; - } - } - - bookTitle = doc.evaluate(jXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - //Zotero.debug("bookTitle: " + bookTitle); - - // 16apr08 - fwg - //instead of general failure, let's admit we can't get the title and save everything else - // this is useful when a book review page has a one-off introduction or strange formatting that we can't anticipate. - if (bookTitle) { - newItem.title = "Review of " + bookTitle.textContent; - } else { - newItem.title = "Review of <unable to get title from page>"; - } - } - - var author = metaTags.namedItem("Author"); - if(author) { - var authors = author.getAttribute("content").split(" and "); - for(j in authors) { - authors[j] = authors[j].replace("Reviewed by ", ""); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j], "author")); - } - } - - var month = metaTags.namedItem("PublicationMonth"); - var year = metaTags.namedItem("PublicationYear"); - if(month && year) { - newItem.date = month.getAttribute("content")+" "+year.getAttribute("content"); - } - - newItem.attachments.push({document:doc, title:"History Cooperative Snapshot"}); - - newItem.complete(); -} - -function doWeb(doc, url) { - var contents = doc.title.replace(" Contents | ", ""); - if(doc.title != contents || doc.title == "History Cooperative: Search Results") { - var items = Zotero.Utilities.getItemArray(doc, doc, '^https?://[^/]+/journals/.+/.+/.+\.html$'); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var uris = new Array(); - for(var i in items) { - uris.push(i); - } - - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, - function() { Zotero.done(); }, null); - - Zotero.wait(); - } else { - scrape(doc); - } -} -\ No newline at end of file diff --git a/translators/Hurricane Digital Memory Bank.js b/translators/Hurricane Digital Memory Bank.js @@ -1,114 +0,0 @@ -{ - "translatorID":"9418dcc2-cc1e-432b-b7a6-7b00b7402d2f", - "translatorType":4, - "label":"Hurricane Digital Memory Bank", - "creator":"Adam Crymble", - "target":"http://hurricanearchive.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-21 15:45:00" -} - -function detectWeb(doc, url) { - - if (doc.evaluate('//p[@id="cite-as"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } else if (doc.evaluate('//p[@class="object_description"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } -} - -//Hurricane Digital Memory Bank translator; Code by Adam Crymble - -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("book"); - - var dataTags = new Object(); - var tagsContent = new Array(); - var tags; - var cite = doc.evaluate('//p[@id="cite-as"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var split1 = new Array(); - var split2 = new Array(); - var split3 = new Array(); - var split4 = new Array(); - var split5 = new Array(); - - //author - split1 = cite.split(', "'); - var authorWords = split1[0].split(/\b\s/); - if (authorWords.length > 3) { - newItem.creators.push({lastName: split1[0], creatorType: "creator"}); - } else { - - newItem.creators.push(Zotero.Utilities.cleanAuthor(split1[0], "author")); - } - - //title - split2 = split1[1].split('." '); - newItem.title = split2[0]; - - //repository - split3 = split2[1].split("Bank, "); - - //object number - split4 = split3[1].split(" ("); - newItem.callNumber = split4[0]; - - //date posted and URL - split5 = split4[1].split(")<"); - newItem.date = split5[0]; - - //tags - if (doc.evaluate('//ul[@class="taglist"][@id="tags"]/li', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var xPathTags = doc.evaluate('//ul[@class="taglist"][@id="tags"]/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var tagsCount = doc.evaluate('count (//ul[@class="taglist"][@id="tags"]/li)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (var i =0; i < tagsCount.numberValue; i++) { - newItem.tags[i] = xPathTags.iterateNext().textContent; - } - } - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - - var links = doc.evaluate('//p[@class="object_description"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('//p[@class="object_description"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - - while (next_title = titles.iterateNext()) { - - items[links.iterateNext().href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/IEEE Computer Society.js b/translators/IEEE Computer Society.js @@ -1,224 +0,0 @@ -{ - "translatorID":"8d72adbc-376c-4a33-b6be-730bc235190f", - "translatorType":4, - "label":"IEEE Computer Society", - "creator":"fasthae@gmail.com", - "target":"^http?://(www[0-9]?|search[0-9]?).computer.org/(portal/web/csdl/(magazines/[0-9a-z]+#(3|4)|transactions/[0-9a-z]+#(3|4)|letters/[0-9a-z]+#(3|4)|proceedings/[0-9a-z]+#(4|5)|doi|abs/proceedings)|search/results)", - "minVersion":"1.0.7", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2009-03-14 16:07:05" -} - -function detectWeb(doc, url) { - //supports table of contents, seach results and single document pages - if (url.indexOf("search/results") >1) { - return "multiple"; - } else if (url.indexOf("/portal/web/csdl/magazines/") > 1) { - if (url.indexOf("#3") != -1) return "multiple"; - else return "magazineArticle"; - } else if (url.indexOf("/portal/web/csdl/transactions/") > 1) { - if (url.indexOf("#3") != -1) return "multiple"; - else return "journalArticle"; - } else if (url.indexOf("/portal/web/csdl/proceedings/") > 1) { - if (url.indexOf("#4") != -1) return "multiple"; - else return "conferencePaper"; - } else if (url.indexOf("/portal/web/csdl/abs/proceedings/") > 1) { - return "multiple"; - } else if (url.indexOf("/portal/web/csdl/letters/") > 1) { - if (url.indexOf("#3") != -1) return "multiple"; - else return "letter"; - } else if (url.indexOf("/portal/web/csdl/doi/") > 1) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; - else return null; - } : null; - var refWork = doc.evaluate('//div[@id="refWorksText-content"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - refWork = refWork.textContent.substr(0,9); - if (refWork.indexOf("JOUR")>1) return "journalArticle"; - else if (refWork.indexOf("MGZN")>1) return "magazineArticle"; - else if (refWork.indexOf("CONF")>1) return "conferencePaper"; - else return false; - } else { - return false; - } - -} -// move this to a var to pass to scrape -var templte; - -function doWeb(doc, url) { - if (detectWeb(doc,url) == 'multiple') { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - templte = doc.body.innerHTML; - templte = templte.substr(templte.indexOf("linkWithParms += '&")+19); - templte = templte.substr(0,templte.indexOf("';")); - - var items = new Array(); - var search = 0; - - if (url.indexOf("search/results") != -1) { - var entries = doc.evaluate('//div[@id="toc-articles-list" or @class="searchresult-data"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var entry; - while(entry = entries.iterateNext()) { - var title = ""; - var titleNode = doc.evaluate('.//b', entry, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (titleNode) title += titleNode.textContent; - var linkNode = doc.evaluate('.//img[@src="images/abstract_icon.gif"]/ancestor::a', entry, nsResolver, XPathResult.ANY_TYPE,null).iterateNext(); - if (linkNode) { - var link = linkNode.href; - items[link] = Zotero.Utilities.trimInternal(title); - } - } - } - else { - var entries = doc.evaluate('//div[@id="toc-articles-list"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var entry; - while(entry = entries.iterateNext()) { - var title = ""; - titleNode = doc.evaluate('./a', entry,nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (titleNode) { - title += titleNode.textContent; - //add link url of the abstract icon - var linkk; - if (titleNode.href.indexOf( 'javascript:void(0)') != -1) { - linkk = titleNode.attributes.getNamedItem("onclick").value; - linkk = linkk.substr(linkk.indexOf('"')+1); - linkk = linkk.substr(0,linkk.indexOf('"')); - if (linkk.indexOf("?") > -1) { - linkk += '&'+templte; - } - else { - linkk += '?'+templte; - } - linkk = "http://www2.computer.org"+linkk; - } else linkk=titleNode.href; - - items[linkk] = Zotero.Utilities.trimInternal(title); - } - } - } - - // let user select documents to scrape - items = Zotero.selectItems(items); - if(!items) return true; - var urls = new Array(); - for(var url in items) { - urls.push(url); - } - - if (search != 1) Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - else Zotero.Utilities.doGet(urls, scrapt,function() { Zotero.done(); }); - - Zotero.wait(); - } else { - scrape(doc); - } -} - -function scrapt(txt) { - throw "Not Supported yet!"; -} - - -function scrape(doc,url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - var itemType = detectWeb(doc, doc.location.href); - var abstractText = doc.evaluate('//div[@class="abs-articlesummary"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abstractText) abstractText = Zotero.Utilities.trimInternal(abstractText.textContent); - var keywords = new Array(); - var keywordText = doc.evaluate('//div[span="Index Terms:"]/div', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (keywordText) keywords = (Zotero.Utilities.trimInternal(keywordText.textContent.toLowerCase())).split(","); - var attachments = new Array(); - var notes = new Array(); - attachments.push({document:doc}); - - var htmls = doc.evaluate('//img[@src="/plugins/images/digitalLibrary/dl_html_icon.gif"]/ancestor::a', doc,nsResolver,XPathResult.ANY_TYPE, null); - var htmlDoc; - - if (htmlDoc = htmls.iterateNext()) { - //var urlField = htmlDoc.attributes.getNamedItem("onclick").value; - var urlField = htmlDoc.href; - urlField = urlField.substr(urlField.indexOf('"')+1); - urlField = urlField.substr(0,urlField.indexOf('"')); - if (urlField.indexOf("?") > -1) { - urlField += '&'+templte; - } - else { - urlField += '?'+templte; - } - urlField = "http://www2.computer.org"+urlField; - var mimeTypeField = "text/html"; - var titleField = "Complete HTML document"; - var attachment = {url:urlField, mimeType:mimeTypeField, title:titleField}; - attachments.push(attachment); - } - - var pdfs = doc.evaluate('//img[@src="/plugins/images/digitalLibrary/dl_pdf_icon.gif"]/ancestor::a', doc,nsResolver,XPathResult.ANY_TYPE, null); - var pdf; - - if (pdf = pdfs.iterateNext()) { - //deprecated - //var onclickAttrValue = pdf.attributes.getNamedItem("onclick").value; - //var urlField = onclickAttrValue.substring( 10, onclickAttrValue.indexOf("',") ); - var urlField = pdf.attributes.getNamedItem("onclick").value; - urlField = urlField.substr(urlField.indexOf('"')+1); - urlField = urlField.substr(0,urlField.indexOf('"')); - - if (urlField.indexOf("?") > -1) { - urlField += '&'+templte; - } - else { - urlField += '?'+templte; - } - urlField = "http://www2.computer.org"+urlField; - var mimeTypeField = "application/pdf"; - var titleField = "Complete PDF document"; - var attachment = {url:urlField, mimeType:mimeTypeField, title:titleField}; - attachments.push(attachment); - } else { - notes.push( {note:"Complete PDF document was either not available or accessible. Please make sure you're logged in to the digital library to retrieve the complete PDF document."} ); - } - - var bibtex = doc.evaluate('//div[@id="bibText-content"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if (bibtex) { - bibtex = bibtex.textContent; - //bibtex = bibtex.substring(bibtex.indexOf("document.write('")+16,bibtex.indexOf("');Popup.document.close();")); - //workaround as bibtex translator obviously needs a whitespace following the first curly brace - bibtex = Zotero.Utilities.cleanTags(bibtex); - bibtex = Zotero.Utilities.trimInternal(bibtex); - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(bibtex); - translator.setHandler("itemDone", function(obj, item) { - if (item.url) { // add http to url - item.url = "http://"+item.url; - } - if (itemType) item.itemType = itemType; - item.attachments = attachments; - if (abstractText) item.abstractNote = abstractText; - if (keywords) item.tags = keywords; - if (notes) item.notes = notes; - - item.complete(); - }); - translator.translate(); - - } else { - throw "No BibTeX found!"; - } -} -\ No newline at end of file diff --git a/translators/IEEE Xplore.js b/translators/IEEE Xplore.js @@ -1,396 +0,0 @@ -{ - "translatorID": "92d4ed84-8d0-4d3c-941f-d4b9124cfbb", - "label": "IEEE Xplore", - "creator": "Simon Kornblith, Michael Berkowitz, Bastian Koenings, and Avram Lyon", - "target": "^https?://[^/]*ieeexplore\\.ieee\\.org[^/]*/(?:[^\\?]+\\?(?:|.*&)arnumber=[0-9]+|search/(?:searchresult.jsp|selected.jsp))", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-04 12:17:06" -} - -function detectWeb(doc, url) { - var articleRe = /[?&]ar(N|n)umber=([0-9]+)/; - var m = articleRe.exec(url); - - if(m) { - return "journalArticle"; - } else { - return "multiple"; - } - - return false; -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var hostRe = new RegExp("^(https?://[^/]+)/"); - var hostMatch = hostRe.exec(url); - - var articleRe = /[?&]ar(?:N|n)umber=([0-9]+)/; - var m = articleRe.exec(url); - - if(detectWeb(doc, url) == "multiple") { - // search page - var items = new Array(); - - var xPathRows = '//ul[@class="Results"]/li[@class="noAbstract"]/div[@class="header"]'; - var tableRows = doc.evaluate(xPathRows, doc, nsResolver, XPathResult.ANY_TYPE, null); - var tableRow; - while(tableRow = tableRows.iterateNext()) { - var linknode = doc.evaluate('.//div[@class="detail"]/h3/a', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(!linknode) { - // There are things like tables of contents that don't have item pages, so we'll just skip them - continue; - } - var link = linknode.href; - var title = ""; - var strongs = tableRow.getElementsByTagName("h3"); - for each(var strong in strongs) { - if(strong.textContent) { - title += strong.textContent+" "; - } - } - - items[link] = Zotero.Utilities.trimInternal(title); - } - - items = Zotero.selectItems(items); - if(!items) return true; - - var urls = new Array(); - for(var url in items) { - // Some pages don't show the metadata we need (http://forums.zotero.org/discussion/16283) - // No data: http://ieeexplore.ieee.org/search/srchabstract.jsp?tp=&arnumber=1397982 - // No data: http://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=1397982 - // Data: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=1397982 - var arnumber = url.match(/arnumber=(\d+)/)[1]; - url = url.replace(/\/(?:search|stamp)\/.*$/, "/xpls/abs_all.jsp?arnumber="+arnumber); - urls.push(url); - } - Zotero.Utilities.processDocuments(urls, scrape, function () { Zotero.done(); }); - Zotero.wait(); - } else { - if (url.indexOf("/search/") !== -1 || url.indexOf("/stamp/") !== -1 || url.indexOf("/ielx4/")) { - // Address the same missing metadata problem as above - // Also address issue of saving from PDF itself, I hope - // URL like http://ieeexplore.ieee.org/ielx4/78/2655/00080767.pdf?tp=&arnumber=80767&isnumber=2655 - var arnumber = url.match(/arnumber=(\d+)/)[1]; - url = url.replace(/\/(?:search|stamp|ielx4)\/.*$/, "/xpls/abs_all.jsp?arnumber="+arnumber); - Zotero.Utilities.processDocuments([url], scrape, function () { Zotero.done(); }); - Zotero.wait(); - } else { - scrape(doc, url); - } - } -} - -function parseIdentifier(identifier) { - var idPieces = identifier.split(':'); - if (idPieces.length > 1) { - var prefix = idPieces.shift(); - switch (prefix.toLowerCase()) { - case "doi": return ["doi", idPieces.join(':')]; - case "isbn": return ["isbn", idPieces.join(':')]; - case "issn": return ["issn", idPieces.join(':')]; - case "pmid": return ["pmid", idPieces.join(':')]; - default: // do nothing - } - Zotero.debug("Unknown identifier prefix '"+prefix+"'"); - return [prefix, idPieces.join(':')]; - } - if (identifer.substr(0,3) == '10.') return ["doi", identifier]; - - // If we're here, we have a funny number, and we don't know what to do with it. - var ids = idCheck(identifier); - if (ids.isbn13) return ["isbn13", isbn13]; - if (ids.isbn10) return ["isbn10", isbn10]; - if (ids.issn) return ["issn", isbn10]; - - return ["unknown", identifier]; -} - -function addIdentifier(identifier, item) { - var parsed = parseIdentifier(identifier); - switch (parsed[0]) { - case "doi": item.DOI = parsed[1]; break; - case "isbn": item.ISBN = parsed[1]; break; - case "isbn13": item.ISBN = parsed[1]; break; - case "isbn10": item.ISBN = parsed[1]; break; - case "issn": item.ISSN = parsed[1]; break; - default: - } -} - -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.attachments = []; - newItem.tags = []; - 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) { - // PRISM - case "prism.publicationName": newItem.publicationTitle = value; break; - case "prism.issn": if (!newItem.ISSN && value != "NaN" && value != "") newItem.ISSN = value; break; - case "prism.eIssn": if (!newItem.ISSN && value != "NaN" && value != "") newItem.ISSN = value; break; - // This is often NaN for some reason - case "prism.publicationDate": if (!newItem.date && value != "NaN" && value !== "") newItem.date = value; break; - case "prism.volume": if (!newItem.volume && value != "NaN" && value != "") newItem.volume = value; break; - case "prism.number": if (!newItem.issue && value != "NaN" && value != "") newItem.issue = value; break; - // These also seem bad - case "prism.startingPage": if(!pages[0] && value != "null" && value != "") pages[0] = value; break; - case "prism.endingPage": if(!pages[1] && value != "null" && value != "") pages[1] = value; break; - case "prism.number": newItem.issue = value; break; - // Google. - case "citation_journal_title": if (!newItem.publicationTitle) newItem.publicationTitle = value; break; - case "citation_authors": - case "citation_author": - // I'm a little concerned we'll see multiple copies of the author names... - for each(var author in value.split(';')) - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author", true)); - break; - 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; - // Prefer long language names - case "citation_language": if ((!newItem.language || newItem.language.length < 4) - && value != "null" && value != "") newItem.language = value; break; - case "citation_doi": if (!newItem.DOI) newItem.DOI = value; break; - case "citation_conference": - newItem.itemType = "conferencePaper"; - newItem.conferenceName = value; - break; - case "citation_abstract": newItem.abstractNote = value; break; - case "citation_abstract_html_url": newItem.attachments.push({url:value, title:"IEEE Xplore Abstract Record", snapshot:false}); break; - case "citation_pdf_url": if(!pdf) pdf = value; break; - case "citation_keywords": newItem.tags.push(value); break; - case "citation_fulltext_html_url": if(!pdf) pdf = value; break; - case "fulltext_pdf": if(!pdf) pdf = value; break; - // Dublin Core - case "dc.publisher": if(!newItem.publisher) newItem.publisher = value; break; - case "dc.language": if(!newItem.language) newItem.language = value; break; - case "dc.rights": if(!newItem.rights) newItem.rights = value; break; - case "dc.title": if(!newItem.title) newItem.title = value; break; - case "dc.creator": if(!newItem.creators.length == 0) newItem.creators.push(Zotero.Utilities.cleanAuthor(value)); break; - // This is often NaN for some reason - case "dc.date": if (!newItem.date && value != "NaN" && value !== "") newItem.date = value; break; - case "dc.identifier": addIdentifier(value, newItem); break; - default: - Zotero.debug("Ignoring meta tag: " + tag + " => " + value); - } - } - - // Split if we have only one tag - if (newItem.tags.length == 1) { - newItem.tags = newItem.tags[0].split(";"); - } - - if (html) newItem.attachments.push({url:html, title:"IEEE Xplore Full Text HTML"}); - - if (pages[0] && pages[1]) newItem.pages = pages.join('-') - else newItem.pages = pages[0] ? pages[1] : (pages[1] ? pages[1] : ""); - - // Re-assign fields if the type changed - if (newItem.itemType == "conferencePaper") { - newItem.proceedingsTitle = newItem.publicationTitle = newItem.conferenceName; - } - - // Abstracts don't seem to come with - if (!newItem.abstractNote) { - var abstractNode = doc.evaluate('//a[@name="Abstract"]/following-sibling::p[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abstractNode) newItem.abstractNote = Zotero.Utilities.trimInternal(abstractNode.textContent); - } - - var res; - // Rearrange titles, per http://forums.zotero.org/discussion/8056 - // If something has a comma or a period, and the text after comma ends with - //"of", "IEEE", or the like, then we switch the parts. Prefer periods. - if (res = (newItem.publicationTitle.indexOf(".") !== -1) ? - newItem.publicationTitle.trim().match(/^(.*)\.(.*(?:of|on|IEE|IEEE|IET|IRE))$/) : - newItem.publicationTitle.trim().match(/^(.*),(.*(?:of|on|IEE|IEEE|IET|IRE))$/)) - newItem.publicationTitle = res[2]+" "+res[1]; - newItem.proceedingsTitle = newItem.conferenceName = newItem.publicationTitle; - - if (pdf) { - Zotero.Utilities.processDocuments([pdf], function (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var pdfFrame = doc.evaluate('//frame[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (pdfFrame) newItem.attachments = [{url:pdfFrame.src, title:"IEEE Xplore Full Text PDF", mimeType:"application/pdf"}]; - newItem.complete(); - }, null); - } else { - newItem.complete(); - } -} - -// Implementation of ISBN and ISSN check-digit verification -// Based on ISBN Users' Manual (http://www.isbn.org/standards/home/isbn/international/html/usm4.htm) -// and the Wikipedia treatment of ISBN (http://en.wikipedia.org/wiki/International_Standard_Book_Number) -// and the Wikipedia treatment of ISSN (http://en.wikipedia.org/wiki/International_Standard_Serial_Number) - -// This will also check ISMN validity, although it does not distinguish from their -// neighbors in namespace, ISBN-13. It does not handle pre-2008 M-prefixed ISMNs; see -// http://en.wikipedia.org/wiki/International_Standard_Music_Number - -// This does not validate multiple identifiers in one field, -// but it will gracefully ignore all non-number detritus, -// such as extraneous hyphens, spaces, and comments. - -// It currently maintains hyphens in non-initial and non-final position, -// discarding consecutive ones beyond the first as well. - -// It also adds the customary hyphen to valid ISSNs. - -// Takes the first 8 valid digits and tries to read an ISSN, -// takes the first 10 valid digits and tries to read an ISBN 10, -// and takes the first 13 valid digits to try to read an ISBN 13 -// Returns an object with four attributes: -// "issn" -// "isbn10" -// "isbn13" -// Each will be set to a valid identifier if found, and otherwise be a -// boolean false. - -// There could conceivably be a valid ISBN-13 with an ISBN-10 -// substring; this should probably be interpreted as the latter, but it is a -idCheck = function(isbn) { - // For ISBN 10, multiple by these coefficients, take the sum mod 11 - // and subtract from 11 - var isbn10 = [10, 9, 8, 7, 6, 5, 4, 3, 2]; - - // For ISBN 13, multiple by these coefficients, take the sum mod 10 - // and subtract from 10 - var isbn13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]; - - // For ISSN, multiply by these coefficients, take the sum mod 11 - // and subtract from 11 - var issn = [8, 7, 6, 5, 4, 3, 2]; - - // We make a single pass through the provided string, interpreting the - // first 10 valid characters as an ISBN-10, and the first 13 as an - // ISBN-13. We then return an array of booleans and valid detected - // ISBNs. - - var j = 0; - var sum8 = 0; - var num8 = ""; - var sum10 = 0; - var num10 = ""; - var sum13 = 0; - var num13 = ""; - var chars = []; - - for (var i=0; i < isbn.length; i++) { - if (isbn.charAt(i) == " ") { - // Since the space character evaluates as a number, - // it is a special case. - } else if (j > 0 && isbn.charAt(i) == "-" && isbn.charAt(i-1) != "-") { - // Preserve hyphens, except in initial and final position - // Also discard consecutive hyphens - if(j < 7) num8 += "-"; - if(j < 10) num10 += "-"; - if(j < 13) num13 += "-"; - } else if (j < 7 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum8 += isbn.charAt(i) * issn[j]; - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num8 += isbn.charAt(i); - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } else if (j == 7 && - (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || - ((isbn.charAt(i) - 0) == isbn.charAt(i)))) { - // In ISSN, an X represents the check digit "10". - if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") { - var check8 = 10; - num8 += "X"; - } else { - var check8 = isbn.charAt(i); - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num8 += isbn.charAt(i); - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } - } else if (j < 9 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } else if (j == 9 && - (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || - ((isbn.charAt(i) - 0) == isbn.charAt(i)))) { - // In ISBN-10, an X represents the check digit "10". - if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") { - var check10 = 10; - num10 += "X"; - } else { - var check10 = isbn.charAt(i); - sum13 += isbn.charAt(i) * isbn13[j]; - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } - } else if(j < 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum13 += isbn.charAt(i) * isbn13[j]; - num13 += isbn.charAt(i); - j++; - } else if (j == 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - var check13 = isbn.charAt(i); - num13 += isbn.charAt(i); - } - } - var valid8 = ((11 - sum8 % 11) % 11) == check8; - var valid10 = ((11 - sum10 % 11) % 11) == check10; - var valid13 = (10 - sum13 % 10 == check13); - var matches = false; - - // Since ISSNs have a standard hyphen placement, we can add a hyphen - if (valid8 && (matches = num8.match(/([0-9]{4})([0-9]{3}[0-9Xx])/))) { - num8 = matches[1] + '-' + matches[2]; - } - - if(!valid8) {num8 = false}; - if(!valid10) {num10 = false}; - if(!valid13) {num13 = false}; - return {"isbn10" : num10, "isbn13" : num13, "issn" : num8}; -} diff --git a/translators/IGN.js b/translators/IGN.js @@ -1,68 +0,0 @@ -{ - "translatorID":"d210c5a1-73e1-41ad-a3c9-331d5a3ead48", - "label":"IGN", - "creator":"odie5533", - "target":"^http://[^/]*\\.ign\\.com/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-08-12 16:16:53" -} - -/* - IGN Translator - Parses IGN articles and creates Zotero-based metadata - Copyright (C) 2010-2011 odie5533 - - 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) { - if (url.match(/articles/)) { - return "webpage"; - } -} - -function scrape(doc, url) { - var newItem = new Zotero.Item("webpage"); - newItem.publicationTitle = "IGN"; - newItem.url = doc.location.href; - newItem.title = doc.title.replace(/ - [^-]+ at IGN/, ""); - - // pages - var pages = doc.evaluate('//div[@class="ui-page-list clear"]/ul/li[last()-1]', doc, null, XPathResult.ANY_TYPE, null); - if (p = pages.iterateNext()) - newItem.pages = p.textContent; - - // date - var dates = doc.evaluate('//h2[@class="publish-date"]/text()', doc, null, XPathResult.ANY_TYPE, null); - newItem.date = dates.iterateNext().textContent.replace(/^\s+|\s+$/g,''); - - //authors - var byline = doc.evaluate('//div[@class="hdr-sub byline"]/a/text()', doc, null, XPathResult.ANY_TYPE, null); - var authors = byline.iterateNext().textContent.split(" and "); - for each(var a in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(a, "author")); - } - - // attach html - newItem.attachments.push({title:"IGN Article Snapshot", document:doc}); - - newItem.complete(); -} - -function doWeb(doc, url) { - scrape(doc, url); -} diff --git a/translators/IMDb.js b/translators/IMDb.js @@ -1,123 +0,0 @@ -{ - "translatorID": "a30274ac-d3d1-4977-80f4-5320613226ec", - "label": "IMDb", - "creator": "Avram Lyon", - "target": "^https?://www\\.imdb\\.com/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-29 09:44:03" -} - -/* - IMDB 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){ - if (url.match(/\/title\/tt\d+/)) { - return "film"; - } else if (url.match(/\/find\?/)){ - return "multiple"; - } -} - -function doWeb(doc, url){ - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var ids = new Array(); - if (detectWeb(doc, url) == "multiple") { - var results = doc.evaluate('//td[a[contains(@href,"/title/tt")]]', doc, ns, XPathResult.ANY_TYPE, null); - var items = new Array(); - var result; - while(result = results.iterateNext()) { - var link = doc.evaluate('./a[contains(@href,"/title/tt")]', result, ns, XPathResult.ANY_TYPE, null).iterateNext(); - var title = result.textContent; - Zotero.debug(link.href); - var url = link.href.match(/\/title\/(tt\d+)/)[1]; - items[url] = title; - } - - Zotero.selectItems(items, function(items) { - if(!items) { - Zotero.done(); - return true; - } - for (var i in items) { - ids.push(i); - } - apiFetch(ids); - }); - } else { - var id = url.match(/\/title\/(tt\d+)/)[1]; - apiFetch([id]); - } - Zotero.wait(); -} - -// Takes IMDB IDs and makes items -function apiFetch(ids) { - var apiRoot = "http://imdbapi.com/?tomatoes=true&i="; - for (i in ids) ids[i] = apiRoot + ids[i]; - Zotero.Utilities.doGet(ids, parseIMDBapi, function() {Zotero.done()}); -} - -// parse result from imdbapi.com -// should be json -function parseIMDBapi(text, response, url) { - Zotero.debug(url); - Zotero.debug(text); - try { - var obj = JSON.parse(text); - } catch (e) { - Zotero.debug("JSON parse error"); - throw e; - } - var item = new Zotero.Item("film"); - item.title = obj.Title; - item.date = obj.Released ? obj.Released : obj.Year; - item.genre = obj.Genre; - if(obj.Director) item = addCreator(item, obj.Director, "director"); - if(obj.Writer) item = addCreator(item, obj.Writer, "scriptwriter"); - if(obj.Actors) item = addCreator(item, obj.Actors, "contributor"); - item.abstractNote = obj.Plot; - item.attachments.push({url:obj.Poster, title:"Poster"}); - item.runningTime = obj.Runtime; - item.extra = "IMDB ID: " + obj.ID; - item.extra += "; IMDB Rating: " + obj.Rating + " ("+obj.Votes+" votes)"; - item.extra += "; Rotten Tomatoes: " + obj.tomatoRating - + " ("+obj.tomatoReviews+" reviews " - +" "+obj.tomatoFresh +" fresh, "+obj.tomatoRotten+" rotten)" - +", Tomato Meter: "+obj.tomatoMeter; - item.complete(); -} - -function addCreator (item, creator, type) { - if (creator == "N/A") { - Zotero.debug("Discarding "+type+"="+creator); - return item; - } - var broken = creator.split(","); - for (i in broken) { - item.creators.push(Zotero.Utilities.cleanAuthor(broken[i], type)); - } - return item; -} diff --git a/translators/IRIS.js b/translators/IRIS.js @@ -1,326 +0,0 @@ -{ - "translatorID":"8381bf68-11fa-418c-8530-2e00284d3efd", - "translatorType":4, - "label":"IRIS", - "creator":"Chad Mills and Michael Berkowitz", - "target":"https://[^/]*www.iris.rutgers.edu[^/]*/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('/html/body/div[@class="columns_container"]/div[contains(@class, "left_column")]/div[@class="content_container"]/div[@class="content"]/form[@id="hitlist"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('/html/body/div[@class="columns_container"]/div[contains(@class, "left_column")]/form[@name="item_view"]/div[@class="content_container item_details"]/div[@class="content"]/ul[contains(@class, "detail_page")]/li/div/table', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '/html/body/div[@class="columns_container"]/div[contains(@class, "left_column")]/form[@name="item_view"]/div[@class="content_container item_details"]/div[@class="content"]/ul[contains(@class, "detail_page")]/li/div/table//tr[th[@class="viewmarctags1"]][td[@class="viewmarctags"]]'; - - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - - var elmt = elmts.iterateNext(); - - if(!elmt) { - return false; - } - - var newItem = new Zotero.Item("book"); - newItem.extra = ""; - - newItem.series = ""; - var seriesItemCount = 0; - - while(elmt) { - try { - var node = doc.evaluate('./TD[1]/A[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(!node) { - var node = doc.evaluate('./TD[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - } - if(node) { - var casedField = Zotero.Utilities.superCleanString(doc.evaluate('./TH[1]/text()', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - field = casedField.toLowerCase(); - - var value = Zotero.Utilities.superCleanString(node.nodeValue); - - if(field == "publisher") { - newItem.publisher = value; - }else if(field == "pub date") { - var re = /[0-9]+/; - var m = re.exec(value); - newItem.date = m[0]; - }else if(field == "isbn") { - var re = /^[0-9](?:[0-9X]+)/; - var m = re.exec(value); - newItem.ISBN = m[0]; - }else if(field == "title") { - Zotero.debug(value); - var titleParts = value.split(" / "); - re = /\[(.+)\]/i; - if (re.test(titleParts[0])) { - var ar = re.exec(titleParts[0]); - var itype = ar[1].toLowerCase(); - if(itype== "phonodisc" || itype == "sound recording"){ - newItem.itemType = "audioRecording"; - }else if(itype=="videorecording"){ - newItem.itemType = "videoRecording"; - }else if(itype=="electronic resource"){ - newItem.itemType = "webPage"; - } - } - newItem.title = Zotero.Utilities.capitalizeTitle(titleParts[0]); - }else if(field == "series") {//push onto item, delimit with semicolon when needed - if (seriesItemCount != 0){ - newItem.series += "; " + value; - }else if(seriesItemCount == 0) { - newItem.series = value; - } - seriesItemCount++;//bump counter - }else if(field == "dissertation note") { - newItem.itemType = "thesis"; - var thesisParts = value.split("--"); - var uniDate = thesisParts[1].split(", "); - newItem.university = uniDate[0]; - newItem.date = uniDate[1]; - }else if(field == "edition") { - newItem.edition = value; - }else if(field == "physical descrip") { - //support - var physParts = value.split(" : "); - var physParts = physParts[0].split(" ; "); - //determine pages, split on " p." - var physPages = value.split(" p."); - //break off anything in the beginning before the numbers - var pageParts = physPages[0].split(" "); - newItem.numPages = pageParts[pageParts.length-1]; - }else if(field == "publication info") { - var pubParts = value.split(" : "); - newItem.place = pubParts[0]; - //drop off first part of array and recombine - pubParts.shift(); - var i; - var publisherInfo; - for (i in pubParts) { - if (i == 0) { - publisherInfo = pubParts[i] + " : "; - } else { - publisherInfo = publisherInfo + pubParts[i] + " : "; - } - }//END for - //drop off last colon - publisherInfo = publisherInfo.substring(0,(publisherInfo.length - 3)); - //break apart publication parts into Publisher and Date - var publisherParts = publisherInfo.split(","); - newItem.publisher = publisherParts[0]; - //check that first character isn't a 'c', if so drop it - if (publisherParts[1].substring(1,2) == "c") { - newItem.date = publisherParts[1].substring(2); - } - else { - newItem.date = publisherParts[1]; - } - }else if(field == "personal author") { - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); - }else if(field == "performer") { - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "performer", true)); - }else if(field == "author"){ - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); - }else if(field == "added author") { - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "contributor", true)); - }else if(field == "conference author" || field == "corporate author") { - newItem.creators.push(value); - }else if(field == "subject" || field == "corporate subject" || field == "geographic term") { - var subjects = value.split("--"); - newItem.tags = newItem.tags.concat(subjects); - }else if(field == "personal subject") { - var subjects = value.split(", "); - newItem.tags = newItem.tags.push(value[0]+", "+value[1]); - }else if(value && field != "http") { - newItem.extra += casedField+": "+value+"\n"; - } - } - } catch (e) {} - elmt = elmts.iterateNext(); - }//END if node - - if(newItem.extra) { - newItem.extra = newItem.extra.substr(0, newItem.extra.length-1); - } - - var callNumber = doc.evaluate('//tr/td[1][@class="holdingslist"]/strong/text()', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if(callNumber && callNumber.nodeValue) { - newItem.callNumber = callNumber.nodeValue; - } - - newItem.libraryCatalog = "IRIS"; - newItem.complete(); - return true; - }//END try - - function doWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var sirsiNew = true; //toggle between SIRSI -2003 and SIRSI 2003+ - - var xpath = '/html/body/div[@class="columns_container"]/div[contains(@class, "left_column")]/div[@class="content_container"]/div[@class="content"]/form[@id="hitlist"]/ul[@class="hit_list"]/li/ul[starts-with(@class, "hit_list_row")]/li[@class="hit_list_item_info"]/dl'; - - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: searchsum"); - sirsiNew = true; - }else if (doc.evaluate('//form[@name="hitlist"]/table/tbody/tr', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: hitlist"); - sirsiNew = false; - }else if (doc.evaluate('//tr[th[@class="viewmarctags"]][td[@class="viewmarctags"]]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: viewmarctags"); - sirsiNew = true; - }else if (doc.evaluate('//input[@name="VOPTIONS"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: VOPTIONS"); - sirsiNew = false; - }else { - var elmts = doc.evaluate('/html/body/form//text()', doc, nsResolver, XPathResult.ANY_TYPE, null); - //var elmts = doc.evaluate(' ', doc, nsResolver, XPathResult.ANY_TYPE, null); - while(elmt = elmts.iterateNext()) { - if(Zotero.Utilities.superCleanString(elmt.nodeValue) == "Viewing record") { - Zotero.debug("SIRSI doWeb: Viewing record"); - sirsiNew = false; - } - }//END while elmts - }//END FUNCTION doWeb - - if (sirsiNew) { //executes Simon's SIRSI 2003+ scraper code - if(!scrape(doc)) { - var checkboxes = new Array(); - var urls = new Array(); - var availableItems = new Array(); - //pull items - var tableRows = doc.evaluate('//ul[@class="hit_list"]/li/ul[contains(@class, "hit_list_row")][//input[@value="Details"]]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - var input = doc.evaluate('.//input[@value="Details"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var text = doc.evaluate('.//strong', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if(text) { - availableItems[input.name] = text; - } - }//END while - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - var hostRe = new RegExp("^http(?:s)?://[^/]+"); - var m = hostRe.exec(doc.location.href); - Zotero.debug("href: " + doc.location.href); - var hitlist = doc.forms.namedItem("hitlist"); - var baseUrl = m[0]+hitlist.getAttribute("action")+"?first_hit="+hitlist.elements.namedItem("first_hit").value+"&last_hit="+hitlist.elements.namedItem("last_hit").value; - var uris = new Array(); - for(var i in items) { - uris.push(baseUrl+"&"+i+"=Details"); - } - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, function() { Zotero.done() }, null); - Zotero.wait(); - }//END if not scrape(doc) - }else{ //executes Simon's SIRSI -2003 translator code - Zotero.debug("Running SIRSI -2003 code"); - var uri = doc.location.href; - var recNumbers = new Array(); - var xpath = '//form[@name="hitlist"]/table/tbody/tr'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - if(elmt) { // Search results page - var uriRegexp = /^http:\/\/[^\/]+/; - var m = uriRegexp.exec(uri); - var postAction = doc.forms.namedItem("hitlist").getAttribute("action"); - var newUri = m[0]+postAction.substr(0, postAction.length-1)+"40"; - var titleRe = /<br>\s*(.*[^\s])\s*<br>/i; - var items = new Array(); - do { - var checkbox = doc.evaluate('.//input[@type="checkbox"]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - // Collect title - var title = doc.evaluate("./td[2]", elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if(checkbox && title) { - items[checkbox.name] = Zotero.Utilities.trimInternal(title); - } - } while(elmt = elmts.iterateNext()); - items = Zotero.selectItems(items); - if(!items) { - return true; - } - for(var i in items) { - recNumbers.push(i); - } - } else {// Normal page - // this regex will fail about 1/100,000,000 tries - var uriRegexp = /^((.*?)\/([0-9]+?))\//; - var m = uriRegexp.exec(uri); - var newUri = m[1]+"/40" - var elmts = doc.evaluate('/html/body/form', doc, nsResolver, XPathResult.ANY_TYPE, null); - while(elmt = elmts.iterateNext()) { - var initialText = doc.evaluate('.//text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(initialText && initialText.nodeValue && Zotero.Utilities.superCleanString(initialText.nodeValue) == "Viewing record") { - recNumbers.push(doc.evaluate('./b[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - break; - } - } - } - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.loadDocument(newUri+'?marks='+recNumbers.join(",")+'&shadow=NO&format=FLAT+ASCII&sort=TITLE&vopt_elst=ALL&library=ALL&display_rule=ASCENDING&duedate_code=l&holdcount_code=t&DOWNLOAD_x=22&DOWNLOAD_y=12&address=&form_type=', function(doc) { - var pre = doc.getElementsByTagName("pre"); - var text = pre[0].textContent; - var documents = text.split("*** DOCUMENT BOUNDARY ***"); - for(var j=1; j<documents.length; j++) { - var uri = newUri+"?marks="+recNumbers[j]+"&shadow=NO&format=FLAT+ASCII&sort=TITLE&vopt_elst=ALL&library=ALL&display_rule=ASCENDING&duedate_code=l&holdcount_code=t&DOWNLOAD_x=22&DOWNLOAD_y=12&address=&form_type="; - var lines = documents[j].split("\n"); - var record = new marc.record(); - var tag, content; - var ind = ""; - for(var i=0; i<lines.length; i++) { - var line = lines[i]; - if(line[0] == "." && line.substr(4,2) == ". ") { - if(tag) { - content = content.replace(/\|([a-z])/g, marc.subfieldDelimiter+"$1"); - record.addField(tag, ind, content); - } - } else { - content += " "+line.substr(6); - continue; - } - tag = line.substr(1, 3); - if(tag[0] != "0" || tag[1] != "0") { - ind = line.substr(6, 2); - content = line.substr(8); - } else { - content = line.substr(7); - if(tag == "000") { - tag = undefined; - record.leader = "00000"+content; - Zotero.debug("the leader is: "+record.leader); - } - } - }//end FOR - var newItem = new Zotero.Item(); - record.translate(newItem); - - newItem.libraryCatalog = "IRIS"; - newItem.complete(); - }//end FOR - Zotero.done(); - }); - Zotero.wait(); - }//END while -}//END scrape function diff --git a/translators/ISI Web of Knowledge.js b/translators/ISI Web of Knowledge.js @@ -1,877 +0,0 @@ -{ - "translatorID": "594ebe3c-90a0-4830-83bc-9502825a6810", - "label": "ISI Web of Knowledge", - "creator": "Michael Berkowitz, Avram Lyon", - "target": "^https?://[^/]*webofknowledge\\.com/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 5, - "lastUpdated": "2011-08-01 16:50:59" -} - -function detectWeb(doc, url) { - if (url.indexOf("full_record.do") !== -1) { - return "multiple"; - } else if ((doc.title.indexOf(" Results") !== -1)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var ids = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object; - var xpath = '//a[@class="smallV110"]'; - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href.match(/\?(.*)/)[1]] = next_title.textContent; - } - Zotero.selectItems(items, function (items) { - for (var i in items) { - ids.push(i); - } - fetchIds(ids, url); - }); - } else { - ids.push(url.match(/\?(.*)/)[1]); - fetchIds(ids, url); - } -} - -function fetchIds(ids, url) { - // Call yourself - var importer = Zotero.loadTranslator("import"); - importer.setTranslator("594ebe3c-90a0-4830-83bc-9502825a6810"); - - var hostRegexp = new RegExp("^(https?://[^/]+)/"); - var m = hostRegexp.exec(url); - var host = m[1]; - for (var i in ids) { - ids[i] = host+"/full_record.do?" + ids[i]; - } - var product = url.match("product=([^\&]+)\&")[1]; - Zotero.Utilities.processDocuments(ids, function (newDoc) { - var url = newDoc.location.href; - 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"}]; - item.complete(); - }); - importer.translate(); - }); - }); - }, function() {}); - Zotero.wait(); -} - -function detectImport() { - var line; - var i = 0; - while((line = Zotero.read()) !== false) { - line = line.replace(/^\s+/, ""); - if(line != "") { - if(line.substr(0, 4).match(/^PT [A-Z]/)) { - return true; - } else { - if(i++ > 3) { - return false; - } - } - } - } -} - -function processTag(item, field, content) { - var map = { - "J": "journalArticle", - "S": "bookSection", // Not sure - "P": "patent", - "B": "book" - }; - if (field == "PT") { - item.itemType = map[content]; - if (item.itemType === undefined) { - item.itemType = "journalArticle"; - Zotero.debug("Unknown type: " + content); - } - } else if ((field == "AF" || field == "AU")) { - //Z.debug(content); - authors = content.split("\n"); - for each (var i in authors) { - var author = i.split(","); - item.creators[0][field].push({firstName:author[1].trim(), - lastName:author[0].trim(), - creatorType:"author"}); - } - } else if ((field == "BE")) { - //Z.debug(content); - authors = content.split("\n"); - for each (var i in authors) { - var author = i.split(","); - item.creators[1].push({firstName:author[1].trim(), - lastName:author[0].trim(), - creatorType:"editor"}); - } - } else if (field == "TI") { - item.title = content; - } else if (field == "JI") { - item.journalAbbreviation = content; - } else if (field == "SO") { - item.publicationTitle = content; - } else if (field == "SN") { - item.ISSN = content; - } else if (field == "BN") { - item.ISBN = content; - } else if (field == "PD" || field == "PY") { - if (item.date) { - item.date += " " + content; - } else { - item.date = content; - } - var year = item.date.match(/\d{4}/); - // If we have a double year, eliminate one - 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") { - item.issue = content; - } else if (field == "UT") { - item.extra += content; - } else if (field == "BP") { - item.pages = content; - } else if (field == "EP") { - item.pages += "-" + content; - } else if (field == "AB") { - item.abstractNote = content; - } else if (field == "PI" || field == "C1") { - item.place = content; - } else if (field == "LA") { - item.language = content; - } else if (field == "PU") { - item.publisher = content; - // Patent stuff - } else if (field == "DG") { - item.issueDate = content; - } else if (field == "PN") { - item.patentNumber = content; - } else if (field == "AE") { - item.assignee = content; - } else if (field == "PL") { // not sure... - item.priorityNumber = content; - } else if (field == "PC") { // use for patents - item.country = content; - // A whole mess of tags - } else if (field == "DE" || field == "BD" - || field == "OR" || field == "ID" - || field == "MC" || field == "MQ") { - item.tags = item.tags.concat(content.split(";")); - } else if (field == "DI") { - item.DOI = content; - } else { - Zotero.debug("Discarding: " + field + " => "+content); - } -} - -function completeItem(item) { - var i; - var creators = []; - // If we have full names, drop the short ones - if (item.creators[0]["AF"].length) { - creators = item.creators[0]["AF"]; - } else { - creators = item.creators[0]["AU"]; - } - // Add other creators - if (item.creators[1]) - item.creators = creators.concat(item.creators[1]); - else - item.creators = creators; - - // If we have a patent, change author to inventor - if (item.itemType == "patent") { - for (i in item.creators) { - if (item.creators[i].creatorType == "author") { - item.creators[i].creatorType = "inventor"; - } - } - } - - // Fix caps, trim in various places - for (i in item.tags) { - item.tags[i] = item.tags[i].trim(); - if (item.tags[i].toUpperCase() == item.tags[i]) - item.tags[i]=item.tags[i].toLowerCase(); - } - - var toFix = ["publisher", "publicationTitle", "place"]; - for (i in toFix) { - var field = toFix[i]; - if (item[field] && item[field].toUpperCase() == item[field]) - item[field]=ZU.capitalizeTitle(item[field].toLowerCase(),true); - } - - item.complete(); -} - -function doImport(text) { - var line = true; - var tag = data = false; - do { // first valid line is type - line = Zotero.read(); - line = line.replace(/^\s+/, ""); - } while(line !== false && !line.substr(0, 6).match(/^PT [A-Z]/)); - - var item = new Zotero.Item(); - var i = 0; - item.creators = [{"AU":[], "AF":[]}, []]; - item.extra = ""; - - - var tag = "PT"; - - var data = line.substr(3); - - var rawLine; - while((rawLine = Zotero.read()) !== false) { // until EOF - // trim leading space if this line is not part of a note - line = rawLine.replace(/^\s+/, ""); - var split = line.match(/^([A-Z0-9]{2}) (?:([^\n]*))?/); - // Force a match for ER - if (line.substr(0,2) == "ER") split = ["","ER",""]; - if(split) { - // if this line is a tag, take a look at the previous line to map - // its tag - if(tag) { - //Zotero.debug("tag: '"+tag+"'; data: '"+data+"'"); - processTag(item, tag, data); - } - - // then fetch the tag and data from this line - tag = split[1]; - data = split[2]; - - if(tag == "ER") { // ER signals end of reference - // unset info - tag = data = false; - completeItem(item); - } - if(tag == "PT") { - // new item - item = new Zotero.Item(); - item.creators = [{"AU":[], "AF":[]}, []]; - item.extra = ""; - i++; - } - } else { - // otherwise, assume this is data from the previous line continued - if(tag == "AU" || tag == "AF" || tag == "BE") { - //Z.debug(rawLine); - // preserve line endings for AU fields - data += rawLine.replace(/^ /,"\n"); - } else if(tag) { - // otherwise, concatenate and avoid extra spaces - if(data[data.length-1] == " " || rawLine[0] == " ") { - data += rawLine; - } else { - data += " "+rawLine; - } - } - } - } - - if(tag && tag != "ER") { // save any unprocessed tags - //Zotero.debug(tag); - processTag(item, tag, data); - completeItem(item); - } -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "import", - "input": "FN Thomson Reuters Web of Knowledge\u000aVR 1.0\u000aPT J\u000aAU Zelle, Rintze M.\u000a Harrison, Jacob C.\u000a Pronk, Jack T.\u000a van Maris, Antonius J. A.\u000aTI Anaplerotic Role for Cytosolic Malic Enzyme in Engineered Saccharomyces\u000a cerevisiae Strains\u000aSO APPLIED AND ENVIRONMENTAL MICROBIOLOGY\u000aVL 77\u000aIS 3\u000aBP 732\u000aEP 738\u000aDI 10.1128/AEM.02132-10\u000aPD FEB 2011\u000aPY 2011\u000aAB Malic enzyme catalyzes the reversible oxidative decarboxylation of\u000a malate to pyruvate and CO(2). The Saccharomyces cerevisiae MAE1 gene\u000a encodes a mitochondrial malic enzyme whose proposed physiological roles\u000a are related to the oxidative, malate-decarboxylating reaction. Hitherto,\u000a the inability of pyruvate carboxylase-negative (Pyc(-)) S. cerevisiae\u000a strains to grow on glucose suggested that Mae1p cannot act as a\u000a pyruvate-carboxylating, anaplerotic enzyme. In this study, relocation of\u000a malic enzyme to the cytosol and creation of thermodynamically favorable\u000a conditions for pyruvate carboxylation by metabolic engineering, process\u000a design, and adaptive evolution, enabled malic enzyme to act as the sole\u000a anaplerotic enzyme in S. cerevisiae. The Escherichia coli NADH-dependent\u000a sfcA malic enzyme was expressed in a Pyc(-) S. cerevisiae background.\u000a When PDC2, a transcriptional regulator of pyruvate decarboxylase genes,\u000a was deleted to increase intracellular pyruvate levels and cells were\u000a grown under a CO(2) atmosphere to favor carboxylation, adaptive\u000a evolution yielded a strain that grew on glucose (specific growth rate,\u000a 0.06 +/- 0.01 h(-1)). Growth of the evolved strain was enabled by a\u000a single point mutation (Asp336Gly) that switched the cofactor preference\u000a of E. coli malic enzyme from NADH to NADPH. Consistently, cytosolic\u000a relocalization of the native Mae1p, which can use both NADH and NADPH,\u000a in a pyc1,2 Delta pdc2 Delta strain grown under a CO(2) atmosphere, also\u000a enabled slow-growth on glucose. Although growth rates of these strains\u000a are still low, the higher ATP efficiency of carboxylation via malic\u000a enzyme, compared to the pyruvate carboxylase pathway, may contribute to\u000a metabolic engineering of S. cerevisiae for anaerobic, high-yield\u000a C(4)-dicarboxylic acid production.\u000aTC 0\u000aZ9 0\u000aSN 0099-2240\u000aUT WOS:000286597100004\u000aER\u000a\u000aPT J\u000aAU Zelle, Rintze M.\u000a Trueheart, Josh\u000a Harrison, Jacob C.\u000a Pronk, Jack T.\u000a van Maris, Antonius J. A.\u000aTI Phosphoenolpyruvate Carboxykinase as the Sole Anaplerotic Enzyme in\u000a Saccharomyces cerevisiae\u000aSO APPLIED AND ENVIRONMENTAL MICROBIOLOGY\u000aVL 76\u000aIS 16\u000aBP 5383\u000aEP 5389\u000aDI 10.1128/AEM.01077-10\u000aPD AUG 2010\u000aPY 2010\u000aAB Pyruvate carboxylase is the sole anaplerotic enzyme in glucose-grown\u000a cultures of wild-type Saccharomyces cerevisiae. Pyruvate\u000a carboxylase-negative (Pyc(-)) S. cerevisiae strains cannot grow on\u000a glucose unless media are supplemented with C(4) compounds, such as\u000a aspartic acid. In several succinate-producing prokaryotes,\u000a phosphoenolpyruvate carboxykinase (PEPCK) fulfills this anaplerotic\u000a role. However, the S. cerevisiae PEPCK encoded by PCK1 is repressed by\u000a glucose and is considered to have a purely decarboxylating and\u000a gluconeogenic function. This study investigates whether and under which\u000a conditions PEPCK can replace the anaplerotic function of pyruvate\u000a carboxylase in S. cerevisiae. Pyc(-) S. cerevisiae strains\u000a constitutively overexpressing the PEPCK either from S. cerevisiae or\u000a from Actinobacillus succinogenes did not grow on glucose as the sole\u000a carbon source. However, evolutionary engineering yielded mutants able to\u000a grow on glucose as the sole carbon source at a maximum specific growth\u000a rate of ca. 0.14 h(-1), one-half that of the (pyruvate\u000a carboxylase-positive) reference strain grown under the same conditions.\u000a Growth was dependent on high carbon dioxide concentrations, indicating\u000a that the reaction catalyzed by PEPCK operates near thermodynamic\u000a equilibrium. Analysis and reverse engineering of two independently\u000a evolved strains showed that single point mutations in pyruvate kinase,\u000a which competes with PEPCK for phosphoenolpyruvate, were sufficient to\u000a enable the use of PEPCK as the sole anaplerotic enzyme. The PEPCK\u000a reaction produces one ATP per carboxylation event, whereas the original\u000a route through pyruvate kinase and pyruvate carboxylase is ATP neutral.\u000a This increased ATP yield may prove crucial for engineering of efficient\u000a and low-cost anaerobic production of C(4) dicarboxylic acids in S.\u000a cerevisiae.\u000aTC 1\u000aZ9 1\u000aSN 0099-2240\u000aUT WOS:000280633400006\u000aER\u000a\u000aPT J\u000aAU Zelle, Rintze M.\u000a De Hulster, Erik\u000a Kloezen, Wendy\u000a Pronk, Jack T.\u000a van Maris, Antonius J. A.\u000aTI Key Process Conditions for Production of C(4) Dicarboxylic Acids in\u000a Bioreactor Batch Cultures of an Engineered Saccharomyces cerevisiae\u000a Strain\u000aSO APPLIED AND ENVIRONMENTAL MICROBIOLOGY\u000aVL 76\u000aIS 3\u000aBP 744\u000aEP 750\u000aDI 10.1128/AEM.02396-09\u000aPD FEB 2010\u000aPY 2010\u000aAB A recent effort to improve malic acid production by Saccharomyces\u000a cerevisiae by means of metabolic engineering resulted in a strain that\u000a produced up to 59 g liter(-1) of malate at a yield of 0.42 mol (mol\u000a glucose)(-1) in calcium carbonate-buffered shake flask cultures. With\u000a shake flasks, process parameters that are important for scaling up this\u000a process cannot be controlled independently. In this study, growth and\u000a product formation by the engineered strain were studied in bioreactors\u000a in order to separately analyze the effects of pH, calcium, and carbon\u000a dioxide and oxygen availability. A near-neutral pH, which in shake\u000a flasks was achieved by adding CaCO(3), was required for efficient C(4)\u000a dicarboxylic acid production. Increased calcium concentrations, a side\u000a effect of CaCO(3) dissolution, had a small positive effect on malate\u000a formation. Carbon dioxide enrichment of the sparging gas (up to 15%\u000a [vol/vol]) improved production of both malate and succinate. At higher\u000a concentrations, succinate titers further increased, reaching 0.29 mol\u000a (mol glucose)(-1), whereas malate formation strongly decreased. Although\u000a fully aerobic conditions could be achieved, it was found that moderate\u000a oxygen limitation benefitted malate production. In conclusion, malic\u000a acid production with the engineered S. cerevisiae strain could be\u000a successfully transferred from shake flasks to 1-liter batch bioreactors\u000a by simultaneous optimization of four process parameters (pH and\u000a concentrations of CO(2), calcium, and O(2)). Under optimized conditions,\u000a a malate yield of 0.48 +/- 0.01 mol (mol glucose)(-1) was obtained in\u000a bioreactors, a 19% increase over yields in shake flask experiments.\u000aTC 2\u000aZ9 2\u000aSN 0099-2240\u000aUT WOS:000274017400015\u000aER\u000a\u000aPT J\u000aAU Abbott, Derek A.\u000a Zelle, Rintze M.\u000a Pronk, Jack T.\u000a van Maris, Antonius J. A.\u000aTI Metabolic engineering of Saccharomyces cerevisiae for production of\u000a carboxylic acids: current status and challenges\u000aSO FEMS YEAST RESEARCH\u000aVL 9\u000aIS 8\u000aBP 1123\u000aEP 1136\u000aDI 10.1111/j.1567-1364.2009.00537.x\u000aPD DEC 2009\u000aPY 2009\u000aAB To meet the demands of future generations for chemicals and energy and\u000a to reduce the environmental footprint of the chemical industry,\u000a alternatives for petrochemistry are required. Microbial conversion of\u000a renewable feedstocks has a huge potential for cleaner, sustainable\u000a industrial production of fuels and chemicals. Microbial production of\u000a organic acids is a promising approach for production of chemical\u000a building blocks that can replace their petrochemically derived\u000a equivalents. Although Saccharomyces cerevisiae does not naturally\u000a produce organic acids in large quantities, its robustness, pH tolerance,\u000a simple nutrient requirements and long history as an industrial workhorse\u000a make it an excellent candidate biocatalyst for such processes. Genetic\u000a engineering, along with evolution and selection, has been successfully\u000a used to divert carbon from ethanol, the natural endproduct of S.\u000a cerevisiae, to pyruvate. Further engineering, which included expression\u000a of heterologous enzymes and transporters, yielded strains capable of\u000a producing lactate and malate from pyruvate. Besides these metabolic\u000a engineering strategies, this review discusses the impact of transport\u000a and energetics as well as the tolerance towards these organic acids. In\u000a addition to recent progress in engineering S. cerevisiae for organic\u000a acid production, the key limitations and challenges are discussed in the\u000a context of sustainable industrial production of organic acids from\u000a renewable feedstocks.\u000aTC 11\u000aZ9 11\u000aSN 1567-1356\u000aUT WOS:000271264400001\u000aER\u000a\u000aPT J\u000aAU Zelle, Rintze M.\u000a de Hulster, Erik\u000a van Winden, WoUter A.\u000a de Waard, Pieter\u000a Dijkema, Cor\u000a Winkler, Aaron A.\u000a Geertman, Jan-Maarten A.\u000a van Dijken, Johannes P.\u000a Pronk, Jack T.\u000a van Maris, Antonius J. A.\u000aTI Malic acid production by Saccharomyces cerevisiae: Engineering of\u000a pyruvate carboxylation, oxaloacetate reduction, and malate export\u000aSO APPLIED AND ENVIRONMENTAL MICROBIOLOGY\u000aVL 74\u000aIS 9\u000aBP 2766\u000aEP 2777\u000aDI 10.1128/AEM.02591-07\u000aPD MAY 2008\u000aPY 2008\u000aAB Malic acid is a potential biomass-derivable \"building block\" for\u000a chemical synthesis. Since wild-type Saccharomyces cerevisiae strains\u000a produce only low levels of malate, metabolic engineering is required to\u000a achieve efficient malate production with this yeast. A promising pathway\u000a for malate production from glucose proceeds via carboxylation of\u000a pyruvate, followed by reduction of oxaloacetate to malate. This redox-\u000a and ATP-neutral, CO2-fixing pathway has a theoretical maximum yield of 2\u000a mol malate (mol glucose)(-1). A previously engineered glucose-tolerant,\u000a C-2-independent pyruvate decarboxylase-negative S. cerevisiae strain was\u000a used as the platform to evaluate the impact of individual and combined\u000a introduction of three genetic modifications: (i) overexpression of the\u000a native pyruvate carboxylase encoded by PYC2, (ii) high-level expression\u000a of an allele of the MDH3 gene, of which the encoded malate dehydrogenase\u000a was retargeted to the cytosol by deletion of the C-terminal peroxisomal\u000a targeting sequence, and (iii) functional expression of the\u000a Schizosaccharomyces pombe malate transporter gene SpMAE1. While single\u000a or double modifications improved malate production, the highest malate\u000a yields and titers were obtained with the simultaneous introduction of\u000a all three modifications. In glucose-grown batch cultures, the resulting\u000a engineered strain produced malate at titers of up to 59 g liter(-1) at a\u000a malate yield of 0.42 mol (mol glucose)(-1). Metabolic flux analysis\u000a showed that metabolite labeling patterns observed upon nuclear magnetic\u000a resonance analyses of cultures grown on C-13-labeled glucose were\u000a consistent with the envisaged nonoxidative, fermentative pathway for\u000a malate production. The engineered strains still produced substantial\u000a amounts of pyruvate, indicating that the pathway efficiency can be\u000a further improved.\u000aTC 15\u000aZ9 17\u000aSN 0099-2240\u000aUT WOS:000255567900024\u000aER\u000a\u000aEF", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Rintze M.", - "lastName": "Zelle", - "creatorType": "author" - }, - { - "firstName": "Jacob C.", - "lastName": "Harrison", - "creatorType": "author" - }, - { - "firstName": "Jack T.", - "lastName": "Pronk", - "creatorType": "author" - }, - { - "firstName": "Antonius J. A.", - "lastName": "van Maris", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "WOS:000286597100004", - "title": "Anaplerotic Role for Cytosolic Malic Enzyme in Engineered Saccharomyces cerevisiae Strains", - "publicationTitle": "Applied and Environmental Microbiology", - "volume": "77", - "issue": "3", - "pages": "732-738", - "DOI": "10.1128/AEM.02132-10", - "date": "FEB 2011", - "abstractNote": "Malic enzyme catalyzes the reversible oxidative decarboxylation of malate to pyruvate and CO(2). The Saccharomyces cerevisiae MAE1 gene encodes a mitochondrial malic enzyme whose proposed physiological roles are related to the oxidative, malate-decarboxylating reaction. Hitherto, the inability of pyruvate carboxylase-negative (Pyc(-)) S. cerevisiae strains to grow on glucose suggested that Mae1p cannot act as a pyruvate-carboxylating, anaplerotic enzyme. In this study, relocation of malic enzyme to the cytosol and creation of thermodynamically favorable conditions for pyruvate carboxylation by metabolic engineering, process design, and adaptive evolution, enabled malic enzyme to act as the sole anaplerotic enzyme in S. cerevisiae. The Escherichia coli NADH-dependent sfcA malic enzyme was expressed in a Pyc(-) S. cerevisiae background. When PDC2, a transcriptional regulator of pyruvate decarboxylase genes, was deleted to increase intracellular pyruvate levels and cells were grown under a CO(2) atmosphere to favor carboxylation, adaptive evolution yielded a strain that grew on glucose (specific growth rate, 0.06 +/- 0.01 h(-1)). Growth of the evolved strain was enabled by a single point mutation (Asp336Gly) that switched the cofactor preference of E. coli malic enzyme from NADH to NADPH. Consistently, cytosolic relocalization of the native Mae1p, which can use both NADH and NADPH, in a pyc1,2 Delta pdc2 Delta strain grown under a CO(2) atmosphere, also enabled slow-growth on glucose. Although growth rates of these strains are still low, the higher ATP efficiency of carboxylation via malic enzyme, compared to the pyruvate carboxylase pathway, may contribute to metabolic engineering of S. cerevisiae for anaerobic, high-yield C(4)-dicarboxylic acid production.", - "ISSN": "0099-2240" - }, - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Rintze M.", - "lastName": "Zelle", - "creatorType": "author" - }, - { - "firstName": "Josh", - "lastName": "Trueheart", - "creatorType": "author" - }, - { - "firstName": "Jacob C.", - "lastName": "Harrison", - "creatorType": "author" - }, - { - "firstName": "Jack T.", - "lastName": "Pronk", - "creatorType": "author" - }, - { - "firstName": "Antonius J. A.", - "lastName": "van Maris", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "WOS:000280633400006", - "title": "Phosphoenolpyruvate Carboxykinase as the Sole Anaplerotic Enzyme in Saccharomyces cerevisiae", - "publicationTitle": "Applied and Environmental Microbiology", - "volume": "76", - "issue": "16", - "pages": "5383-5389", - "DOI": "10.1128/AEM.01077-10", - "date": "AUG 2010", - "abstractNote": "Pyruvate carboxylase is the sole anaplerotic enzyme in glucose-grown cultures of wild-type Saccharomyces cerevisiae. Pyruvate carboxylase-negative (Pyc(-)) S. cerevisiae strains cannot grow on glucose unless media are supplemented with C(4) compounds, such as aspartic acid. In several succinate-producing prokaryotes, phosphoenolpyruvate carboxykinase (PEPCK) fulfills this anaplerotic role. However, the S. cerevisiae PEPCK encoded by PCK1 is repressed by glucose and is considered to have a purely decarboxylating and gluconeogenic function. This study investigates whether and under which conditions PEPCK can replace the anaplerotic function of pyruvate carboxylase in S. cerevisiae. Pyc(-) S. cerevisiae strains constitutively overexpressing the PEPCK either from S. cerevisiae or from Actinobacillus succinogenes did not grow on glucose as the sole carbon source. However, evolutionary engineering yielded mutants able to grow on glucose as the sole carbon source at a maximum specific growth rate of ca. 0.14 h(-1), one-half that of the (pyruvate carboxylase-positive) reference strain grown under the same conditions. Growth was dependent on high carbon dioxide concentrations, indicating that the reaction catalyzed by PEPCK operates near thermodynamic equilibrium. Analysis and reverse engineering of two independently evolved strains showed that single point mutations in pyruvate kinase, which competes with PEPCK for phosphoenolpyruvate, were sufficient to enable the use of PEPCK as the sole anaplerotic enzyme. The PEPCK reaction produces one ATP per carboxylation event, whereas the original route through pyruvate kinase and pyruvate carboxylase is ATP neutral. This increased ATP yield may prove crucial for engineering of efficient and low-cost anaerobic production of C(4) dicarboxylic acids in S. cerevisiae.", - "ISSN": "0099-2240" - }, - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Rintze M.", - "lastName": "Zelle", - "creatorType": "author" - }, - { - "firstName": "Erik", - "lastName": "De Hulster", - "creatorType": "author" - }, - { - "firstName": "Wendy", - "lastName": "Kloezen", - "creatorType": "author" - }, - { - "firstName": "Jack T.", - "lastName": "Pronk", - "creatorType": "author" - }, - { - "firstName": "Antonius J. A.", - "lastName": "van Maris", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "WOS:000274017400015", - "title": "Key Process Conditions for Production of C(4) Dicarboxylic Acids in Bioreactor Batch Cultures of an Engineered Saccharomyces cerevisiae Strain", - "publicationTitle": "Applied and Environmental Microbiology", - "volume": "76", - "issue": "3", - "pages": "744-750", - "DOI": "10.1128/AEM.02396-09", - "date": "FEB 2010", - "abstractNote": "A recent effort to improve malic acid production by Saccharomyces cerevisiae by means of metabolic engineering resulted in a strain that produced up to 59 g liter(-1) of malate at a yield of 0.42 mol (mol glucose)(-1) in calcium carbonate-buffered shake flask cultures. With shake flasks, process parameters that are important for scaling up this process cannot be controlled independently. In this study, growth and product formation by the engineered strain were studied in bioreactors in order to separately analyze the effects of pH, calcium, and carbon dioxide and oxygen availability. A near-neutral pH, which in shake flasks was achieved by adding CaCO(3), was required for efficient C(4) dicarboxylic acid production. Increased calcium concentrations, a side effect of CaCO(3) dissolution, had a small positive effect on malate formation. Carbon dioxide enrichment of the sparging gas (up to 15% [vol/vol]) improved production of both malate and succinate. At higher concentrations, succinate titers further increased, reaching 0.29 mol (mol glucose)(-1), whereas malate formation strongly decreased. Although fully aerobic conditions could be achieved, it was found that moderate oxygen limitation benefitted malate production. In conclusion, malic acid production with the engineered S. cerevisiae strain could be successfully transferred from shake flasks to 1-liter batch bioreactors by simultaneous optimization of four process parameters (pH and concentrations of CO(2), calcium, and O(2)). Under optimized conditions, a malate yield of 0.48 +/- 0.01 mol (mol glucose)(-1) was obtained in bioreactors, a 19% increase over yields in shake flask experiments.", - "ISSN": "0099-2240" - }, - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Derek A.", - "lastName": "Abbott", - "creatorType": "author" - }, - { - "firstName": "Rintze M.", - "lastName": "Zelle", - "creatorType": "author" - }, - { - "firstName": "Jack T.", - "lastName": "Pronk", - "creatorType": "author" - }, - { - "firstName": "Antonius J. A.", - "lastName": "van Maris", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "WOS:000271264400001", - "title": "Metabolic engineering of Saccharomyces cerevisiae for production of carboxylic acids: current status and challenges", - "publicationTitle": "Fems Yeast Research", - "volume": "9", - "issue": "8", - "pages": "1123-1136", - "DOI": "10.1111/j.1567-1364.2009.00537.x", - "date": "DEC 2009", - "abstractNote": "To meet the demands of future generations for chemicals and energy and to reduce the environmental footprint of the chemical industry, alternatives for petrochemistry are required. Microbial conversion of renewable feedstocks has a huge potential for cleaner, sustainable industrial production of fuels and chemicals. Microbial production of organic acids is a promising approach for production of chemical building blocks that can replace their petrochemically derived equivalents. Although Saccharomyces cerevisiae does not naturally produce organic acids in large quantities, its robustness, pH tolerance, simple nutrient requirements and long history as an industrial workhorse make it an excellent candidate biocatalyst for such processes. Genetic engineering, along with evolution and selection, has been successfully used to divert carbon from ethanol, the natural endproduct of S. cerevisiae, to pyruvate. Further engineering, which included expression of heterologous enzymes and transporters, yielded strains capable of producing lactate and malate from pyruvate. Besides these metabolic engineering strategies, this review discusses the impact of transport and energetics as well as the tolerance towards these organic acids. In addition to recent progress in engineering S. cerevisiae for organic acid production, the key limitations and challenges are discussed in the context of sustainable industrial production of organic acids from renewable feedstocks.", - "ISSN": "1567-1356" - }, - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Rintze M.", - "lastName": "Zelle", - "creatorType": "author" - }, - { - "firstName": "Erik", - "lastName": "de Hulster", - "creatorType": "author" - }, - { - "firstName": "WoUter A.", - "lastName": "van Winden", - "creatorType": "author" - }, - { - "firstName": "Pieter", - "lastName": "de Waard", - "creatorType": "author" - }, - { - "firstName": "Cor", - "lastName": "Dijkema", - "creatorType": "author" - }, - { - "firstName": "Aaron A.", - "lastName": "Winkler", - "creatorType": "author" - }, - { - "firstName": "Jan-Maarten A.", - "lastName": "Geertman", - "creatorType": "author" - }, - { - "firstName": "Johannes P.", - "lastName": "van Dijken", - "creatorType": "author" - }, - { - "firstName": "Jack T.", - "lastName": "Pronk", - "creatorType": "author" - }, - { - "firstName": "Antonius J. A.", - "lastName": "van Maris", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "WOS:000255567900024", - "title": "Malic acid production by Saccharomyces cerevisiae: Engineering of pyruvate carboxylation, oxaloacetate reduction, and malate export", - "publicationTitle": "Applied and Environmental Microbiology", - "volume": "74", - "issue": "9", - "pages": "2766-2777", - "DOI": "10.1128/AEM.02591-07", - "date": "MAY 2008", - "abstractNote": "Malic acid is a potential biomass-derivable \"building block\" for chemical synthesis. Since wild-type Saccharomyces cerevisiae strains produce only low levels of malate, metabolic engineering is required to achieve efficient malate production with this yeast. A promising pathway for malate production from glucose proceeds via carboxylation of pyruvate, followed by reduction of oxaloacetate to malate. This redox- and ATP-neutral, CO2-fixing pathway has a theoretical maximum yield of 2 mol malate (mol glucose)(-1). A previously engineered glucose-tolerant, C-2-independent pyruvate decarboxylase-negative S. cerevisiae strain was used as the platform to evaluate the impact of individual and combined introduction of three genetic modifications: (i) overexpression of the native pyruvate carboxylase encoded by PYC2, (ii) high-level expression of an allele of the MDH3 gene, of which the encoded malate dehydrogenase was retargeted to the cytosol by deletion of the C-terminal peroxisomal targeting sequence, and (iii) functional expression of the Schizosaccharomyces pombe malate transporter gene SpMAE1. While single or double modifications improved malate production, the highest malate yields and titers were obtained with the simultaneous introduction of all three modifications. In glucose-grown batch cultures, the resulting engineered strain produced malate at titers of up to 59 g liter(-1) at a malate yield of 0.42 mol (mol glucose)(-1). Metabolic flux analysis showed that metabolite labeling patterns observed upon nuclear magnetic resonance analyses of cultures grown on C-13-labeled glucose were consistent with the envisaged nonoxidative, fermentative pathway for malate production. The engineered strains still produced substantial amounts of pyruvate, indicating that the pathway efficiency can be further improved.", - "ISSN": "0099-2240" - } - ] - }, - { - "type": "import", - "input": "FN Thomson Reuters Web of Knowledge\u000aVR 1.0\u000aPT J\u000aAU Smith, L. J.\u000a Schwark, W. S.\u000a Cook, D. R.\u000a Moon, P. F.\u000a Erb, H. N.\u000a Looney, A. L.\u000aTI Pharmacokinetics of intravenous mivacurium in halothane-anesthetized\u000a dogs.\u000aSO Veterinary Surgery\u000aVL 27\u000aIS 2\u000aPS 170\u000aPY 1998\u000aUT CABI:19982209000\u000aDT Abstract only\u000aLA English\u000aSN 0161-3499\u000aCC LL900Animal Toxicology, Poisoning and Pharmacology (Discontinued March\u000a 2000); LL070Pets and Companion Animals\u000aCN 151-67-7\u000aDE anaesthesia; halothane; muscle relaxants; pharmacokinetics\u000aOR dogs\u000aBD Canis; Canidae; Fissipeda; carnivores; mammals; vertebrates; Chordata;\u000a animals; small mammals; eukaryotes\u000aER\u000a\u000aEF", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "L. J.", - "lastName": "Smith", - "creatorType": "author" - }, - { - "firstName": "W. S.", - "lastName": "Schwark", - "creatorType": "author" - }, - { - "firstName": "D. R.", - "lastName": "Cook", - "creatorType": "author" - }, - { - "firstName": "P. F.", - "lastName": "Moon", - "creatorType": "author" - }, - { - "firstName": "H. N.", - "lastName": "Erb", - "creatorType": "author" - }, - { - "firstName": "A. L.", - "lastName": "Looney", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "anaesthesia", - "halothane", - "muscle relaxants", - "pharmacokinetics", - "dogs", - "Canis", - "Canidae", - "Fissipeda", - "carnivores", - "mammals", - "vertebrates", - "Chordata", - "animals", - "small mammals", - "eukaryotes" - ], - "seeAlso": [], - "attachments": [], - "extra": "CABI:19982209000", - "title": "Pharmacokinetics of intravenous mivacurium in halothane-anesthetized dogs.", - "publicationTitle": "Veterinary Surgery", - "volume": "27", - "issue": "2", - "date": "1998", - "language": "English", - "ISSN": "0161-3499" - } - ] - }, - { - "type": "import", - "input": "FN Thomson Reuters Web of Knowledge\u000aVR 1.0\u000aPT J\u000aAU Smith, JM \u000aAF Smith, J. Mark\u000aTI Gripewater\u000aSO FIDDLEHEAD\u000aLA English \u000aDT Poetry\u000aNR 0\u000aTC 0\u000aZ9 0\u000aPU UNIV NEW BRUNSWICK\u000aPI FREDERICTON\u000aPA DEPT ENGLISH, CAMPUS HOUSE, PO BOX 4400, FREDERICTON, NB E3B 5A3, CANADA\u000aSN 0015-0630\u000aJ9 FIDDLEHEAD\u000aJI Fiddlehead\u000aPD SPR\u000aPY 2011\u000aIS 247\u000aBP 82\u000aEP 82\u000aPG 1\u000aWC Literary Reviews\u000aSC Literature\u000aGA 757VG\u000aUT WOS:000290115300030\u000aER\u000a\u000aEF", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "J. Mark", - "lastName": "Smith", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "WOS:000290115300030", - "title": "Gripewater", - "publicationTitle": "Fiddlehead", - "language": "English", - "publisher": "Univ New Brunswick", - "place": "Fredericton", - "ISSN": "0015-0630", - "journalAbbreviation": "Fiddlehead", - "date": "SPR 2011", - "issue": "247", - "pages": "82-82" - } - ] - }, - { - "type": "import", - "input": "FN Thomson Reuters Web of Knowledge\u000aVR 1.0\u000aPT S\u000aAU McCormick, MC\u000a Litt, JS\u000a Smith, VC\u000a Zupancic, JAF\u000aAF McCormick, Marie C.\u000a Litt, Jonathan S.\u000a Smith, Vincent C.\u000a Zupancic, John A. F.\u000aBE Fielding, JE\u000a Brownson, RC\u000a Green, LW\u000aTI Prematurity: An Overview and Public Health Implications\u000aSO ANNUAL REVIEW OF PUBLIC HEALTH, VOL 32\u000aSE Annual Review of Public Health\u000aLA English\u000aDT Review\u000aDE infant mortality; childhood morbidity; prevention\u000aID LOW-BIRTH-WEIGHT; NEONATAL INTENSIVE-CARE; QUALITY-OF-LIFE; EXTREMELY\u000a PRETERM BIRTH; YOUNG-ADULTS BORN; AGE 8 YEARS; CHILDREN BORN;\u000a BRONCHOPULMONARY DYSPLASIA; LEARNING-DISABILITIES; EXTREME PREMATURITY\u000aAB The high rate of premature births in the United States remains a public\u000a health concern. These infants experience substantial morbidity and\u000a mortality in the newborn period, which translate into significant\u000a medical costs. In early childhood, survivors are characterized by a\u000a variety of health problems, including motor delay and/or cerebral palsy,\u000a lower IQs, behavior problems, and respiratory illness, especially\u000a asthma. Many experience difficulty with school work, lower\u000a health-related quality of life, and family stress. Emerging information\u000a in adolescence and young adulthood paints a more optimistic picture,\u000a with persistence of many problems but with better adaptation and more\u000a positive expectations by the young adults. Few opportunities for\u000a prevention have been identified; therefore, public health approaches to\u000a prematurity include assurance of delivery in a facility capable of\u000a managing neonatal complications, quality improvement to minimize\u000a interinstitutional variations, early developmental support for such\u000a infants, and attention to related family health issues.\u000aC1 [McCormick, MC] Harvard Univ, Dept Soc Human Dev & Hlth, Sch Publ Hlth, Boston, MA 02115 USA\u000a [McCormick, MC; Litt, JS; Smith, VC; Zupancic, JAF] Beth Israel Deaconess Med Ctr, Dept Neonatol, Boston, MA 02215 USA\u000a [Litt, JS] Childrens Hosp Boston, Div Newborn Med, Boston, MA 02115 USA\u000aRP McCormick, MC (reprint author), Harvard Univ, Dept Soc Human Dev & Hlth, Sch Publ Hlth, Boston, MA 02115 USA\u000aEM mmccormi@hsph.harvard.edu\u000a vsmith1@bidmc.harvard.edu\u000a jzupanci@bidmc.harvard.edu\u000a Jonathan.Litt@childrens.harvard.edu\u000aNR 91\u000aTC 1\u000aZ9 1\u000aPU ANNUAL REVIEWS\u000aPI PALO ALTO\u000aPA 4139 EL CAMINO WAY, PO BOX 10139, PALO ALTO, CA 94303-0897 USA\u000aSN 0163-7525\u000aBN 978-0-8243-2732-3\u000aJ9 ANNU REV PUBL HEALTH\u000aJI Annu. Rev. Public Health\u000aPY 2011\u000aVL 32\u000aBP 367\u000aEP 379\u000aDI 10.1146/annurev-publhealth-090810-182459\u000aPG 13\u000aGA BUZ33\u000aUT WOS:000290776200020\u000aER\u000a\u000aEF", - "items": [ - { - "itemType": "bookSection", - "creators": [ - { - "firstName": "Marie C.", - "lastName": "McCormick", - "creatorType": "author" - }, - { - "firstName": "Jonathan S.", - "lastName": "Litt", - "creatorType": "author" - }, - { - "firstName": "Vincent C.", - "lastName": "Smith", - "creatorType": "author" - }, - { - "firstName": "John A. F.", - "lastName": "Zupancic", - "creatorType": "author" - }, - { - "firstName": "JE", - "lastName": "Fielding", - "creatorType": "editor" - }, - { - "firstName": "RC", - "lastName": "Brownson", - "creatorType": "editor" - }, - { - "firstName": "LW", - "lastName": "Green", - "creatorType": "editor" - } - ], - "notes": [], - "tags": [ - "infant mortality", - "childhood morbidity", - "prevention", - "low-birth-weight", - "neonatal intensive-care", - "quality-of-life", - "extremely preterm birth", - "young-adults born", - "age 8 years", - "children born", - "bronchopulmonary dysplasia", - "learning-disabilities", - "extreme prematurity" - ], - "seeAlso": [], - "attachments": [], - "extra": "WOS:000290776200020", - "title": "Prematurity: An Overview and Public Health Implications", - "publicationTitle": "Annual Review of Public Health, Vol 32", - "language": "English", - "abstractNote": "The high rate of premature births in the United States remains a public health concern. These infants experience substantial morbidity and mortality in the newborn period, which translate into significant medical costs. In early childhood, survivors are characterized by a variety of health problems, including motor delay and/or cerebral palsy, lower IQs, behavior problems, and respiratory illness, especially asthma. Many experience difficulty with school work, lower health-related quality of life, and family stress. Emerging information in adolescence and young adulthood paints a more optimistic picture, with persistence of many problems but with better adaptation and more positive expectations by the young adults. Few opportunities for prevention have been identified; therefore, public health approaches to prematurity include assurance of delivery in a facility capable of managing neonatal complications, quality improvement to minimize interinstitutional variations, early developmental support for such infants, and attention to related family health issues.", - "place": "Palo Alto", - "publisher": "Annual Reviews", - "ISSN": "0163-7525", - "ISBN": "978-0-8243-2732-3", - "journalAbbreviation": "Annu. Rev. Public Health", - "date": "2011", - "volume": "32", - "pages": "367-379", - "DOI": "10.1146/annurev-publhealth-090810-182459" - } - ] - }, - { - "type": "import", - "input": "FN Thomson Reuters Web of Knowledge\u000aVR 1.0\u000aPT P\u000aUT BIOSIS:PREV201100469175\u000aDT Patent\u000aTI Indexing cell delivery catheter\u000aAU Solar, Matthew S.\u000a Parmer, Kari\u000a Smith, Philip\u000a Murdock, Frank\u000aPN US 07967789\u000aAE Medtronic Inc\u000aDG June 28, 2011\u000aPC USA\u000aPL 604-16501\u000aSO Official Gazette of the United States Patent and Trademark Office\u000a Patents\u000aPY 2011\u000aPD JUN 28 2011\u000aLA English\u000aAB An insertion device with an insertion axis includes an axial actuator\u000a with a first portion and a second portion. The first portion is moveable\u000a along the insertion axis relative to the second portion. The insertion\u000a device further includes a first tube coupled to the first portion of the\u000a axial actuator, and the first tube is movable along the insertion axis\u000a in response to movement of the first portion relative to the second\u000a portion. The device further includes a second tube having a radially\u000a biased distal end. The distal end is substantially contained within the\u000a first tube in a first state, and the second tube is rotatable with\u000a respect to the first tube. Also, the second tube is axially movable to a\u000a second state, and a portion of a distal end of the second tube is\u000a exposed from a distal end of the first tube in the second state.\u000aC1 Indialantic, FL USA\u000aSN 0098-1133\u000aMC Human Medicine (Medical Sciences); Equipment Apparatus Devices and\u000a Instrumentation\u000aCC 12502, Pathology - General\u000aMQ indexing cell delivery catheter; medical supplies\u000aER\u000a\u000aEF", - "items": [ - { - "itemType": "patent", - "creators": [ - { - "firstName": "Matthew S.", - "lastName": "Solar", - "creatorType": "inventor" - }, - { - "firstName": "Kari", - "lastName": "Parmer", - "creatorType": "inventor" - }, - { - "firstName": "Philip", - "lastName": "Smith", - "creatorType": "inventor" - }, - { - "firstName": "Frank", - "lastName": "Murdock", - "creatorType": "inventor" - } - ], - "notes": [], - "tags": [ - "Human Medicine (Medical Sciences)", - "Equipment Apparatus Devices and Instrumentation", - "indexing cell delivery catheter", - "medical supplies" - ], - "seeAlso": [], - "attachments": [], - "extra": "BIOSIS:PREV201100469175", - "title": "Indexing cell delivery catheter", - "patentNumber": "US 07967789", - "assignee": "Medtronic Inc", - "issueDate": "June 28, 2011", - "country": "USA", - "priorityNumber": "604-16501", - "publicationTitle": "Official Gazette of the United States Patent and Trademark Office Patents", - "date": "JUN 28 2011", - "language": "English", - "abstractNote": "An insertion device with an insertion axis includes an axial actuator with a first portion and a second portion. The first portion is moveable along the insertion axis relative to the second portion. The insertion device further includes a first tube coupled to the first portion of the axial actuator, and the first tube is movable along the insertion axis in response to movement of the first portion relative to the second portion. The device further includes a second tube having a radially biased distal end. The distal end is substantially contained within the first tube in a first state, and the second tube is rotatable with respect to the first tube. Also, the second tube is axially movable to a second state, and a portion of a distal end of the second tube is exposed from a distal end of the first tube in the second state.", - "place": "Indialantic, FL USA", - "ISSN": "0098-1133" - } - ] - }, - { - "type": "import", - "input": "FN Thomson Reuters Web of Knowledge\u000aVR 1.0\u000aPT B\u000aAU Smith, W. G.\u000aTI Ecological anthropology of households in East Madura, Indonesia.\u000aSO Ecological anthropology of households in East Madura, Indonesia\u000aPD 2011\u000aPY 2011\u000aZ9 0\u000aBN 978-90-8585933-8\u000aUT CABI:20113178956\u000aER\u000a\u000aPT J\u000aAU Smith, S. A.\u000aTI Production and characterization of polyclonal antibodies to\u000a hexanal-lysine adducts for use in an ELISA to monitor lipid oxidation in\u000a a meat model system.\u000aSO Dissertation Abstracts International, B\u000aVL 58\u000aIS 9\u000aPD 1998, thesis publ. 1997\u000aPY 1998\u000aZ9 0\u000aSN 0419-4217\u000aUT FSTA:1998-09-Sn1570\u000aER\u000a\u000aPT J\u000aAU Smith, E. H.\u000aTI The enzymic oxidation of linoleic and linolenic acid.\u000aSO Dissertation Abstracts International, B\u000aVL 49\u000aIS 4\u000aBP BRD\u000aPD 1988\u000aPY 1988\u000aZ9 0\u000aSN 0419-4217\u000aUT FSTA:1989-04-N-0004\u000aER\u000a\u000aPT J\u000aAU Smith, C. S.\u000aTI The syneresis of renneted milk gels.\u000aSO Dissertation Abstracts International. B, Sciences and Engineering\u000aVL 49\u000aIS 5\u000aBP 1459\u000aPD 1988\u000aPY 1988\u000aZ9 0\u000aSN 0419-4217\u000aUT CABI:19910448509\u000aER\u000a\u000aEF", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "W. G.", - "lastName": "Smith", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "CABI:20113178956", - "title": "Ecological anthropology of households in East Madura, Indonesia.", - "publicationTitle": "Ecological anthropology of households in East Madura, Indonesia", - "date": "2011", - "ISBN": "978-90-8585933-8" - }, - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "S. A.", - "lastName": "Smith", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "FSTA:1998-09-Sn1570", - "title": "Production and characterization of polyclonal antibodies to hexanal-lysine adducts for use in an ELISA to monitor lipid oxidation in a meat model system.", - "publicationTitle": "Dissertation Abstracts International, B", - "volume": "58", - "issue": "9", - "date": ", thesis publ. 1997 1998", - "ISSN": "0419-4217" - }, - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "E. H.", - "lastName": "Smith", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "FSTA:1989-04-N-0004", - "title": "The enzymic oxidation of linoleic and linolenic acid.", - "publicationTitle": "Dissertation Abstracts International, B", - "volume": "49", - "issue": "4", - "pages": "BRD", - "date": "1988", - "ISSN": "0419-4217" - }, - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "C. S.", - "lastName": "Smith", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "extra": "CABI:19910448509", - "title": "The syneresis of renneted milk gels.", - "publicationTitle": "Dissertation Abstracts International. B, Sciences and Engineering", - "volume": "49", - "issue": "5", - "pages": "1459", - "date": "1988", - "ISSN": "0419-4217" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/InderScience.js b/translators/InderScience.js @@ -1,83 +0,0 @@ -{ - "translatorID":"409c520b-0720-4011-8fce-70fcd9806493", - "translatorType":4, - "label":"InderScience", - "creator":"Michael Berkowitz", - "target":"http://www.inderscience.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('/html/body/table/tbody/tr/td[2]/table[tbody/tr/td[3]][2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() - || doc.evaluate('//td[1][@class="textcontent"]/table/tbody/tr/td[2]/b/u/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("rec_id") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - if (detectWeb(doc, url) == "journalArticle") { - scrape(url); - } else if ((detectWeb(doc, url) == "multiple")) { - if (doc.evaluate('/html/body/table/tbody/tr/td[2]/table[tbody/tr/td[3]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var items = new Object(); - var results = doc.evaluate('/html/body/table/tbody/tr/td[2]/table[tbody/tr/td[3]]', doc, null, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - var title = Zotero.Utilities.trimInternal(doc.evaluate('.//tr[1]/td[3]', result, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var id = doc.evaluate('.//tr[8]/td[2]/a[2]', result, null, XPathResult.ANY_TYPE, null).iterateNext().href.match(/rec_id=([^&]+)/)[1]; - items[id] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - scrape('http://www.inderscience.com/search/index.php?action=record&rec_id=' + i); - } - } else { - var arts = new Array(); - var items = Zotero.Utilities.getItemArray(doc, doc, "&rec_id"); - items = Zotero.selectItems(items); - for (var i in items) { - scrape(i); - } - } - } - Zotero.wait(); -} - -function scrape(link) { - Zotero.Utilities.loadDocument(link, function(newDoc) { - var data = new Object(); - var rows = newDoc.evaluate('/html/body/table/tbody/tr/td[2]/table[tbody/tr/td[3]]//tr[td[3]]', newDoc, null, XPathResult.ANY_TYPE, null); - var row; - while (row = rows.iterateNext()) { - var tag = Zotero.Utilities.trimInternal(newDoc.evaluate('./td[2]', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var value = Zotero.Utilities.trimInternal(newDoc.evaluate('./td[3]', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - data[tag] = value; - } - Zotero.debug(data); - var item = new Zotero.Item("journalArticle"); - item.title = data['Title:']; - item.abstractNote = data['Abstract:']; - item.url = newDoc.location.href; - item.tags = data['Keywords:'].substr(0, data['Keywords:'].length - 1).split(/\s*;\s*/); - item.DOI = data['DOI:']; - item.attachments.push({url:item.url, title:item.title + ": InderScience Snapshot", mimeType:"text/html"}); - var authors = data['Author:'].split(/\s*,\s*/); - for each (var author in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - var voliss = data['Journal:'].match(/^([^\d]+)(\d+)\s*\-\s*Vol\.\s*(\d+)\s*,\s*No\.(.+)pp\.\s*(.*)$/); - Zotero.debug(voliss); - item.publicationTitle = voliss[1]; - item.date = voliss[2]; - item.volume = voliss[3]; - item.issue = voliss[4]; - item.pages = voliss[5]; - item.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/InfoTrac OneFile.js b/translators/InfoTrac OneFile.js @@ -1,131 +0,0 @@ -{ - "translatorID":"63c25c45-6257-4985-9169-35b785a2995e", - "translatorType":4, - "label":"InfoTrac OneFile", - "creator":"Simon Kornblith", - "target":"^https?://[^/]+/itx/(?:[a-z]+Search|retrieve|paginate|tab)\\.do", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2006-12-15 03:40:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.evaluate('//img[@alt="Thomson Gale"]', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext()) { - if(doc.evaluate('//table[@class="resultstable"][tbody/tr[@class="unselectedRow"]]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else { - return "journalArticle"; - } - } -} - -function infoTracRIS(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if(item.notes && item.notes[0]) { - item.extra = item.notes[0].note; - - delete item.notes; - item.notes = undefined; - } - - // get underscored terms (term headings?) out of tags - for(var i in item.tags) { - var index = item.tags[i].indexOf("_"); - if(index != -1) { - item.tags[i] = item.tags[i].substr(0, index); - } - } - - // add names to attachments - for(var i in item.attachments) { - if(!item.attachments[i].title) { - item.attachments[i] = undefined; - } else { - item.attachments[i].title = "InfoTrac OneFile "+item.attachments[i].title; - } - } - - //item.attachments = newAttachments.shift(); - //Zotero.debug(item.attachments); - item.complete(); - }); - translator.translate(); - Zotero.done(); -} - -function readEncoded(url) { - var newArray = new Array(); - - var parts = url.split(/[?&]/); - for each(var part in parts) { - var index = part.indexOf("="); - if(index !== -1) { - newArray[part.substr(0, index)] = part.substr(index+1); - } - } - - return newArray; -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var hostRe = new RegExp("^https?://[^/]+/"); - var host = hostRe.exec(doc.location.href)[0]; - - if(doc.evaluate('//table[@class="resultstable"][tbody/tr[@class="unselectedRow"]]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var items = Zotero.Utilities.getItemArray(doc, doc, '^https?://[^/]+/itx/retrieve\\.do\\?.*docId='); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - // parse things out of URLs - var time = new Date(); - time = time.getTime(); - var markedString = ""; - for(var i in items) { - var postVal = readEncoded(i); - markedString += postVal.tabID+"_"+postVal.docId+"_1_0_"+postVal.contentSet+"_srcprod="+postVal.prodId+"|^"; - } - - var postData = "inPS=true&ts="+time+"&prodId="+postVal.prodId+"&actionCmd=UPDATE_MARK_LIST&userGroupName="+postVal.userGroupName+"&markedString="+markedString+"&a="+time; - Zotero.Utilities.HTTP.doGet(host+"itx/marklist.do?inPS=true&ts="+time+"&prodId="+postVal.prodId+"&actionCmd=CLEAR_MARK_LIST&userGroupName="+postVal.userGroupName, - function(text) { // clear marked - Zotero.Utilities.HTTP.doPost(host+"itx/marklist.do", postData, - function(text) { // mark - Zotero.Utilities.HTTP.doGet(host+"itx/generateCitation.do?contentSet="+postVal.contentSet+"&inPS=true&tabID=T-ALL&prodId="+postVal.prodId+"&docId=&actionString=FormatCitation&userGroupName="+postVal.userGroupName+"&citationFormat=ENDNOTE", - function(text) { // get marked - infoTracRIS(text); - }); - }); - }); - } else { - // just extract from single page - var postVal = readEncoded(url); - Zotero.Utilities.HTTP.doGet(host+"itx/generateCitation.do?contentSet="+postVal.contentSet+"&inPS=true&tabID="+postVal.tabID+"&prodId="+postVal.prodId+"&docId="+postVal.docId+"&actionString=FormatCitation&citationFormat=ENDNOTE", - function(text) { - infoTracRIS(text); - }); - } - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/InfoTrac.js b/translators/InfoTrac.js @@ -1,214 +0,0 @@ -{ - "translatorID":"6773a9af-5375-3224-d148-d32793884dec", - "translatorType":4, - "label":"InfoTrac", - "creator":"Simon Kornblith", - "target":"^https?://[^/]+/itw/infomark/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // ensure that there is an InfoTrac logo - if(!doc.evaluate('//img[substring(@alt, 1, 8) = "InfoTrac"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) return false; - - if(doc.title.substring(0, 8) == "Article ") { - var genre = doc.evaluate('//comment()[substring(., 1, 6) = " Genre"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if(genre) { - var value = Zotero.Utilities.trimInternal(genre.nodeValue.substr(7)); - if(value == "article") { - return "journalArticle"; - } else if(value == "book") { - return "book"; - } else if(value == "dissertation") { - return "thesis"; - } else if(value == "bookitem") { - return "bookSection"; - } - } - - return "magazineArticle"; - } else if(doc.title.substring(0, 10) == "Citations ") { - return "multiple"; - } -} - -function extractCitation(url, elmts, title, doc) { - var newItem = new Zotero.Item(); - newItem.url = url; - - if(title) { - newItem.title = Zotero.Utilities.superCleanString(title); - } - while(elmt = elmts.iterateNext()) { - var colon = elmt.nodeValue.indexOf(":"); - var field = elmt.nodeValue.substring(1, colon).toLowerCase(); - var value = elmt.nodeValue.substring(colon+1, elmt.nodeValue.length-1); - if(field == "title") { - newItem.title = Zotero.Utilities.superCleanString(value); - } else if(field == "journal") { - newItem.publicationTitle = value; - } else if(field == "pi") { - parts = value.split(" "); - var date = ""; - var field = null; - for(j in parts) { - firstChar = parts[j].substring(0, 1); - - if(firstChar == "v") { - newItem.itemType = "journalArticle"; - field = "volume"; - } else if(firstChar == "i") { - field = "issue"; - } else if(firstChar == "p") { - field = "pages"; - - var pagesRegexp = /p(\w+)\((\w+)\)/; // weird looking page range - var match = pagesRegexp.exec(parts[j]); - if(match) { // yup, it's weird - var finalPage = parseInt(match[1])+parseInt(match[2]) - parts[j] = "p"+match[1]+"-"+finalPage.toString(); - } else if(!newItem.itemType) { // no, it's normal - // check to see if it's numeric, bc newspaper pages aren't - var justPageNumber = parts[j].substr(1); - if(parseInt(justPageNumber).toString() != justPageNumber) { - newItem.itemType = "newspaperArticle"; - } - } - } else if(!field) { // date parts at the beginning, before - // anything else - date += " "+parts[j]; - } - - if(field) { - isDate = false; - - if(parts[j] != "pNA") { // make sure it's not an invalid - // page number - // chop of letter - newItem[field] = parts[j].substring(1); - } else if(!newItem.itemType) { // only newspapers are missing - // page numbers on infotrac - newItem.itemType = "newspaperArticle"; - } - } - } - - // Set type - if(!newItem.itemType) { - newItem.itemType = "magazineArticle"; - } - - if(date != "") { - newItem.date = date.substring(1); - } - } else if(field == "author") { - var author = Zotero.Utilities.cleanAuthor(value, "author", true); - - // ensure author is not already there - var add = true; - for each(var existingAuthor in newItem.creators) { - if(existingAuthor.firstName == author.firstName && existingAuthor.lastName == author.lastName) { - add = false; - break; - } - } - if(add) newItem.creators.push(author); - } else if(field == "issue") { - newItem.issue = value; - } else if(field == "volume") { - newItem.volume = value; - } else if(field == "issn") { - newItem.ISSN = value; - } else if(field == "gjd") { - var m = value.match(/\(([0-9]{4}[^\)]*)\)(?:, pp\. ([0-9\-]+))?/); - if(m) { - newItem.date = m[1]; - newItem.pages = m[2]; - } - } else if(field == "BookTitle") { - newItem.publicationTitle = value; - } else if(field == "genre") { - value = value.toLowerCase(); - if(value == "article") { - newItem.itemType = "journalArticle"; - } else if(value == "book") { - newItem.itemType = "book"; - } else if(value == "dissertation") { - newItem.itemType = "thesis"; - } else if(value == "bookitem") { - newItem.itemType = "bookSection"; - } - } - } - - if(doc) { - newItem.attachments.push({document:doc, title:"InfoTrac Snapshot"}); - } else { - newItem.attachments.push({url:url, title:"InfoTrac Snapshot", - mimeType:"text/html"}); - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var uri = doc.location.href; - if(doc.title.substring(0, 8) == "Article ") { // article - var xpath = '/html/body//comment()'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - extractCitation(uri, elmts); - } else { // search results - var items = new Array(); - var uris = new Array(); - var elmts = new Array(); - - var host = doc.location.href.match(/^https?:\/\/[^\/]+/)[0]; - - var tableRows = doc.evaluate('/html/body//table/tbody/tr/td[a/b]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var tableRow; - var javaScriptRe = /'([^']*)' *, *'([^']*)'/ - var i = 0; - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - var link = doc.evaluate('./a', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var m = javaScriptRe.exec(link.href); - if(m) { - uris[i] = host+"/itw/infomark/192/215/90714844w6"+m[1]+"?sw_aep=olr_wad"+m[2]; - } - var article = doc.evaluate('./b/text()', link, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - items[i] = article.nodeValue; - // Chop off final period - if(items[i].substr(items[i].length-1) == ".") { - items[i] = items[i].substr(0, items[i].length-1); - } - elmts[i] = doc.evaluate(".//comment()", tableRow, nsResolver, XPathResult.ANY_TYPE, null); - i++; - } - - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - for(var i in items) { - extractCitation(uris[i], elmts[i], items[i]); - } - } -} -\ No newline at end of file diff --git a/translators/Informaworld.js b/translators/Informaworld.js @@ -1,277 +0,0 @@ -{ - "translatorID": "1885b93c-cf37-4b25-aef5-283f42eada9d", - "label": "Informaworld", - "creator": "Michael Berkowitz", - "target": "^http://www\\.informaworld\\.com", - "minVersion": "1.0.0b4.r5", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-22 23:21:54" -} - -/* Test URLs -Book section: -Book: - http://www.informaworld.com/smpp/title~db=all~content=t777453493 -Journal article: - http://www.informaworld.com/smpp/content~content=a903855250&db=all -Journal issue ToC: - http://www.informaworld.com/smpp/title~db=all~content=g921992177 -*/ - -function detectWeb(doc, url) { - if (url.indexOf("quicksearch") !== -1 || - (url.indexOf("title~db") !== -1 - && !doc.evaluate('//div[@id="breadcrumb"]/a[text() = "Books"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext())) { - return "multiple"; - } else if (url.indexOf("content=g") != -1 || - doc.evaluate('//div[@id="browse"]//tbody/tr/td[2]/a[2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || - doc.evaluate('//div[@id="title"]//td[2]/div/strong/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//a[substring(text(), 2, 8) = "Download"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || - doc.evaluate('//div[@id="breadcrumb"]/a[text() = "Journals" or text() = "Books"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() ) { - if (doc.evaluate('//img[substring(@title, 1, 17) = "Publication type:"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var pubtype = doc.evaluate('//div[@id="breadcrumb"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext().title; - if (pubtype.match("journal")) { - return "journalArticle"; - } else if (pubtype.match("book")) { - return "bookSection"; - } - } else { - if (doc.evaluate('//div[@id="breadcrumb"]/a[text() = "Books"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } - // Default to journal article - return "journalArticle"; - } - } else { - return false; - } -} - - -function doWeb(doc, url) { - // Scrape some data from page - var getDocumentData = function (newDoc, data) { - var xpath = '//div[@id="metahead"]/div'; - var stuff = newDoc.evaluate(xpath, newDoc, null, XPathResult.ANY_TYPE, null); - var thing = stuff.iterateNext(); - while (thing) { - if (thing.textContent.match(/DOI/)) { - data.doi = Zotero.Utilities.trimInternal(thing.textContent).match(/:\s+(.*)/)[1]; - break; - } - thing = stuff.iterateNext(); - } - // There seem to be multiple page structures - data.pdfurl = newDoc.evaluate('//div[@id="content"]/div/a[1]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (data.pdfurl == null) { - // If we didn't find the URL there, try elsewhere: - data.pdfurl = newDoc.evaluate('//a[@title="Download PDF"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext(); - } - data.pdfurl = data.pdfurl ? data.pdfurl.href : null; // Don't break on missing PDF - var id = newDoc.location.href.match(/content=([\w\d]+)/); - // If URL has DOI rather than id, use navbar link to get id - if (id[1] == 10) { - id = newDoc.evaluate('//div[@id="contenttabs"]//a[@title = "Article"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (!id) id = newDoc.evaluate('//a[img[@class="downloadicon" and @title = "Download PDF"]]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext(); - id = id.href.match(/content=([\w\d]+)/); - } - var post = 'tab=citation&selecteditems=' + id[1].substr(1) + '&content=' + id[1] + '&citstyle=refworks&showabs=false&format=file'; - data.postdata = post; - } - - - var sets = []; - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('//div[@id="quicksearch"]//tr/td/b/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="quicksearch"]//tr/td/b/a'; - } else if (doc.evaluate('//div[@id="title"]/table/tbody/tr[2]//strong/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="title"]/table/tbody/tr[2]//strong/a'; - } else if (doc.evaluate('//div[@id="browse"]//tbody/tr/td[2]/a[2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="browse"]//tbody/tr/td[2]/a[2]'; - } else if (doc.evaluate('//div[@id="title"]//td[2]/div/strong/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="title"]//td[2]/div/strong/a'; - } else if (doc.evaluate('//div[@id="title"]/table//tr[2]/td/table//tr/td[2]/b/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="title"]/table//tr[2]/td/table//tr/td[2]/b/a'; - } else if (doc.evaluate('//a[@title="Click to view this record"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//a[@title="Click to view this record"]'; - } - - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var title = titles.iterateNext(); - while (title) { - items[title.href] = title.textContent; - title = titles.iterateNext(); - } - items = Zotero.selectItems(items); - for (var i in items) { - sets.push({ url: i }); - } - } else { - // If we're on the citation page, get back to the article page, which has the PDF link - var newurl = url.replace('~tab=citation', '~tab=content'); - // If we're already on the main page, just pull out data here - if (newurl == url) { - sets[0] = {}; - getDocumentData(doc, sets[0]); - // Dummy first callback, since we already have the data - var first = function (set, next) { - next(); - }; - } - else { - sets.push({ - url: newurl - }); - } - } - - if (!first) { - var first = function (set, next) { - var url = set.url; - Zotero.Utilities.processDocuments(url, function(newDoc) { - getDocumentData(newDoc, set); - next(); - }); - }; - } - - var second = function (set, next) { - Zotero.Utilities.HTTP.doPost('http://www.informaworld.com/smpp/content', set.postdata, function(text) { - Zotero.debug(text); - text = text.replace(/RT/, "TY"); - text = text.replace(/VO/, "VL"); - text = text.replace(/LK/, "UR"); - text = text.replace(/YR/, "PY"); - text = text.replace(/([A-Z][A-Z\d]\s)/g, "$1 - ") - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var type = text.match(/TY\s+\-\s+([^\n]*)/)[1]; - if (type == "Journal") { - item.itemType = "journalArticle"; - } else if (type == "Book, Whole") { - item.itemType = "book"; - } else if (type == "Book, Section") { - item.itemType = "bookSection"; - } - if (set.doi) { - item.DOI = set.doi; - } - - // Remove the existing attachment that the RIS translator gives us - item.attachments = []; - - // Make URLs into DOIs if needed - if (item.url.match(/10\..*/) && !item.DOI) { - item.DOI = item.url.match(/10\..*/)[0]; - item.url = ""; - } else { - // Otherwise make a _link_ and remove the URL from the item - item.attachments.push({url:item.url, title:"Informaworld Link", snapshot:false}); - item.url = ""; - } - item.attachments.push({url:set.pdfurl, title:item.title, mimeType:'application/pdf'}); - item.complete(); - }); - translator.translate(); - - next(); - }); - } - - var callbacks = [first, second]; - Zotero.Utilities.processAsync(sets, callbacks, function () { Zotero.done(); }); - Zotero.wait(); -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.informaworld.com/smpp/content~db=all?content=10.1080/00221687509499713", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Savage", - "firstName": "S. B.", - "creatorType": "author" - }, - { - "lastName": "Brimberg", - "firstName": "J.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.informaworld.com/smpp/ftinterface~content=a918972008~fulltext=713240930~frm=content", - "title": "Analysis Of Plunging Phenomena In Water Reservoirs", - "mimeType": "application/pdf" - } - ], - "publicationTitle": "Journal of Hydraulic Research", - "title": "Analysis Of Plunging Phenomena In Water Reservoirs", - "publisher": "Taylor & Francis", - "ISBN": "0022-1686", - "ISSN": "0022-1686", - "date": "1975", - "volume": "13", - "issue": "2", - "pages": "187", - "url": "", - "DOI": "10.1080/00221687509499713", - "libraryCatalog": "Informaworld" - } - ] - }, - { - "type": "web", - "url": "http://www.informaworld.com/smpp/title~db=all~content=t777453493", - "items": [ - { - "itemType": "book", - "creators": [ - { - "lastName": "Wisnicki", - "firstName": "Adrian", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.informaworld.com/978-0-415-95560-7", - "title": "Informaworld Link", - "snapshot": false - }, - { - "url": null, - "title": "Conspiracy, Revolution, and Terrorism from Victorian Fiction to the Modern Novel", - "mimeType": "application/pdf" - } - ], - "title": "Conspiracy, Revolution, and Terrorism from Victorian Fiction to the Modern Novel", - "publisher": "Routledge", - "ISBN": "978-0-415-95560-7", - "ISSN": "978-0-415-95560-7", - "url": "", - "libraryCatalog": "Informaworld" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/IngentaConnect.js b/translators/IngentaConnect.js @@ -1,81 +0,0 @@ -{ - "translatorID":"9e306d5d-193f-44ae-9dd6-ace63bf47689", - "translatorType":4, - "label":"IngentaConnect", - "creator":"Michael Berkowitz", - "target":"^https?://(www\\.)?ingentaconnect\\.com", - "minVersion":"1.0.0b3r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-04-03 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("article?") != -1 || url.indexOf("article;") != -1 || url.indexOf("/art") != -1) { - return "journalArticle"; - } else if (url.indexOf("search?") !=-1 || url.indexOf("search;") != -1) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var artlink = '//div//p/strong/a'; - var links = doc.evaluate(artlink, doc, null, XPathResult.ANY_TYPE, null); - var next_link; - while (next_link = links.iterateNext()) { - items[next_link.href] = next_link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - Zotero.Utilities.processDocuments(articles, function(newDoc) { - 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, 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"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if (abs) item.abstractNote = abs; - 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:/)) { - item.DOI = item.DOI.substr(4); - } - } - item.complete(); - }); - translator.translate(); - }); - }, function() {Zotero.done();}); -} diff --git a/translators/Innovate Online.js b/translators/Innovate Online.js @@ -1,102 +0,0 @@ -{ - "translatorID":"ca6e95d1-46b9-4535-885c-df0c2d4b7f7a", - "translatorType":4, - "label":"Innovate Online", - "creator":"Michael Berkowitz", - "target":"^http://(www.)?innovateonline.info/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("view=article") != -1) { - return "journalArticle"; - } else if (url.indexOf("view=search") != -1) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var newURIs = new Array(); - - if (url.indexOf("view=search") != -1) { - var titles = new Array(); - var hrefs = new Array(); - var items = new Object(); - var xpath = '//ul[@class="articles"]/li[@class="result"]/div[@class="header"]'; - var names = doc.evaluate(xpath, doc, namespace, XPathResult.ANY_TYPE, null); - var next_item = names.iterateNext(); - while (next_item) { - titles.push(next_item.textContent.split(/\n/)[3]); - next_item = names.iterateNext(); - } - - var nextpath = '//ul[@class="articles"]/li/@onclick'; - var links = doc.evaluate(nextpath, doc, namespace, XPathResult.ANY_TYPE, null); - var next_link = links.iterateNext(); - while (next_link) { - hrefs.push(next_link.textContent); - next_link = links.iterateNext(); - } - - for (var i = 0 ; i < titles.length ; i++) { - items[hrefs[i].match(/\d+/)] = titles[i]; - } - items = Zotero.selectItems(items); - - for (var i in items) { - newURIs.push('http://innovateonline.info/index.php?view=article&id=' + i); - } - } else { - var newURL = url; - if (newURL.indexOf("highlight") != -1) { - newURL = newURL.substring(0, newURL.indexOf("highlight") -1); - } - if (newURL.indexOf("action=synopsis") != -1) { - newURL = newURL.replace("action=synopsis", "action=article"); - } - newURIs.push(newURL); - } - Zotero.debug(newURIs); - - Zotero.Utilities.processDocuments(newURIs, function(newDoc) { - var newItem = new Zotero.Item("journalArticle"); - newItem.repository = "Innovate Online"; - newItem.publicationTitle = "Innovate"; - newItem.title = newDoc.title.substring(10); - - var authors = newDoc.evaluate('//div[@id="title"]/div[@class="author"]/a', newDoc, namespace, XPathResult.ANY_TYPE, null); - var author = authors.iterateNext(); - while (author) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author.textContent, "author")); - author = authors.iterateNext(); - } - - newItem.date = newDoc.evaluate('//div[@id="page"]/a/div[@class="title"]', newDoc, namespace, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var voliss = newDoc.evaluate('//div[@id="page"]/a/div[@class="subtitle"]', newDoc, namespace, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/Volume\s+(\d+).*Issue\s+(\d+)/); - newItem.volume = voliss[1]; - newItem.issue = voliss[2]; - - var id = newDoc.location.href.match(/\d+/)[0]; - var PDFurl = "http://innovateonline.info/print.php?view=pdf&id=" + id; - newItem.attachments = [ - {url:newDoc.location.href, title:"Innovate Online Snapshot", mimeType:"text/html"}, - {url:PDFurl, title:"Innovate Online PDF", mimeType:"application/pdf"} - ] - - Zotero.Utilities.HTTP.doGet(newDoc.location.href.replace("action=article", "action=synopsis"), function(text) { - var abs = text.match(/<div id=\"synopsis\">\n<p>(.*)<\/p>/)[1]; - newItem.abstractNote = Zotero.Utilities.unescapeHTML(Zotero.Utilities.cleanTags(abs)); - newItem.complete(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Institute of Physics.js b/translators/Institute of Physics.js @@ -1,163 +0,0 @@ -{ - "translatorID": "9346ddef-126b-47ec-afef-8809ed1972ab", - "label": "Institute of Physics", - "creator": "Michael Berkowitz and Avram Lyon", - "target": "^http://iopscience\\.iop\\.org/[0-9-]+/.+", - "minVersion": "2.1", - "maxVersion": "", - "priority": 99, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:29:32" -} - -function detectWeb(doc, url) { - if (url.indexOf("search") == -1) { - return "journalArticle"; - } else { - return "multiple"; - } -} - -function fetchDOIs(DOIs) { - var DOI = DOIs.shift(); - if (!DOI) { - Zotero.done(); - return true; - } - var articleID = DOI.slice(DOI.indexOf('/')+1); - var pdfURL = "http://iopscience.iop.org/"+articleID+"/pdf/"+articleID.replace("/","_","g")+".pdf"; - var doitranslate = Zotero.loadTranslator("search"); - doitranslate.setTranslator("11645bd1-0420-45c1-badb-53fb41eeb753"); - var item = {"itemType":"journalArticle", "DOI":DOI}; - doitranslate.setSearch(item); - doitranslate.setHandler("itemDone", function(obj, item) { - item.url = "http://iopscience.iop.org/"+articleID; - item.attachments.push({url:pdfURL, title:"IOP Full Text PDF", mimeType:"application/pdf"}); - item.libraryCatalog = "Intitute of Physics"; - item.complete(); - fetchDOIs(DOIs); - }); - - var fallback = function() { - Zotero.debug("Error saving using DOI and CrossRef; trying RIS"); - // If there is something wrong with the item - var postVars = "exportFormat=iopexport_ris&exportType=abs&articleId="+articleID; - Zotero.Utilities.HTTP.doPost("http://iopscience.iop.org/export", postVars, function(text){ - // load translator for RIS - var ristranslator = Zotero.loadTranslator ("import"); - ristranslator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - ristranslator.setString(text); - ristranslator.setHandler("itemDone", function(obj, item) { - item.url = "http://iopscience.iop.org/"+articleID; - item.libraryCatalog = "Intitute of Physics"; - item.attachments.push({url:pdfURL, title:"IOP Full Text PDF", mimeType:"application/pdf"}); - item.complete(); - fetchDOIs(DOIs); - }); - ristranslator.translate(); - }, function() {}); - } - - doitranslate.setHandler("error", fallback); - try { doitranslate.translate() } catch (e) { - Zotero.debug("Caught exception"); - fallback(); - }; -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var results = doc.evaluate('//div[@class="searchResCol1"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - var title = doc.evaluate('.//h4/a', result, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var doi = doc.evaluate('.//span[@class="doi"]/strong/a', result, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - items[doi] = title.trim(); - } - Zotero.selectItems(items, function(items) { - if(!items) return true; - for (var i in items) { - arts.push(i); - } - fetchDOIs(arts); - Zotero.wait(); - }); - } else { - var doi = doc.evaluate('//meta[@name="citation_doi"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - fetchDOIs([doi]); - Zotero.wait(); - } -} -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://iopscience.iop.org/0022-3727/34/10/311", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "creatorType": "author", - "firstName": "J", - "lastName": "Batina" - }, - { - "creatorType": "author", - "firstName": "F", - "lastName": "Noël" - }, - { - "creatorType": "author", - "firstName": "S", - "lastName": "Lachaud" - }, - { - "creatorType": "author", - "firstName": "R", - "lastName": "Peyrous" - }, - { - "creatorType": "author", - "firstName": "J F", - "lastName": "Loiseau" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "IOP Full Text PDF", - "mimeType": "application/pdf" - } - ], - "publicationTitle": "Journal of Physics D: Applied Physics", - "volume": "34", - "ISSN": "0022-3727, 1361-6463", - "date": "2001-05-21", - "pages": "1510-1524", - "DOI": "10.1088/0022-3727/34/10/311", - "url": "http://iopscience.iop.org/0022-3727/34/10/311", - "title": "Hydrodynamical simulation of the electric wind in a cylindrical vessel with positive point-to-plane device", - "libraryCatalog": "CrossRef" - } - ] - }, - { - "type": "web", - "url": "http://iopscience.iop.org/search?searchType=fullText&fieldedquery=fun&f=titleabs&time=all&submit=Search&navsubmit=Search", - "items": "multiple" - } -] -/** END TEST CASES **/ diff --git a/translators/Institute of Pure and Applied Physics.js b/translators/Institute of Pure and Applied Physics.js @@ -1,125 +0,0 @@ -{ - "translatorID":"0863b8ec-e717-4b6d-9e35-0b2db2ac6b0f", - "translatorType":4, - "label":"Institute of Pure and Applied Physics", - "creator":"Michael Berkowitz", - "target":"http://(jjap|apex|jpsj)\\.ipap\\.jp/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.title.indexOf("Table of Contents") != -1 || doc.title.indexOf("Search Result") != -1) { - return "multiple"; - } else if (url.indexOf("link?") != -1) { - return "journalArticle"; - } -} - -var journalNames = { - jpsj:["Journal of the Physical Society of Japan", "0031-9015"], - jjap:["Japanese Journal of Applied Physics", "0021-4922"], - apex:["Applied Physics Express", "1882-0778"] -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.title.toLowerCase().indexOf("table of contents") != -1) { - if (url.match(/apex/)) { - var titlesx = '//div[@id="contents"]/dl/dt'; - var linksx = '//div[@id="contents"]/dl/dd/a[1]'; - } else if (url.match(/jjap/)) { - //var xpath = '/html/body/dt/a'; - var titlesx = '//div[@id="contents"]//dl/dt/b'; - var linksx = '//div[@id="contents"]//dl/dd/a[1]'; - } else if (url.match(/jpsj/)) { - var xpath = '/html/body/dl/dt/a[contains(@href, "link")]'; - } - } else if (doc.title.toLowerCase().indexOf("search result") != -1) { - var linksx = '/html/body//li/a'; - var titlesx = '/html/body//li//dt/b'; - } - if (xpath) { - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - items[title.href] = Zotero.Utilities.trimInternal(title.textContent); - } - } else { - var titles = doc.evaluate(titlesx, doc, null, XPathResult.ANY_TYPE, null); - var links = doc.evaluate(linksx, doc, null, XPathResult.ANY_TYPE, null); - var title; - var link; - while ((title = titles.iterateNext()) && (link = links.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent); - } - } - items = Zotero.selectItems(items); - if(!items) return true; - - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.url = doc.location.href; - var jour = item.url.match(/http:\/\/([^.]+)\./)[1]; - item.publicationTitle = journalNames[jour][0]; - item.ISSN = journalNames[jour][1]; - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//h2[@class="title"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var authors = doc.evaluate('//p[@class="author"]/a', doc, null, XPathResult.ANY_TYPE, null); - while (aut = authors.iterateNext()) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut.textContent, "author")); - } - - //get info - var infos = doc.evaluate('//p[@class="info"]', doc, null, XPathResult.ANY_TYPE, null); - var voliss = infos.iterateNext().textContent; - var keys = infos.iterateNext().textContent; - if (voliss.match(/([^\d]+)(\d+)\s+\((\d+)\)\s+([\d\-]+)/)) { - voliss = voliss.match(/([^\d]+)(\d+)\s+\((\d+)\)\s+([\d\-]+)/); - var x = 4 - } else { - voliss = voliss.match(/([^\d]+)(\d+)\s+\((\d+)\)\s+(pp\.)?\s+(\S+)/); - var x = 5 - } - item.journalAbbreviation = Zotero.Utilities.trimInternal(voliss[1]); - item.volume = voliss[2]; - item.date = voliss[3]; - item.pages = voliss[x]; - - keys = Zotero.Utilities.trimInternal(keys); - - if (keys.match(/KEYWORDS/)) { - keys = keys.match(/KEYWORDS:\s+(.*)URL:\s+(.*)DOI:\s+(.*)$/); - var a = 1; - var c = 3; - } else { - keys = keys.match(/URL:\s+(.*)DOI:\s+(.*)$/); - var c = 2; - } - if (a) { - item.tags = keys[a].split(/,\s+/); - } - item.DOI = keys[c]; - var abstracts = doc.evaluate('//p[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (abstracts) { - item.abstractNote = Zotero.Utilities.trimInternal(abstracts.textContent); - } - var pdfurl = doc.evaluate('//a[contains(text(), "PDF")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - item.attachments = [ - {url:item.url, title:"IPAP Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/Inter-Research Science Center.js b/translators/Inter-Research Science Center.js @@ -1,106 +0,0 @@ -{ - "translatorID":"0eeb2ac0-fbaf-4994-b98f-203d273eb9fa", - "translatorType":4, - "label":"Inter-Research Science Center", - "creator":"Michael Berkowitz", - "target":"http://www.int-res.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="journal-index"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || - doc.evaluate('//div[@class="tx-indexedsearch-res"]//tr[1]/td[2]//a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//a[@class="citeexport"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } -} - -var journals = { - meps:["Marine Ecology Progress Series", "Mar Ecol Prog Ser"], - ab:["Aquatic Biology", "Aquat Biol"], - ame:["Aquatic Microbial Ecology", "Aquat Microb Ecol"], - dao:["Diseases of Aquatic Organisms", "Dis Aquat Org"], - cr:["Climate Research", "Clim Res"], - esr:["Endangered Species Research", "Endang Species Res"] -}; - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('//div[@class="tx-indexedsearch-res"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var titlesx = doc.evaluate('//div[@class="tx-indexedsearch-res"]//tr[2]/td[2]', doc, null, XPathResult.ANY_TYPE, null); - var linksx = doc.evaluate('//div[@class="tx-indexedsearch-res"]//tr[1]/td[2]//a', doc, null, XPathResult.ANY_TYPE, null); - var title; - var link; - while ((title = titlesx.iterateNext()) && (link = linksx.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent).match(/doi:\s+[^\s]+\s+(.*)$/)[1]; - } - } else { - var stuff = doc.evaluate('//div[@class="journal-index"]/*[a[contains(text(), "pdf format")]]', doc, null, XPathResult.ANY_TYPE, null); - var thing; - var titles = ""; - while (thing = stuff.iterateNext()) { - titles += thing.textContent; - } - titles = titles.split(/\n/); - Zotero.debug(titles); - var names = new Array(); - for (var i = 0; i < titles.length; i++) { - if (((i-1)%2 == 0) && (titles[i].match(/\w+/))) { - names.push(titles[i]); - } - } - Zotero.debug(names); - var links = doc.evaluate('//div[@class="journal-index"]/*[a[contains(text(), "pdf format")]]/a[1]', doc, null, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = names.shift(); - } - } - - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="bb"]/h2', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.url = doc.location.href; - var voliss = item.url.match(/v(\d+)\/(n(\d+)\/)?p([^/]+)\//); - item.volume = voliss[1]; - item.pages = voliss[4]; - if (voliss[2]) item.issue = voliss[3]; - var jour = item.url.match(/abstracts\/([^/]+)\//)[1]; - item.publicationTitle = journals[jour][0]; - item.journalAbbreviation = journals[jour][1]; - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//p[@class="abstract_block"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var authors = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="bb"]/h3', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).split(/,\s+/); - for each (var aut in authors) { - aut = aut.replace(/[^\w^\s^\.]/g, "").replace(/\d/g, ""); - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - item.date = doc.evaluate('//div[@class="abs-footer"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/date:\s+(.*)/)[1]; - item.DOI = Zotero.Utilities.trimInternal(doc.evaluate('//h1[@class="csc-firstHeader"]/span', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).match(/doi:\s*(.*)/)[1]; - var tags = doc.evaluate('//div[@class="box"]/p/a', doc, null, XPathResult.ANY_TYPE, null); - var tag; - while (tag = tags.iterateNext()) { - item.tags.push(tag.textContent); - } - var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - item.attachments = [ - {url:item.url, title:item.publicationTitle + " Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:item.publicationTitle + " Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/International Herald Tribune.js b/translators/International Herald Tribune.js @@ -1,129 +0,0 @@ -{ - "translatorID":"84bd421d-c6d1-4223-ab80-a156f98a8e30", - "translatorType":4, - "label":"International Herald Tribune", - "creator":"Michael Berkowitz", - "target":"^http://(www.)?iht.com/", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if (doc.title == "Search - International Herald Tribune" && doc.location.href != "http://www.iht.com/info/nytarchive.php") { - return "multiple"; - } else { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - var xpath = '//meta[@name="Headline"]'; - if (doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "newspaperArticle"; - } - } -} - -function associateMeta(newItem, metaTags, field, zoteroField) { - if(metaTags[field]) { - newItem[zoteroField] = metaTags[field]; - } -} - -function scrape(doc, url) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "The International Herald Tribune"; - newItem.ISSN = "0294-8052"; - newItem.url = doc.location.href; - - var metaTags = new Object(); - - var metaTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < metaTagHTML.length ; i++) { - metaTags[metaTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content")); - } - - associateMeta(newItem, metaTags, "Headline", "title"); - associateMeta(newItem, metaTags, "PrintPubDate", "date"); - associateMeta(newItem, metaTags, "Summary", "abstractNote"); - associateMeta(newItem, metaTags, "ArticleID", "accessionNumber"); - associateMeta(newItem, metaTags, "Owner", "extra"); - - if (metaTags["Author"]) { - var author = Zotero.Utilities.trimInternal(metaTags["Author"]); - if (author.substr(0,3).toLowerCase() == "by ") { - author = author.substr(3); - } - - var authors = author.split(" and "); - for each(var author in authors) { - var words = author.split(" "); - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - } - author = words.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - - if (metaTags["keywords"]) { - var keywords = metaTags["keywords"]; - newItem.tags = keywords.split(","); - if (newItem.tags[0].toLowerCase()) { - newItem.tags = newItem.tags.slice(1, newItem.tags.length); - } - Zotero.debug(newItem.tags); - for (var i in newItem.tags) { - if (newItem.tags[i] != "") { - newItem.tags[i] = Zotero.Utilities.trimInternal(newItem.tags[i].replace(" ", ", ")); - var words = newItem.tags[i].split(" "); - for (var j = 0 ; j < words.length ; j++) { - if (words[j][0] == words[j][0].toLowerCase()) { - words[j] = words[j][0].toUpperCase() + words[j].substr(1).toLowerCase(); - } - } - newItem.tags[i] = words.join(" "); - } - } - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var uris = new Array(); - if (doc.title == "Search - International Herald Tribune") { - var result = doc.evaluate('//td[@class="searchheadline"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var items = new Array(); - var elmt = result.iterateNext(); - while (elmt) { - items.push(elmt.href); - elmt = result.iterateNext(); - } - var items = Zotero.Utilities.getItemArray(doc, doc, '^http://(www.)*iht.com/articles/.*\.php$'); - items = Zotero.selectItems(items); - - if (!items) { - return true; - } - - for (var i in items) { - uris.push(i); - } - - } else if (doc.evaluate('//meta[@name="Headline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - uris.push(url); - } - - Zotero.Utilities.processDocuments(uris, scrape, function() { Zotero.done(); }); - - Zotero.wait(); -} diff --git a/translators/Internet Archive Wayback Machine.js b/translators/Internet Archive Wayback Machine.js @@ -1,63 +0,0 @@ -{ - "translatorID":"513a53f5-b95e-4df6-a03e-3348d9ec9f44", - "translatorType":4, - "label":"Internet Archive Wayback Machine", - "creator":"Sean Takats", - "target":"^http://web.archive.org/web/", - "minVersion":"1.0", - "maxVersion":null, - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - var xpath = '//td[@class="mainBody"]/a'; - var links = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - if (links.iterateNext()){ - return "multiple"; - } - return "webpage"; -} - -function doWeb(doc, url){ - var uris = new Array(); - var dateRe = new RegExp("^http://web.archive.org/web/([0-9]+)"); - if (dateRe.test(url)){ //handle single item - uris.push(url); - } else{//handle multiple items - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - var xpath = '//td[@class="mainBody"]/a'; - var links = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var items=new Array(); - var link; - while (link = links.iterateNext()){ - items[link.href] = link.textContent; - } - items=Zotero.selectItems(items); - for (var i in items) { - uris.push(i); - } - } - Zotero.Utilities.processDocuments(uris, function(newDoc) { - //create new webpage Item from page - var newItem = new Zotero.Item("webpage"); - newItem.title = newDoc.title; - //parse date and add - var m = dateRe.exec(newDoc.location.href); - var date = m[1]; - date = date.substr(0, 4) + "-" + date.substr(4,2) + "-" + date.substr(6,2); - newItem.date = date; - //create snapshot - newItem.attachments = [{url:newDoc.location.href, title:newDoc.title, mimeType:"text/html"}]; - newItem.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Internet Archive.js b/translators/Internet Archive.js @@ -1,414 +0,0 @@ -{ - "translatorID":"db0f4858-10fa-4f76-976c-2592c95f029c", - "translatorType":4, - "label":"Internet Archive", - "creator":"Adam Crymble", - "target":"http://www.archive.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-04-29 21:53:40" -} - -function detectWeb(doc, url) { - var mediaType = "1"; - - if (doc.evaluate('//h3', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - mediaType = doc.evaluate('//h3', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - } else if (doc.evaluate('//div[@class="box"][@id="spotlight"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - mediaType = doc.evaluate('//div[@class="box"][@id="spotlight"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - }else if (doc.evaluate('//div[@class="box"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - mediaType = doc.evaluate('//div[@class="box"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - if (mediaType == "The Item") { - return "artwork"; - } else if ( mediaType.match("Spotlight")) { - return "book"; - }else if (mediaType.match("book")) { - return "book"; - } else if (mediaType.match("movie")) { - return "videoRecording"; - } else if (mediaType.match("audio")) { - return "audioRecording"; - } else if (doc.location.href.match("search") && mediaType == "1") { - return "multiple"; - } -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -var detailsURL = 'http://www.archive.org/details'; -var downloadURL = 'http://www.archive.org/download'; -var apiURL = 'http://s3.us.archive.org'; - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldContents = new Array(); - var fieldTitleLength; - var fieldTitle; - var scrapeType = 0; - - var mediaType1 = detectWeb(doc, url); - - if (mediaType1 == "commons") { - doWeb(doc, url); - return; - } - - else if (mediaType1 == "artwork") { - var newItem = new Zotero.Item("artwork"); - - //split contents by linebreak and push into an array if it is not empty - var contents = doc.evaluate('//div[@id="col2"]/div[@class="box"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\n/); - for (var i = 0; i < contents.length; i++) { - if (contents[i].match(/\w/)) { - fieldContents.push(contents[i]); - } - } - var headers = doc.evaluate('//div[@id="col2"]/div[@class="box"]/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var headersCount = doc.evaluate('count (//div[@id="col2"]/div[@class="box"]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (var k = 0; k < headersCount.numberValue; k++) { - fieldTitle = headers.iterateNext().textContent.toLowerCase(); - fieldTitleLength = fieldTitle.length; - var fieldTitleSpot; - - for (var j = 0; j < fieldContents.length; j++) { - if (fieldContents[j].match(fieldTitle)) { - fieldTitleSpot = fieldContents[j].indexOf(fieldTitle); - if (fieldTitleSpot != 0) { - fieldContents[j] = fieldContents[j].substr(fieldTitleSpot + fieldTitleLength); - } else { - fieldContents[j] = fieldContents[j].substr(fieldTitleLength); - } - - dataTags[fieldTitle] = fieldContents[j].replace(/^\s*|\s*$/g, ''); - fieldContents[j] = ''; - } - } - } - - } else if (mediaType1 == "book") { - var newItem = new Zotero.Item("book"); - - if (doc.evaluate('//div[@class="darkBorder roundbox"][@id="main"]/table/tbody/tr/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var headers = doc.evaluate('//div[@class="darkBorder roundbox"][@id="main"]/table/tbody/tr/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//div[@class="darkBorder roundbox"][@id="main"]/table/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = headers.iterateNext()) { - fieldTitle = next_title.textContent.toLowerCase().replace(/\s+/g, ''); - if (!fieldTitle.match(":")) { - fieldTitle = fieldTitle + ":"; - } - fieldContent = contents.iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - dataTags[fieldTitle] = fieldContent; - } - } - - } else if (mediaType1 == "videoRecording") { - var newItem = new Zotero.Item("videoRecording"); - scrapeType = 1; - - } else if (mediaType1 == "audioRecording") { - var newItem = new Zotero.Item("audioRecording"); - scrapeType = 1; - } - - - if (scrapeType == 1) { - var xPathHeaders = '//div[@class="darkBorder roundbox"][@id="main"]/p[@class="content"]/span[@class="key"]'; - - if (doc.evaluate('xPathHeaders', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var headers = doc.evaluate('xPathHeaders', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//span[@class="value"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = headers.iterateNext()) { - fieldTitle = next_title.textContent.toLowerCase().replace(/\s+/g, ''); - fieldContent = contents.iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - dataTags[fieldTitle] = fieldContent; - } - } - } - - if (dataTags["creator:"]) { - var author = dataTags["creator:"]; - if (author.match(", ")) { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "creator")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - - if (dataTags["author:"]) { - var author = dataTags["author:"]; - if (author.match(", ")) { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "author"}); - } - } - - if (doc.evaluate('//div[@class="box"][@id="description"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//div[@class="box"][@id="description"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//div[@class="darkBorder roundbox"][@id="main"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//div[@class="darkBorder roundbox"][@id="main"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - newItem.title = doc.title; - } - - var tagsCount = "none"; - if (dataTags["keywords:"]) { - if (dataTags["keywords:"].match(";")) { - var tagsContent = (dataTags["keywords:"].split(";")); - tagsCount = "multiple"; - } else if (dataTags["keywords:"].match(", ")) { - var tagsContent = (dataTags["keywords:"].split(", ")); - tagsCount = "multiple"; - } else { - var tagsContent = (dataTags["keywords:"]); - tagsCount = "one"; - } - if (tagsCount == "multiple") { - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - } else if (tagsCount == "one") { - newItem.tags = tagsContent; - } - } - - if (dataTags["publisher:"]) { - if (dataTags["publisher:"].match(":")) { - var place1 = dataTags["publisher:"].split(":"); - newItem.place = place1[0]; - newItem.publisher = place1[1]; - } else { - associateData (newItem, dataTags, "publisher:", "publisher"); - } - } - - if (dataTags["rights:"]) { - associateData (newItem, dataTags, "rights:", "rights"); - } else if (dataTags["creativecommonslicense:"]) { - newItem.rights = "Creative Commons License: " + dataTags["creativecommonslicense:"]; - } - - associateData (newItem, dataTags, "title:", "title");; - associateData (newItem, dataTags, "date:", "date"); - associateData (newItem, dataTags, "callnumber:", "callNumber"); - - newItem.url = doc.location.href; - - newItem.complete(); -} - - -function processBuckets(doc, url, ids) { - var httpLink = doc.evaluate('//a[text()="HTTP"]/@href', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - for (var i=0; i<ids.length; i++) { - var id = ids[i]; - var rdfURL = downloadURL + '/' + id + '/' + id + '.rdf'; - - var text = Zotero.Utilities.retrieveSource(rdfURL); - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("5e3ad958-ac79-463d-812b-a86a9235c28f"); // RDF - translator.setString(text); - translator.waitForCompletion = true; - translator.setHandler("itemDone", function(obj, item) { - // Don't set access date - if (!item.accessDate) { - item.accessDate = false; - } - - // Don't set to "Internet Archive" - if (!item.libraryCatalog) { - item.libraryCatalog = false; - } - - // Clear any attachments from the RDF file - item.attachments = []; - - // TODO: get list of items in bucket - - var itemURL = downloadURL + '/' + id + '/' + id + '_files.xml'; - - var xmlstr = Zotero.Utilities.retrieveSource(itemURL); - Zotero.debug(xmlstr); - - // Strip XML declaration and convert to E4X - var xml = new XML(xmlstr.replace(/<\?xml.*\?>/, '')); - var files = xml.file; - - var attachments = []; - var titles = []; - // loop through files listed in bucket contents file - for each(var f in files) { - var fileName = f.@name.toString(); - - // Skip derivative files other than OCRed PDFs - if (f.@source.toString() != 'original' && !fileName.match(/_text\.pdf$/)) { - Zotero.debug("Skipping " + fileName); - continue; - } - - // Skip default files - if (fileName.indexOf(id) == 0) { - continue; - } - - // TEMP -- shouldn't be necessary after IA changes - if (fileName.match(/\.zip(_meta\.txt)?$/)) { - Zotero.debug("Skipping " + fileName); - continue; - } - - var title = f.title.toString(); - if (!title) { - title = fileName; - } - - attachments.push(fileName); - titles.push(title); - } - - for (var i=0; i<attachments.length; i++) { - var fileName = attachments[i]; - var title = titles[i]; - - // Skip PDF if there's an OCRed version - if (fileName.match(/\.pdf$/) && !fileName.match(/_text\.pdf$/)) { - var n = fileName.replace(".pdf", "_text.pdf"); - if (fileName.indexOf(n) != -1) { - Zotero.debug("Skipping " + fileName + " in favor of _text version"); - continue; - } - } - - var resourceURL = downloadURL + '/' + id + '/' + fileName; - item.attachments.push({url:resourceURL, title:title}); - } - - // item.DOI = item.url.match(/\.org\/(.*)$/)[1]; - //item.url = doc.location.href; - - item.attachments.push({url:detailsURL + '/' + id, title:"Internet Archive Details Page", snapshot:false}); - - item.complete(); - }); - translator.translate(); - } -} - - -function doWeb(doc, url) { - var items = {}; - var articles = {}; - var itemCount = 0; - - // iterate through links under item/bucket name to check for zoterocommons (the collection name) - var links = doc.evaluate('//div/p/span/a', doc, null, XPathResult.ANY_TYPE, null); - var commons = false; - while (nextLink = links.iterateNext()) { - if (nextLink.textContent.match(/zoterocommons/)) { - commons = true; - } - } - - if (commons) { - var buckets = []; - var id = url.match(/.+\/([^\?]+)[^\/]*$/)[1]; - buckets.push(id); - - /*var titles = doc.evaluate('/html/body/div[5]/div/table/tbody/tr/td[2]/span', doc, nsResolver, XPathResult.ANY_TYPE, null); - var httpLink = doc.evaluate('//a[text()="HTTP"]/@href', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - // scrape the item titles and item keys off page for selection - // TODO: if called from scrape (ie getting a bucket from search result page), get all items automatically? - while(next_title = titles.iterateNext()) { - Zotero.debug("examining:" + next_title.textContent); - if (next_title.textContent.match(/\|/)) { - split = next_title.textContent.split('|'); - zipfile = split[1].substr(0,split[1].length-4) + ".rdf"; - zipfile = httpLink + "/" + zipfile; - items[zipfile] = split[0]; - Zotero.debug("added: "+ zipfile + " = " + split[0]); - itemCount++; - } - } - - if (itemCount > 1) { - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } - else { - articles.push(zipfile) - }*/ - - processBuckets(doc, url, buckets); - return; - } - - if (detectWeb(doc, url) == "multiple") { - Zotero.debug("multiple"); - var items = new Object(); - - var titles = doc.evaluate('//td[2][@class="hitCell"]/a', doc, null, XPathResult.ANY_TYPE, null); - var titlesCount = doc.evaluate('count (//td[2][@class="hitCell"]/a)', doc, null, XPathResult.ANY_TYPE, null); - - Zotero.debug(titlesCount.numberValue); - - var next_title; - for (var i = 0; i < titlesCount.numberValue; i++) { - next_title = titles.iterateNext(); - - while (!next_title.href.match(/details/)) { - i++; - if (i == titlesCount.numberValue) { - Zotero.debug(i); - break; - } - next_title = titles.iterateNext(); - } - - if (next_title.href.match(/details/)) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Investigative Ophthalmology and Visual Science.js b/translators/Investigative Ophthalmology and Visual Science.js @@ -1,84 +0,0 @@ -{ - "translatorID":"4654c76f-451c-4ae6-9a36-575e982b3cdb", - "translatorType":4, - "label":"Investigative Ophthalmology and Visual Science", - "creator":"Michael Berkowitz", - "target":"http://www.iovs.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-03-14 19:10:00" -} - -function detectWeb(doc, url) { - if (doc.title.indexOf("Table of Contents") != -1 || doc.title.indexOf("Search Result") != -1) { - return "multiple" - } else if (url.indexOf("abstract") != -1 || url.indexOf("full") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var host = doc.location.host; - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.title.indexOf("Search Result") != -1) { - var boxes = doc.evaluate('//table/tbody/tr/td/font/table/tbody/tr[1]', doc, null, XPathResult.ANY_TYPE, null); - var box; - while (box = boxes.iterateNext()) { - var id = doc.evaluate('.//input', box, null, XPathResult.ANY_TYPE, null).iterateNext().value; - var titles = doc.evaluate('./td/font/strong', box, null, XPathResult.ANY_TYPE, null); - var titletext = ''; - var title; - while (title = titles.iterateNext()) { - titletext += title.textContent; - } - items[id] = titletext; - } - } else if (doc.title.indexOf("Table of Content") != -1) { - var ids = doc.evaluate('/html/body/form/dl/dt/input', doc, null, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('/html/body/form/dl/dd/strong', doc, null, XPathResult.ANY_TYPE, null); - var id; - var title; - while ((title = titles.iterateNext()) && (id = ids.iterateNext())) { - items['iovs;' + id.value] = title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [doc.evaluate('//a[contains(@href, "citmgr")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.match(/=(.*)$/)[1]] - } - Zotero.debug(arts); - for each (var id in arts) { - var post = 'type=refman&gca=' + id; - Zotero.debug(post); - post = 'http://www.iovs.org/cgi/citmgr?' + post; - Zotero.debug(post); - Zotero.Utilities.HTTP.doGet(post, function(text) { - Zotero.debug(text); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var pdfurl = item.url.replace(/content\/[^/]+/, "reprint") + ".pdf"; - item.attachments = [ - {url:item.url, title:"IOVS Snapshot", mimeType:"text/html"}, - {url:pdfurl, tite:"IOVS Full Text PDF", mimeType:"application/pdf"} - ]; - if (item.notes[0]['note'].match(/\d/)) { - item.DOI = item.notes[0]['note']; - item.notes = new Array(); - } - item.complete(); - }); - translator.translate(); - - Zotero.done(); - }); - } -} -\ No newline at end of file diff --git a/translators/J-Stage.js b/translators/J-Stage.js @@ -1,85 +0,0 @@ -{ - "translatorID":"e40a27bc-0eef-4c50-b78b-37274808d7d2", - "translatorType":4, - "label":"J-Stage", - "creator":"Michael Berkowitz", - "target":"http://www.jstage.jst.go.jp/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-06 08:45:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//a[contains(@href, "_ris")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } else if (doc.evaluate('//tr/td[2]/table/tbody/tr/td/table/tbody/tr[td[2]//a]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || - doc.evaluate('//tr/td/table/tbody/tr/td/table/tbody/tr[td[1]//a]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - - -function RISify(str) { - return str.replace("_article", "_ris").replace("article", "download"); -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath; - var titlex; - var linkx; - if (doc.evaluate('//tr/td[2]/table/tbody/tr/td/table/tbody/tr[td[2]//a]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - xpath = '//tr/td[2]/table/tbody/tr/td/table/tbody/tr[td[2]//a]'; - titlex = './td[2]//strong'; - linkx = './td[2]//a[1]'; - } else if (doc.evaluate('//tr/td/table/tbody/tr/td/table/tbody/tr[td[1]//a]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - xpath = '/html/body/div/table/tbody/tr/td/table/tbody/tr/td/table/tbody/tr[td//a[contains(@href, "_pdf")]]'; - titlex = './/td/b'; - linkx = './/td/a[contains(@href, "_article")]'; - } - Zotero.debug(xpath); - - var list = doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null); - var nextitem; - while (nextitem = list.iterateNext()) { - var title = Zotero.Utilities.trimInternal(doc.evaluate(titlex, nextitem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var link = doc.evaluate(linkx, nextitem, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(RISify(i)); - } - } else { - arts = [RISify(url)]; - } - Zotero.debug(arts); - for each (var uri in arts) { - Zotero.Utilities.HTTP.doGet(uri, function(text) { - Zotero.debug(text); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.url = uri.replace("download", "article").replace("_ris", "_article"); - var pdfurl = item.url.replace(/(\d+)_(\d+)\/_article/, "$2/_pdf").replace("download", "article"); - Zotero.debug(pdfurl); - item.attachments = [ - {url:item.url, title:item.publicationTitle + " Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:item.publicationTitle + " PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }); - translator.translate(); - }); - } -} -\ No newline at end of file diff --git a/translators/JBJS Am.js b/translators/JBJS Am.js @@ -1,201 +0,0 @@ -{ - "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 <http://www.gnu.org/licenses/>. - */ - -/* - 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/JSTOR.js b/translators/JSTOR.js @@ -1,255 +0,0 @@ -{ - "translatorID": "d921155f-0186-1684-615c-ca57682ced9b", - "label": "JSTOR", - "creator": "Simon Kornblith, Sean Takats, Michael Berkowitz, and Eli Osherovich", - "target": "https?://[^/]*jstor\\.org[^/]*/(action/(showArticle|doBasicSearch|doAdvancedSearch|doLocatorSearch|doAdvancedResults|doBasicResults)|stable/|pss/)", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-01 02:58:17" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // See if this is a seach results page or Issue content - if (doc.title == "JSTOR: Search Results" || url.match(/\/i\d+/) || - (url.match(/stable|pss/) // Issues with DOIs can't be identified by URL - && doc.evaluate('//form[@id="toc"]', doc, nsResolver, - XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) - ) { - return "multiple"; - } else if(url.indexOf("/search/") != -1) { - return false; - } - - // If this is a view page, find the link to the citation - var xpath = '//a[@id="favorites"]'; - var elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - if(elmt || url.match(/pss/)) { - 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 = doc.location.host; - - // If this is a view page, find the link to the citation - var xpath = '//a[@id="favorites"]'; - var elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - var allJids = new Array(); - if (elmt && /jid=10\.2307%2F(\d+)/.test(elmt.href)) { - allJids.push(RegExp.$1); - var jid = RegExp.$1; - Zotero.debug("JID found 1 " + jid); - } - // Sometimes JSTOR uses DOIs as JID; here we exclude "?" characters, since it's a URL - // And exclude TOC for journal issues that have their own DOI - else if (/(?:pss|stable)\/(10\.\d+\/.+)(?:\?.*)?/.test(url) - && !doc.evaluate('//form[@id="toc"]', doc, nsResolver, - XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) { - Zotero.debug("URL " + url); - jid = RegExp.$1; - allJids.push(jid); - Zotero.debug("JID found 2 " + jid); - } - else if (/(?:pss|stable)\/(\d+)/.test(url) - && !doc.evaluate('//form[@id="toc"]', doc, nsResolver, - XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) { - Zotero.debug("URL " + url); - jid = RegExp.$1; - allJids.push(jid); - Zotero.debug("JID found 2 " + jid); - } - else { - // We have multiple results - var resultsBlock = doc.evaluate('//fieldset[@id="results"]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - if (! resultsBlock) { - return true; - } - - var allTitlesElmts = doc.evaluate('//li//a[@class="title"]', resultsBlock, nsResolver, XPathResult.ANY_TYPE, null); - var currTitleElmt; - var availableItems = new Object(); - while (currTitleElmt = allTitlesElmts.iterateNext()) { - var title = currTitleElmt.textContent; - // Sometimes JSTOR uses DOIs as JID; here we exclude "?" characters, since it's a URL - if (/(?:pss|stable)\/(10\.\d+\/[^?]+)(?:\?.*)?/.test(currTitleElmt.href)) - var jid = RegExp.$1; - else - var jid = currTitleElmt.href.match(/(?:stable|pss)\/([a-z]*?\d+)/)[1]; - if (jid) { - availableItems[jid] = title; - } - Zotero.debug("Found title " + title+jid); - } - Zotero.debug("End of titles"); - - var selectedItems = Zotero.selectItems(availableItems); - if (!selectedItems) { - return true; - } - for (var j in selectedItems) { - Zotero.debug("Pushing " + j); - allJids.push(j); - } - } - - var sets = []; - for each(var jid in allJids) { - sets.push({ jid: jid }); - } - - function first(set, next) { - var jid = set.jid; - var downloadString = "suffix=" + jid; - - Zotero.Utilities.HTTP.doPost("http://"+host+"/action/downloadSingleCitation?format=refman&direct=true&singleCitation=true", downloadString, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if(item.notes && item.notes[0]) { - // For some reason JSTOR exports abstract with 'AB' tag istead of 'N1' - item.abstractNote = item.notes[0].note; - item.abstractNote = item.abstractNote.replace(/^<p>(ABSTRACT )?/,'').replace(/<\/p>$/,''); - delete item.notes; - item.notes = undefined; - } - - // Don't save HTML snapshot from 'UR' tag - item.attachments = []; - - set.doi = "10.2307/" + jid; - - if (/stable\/(\d+)/.test(item.url)) { - var pdfurl = "http://"+ host + "/stable/pdfplus/" + jid + ".pdf?acceptTC=true"; - item.attachments.push({url:pdfurl, title:"JSTOR Full Text PDF", mimeType:"application/pdf"}); - } - - var matches; - if (matches = item.ISSN.match(/([0-9]{4})([0-9]{3}[0-9Xx])/)) { - item.ISSN = matches[1] + '-' + matches[2]; - } - - set.item = item; - - next(); - }); - - translator.translate(); - }); - } - - function second(set, next) { - var item = set.item; - - if (!set.doi) { - item.complete(); - next(); - } - - var doi = set.doi; - var crossrefURL = "http://www.crossref.org/openurl/?req_dat=zter:zter321&url_ver=Z39.88-2004&ctx_ver=Z39.88-2004&rft_id=info%3Adoi/"+doi+"&noredirect=true&format=unixref"; - - Zotero.Utilities.HTTP.doGet(crossrefURL, function (text) { - // parse XML with DOMParser - try { - var parser = new DOMParser(); - var xml = parser.parseFromString(text, "text/xml"); - } catch(e) { - item.complete(); - next(); - return; - } - - var doi = ZU.xpathText(xml, '//doi'); - - // ensure DOI is valid - if(!ZU.xpath(xml, '//error').length) { - Zotero.debug("DOI is valid"); - item.DOI = doi; - } - - item.complete(); - next(); - }); - } - - var callbacks = [first, second]; - Zotero.Utilities.processAsync(sets, callbacks, function () { Zotero.done(); }); - Zotero.wait(); -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.jstor.org.libproxy.mit.edu/action/doBasicSearch?Query=chicken&Search.x=0&Search.y=0&wc=on", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.jstor.org.libproxy.mit.edu/stable/1593514?&Search=yes&searchText=chicken&list=hide&searchUri=%2Faction%2FdoBasicSearch%3FQuery%3Dchicken%26Search.x%3D0%26Search.y%3D0%26wc%3Don&prevSearch=&item=1&ttl=70453&returnArticleService=showFullText", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Dimier-Poisson", - "firstName": "I. H.", - "creatorType": "author" - }, - { - "lastName": "Bout", - "firstName": "D. T.", - "creatorType": "author" - }, - { - "lastName": "Quéré", - "firstName": "P.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "JSTOR Full Text PDF", - "mimeType": "application/pdf" - } - ], - "publicationTitle": "Avian Diseases", - "title": "Chicken Primary Enterocytes: Inhibition of Eimeria tenella Replication after Activation with Crude Interferon-γ Supernatants", - "volume": "48", - "issue": "3", - "publisher": "American Association of Avian Pathologists, Inc.", - "ISBN": "00052086", - "ISSN": "0005-2086", - "url": "http://www.jstor.org/stable/1593514", - "date": "2004", - "pages": "617-624", - "abstractNote": "A reproducible and original method for the preparation of chicken intestine epithelial cells from 18-day-old embryos for long-term culture was obtained by using a mechanical isolation procedure, as opposed to previous isolation methods using relatively high concentrations of trypsin, collagenase, or EDTA. Chicken intestine epithelial cells typically expressed keratin and chicken E-cadherin, in contrast to chicken embryo fibroblasts, and they increased cell surface MHC II after activation with crude IFN-γ containing supernatants, obtained from chicken spleen cells stimulated with concanavalin A or transformed by reticuloendotheliosis virus. Eimeria tenella was shown to be able to develop until the schizont stage after 46 hr of culture in these chicken intestinal epithelial cells, but it was not able to develop further. However, activation with IFN-γ containing supernatants resulted in strong inhibition of parasite replication, as shown by incorporation of [3 H]uracil. Thus, chicken enterocytes, which are the specific target of Eimeria development in vivo, could be considered as potential local effector cells involved in the protective response against this parasite. /// Se desarrolló un método reproducible y original para la preparación de células epiteliales de intestino de embriones de pollo de 18 días de edad para ser empleadas como cultivo primario de larga duración. Las células epiteliales de intestino fueron obtenidas mediante un procedimiento de aislamiento mecánico, opuesto a métodos de aislamientos previos empleando altas concentraciones de tripsina, colagenasa o EDTA. Las células epiteliales de intestino expresaron típicamente keratina y caderina E, a diferencia de los fibroblastos de embrión de pollo, e incrementaron el complejo mayor de histocompatibilidad tipo II en la superficie de la célula posterior a la activación con sobrenadantes de interferón gamma. Los sobrenadantes de interferón gamma fueron obtenidos a partir de células de bazos de pollos estimuladas con concanavalina A o transformadas con el virus de reticuloendoteliosis. Se observó el desarrollo de la Eimeria tenella hasta la etapa de esquizonte después de 46 horas de cultivo en las células intestinales epiteliales de pollo pero no se observó un desarrollo posterior. Sin embargo, la activación de los enterocitos con los sobrenadantes con interferón gamma resultó en una inhibición fuerte de la replicación del parásito, comprobada mediante la incorporación de uracilo [3 H]. Por lo tanto, los enterocitos de pollo, blanco específico del desarrollo in vivo de la Eimeria, podrían ser considerados como células efectoras locales, involucradas en la respuesta protectora contra este parásito.", - "extra": "ArticleType: research-article / Full publication date: Sep., 2004 / Copyright © 2004 American Association of Avian Pathologists, Inc.", - "libraryCatalog": "JSTOR", - "shortTitle": "Chicken Primary Enterocytes" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Japan Times Online.js b/translators/Japan Times Online.js @@ -1,181 +0,0 @@ -{ - "translatorID":"b56d756e-934e-4b46-bc58-d61dccc9f32f", - "translatorType":4, - "label":"Japan Times Online", - "creator":"Frank Bennett", - "target":"^http://(?:www|search)\\.japantimes\\.co\\.jp/(?:cgi-bin|gsearch|features|entertainment|sports|life|news|rss)", - "minVersion":"2.0b7", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-09-28 07:00:00" -} - - -/* - Japan Times Online Translator - Copyright (C) 2009-2010 Frank Bennett, biercenator@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/>. -*/ - - -// ################################# -// #### Local utility functions #### -// ################################# - -var itemRe = new RegExp('^http://search\.japantimes\.co\.jp/(?:cgi-bin|gsearch|features|entertainment|sports|life|news|rss)/[a-z]{2}[0-9]{8}[a-z0-9]{2}\.html'); - -var getResolver = function (doc) { - var namespace, resolver; - namespace = doc.documentElement.namespaceURI; - if (namespace) { - resolver = function(prefix) { - if (prefix == 'x') { - return namespace; - } else { - return null; - } - }; - } else { - resolver = null; - } - return resolver; -}; - -var getTagContent = function (txt, attribute, value) { - var ret, m, rex; - ret = false; - rex = RegExp("<[^>]*" + attribute + "=\"" + value + "\"[^>]*>([^<]*)<"); - m = rex.exec(txt); - if (m) { - ret = m[1]; - } - return ret; -} - -var getTagsWithAttributeAndContent = function (txt, tag, attribute) { - var ret, pos, len, lst, m, tagsrex, attribrex; - ret = {}; - tagsrex = RegExp("(<" + tag + "(?: [^>]*>|>)|</" + tag+ ">)"); - attribrex = RegExp(' ' + attribute + '="([^"]+)"'); - lst = txt.split(tagsrex); - if (lst.length > 1) { - len = lst.length; - for (pos=1; pos < len; pos += 4) { - if (pos < (len - 2) && lst[pos + 2] == ("</" + tag + ">")) { - m = lst[pos].match(attribrex); - if (m) { - if (!itemRe.exec(m[1])) { - continue; - } - var title = lst[pos + 1]; - title = title.replace(/\|.*/, "").replace(/<[^>]+>/g, "");; - ret[m[1]] = Zotero.Utilities.unescapeHTML(title); - } - } - } - } - return ret; -} - -// ######################### -// ##### API functions ##### -// ######################### - -var detectWeb = function (doc, url) { - if (itemRe.test(doc.location.href)) { - return "newspaperArticle"; - } else { - return "multiple"; - } -} - -var doWeb = function (doc, url) { - var type, nsResolver, availableItems, xpath, found, nodes, headline, pos, myurl, m, items; - nsResolver = getResolver(doc); - type = detectWeb(doc, url); - if (type === "multiple") { - availableItems = {}; - if (url.match(/\/gsearch\//)) { - // - // For Google SafeSearch. Thanks, guys, it was an entertaining afternoon. - // - xpath = '//iframe[@name="googleSearchFrame"]'; - var iframe = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var address = iframe.src; - var page = Zotero.Utilities.retrieveSource(address); - availableItems = getTagsWithAttributeAndContent(page, "a", "href"); - } else { - xpath = '//a[contains(@href, "cgi-bin")]'; - nodes = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - found = nodes.iterateNext(); - while (found) { - if (!itemRe.test(found)) { - found = nodes.iterateNext(); - continue; - } - headline = found.text; - // - // Some headlines have a weird structure that yields two - // entries, the second of which is blank. Nothing is lost - // by this construct. - // - if (!headline.replace("\n", "")) { - found = nodes.iterateNext(); - continue; - } - headline = headline.replace("\u00a0", " ", "g").replace("\n", " ", "g"); - headline = headline.replace(/^\s+/, "").replace(/\s+$/, "").replace(/\s+/g, " "); - availableItems[found.href] = headline; - found = nodes.iterateNext(); - } - } - if (availableItems.__count__) { - items = Zotero.selectItems(availableItems); - for (myurl in items) { - if (items.hasOwnProperty(myurl)) { - scrapeAndParse(myurl); - } - } - } - } else if (type === "newspaperArticle") { - scrapeAndParse(url); - } -}; - -// ############################ -// ##### Scraper function ##### -// ############################ - -var scrapeAndParse = function (url) { - var item, mytxt, m, val; - item = new Zotero.Item("newspaperArticle"); - - mytxt = Zotero.Utilities.retrieveSource(url); - - item.publicationTitle = "Japan Times Online"; - item.ISSN = "0289-1956"; - item.url = url; - val = getTagContent(mytxt, "id", "date"); - if (val) { - item.date = val; - } - val = getTagContent(mytxt, "id", "headline"); - if (val) { - item.title = val; - } - item.attachments.push({title:"Japan Times Online snapshot", mimeType:"text/html", url:url}); - item.complete(); -}; diff --git a/translators/Journal of Electronic Publishing.js b/translators/Journal of Electronic Publishing.js @@ -1,68 +0,0 @@ -{ - "translatorID":"d93c14fb-d327-4540-b60a-327309ea512b", - "translatorType":4, - "label":"Journal of Electronic Publishing", - "creator":"Michael Berkowitz", - "target":"http://quod.lib.umich.edu/.*c=jep", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div/span[text() = "Search Results"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.match(/\d+\.\d+\.\d+/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var links = doc.evaluate('//div[@id="resultslist"]/div[@class="itemcitation"]/div/a', doc, ns, XPathResult.ANY_TYPE, null); - var link; - var items = new Object(); - while (link = links.iterateNext()) { - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var data = new Object(); - var rows = doc.evaluate('//table[@id="itemmdataTable"]//tr', doc, ns, XPathResult.ANY_TYPE, null); - var row; - while (row = rows.iterateNext()) { - var header = doc.evaluate('./td[1]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var value = doc.evaluate('./td[2]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - data[Zotero.Utilities.trimInternal(header.replace(":", "").replace("Authors", "Author"))] = value; - } - var item = new Zotero.Item("journalArticle"); - item.publicationTitle = "Journal of Electronic Publishing"; - item.title = data["Title"]; - var authors = data["Author"].split(","); - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - item.url = data["URL"]; - var voliss = data["Source"].match(/vol\.\s+([^,]+),\s+no\.\s+([^,]+),\s+(.*)$/); - item.volume = voliss[1]; - item.issue = voliss[2]; - item.date = voliss[3]; - - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Journal of Vision.js b/translators/Journal of Vision.js @@ -1,76 +0,0 @@ -{ - "translatorID":"4345839f-b4fd-4e3f-a73d-268b6f280f6e", - "translatorType":4, - "label":"Journal of Vision", - "creator":"Michael Berkowitz & Matt Burton", - "target":"http://(www.)?journalofvision.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-03-19 17:15:00" -} - -function detectWeb(doc, url) { - if (url.indexOf("search.aspx?") != -1 || url.match(/\d+/g).length == 2) { - return "multiple"; - } else if (url.match(/\d+/g).length == 3) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var urls = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('//a[@class="AbsTitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//a[@class="AbsTitle"]'; - } else if (doc.evaluate('//a[@class="toc_ArticleTitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//a[@class="toc_ArticleTitle"]'; - } - var articles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_art; - while (next_art = articles.iterateNext()) { - items[next_art.href] = next_art.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, grabCitation, function() {Zotero.done();}); - Zotero.wait(); - - } else { - if (url.indexOf("article.aspx") == -1 ) { - // no need for a processDocuments request for single item abstrac - grabCitation(doc); - - } else { // html fulltext page doesn't include citation link, load abstract and grab RIS - url = url.substring(0,url.indexOf("article.aspx")); - Zotero.Utilities.processDocuments([url], grabCitation, function() {Zotero.done();}); - Zotero.wait(); - } - } - -} -// breaking out the citation extraction step -function grabCitation(newDoc) { - var rislink = newDoc.evaluate('//div[@id="block0"]/table/tbody/tr/td[@class="body"]/a', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href.replace("info/GetCitation", "AutomaticCitationDownload") + '&type=ReferenceManager'; - var DOI = newDoc.evaluate('//td[2]/span[@class="toc_VolumeLine"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/doi:\s*(.*)$/)[1]; - var PDF = newDoc.evaluate('//div[@class="jovHistory"]//td[2]/a', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - Zotero.debug("RIS="+rislink); - Zotero.Utilities.HTTP.doGet(rislink, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.DOI = DOI; - item.publicationTitle = "Journal of Vision"; - item.attachments = [{url:PDF, title:"Journal of Vision Full Text PDF", mimeType:"application/pdf"}]; - item.complete(); - }); - translator.translate(); - }); - -} -\ No newline at end of file diff --git a/translators/JurPC.js b/translators/JurPC.js @@ -1,127 +0,0 @@ -{ - "translatorID":"b662c6eb-e478-46bd- bad4-23cdfd0c9d67", - "translatorType":4, - "label":"JurPC", - "creator":"Oliver Vivell and Michael Berkowitz", - "target":"http://www.jurpc.de/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-12 19:30:00" -} - -function detectWeb(doc, url) { - var doctype = doc.evaluate('//meta/@doctype', doc, null,XPathResult.ANY_TYPE, null).iterateNext().textContent; - - if (doctype == "Aufsatz"){ - return "Aufsatz"; - }else{ - return "Rechtsprechung"; - } -} - -function doWeb(doc, url) { - - var articles = new Array(); - - if (detectWeb(doc, url) == "Aufsatz") { - - // Aufsatz gefunden - - Zotero.debug("Ok, we have an JurPC Article"); - var authors = '//meta/@Author'; - var title = '//meta/@Title'; - var webdoktext = '//meta/@WebDok'; - - var authors = parseDoc(authors,doc); - var title = parseDoc(title,doc); - - var webabs = webdoktext.substr(webdoktext.lastIndexOf("Abs."), webdoktext.length); - - //Zotero.debug(doctype); - Zotero.debug(webdoktext); - var year = url.substr(28, 4); - - //Get Year & WebDok Number from Url - var webdok = url.substr(32, 4); - - var suche = webdok.indexOf("0"); - if (suche == 0){ - webdok = url.substr(33, 3); - suche = webdok.indexOf("0"); - - if(suche == 0){ - webdok = url.substr(34, 2); - suche = webdok.indexOf("0"); - } - //Zotero.debug(suche); - if(suche == 0){ - webdok = url.substr(35, 1); - suche = webdok.indexOf("0"); - } - } - - var re = /<[^>]*>/ - Zotero.debug(re); - title = title.replace(re,""); - title = title.replace(re,""); - title = title.replace(re,""); - Zotero.debug(title); - - var newArticle = new Zotero.Item('journalArticle'); - - newArticle.title = title; - newArticle.journal = "JurPC"; - newArticle.journalAbbreviation = "JurPC"; - newArticle.year = year; - newArticle.volume = "WebDok " + webdok + "/" + year; - newArticle.pages = webabs ; - newArticle.url = url; - var aus = authors.split("/"); - for (var i=0; i< aus.length ; i++) { - Zotero.debug(aus[0]); - newArticle.creators.push(Zotero.Utilities.cleanAuthor(aus[i], "author")); - } - newArticle.complete(); - } else { - - // Dokument ist ein Urteil - - var gericht = '//meta/@Gericht'; - var ereignis = '//meta/@Ereignis'; - var datum = '//meta/@Datum'; - var aktz = '//meta/@aktz'; - var titel = '//meta/@Title'; - var webdok = '//meta/@WebDok'; - - try{ - var gericht = parseDoc(gericht,doc); - var ereignis = parseDoc(ereignis,doc); - var datum = parseDoc(datum,doc); - var aktz = parseDoc(aktz,doc); - var webdok = parseDoc(webdok,doc); - var titel = parseDoc(titel,doc); - } catch (e) { var titel = doc.evaluate('//meta/@Titel', doc, null,XPathResult.ANY_TYPE, null).iterateNext().textContent;} - //Zotero.debug(titel); - - - // Informationen an Zotero übergeben - - var newCase = new Zotero.Item('case'); - newCase.court = gericht; - newCase.caseName = titel; - newCase.title = titel; - newCase.shortTitle = "WebDok " + webdok; - newCase.dateDecided = ereignis + " , " + aktz; - newCase.url = url; - newCase.journalAbbreviation = "JurPC"; - //Zotero.debug(newCase.codeNumber); - newCase.complete(); - } -} - -function parseDoc(xpath, doc) { - var content = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE,null).iterateNext().textContent; - return content; -} -\ No newline at end of file diff --git a/translators/KOBV.js b/translators/KOBV.js @@ -1,93 +0,0 @@ -{ - "translatorID":"fef07360-ee97-4f67-b022-6f64d5ec0c25", - "translatorType":4, - "label":"KOBV", - "creator":"Gunar Maiwald", - "target":"^http://vs13.kobv.de/V/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//tr /td[@class="no_wrap_center"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } - else if (doc.evaluate('//tr/th[@class="no_wrap"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -function scrape(doc) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - - var xpath; - if (doc.title.match("Freie Universität Berlin")) { xpath ='//li/a[@title="Ansicht des Originalformats"]'; } - else if (doc.title.match("KOBV")) { xpath ='//li/a[@title="Ansicht des bibliothekarischen Formats"]'; } - else if (doc.title.match("UB der HU Berlin")) { xpath ='//li/a[@title="Ansicht des Originalformats"]'; } - else if (doc.title.match("^MetaLib")) { xpath ='//li/a[@title="Ansicht des Originalformats"]'; } - var hrefs = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var href; - - while (href = hrefs.iterateNext()) { - var url = href.getAttribute("href"); - url += "&format=005"; - - Zotero.Utilities.processDocuments([url], function(newDoc) { - var record = new marc.record(); - var xpath = '//table//tr'; - var elmts = newDoc.evaluate(xpath, newDoc, null, XPathResult.ANY_TYPE, null); - var elmt; - - while (elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.trimInternal(newDoc.evaluate('./td[1]', elmt, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var value = Zotero.Utilities.trimInternal(newDoc.evaluate('./td[2]', elmt, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - value = value.replace(/\|([a-z]) /g,marc.subfieldDelimiter+"$1"); - var code = field.substring(0,3); - var ind = field.substr(3); - - // QnD for Authors: - if (code == "100" && ind == "11" && value.match(marc.subfieldDelimiter+"b")) { - var values = value.split(marc.subfieldDelimiter); - var forename = values[1].substr(1); - var surname = values[2].substr(1); - value = marc.subfieldDelimiter+"a"+surname+", "+forename; - ind = 1; - } - record.addField(code, ind, value); - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - newItem.complete(); - - }, function() { Zotero.done(); }); - Zotero.wait(); - } -} - - -function doWeb(doc, url) { - var xpath1 = '//table/tbody/tr/td[@class="no_wrap_center"]/a'; - var xpath2 = '//table/tbody/tr/th[@class="no_wrap"]'; - var newUrls = new Array(); - - if (doc.evaluate(xpath1, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var items = Zotero.Utilities.getItemArray(doc, doc, '^http://vs13.kobv.de/V/.*format=999$','^[0-9]+$'); - items = Zotero.selectItems(items); - for (var url in items) { - newUrls.push(url); - } - } - - else if (doc.evaluate(xpath2, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - newUrls.push(url); - } - - Zotero.Utilities.processDocuments(newUrls, scrape, function() { Zotero.done(); }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Kommersant.js b/translators/Kommersant.js @@ -1,100 +0,0 @@ -{ - "translatorID": "43bc17ed-e994-4fdb-ac28-594c839658ca", - "label": "Kommersant", - "creator": "Avram Lyon", - "target": "^https?:\\/\\/kommersant\\.ru\\/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-24 01:01:53" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};/* - Kommersant 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 FW.detectWeb(doc, url); -} -function doWeb(doc, url) { return FW.doWeb(doc, url); } - - -/** Articles */ -FW.Scraper({ itemType : 'magazineArticle', - detect : FW.Xpath('//div[@class="issue"]/a[contains(text(),"Журнал")]'), - title : FW.Xpath('//div[@class="document"]/div[@class="title"]').text().trim(), - attachments : [ - { - url : FW.Url(), - type : "text/html", - title : "Kommersant Snapshot" - } ], - creators : FW.Xpath('//div[contains(@class, "document_authors")][preceding-sibling::div[@class="document_vvodka"]]').text().split(",").cleanAuthor("author"), - date : FW.Xpath('//div[@class="issue"]/a').text().replace(/.*(\d{2})\.(\d{2})\.(\d{4})\s*$/,"$3-$2-$1"), - issue : FW.Xpath('//div[@class="issue"]/a').text().match(/№\s*(\d+(?: \(\d+\))?)/,1), - abstractNote : FW.Xpath('//div[@class="document_vvodka"]').text().trimInternal(), - publicationTitle : FW.Xpath('//div[@class="issue"]/a').text().match(/^\s*Журнал\s+"([^"]+)"/,1) -}); - -/** News Articles */ -FW.Scraper({ itemType : 'newspaperArticle', - detect : FW.Xpath('//div[@class="issue"]/a[contains(text(),"Газета") or contains(text(),"Online")]'), - title : FW.Xpath('//div[@class="document"]/div[@class="title"]').text().trim(), - attachments : [ - { - url : FW.Url(), - type : "text/html", - title : "Kommersant Snapshot" - } ], - creators : FW.Xpath('//div[contains(@class, "document_authors")][preceding-sibling::div[@class="document_vvodka"]]') - .text().replace(/\s?отдел\s[^,]*,?/gi,"") - .split(",").trim().cleanAuthor("author"), - date : FW.Xpath('//div[@class="issue"]/a').text().replace(/.*(\d{2})\.(\d{2})\.(\d{4})\s*(?:\/\/\s\d+:\d+)?$/,"$3-$2-$1"), - issue : FW.Xpath('//div[@class="issue"]/a').text().match(/№\s*(\d+(?: \(\d+\))?)/,1), - abstractNote : FW.Xpath('//div[@class="document_vvodka"]').text().trimInternal(), - publicationTitle : FW.Xpath('//div[@class="issue"]/a').text().match(/^\s*"([^"]+)"/,1) -}); - -/** News Articles - second format */ -FW.Scraper({ itemType : 'newspaperArticle', - detect : FW.Url().match(/\/News\//), - creators : FW.Xpath('//div[contains(@class, "document_authors")][preceding-sibling::div[@class="title"]]') - .text().replace(/\s?отдел\s[^,]*,?/gi,"") - .split(",").trim().cleanAuthor("author"), - publicationTitle : "Коммерсантъ", - title : FW.Xpath('//table[contains(@class,"news_block")]//div[@class="title"]').text().trim(), - attachments : [ - { - url : FW.Url(), - type : "text/html", - title : "Kommersant Snapshot" - } ], - date : FW.Xpath('//div[contains(@class,"other_blockname")]/div[@class="f-h"]').text().replace(/.*(\d{2})\.(\d{2})\.(\d{4}).*$/,"$3-$2-$1") - }); - -/** Search results */ -FW.MultiScraper({ itemType : "multiple", - detect : FW.Xpath('//table[contains(@class,"searchresults")]'), - choices : { - titles : FW.Xpath('//table[contains(@class,"searchresults")]/tbody/tr/td/a').text(), - urls : FW.Xpath('//table[contains(@class,"searchresults")]/tbody/tr/td/a').key('href').text() - } -}); diff --git a/translators/LA Times.js b/translators/LA Times.js @@ -1,224 +0,0 @@ -{ - "translatorID":"e4fe1596-a8c4-4d09-945f-120c4d83e580", - "translatorType":4, - "label":"LA Times", - "creator":"Ben Parr", - "target":"^https?://(?:www.|travel.)?latimes.com", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//link[@title="Main"]'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE,null).iterateNext()) - {return "newspaperArticle";} - - if(doc.title.indexOf("Search Results")>-1) - {return "multiple";} - - xpath = '//h1'; - var rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - var row; - while(row=rows.iterateNext()) - { - if(Zotero.Utilities.trimInternal(row.textContent.toLowerCase())=="travel") - {return "newspaperArticle";} - } - - return null; -} - -function getCount(s) -{ - if(!s||s=='') - return 0; - if(s.indexOf("Displaying")>-1) - { - s=s.substr(19); - s=s.replace('.',''); - s=s.split(' to '); - return s[1]-s[0]+1; - } - return 0; -} - -function processList(items) -{ - items = Zotero.selectItems(items); - var uris=new Array(); - - if (!items) - {return true;} - - for (var i in items) - {uris.push(i);} - - Zotero.Utilities.processDocuments(uris, scrape,function() {Zotero.done(); }); - Zotero.wait(); - - return true; -} - -function findDate(s) -{ - var words=s.split(" "); - var months=new Array("january","febuary","march","april","may","june","july","august","september","october","november","december"); - for(var n=0;words[n];n++) - { - for(var m in months) - {if(words[n].toLowerCase()==months[m]) - {return words[n]+" "+words[n+1]+" "+words[n+2];} - } - } - return null; -} - - -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("newspaperArticle"); - newItem.publicationTitle = "The Los Angeles Times"; - newItem.ISSN = "0458-3035"; - - var xpath='//h2/a'; - var t=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE,null).iterateNext(); - if(t) - {newItem.section=t.textContent; } - else - { - xpath='//a/img[@alt="WEST"]'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE,null).iterateNext()) - {newItem.section="West";} - else - { - xpath = '//h1'; - var rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - if(t=rows.iterateNext()) - {newItem.section=t.textContent;} - } - } - - - xpath='//h1[last()]'; - var rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - if(t=rows.iterateNext()) - {newItem.title=t.textContent;} - - newItem.url = url; - xpath='//div[@class="storybyline"]'; - var test=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE,null).iterateNext(); - if(!test) - {xpath='//p[@class="by-author"]';} - var info=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE,null).iterateNext().textContent; - info=Zotero.Utilities.trimInternal(info); - var date=findDate(info); - if(date) - { - newItem.date=date; - info=info.replace(date,''); - } - info=Zotero.Utilities.trimInternal(info); - if(info.indexOf(", ")>-1) - { - var phrases=info.split(", "); - var a=phrases[0]; - if (a.substr(0,3).toLowerCase() == "by ") - {a= a.substr(3);} - if(a.substr(0,5).toLowerCase()!="from ") - { - var authors=a.split(" and "); - var n; - for(n in authors) - {newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[n],"author"));} - } - } - else - { - xpath='//div[@class="storydeckhead"]/a'; - temp=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE,null).iterateNext(); - if(temp!=null && temp!='') - {newItem.creators.push(Zotero.Utilities.cleanAuthor(temp.textContent,"author"));} - } - - newItem.attachments.push({document:doc, title:"The Los Angeles Times Snapshot"}); - newItem.complete(); -} - - - -function doWeb(doc, url) -{ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - var xpath='//link[@title="Main"]'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE,null).iterateNext()) - {scrape(doc,url); return true;} - - xpath = '//h1'; - var rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - var row; - while(row=rows.iterateNext()) - { - if(Zotero.Utilities.trimInternal(row.textContent.toLowerCase())=="travel") - {scrape(doc,url); return true;} - } - - if(doc.title.indexOf("Search Results")>-1) - { - xpath='//div[@class="abstract1"]'; - var count=0; - rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - while(row=rows.iterateNext()) - { - count=getCount(row.textContent); - if(count!=0) - {break;} - } - if(count==0) - { - xpath='//td[@class="abstract1"]'; - rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - while(row=rows.iterateNext()) - { - count=getCount(row.textContent); - if(count!=0) - {break;} - } - } - - if(count>0) - { - var items=new Array(); - xpath='//div[@class="headline14"]/a'; - rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null); - while(row=rows.iterateNext()) - { - if(count==0) - {break;} - if(row.href.indexOf("/travel/")<0) - {items[row.href]=Zotero.Utilities.trimInternal(row.textContent);} - count--; - } - - return processList(items); - } - } -} -\ No newline at end of file diff --git a/translators/Le Devoir.js b/translators/Le Devoir.js @@ -1,142 +0,0 @@ -{ - "translatorID":"d1605270-d7dc-459f-9875-74ad8dde1f7d", - "translatorType":4, - "label":"Le Devoir", - "creator":"Adam Crymble", - "target":"http://www.ledevoir.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-21 15:45:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("Recherche")) { - return "multiple"; - } else if (doc.evaluate('//div[@id="autresArticles"]/p', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "newspaperArticle"; - } -} - -//Le Devoir Translator. Code by Adam Crymble - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var tagsContent = new Array(); - - var newItem = new Zotero.Item("newspaperArticle"); - - var contents = doc.evaluate('//div[@id="autresArticles"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var j = 0; - var n = 0; - var contentsArray = new Array(); - var contents1; - - while (contents1 = contents.iterateNext()) { - contentsArray.push(contents1.textContent); - j++; - } - - var author; - var author1; - var author2; - - if (j > 1) { - for (var i in contentsArray) { - if (contentsArray[i].match("Édition du ")) { - var date1 = contentsArray[i].split("Édition du "); - - newItem.date = date1[1]; - - if (date1[0].match(/\w/)) { - - author = date1[0]; - if (author.match(/\n/)) { - author1 = author.split(/\n/); - - for (var k = 0; k < author1.length; k++) { - if (author1[k].match(/\w/) && author1[k].match(", ")) { - author2 = author1[k].split(", "); - if (author2[0].match(/\w/)) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author2[0], "author")); - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author2[1], "author")); - } - } else if (author1[k].match(/\w/) && !author1[k].match(", ")) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[k], "author")); - } - } - } else if (author.match(" et ")) { - author1 = author.split(" et "); - for (var k in author1) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[k], "author")); - } - } else if (author.match(", ")) { - author1 = author.split(", "); - for (var k in author1) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[k], "author")); - } - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(date1[0], "author")); - } - } - } else if (contentsArray[i].match("Mots clés")) { - contentsArray[i] = contentsArray[i].substr(11); - if (contentsArray[i].match(", ")) { - tagsContent = contentsArray[i].split(", "); - } else { - newItem.tags = ontentsArray[i]; - n = 1; - } - } - } - } - - if (n == 0 && tagsContent.length>1) { - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - } - - newItem.title = doc.title; - newItem.url = doc.location.href; - newItem.publicationTitle = "Le Devoir"; - newItem.ISSN = "0319-0722"; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Le Monde Diplomatique_de.js b/translators/Le Monde Diplomatique_de.js @@ -1,139 +0,0 @@ -{ - "translatorID": "530cf18c-e80a-4e67-ae9c-9b8c08591610", - "label": "Le monde diplomatique", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.monde-diplomatique\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-26 16:50:57" -} - -/* -Le Monde Diplomatique (de) Translator -Copyright (C) 2011 Martin Meyerhoff - -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/>. -*/ -/* -Works really well. Try here: -http://www.monde-diplomatique.de/pm/2011/02/11/a0054.text.name,askexfz1c.n,0 -http://www.monde-diplomatique.de/pm/.search?tx=Globalisierung -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (url.match(/^http:\/\/www\.monde-diplomatique\.de\/pm\/\d\d\d\d\/\d\d/) ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (url.match(/search/) ) { - Zotero.debug("multiple"); - return "multiple"; - } -} -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var title_XPath = ".//*[@id='haupt']/div/h3" - if (doc.evaluate(title_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the title! - - - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = Zotero.Utilities.trim(title); - - - // Now for the Author - - var author_XPath = ".//*[@id='haupt']/div/h4"; - if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - author = author.replace(/^\s*von\s|\s*$/g, ''); // remove whitespace around the author and the "Von "at the beginning - } else { - var author = ""; - } - var author = author.split(" | "); // this seems to work even if there's no | - for (var i in author) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - - // No Tags - - - // Date - var date_XPath = ".//*[@id='haupt']/h2" - var date = doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - date = date.split(" vom ")[1]; - newItem.date = date; - - - // Summary - var summary_XPath = ".//*[@id='haupt']/div/h5" - if (doc.evaluate(summary_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = Zotero.Utilities.trim(summary); - } - - newItem.publicationTitle = "Le Monde Diplomatique (Deutsch)"; - - newItem.attachments.push({url:doc.location.href, title:doc.title, mimeType:"text/html"}); - newItem.complete() - - } -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate("//*[@id='haupt']/div/p/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.href.match(/^http:\/\/www\.monde-diplomatique\.de\/pm\/\d\d\d\d\/\d\d/) ){ - items[next_title.href] = next_title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} - diff --git a/translators/LexisNexis.js b/translators/LexisNexis.js @@ -1,159 +0,0 @@ -{ - "translatorID":"b047a13c-fe5c-6604-c997-bef15e502b09", - "translatorType":4, - "label":"LexisNexis", - "creator":"Sean Takats", - "target":"https?://[^/]*lexis-?nexis\\.com[^/]*/us/lnacademic", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-04-19 05:35:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (doc.title.substr(doc.title.length-8, 8)=="Document"){ - var xpath = '//input[@name="cisb"]'; - var elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - if (elmt.iterateNext()){ - return "newspaperArticle"; - } - } - var xpath = '//input[@name="frm_tagged_documents" and @type="checkbox"]'; - var elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - if (elmt.iterateNext()){ - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // define results navigation frame doc for export buttons and hidden fields - //var rfDoc = doc.importNode(doc.defaultView.window.top.frames[1].document, true); - var rfDoc = doc; - var xpath = '//img[@title="Export Bibliographic References"]'; - - var elmt = doc.evaluate(xpath, rfDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - var hostRe = new RegExp("^http(?:s)?://[^/]+"); - var m = hostRe.exec(doc.location.href); - var host = m[0]; - - var risb = doc.evaluate('//input[@name="risb"]', rfDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value; - if (doc.title.substr(doc.title.length-8, 8) == "Document") { - var cisb = doc.evaluate('//input[@name="cisb"]', rfDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value; - var uri = host+"/us/lnacademic/results/listview/delPrep.do?cisb="+cisb+"&risb="+risb+"&mode=delivery_refworks"; - var hiddenInputs = doc.evaluate('//form[@name="results_docview_DocumentForm"]//input[@type="hidden" and not(@name="tagData")]', rfDoc, nsResolver, - XPathResult.ANY_TYPE, null); - - } else { - var cisb = doc.evaluate('//a[@target="_parent"]', rfDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href.match(/cisb=([^&]+)/)[1]; - var uri = host+"/us/lnacademic/results/listview/delPrep.do?cisb="+cisb+"&risb="+risb+"&mode=delivery_refworks"; - var hiddenInputs = doc.evaluate('//input[@type="hidden" and not(@name="tagData") ]', rfDoc, nsResolver, - XPathResult.ANY_TYPE, null); - - } - var hiddenInput; - var poststring=""; - while(hiddenInput = hiddenInputs.iterateNext()) { - poststring = poststring+"&"+hiddenInput.name+"="+encodeURIComponent(hiddenInput.value); - } - - var xpath = '//input[@name="frm_tagged_documents" and @type="checkbox"]'; - var elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - if (doc.title.substr(doc.title.length-8, 8)=="Document"){ - // single page - var delRange = "cur"; - poststring = poststring + "&hiddensearchfield=Narrow+Search&reloadClassif=&format=GNBFI&focusTerms=&nextSteps=0"; - } else { - // get multiple item titles and tags - var xpath = '//tr[td/input[@name="frm_tagged_documents"]]'; - var rows = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - var tagNumber; - var items = new Object(); - while (row = rows.iterateNext()){ - title = doc.evaluate('.//a', row, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - tagNumber = doc.evaluate('./td/input[@name="frm_tagged_documents"]', row, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value; - items[tagNumber] = title; - } - var tagData = ""; - items = Zotero.selectItems(items); - if (!items) { - return true; - } - for (var i in items) { - tagData += "-"+i; - } - tagData = tagData.substr(1); - var delRange = "tag"; - // this is a violatin of human rights - poststring = "followlinks=false&tocLoad=results%2FpubtreeWaitMsg.do&listview=results%2Flistview%2Flistview.do&docview=results%2Fdocview%2Fdocview.do&searchurl=search%2FfocusSearch.do&treeMax=true&treeMod=true&treeWidth=0&pubTreeWidth=&sortId=RELEVANCE&pubTreeMax=false&exit=&startDocNo=1&docNo=&selRCDomainId=4&formatStr=GNBLIST&csi=0&offset=0&ftdividerload=&selTocNodeId=&nextOrPrevious=&curDocLni=null&tocCsiForSeqBrws=null&uri=&viewOptionChanged=false&prevFormat=GNBLIST&prevAction=null&sId=34888793&legVerSupported=false&nodeDisplayName=&unCheckedNodes=&checkedNodes=&grayedNodes=&pisb=&docsInCategory=0&backToBrowseKey=&formatType=LIST&minMaxURI=&docviewAccessed=false&showViewTagged=false&hitNo=0&pageorigin=results_listview_Listview&docTitleFull=&originalDocNo=&dtnAvailable=false&changeLocalePath=&alrtsRqstHndlrPath=&archiveURL=&selectedNodeId=&multipleNodes=&dtnDataHandlerUrl=results%2Fdocview%2FdtnDataHandler.do&totalDocsInResult=1000&fromDocNo=0&cartDocIds=&hiddensearchfield=Search+within+results&reloadClassif=&selDomainID=&urlApiUser=false&editSrchRtUrlPresent=false&showWidget=false&bookmarkUrl=&sourceName=Major+U.S.+and+World+Publications&permalinkNarrowSearchTerms=&prevSortOption=Relevance&format=GNBLIST&inlineLafnNarrow=false&focusTerms=&sort=RELEVANCE&nextSteps=0"; - - poststring = poststring + "&tagData=" + tagData +"&risId=" + risb + "&cisbId=" + cisb + "&risb=" + risb + "&cisb=" + cisb + "&resultrisbId=" + risb; - //Zotero.debug(poststring); - } - Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) { - uri = host+"/us/lnacademic/delivery/refExport.do"; - var disb = text.match(/<input type="hidden" name="disb" value="([^"]+)">/); - poststring = "delRange="+delRange+"&selDocs=&disb="+disb[1]+"&initializationPage=0"; - Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) { - uri = text.match(/url=([^']+)'/) - uri = decodeURIComponent(uri[1]); - uri = uri.replace(/http:\/\/[^/]*\//, host+"/"); - var uris = new Array(); - uris.push(uri); - Zotero.Utilities.processDocuments(uris, function(newDoc){ - var elmts =newDoc.evaluate('//html', newDoc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - while (elmt = elmts.iterateNext()){ - var newItem = new Zotero.Item("newspaperArticle"); - var title = newDoc.evaluate('.//div[@class="HEADLINE"]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (title.textContent){ - newItem.title = title.textContent; - }else{ - newItem.title = " "; - } - var date = newDoc.evaluate('.//meta[@name="_lndateissue"]/@content', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (date){ - date = date.nodeValue; - var m = date.match(/([^T]+)T/); - date = m[1]; - if (date.length == 8){ - date = date.substr(0,4) + "-" + date.substr(4,2) + "-" + date.substr(6,2); - } else if (date.length == 6){ - date = date.substr(0,4) + "-" + date.substr(4,2); - } - newItem.date = date; - } - var publicationTitle = newDoc.evaluate('.//div[@class="PUB"]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (publicationTitle){ - newItem.publicationTitle = publicationTitle.textContent; - } - var section = newDoc.evaluate('.//div[@class="SECTION-INFO"]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (section){ - newItem.section = section.textContent; - } - var author = newDoc.evaluate('.//div[@class="BYLINE"]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (author){ - newItem.creators.push(Zotero.Utilities.cleanAuthor(author.textContent, "author")); - } - newItem.repository = "lexisnexis.com"; - newItem.url = url; - newItem.complete() - } - Zotero.done(); - }); - }); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Library Catalog (Aleph).js b/translators/Library Catalog (Aleph).js @@ -1,214 +0,0 @@ -{ - "translatorID":"cf87eca8-041d-b954-795a-2d86348999d5", - "translatorType":4, - "label":"Library Catalog (Aleph)", - "creator":"Simon Kornblith, Michael Berkowitz, Ming Yeung Cheung", - "target":"https?://[^/]+/F(?:/[A-Z0-9\\-]+(?:\\?.*)?$|\\?func=find|\\?func=scan|\\?func=short)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-10-22 19:00:00" -} - -/* -Aleph OPAC Translator -Example installations (mainly French): -http://naude.bibliotheque-mazarine.fr/ -http://bibli.polytechnique.fr/ -http://sifrix2.sdv.fr/ -http://aleph.insa-rouen.fr -http://brenet.ens-lyon.fr -http://bu-pau.univ-pau.fr/ -http://babel.bu.univ-paris5.fr -http://inti.univ-paris4.fr/ -http://aleph.u-paris10.fr/ -http://servaleph.univ-catholyon.fr/ -http://armada.scd.univ-paris12.fr/ -http://catalogue.univ-angers.fr/ -http://biblio.ville-lehavre.fr/ -http://opac.nebis.ch/ -http://scd2.univ-lille1.fr/ -http://catalogue.univ-paris1.fr/ -http://source.ulg.ac.be/ -http://med.cite-sciences.fr/ -http://biblio.mulhouse.fr/ -http://mediatheque.sigdci76.fr/ -http://opac.biu-montpellier.fr/ -*/ - -function detectWeb(doc, url) { - var singleRe = new RegExp("^https?://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set|func=direct|func=myshelf-full.*)"); - - if(singleRe.test(doc.location.href)) { - return "book"; - } else { - var tags = doc.getElementsByTagName("a"); - for(var i=0; i<tags.length; i++) { - if(singleRe.test(tags[i].href)) { - return "multiple"; - } - } - } -} - -function doWeb(doc, url) { - var detailRe = new RegExp("^https?://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set|func=direct|func=myshelf-full|func=myself_full.*)"); - var mab2Opac = new RegExp("^https?://[^/]+berlin|193\.30\.112\.134|duisburg-essen/F/[A-Z0-9\-]+\?.*"); - var uri = doc.location.href; - var newUris = new Array(); - - if(detailRe.test(uri)) { - // find the 'add to basket' link where it will have the document number, replace the function with 'direct' - if (doc.evaluate('//*[contains(@href, "myshelf-add-ful-1")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var elmts_add = doc.evaluate('//*[contains(@href, "myshelf-add-ful-1")]', doc, null, XPathResult.ANY_TYPE, null); - var adduri = elmts_add.iterateNext().attributes.getNamedItem("href").value; - adduri = adduri.replace("myshelf-add-ful-1", "direct"); - //adduri = adduri.replace("myshelf-add-ful-1", "myshelf-full"); - var baseuri = uri.match(".*\\?"); - var funcuri = adduri.match("\\?.*"); - newuri = baseuri + funcuri[0].match("[^\\?].*"); - newuri += "&format=001"; - //Zotero.debug('baseuri = ' + baseuri); - //Zotero.debug('funcuri = ' + funcuri); - Zotero.debug('directuri = ' + newuri); - } else { - var newuri = uri.replace(/\&format=[0-9]{3}/, "&format=001"); - if (newuri == uri) newuri += "&format=001"; - } - newUris.push(newuri); - } else { - var itemRegexp = '^https?://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=999|func=direct|func=myshelf-full.*)' - var items = Zotero.Utilities.getItemArray(doc, doc, itemRegexp, '^[0-9]+$'); - - // ugly hack to see if we have any items - var haveItems = false; - for(var i in items) { - haveItems = true; - break; - } - - // If we don't have any items otherwise, let us use the numbers - if(!haveItems) { - var items = Zotero.Utilities.getItemArray(doc, doc, itemRegexp); - } - - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - for(var i in items) { - var newUri = i.replace("&format=999", "&format=001"); - if(newUri == i) { - newUri += "&format=001"; - } - newUris.push(newUri); - } - } - var translator = Zotero.loadTranslator("import"); - if(mab2Opac.test(uri)) { - translator.setTranslator("91acf493-0de7-4473-8b62-89fd141e6c74"); - } else { - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - } - var marc = translator.getTranslatorObject(); - Zotero.Utilities.processDocuments(newUris, function(newDoc) { - var uri = newDoc.location.href; - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var nonstandard = false; - var th = false; - var xpath; - if (newDoc.evaluate('//*[tr[td/text()="LDR"]]/tr[td[2]]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - xpath = '//*[tr[td/text()="LDR"]]/tr[td[2]]'; - } else if (newDoc.evaluate('//*[tr[th/text()="LDR"]]/tr[td[1]]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - xpath = '//*[tr[th/text()="LDR"]]/tr[td[1]]'; - th = true; - } else if (newDoc.evaluate('//tr[2]//table[2]//tr', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - xpath = '//tr[2]//table[2]//tr[td[2]]'; - nonstandard = true; - } else if (newDoc.evaluate('//table//tr[td[2][@class="td1"]]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - xpath = '//table//tr[td[2][@class="td1"]]'; - nonstandard = true; - } else if (newDoc.evaluate('//tr/td[2]/table/tbody[tr/td[contains(text(), "LDR")]]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - xpath = '//tr/td[2]/table/tbody[tr/td[contains(text(), "LDR")]]/tr'; - nonstandard = true; - } - var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - var record = new marc.record(); - while(elmt = elmts.iterateNext()) { - if (th) { - var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./th', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } else { - var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./td[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - // if (nonstandard) { - // var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./td[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - // } else { - // var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./TD[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - // } - // var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./td[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if(field) { - var value; - if (th) { - value = newDoc.evaluate('./TD[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; //.split(/\n/)[1]; - } else { - value = newDoc.evaluate('./TD[2]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; //.split(/\n/)[1]; - } - if (value.split(/\n/)[1]) value = Zotero.Utilities.trimInternal(value.split(/\n/)[1]); - Zotero.debug(field + " : " + value); - if(field == "LDR") { - record.leader = value; - } else if(field != "FMT") { - value = value.replace(/\|([a-z]) /g, marc.subfieldDelimiter+"$1"); - - var code = field.substring(0, 3); - var ind = ""; - if(field.length > 3) { - ind = field[3]; - if(field.length > 4) { - ind += field[4]; - } - } - - record.addField(code, ind, value); - } - } - } - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^\/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - for (var i in newItem.creators) { - if (!newItem.creators[i]['firstName']) { - var name = newItem.creators[i]['lastName'].split(/([^\s]+)\s+(.*)$/); - newItem.creators[i] = {lastName:name[1], firstName:name[2], creatorType:'author'}; - } - } - - var oldCreators = newItem.creators; - newItem.creators = new Array(); - var transient = new Array(); - for each (var a in oldCreators) { - if (a.lastName) { - if (!a.lastName.match(/\d+/)) transient.push(a); - } - } - for each (var a in transient) { - if (a.firstName) { - if (a.firstName.match(/\|/)) a.firstName = a.firstName.match(/([^|]+)\s+|/)[1]; - } - } - newItem.creators = transient; - newItem.title = newItem.title.replace(/(<<|>>)/g, ''); - newItem.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/Library Catalog (BiblioCommons).js b/translators/Library Catalog (BiblioCommons).js @@ -1,220 +0,0 @@ -{ - "translatorID": "5d506fe3-dbde-4424-90e8-d219c63faf72", - "label": "Library Catalog (BiblioCommons)", - "creator": "Avram Lyon", - "target": "^https?://[^.]+\\.bibliocommons\\.com\\/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-19 20:37:25" -} - - -/* - BiblioCommons 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) { - if (url.match(/\/item\/(?:show|catalogue_info)/)) - return "book"; - if (url.match(/\/search\?t=/)) - return "multiple"; - return false; -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - // Load MARC - var translator = Z.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - - var domain = url.match(/https?:\/\/([^.\/]+)/)[1]; - - if (url.match(/\/item\/show/)) { - Zotero.Utilities.doGet(url.replace(/\/item\/show/,"/item/catalogue_info"), - function (text) { - translator.getTranslatorObject(function (obj) { - processor({ - translator: obj, - text: text, - domain: domain - }); - }) - }, function() {Zotero.done()}); - } else if (url.match(/\/item\/catalogue_info/)) { - translator.getTranslatorObject(function (obj) { - processor({ - translator: obj, - text: doc.documentElement.innerHTML, - domain: domain - }); - }) - } else if (url.match(/\/search\?t=/)) { - var results = doc.evaluate('//div[@id="bibList"]/div/div//span[@class="title"]/a[1]', doc, ns, XPathResult.ANY_TYPE, null); - var items = new Array(); - var result; - while(result = results.iterateNext()) { - var title = result.textContent; - var url = result.href.replace(/\/show\//,"/catalogue_info/"); - items[url] = title; - } - Zotero.selectItems(items, function (items) { - var urls = []; - var i; - for (i in items) urls.push(i); - Zotero.Utilities.doGet(urls, function (text) { - translator.getTranslatorObject(function (obj) { - processor({ - translator: obj, - text: text, - domain: domain - }); - }) - }, function() {Zotero.done()}); - }); - Zotero.wait(); - } -} - -function processor (obj) { - // Gets {translator: , text: } - // Here, we split up the table and insert little placeholders between record bits - var marced = obj.text.replace(/\s+/g," ") - .replace(/^.*<div id="marc_details">(?:\s*<[^>"]+>\s*)*/,"") - .replace(/<tr +class="(?:odd|even)">\s*/g,"") - .replace(/<td +class="marcTag"><strong>(\d+)<\/strong><\/td>\s*/g,"$1\x1F") - // We may be breaking the indicator here - .replace(/<td\s+class="marcIndicator">\s*(\d*)\s*<\/td>\s*/g,"$1\x1F") - .replace(/<td +class="marcTagData">(.*?)<\/td>\s*<\/tr>\s*/g,"$1\x1E") - .replace(/\x1F(?:[^\x1F]*)$/,"\x1F") - // We have some extra 0's at the start of the leader - .replace(/^000/,""); - //Z.debug(marced); - - // We've used the record delimiter to delimit fields - var fields = marced.split("\x1E"); - - // The preprocess function gets the translator object, if available - // This is pretty vital for fancy translators like MARC - var marc = obj["translator"]; - // Make a record, only one. - var record = new marc.record(); - // The first piece is the MARC leader - record.leader = fields.shift(); - for each (var field in fields) { - // Skip blanks - if (field.replace(/\x1F|\s/g,"") == "") continue; - // We're using the subfield delimiter to separate the field code, - // indicator, and the content. - var pieces = field.split("\x1F"); - record.addField(pieces[0].trim(), - pieces[1].trim(), - // Now we insert the subfield delimiter - pieces[2].replace(/\$([a-z]|$)/g,"\x1F$1").trim()); - } - // returns {translator: , text: false, items: [Zotero.Item[]]} - var item = new Zotero.Item(); - record.translate(item); - item.libraryCatalog = obj.domain + " Library Catalog"; - item.complete(); - return true; -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://bostonpl.bibliocommons.com/item/catalogue_info/2993906042_test", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "William", - "lastName": "Sleator", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Education", - "Immigrants", - "Conspiracies", - "Political corruption", - "Educational tests and measurements" - ], - "seeAlso": [], - "attachments": [], - "ISBN": "0810993562", - "title": "Test", - "place": "New York", - "publisher": "Amulet Books", - "date": "2008", - "numPages": "298", - "callNumber": "SLEATOR W", - "libraryCatalog": "bostonpl Library Catalog" - } - ] - }, - { - "type": "web", - "url": "http://nypl.bibliocommons.com/search?t=smart&search_category=keyword&q=tatar&commit=Search&searchOpt=catalogue", - "items": "multiple" - }, - { - "type": "web", - "url": "http://bostonpl.bibliocommons.com/item/show/3679347042_adam_smith", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "James R", - "lastName": "Otteson", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Smith, Adam", - "Classical school of economics", - "Free enterprise" - ], - "seeAlso": [], - "attachments": [], - "ISBN": "9780826429834", - "title": "Adam Smith", - "place": "New York", - "publisher": "Continuum", - "date": "2011", - "numPages": "179", - "series": "Major conservative and libertarian thinkers", - "seriesNumber": "v. 16", - "callNumber": "HB103.S6", - "libraryCatalog": "bostonpl Library Catalog" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Library Catalog (DRA).js b/translators/Library Catalog (DRA).js @@ -1,83 +0,0 @@ -{ - "translatorID":"fb12ae9e-f473-cab4-0546-27ab88c64101", - "translatorType":4, - "label":"Library Catalog (DRA)", - "creator":"Simon Kornblith", - "target":"/web2/tramp2\\.exe/(?:see\\_record/|authority\\_hits/|goto/.*\\?.*screen=Record\\.html)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-12 18:25:00" -} - -function detectWeb(doc, url) { - if(doc.location.href.indexOf("/authority_hits") > 0) { - return "multiple"; - } else { - return "book"; - } -} - -function doWeb(doc, url) { - var checkItems = false; - - if(doc.location.href.indexOf("/authority_hits") > 0) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - checkItems = Zotero.Utilities.gatherElementsOnXPath(doc, doc, "/html/body//ol/li", nsResolver); - } - - if(checkItems && checkItems.length) { - var items = Zotero.Utilities.getItemArray(doc, checkItems, 'https?://.*/web2/tramp2\.exe/see_record'); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var uris = []; - for(var i in items) { - uris.push(i); - } - } else { - var uris = [doc.location.href]; - } - - for(var i in uris) { - var uri = uris[i]; - var uriRegexp = /^(https?:\/\/.*\/web2\/tramp2\.exe\/)(?:goto|see\_record|authority\_hits)(\/.*)\?(?:screen=Record\.html\&)?(.*)$/i; - var m = uriRegexp.exec(uri); - if(uri.indexOf("/authority_hits") < 0) { - var newUri = m[1]+"download_record"+m[2]+"/RECORD.MRC?format=marc&"+m[3]; - } else { - var newUri = m[1]+"download_record"+m[2]+"/RECORD.MRC?format=marc"; - } - - // Keep track of how many requests have been completed - var j = 0; - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - - var domain = url.match(/https?:\/\/([^/]+)/); - translator.setHandler("itemDone", function(obj, item) { - item.repository = domain[1]+" Library Catalog"; - item.complete(); - }); - - Zotero.Utilities.HTTP.doGet(newUri, function(text) { - translator.setString(text); - translator.translate(); - - j++; - if(j == uris.length) { - Zotero.done(); - } - }); - } - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Library Catalog (Dynix).js b/translators/Library Catalog (Dynix).js @@ -1,237 +0,0 @@ -{ - "translatorID": "774d7dc2-3474-2684-392c-f787789ec63d", - "label": "Library Catalog (Dynix)", - "creator": "Simon Kornblith and Sylvain Machefert", - "target": "ipac\\.jsp\\?.*(?:uri=(?:link|full)=[0-9]|menu=search|term=)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-24 19:43:47" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - // make sure there are multiple results, check to see if the search results number exists - var xpath = '/html/body/table[4]/tbody/tr[2]/td[1]/table/tbody/tr[2]/td/a/b[1]'; - - var detailsRe = new RegExp('ipac\.jsp\?.*uri=(?:full|link)=[0-9]'); - if(detailsRe.test(doc.location.href)) { - return "book"; - } else if(!doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { // this hack catches search results w/ single items - return "book"; - } else { - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var uri = doc.location.href; - var detailsRe = new RegExp('ipac\.jsp\?.*uri=(?:full|link)=[0-9]'); - - var uris = new Array(); - if(detectWeb(doc,uri) == "book") { - if (uri.indexOf("#") !== -1) - uris.push(uri.replace(/#/,'&fullmarc=true#')); - else - uris.push(uri+'&fullmarc=true'); - } else { - var items = Zotero.Utilities.getItemArray(doc, doc, "ipac\.jsp\?.*uri=(?:full|link)=[0-9]|^javascript:buildNewList\\('.*uri%3Dfull%3D[0-9]", "Show details"); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var buildNewList = new RegExp("^javascript:buildNewList\\('([^']+)"); - - var uris = new Array(); - for(var i in items) { - var m = buildNewList.exec(i); - if(m) { - uris.push(unescape(m[1]+'&fullmarc=true')); - } else { - uris.push(i+'&fullmarc=true'); - } - } - } - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - translator.getTranslatorObject(function (marc) { - Zotero.Utilities.processDocuments(uris, function (newDoc) { - scrape(newDoc, marc); - }, function() { Zotero.done() }, null); - }); - Zotero.wait(); -} - -function scrape(newDoc, marc) { - var uri = newDoc.location.href; - - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//form/table[@class="tableBackground"]/tbody/tr/td/table[@class="tableBackground"]/tbody/tr[td[1]/a[@class="normalBlackFont1"]]'; - var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null); - if (!elmts.iterateNext()) { - var xpath2 = '//form/table[@class="tableBackground"]/tbody/tr/td/table[@class="tableBackground"]/tbody/tr[td[1]/a[@class="boldBlackFont1"]]'; - var elmts = newDoc.evaluate(xpath2, newDoc, nsResolver, XPathResult.ANY_TYPE, null); - } - else - { - // Added to restart the evaluation. Otherwise, because of the iteratenext - // used 5 lines above to test the xpath, we miss the first line (LDR) - elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null); - } - - var elmt; - - var record = new marc.record(); - while(elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./TD[1]/A[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - var value = newDoc.evaluate('./TD[2]/TABLE[1]/TBODY[1]/TR[1]/TD[1]/A[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - // value = null for non-marc table entries w/ that xpath - if (!value) { - value = ''; - } else { - value = value.textContent; - } - - // Sometimes, the field contains "LDR: ", "001: ". We can delete these extra characters - field = field.replace(/[\s:]/g, ""); - - if (field == "LDR"){ - record.leader = value; - } else if(field != "FMT") { - // In french catalogs (in unimarc), the delimiter isn't the $ but \xA4 is used. Added there - // Also added the fact that subfield codes can be numerics - value = value.replace(/[\xA4\$]([a-z0-9]) /g, marc.subfieldDelimiter+"$1"); - - var code = field.substring(0, 3); - var ind = ""; - if(field.length > 3) { - ind = field[3]; - if(field.length > 4) { - ind += field[4]; - } - } - record.addField(code, ind, value); - } - } - - - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = uri.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - // 20091210 : We try to get a permalink on the record - var perma = uri.match(/(https?:\/\/[^/]+.*ipac\.jsp\?).*(uri\=[^&]*)/); - var profile = uri.match(/(profile\=[^&]*)/); - if (perma && perma[1] && perma[2]) - { - var permalink = perma[1] + perma[2]; - // Sometimes, for libraries with multiple profiles, it can be useful - // to store the permalink with the profile used - if (profile) - { - permalink = permalink + "&" + profile[1]; - } - newItem.attachments = [{url:permalink, title:"Original record", mimeType:"text/html", snapshot:false}]; - } - else - { - Zotero.debug("Unable to create permalink on " + uri); - } - - newItem.complete(); - } - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://siris-libraries.si.edu/ipac20/ipac.jsp?&profile=all&source=~!silibraries&uri=full=3100001~!820431~!0#focus", - "items": [ - { - "itemType": "book", - "creators": [ - { - "lastName": "Pennsylvania Academy of the Fine Arts", - "fieldMode": true - }, - { - "firstName": "Thomas", - "lastName": "Eakins", - "creatorType": "contributor" - }, - { - "firstName": "Susan Macdowell", - "lastName": "Eakins", - "creatorType": "contributor" - }, - { - "firstName": "Benjamin", - "lastName": "Eakins", - "creatorType": "contributor" - }, - { - "firstName": "Charles", - "lastName": "Bregler", - "creatorType": "contributor" - }, - { - "firstName": "Kathleen A", - "lastName": "Foster", - "creatorType": "contributor" - } - ], - "notes": [], - "tags": [ - "Eakins, Thomas", - "Eakins, Susan Macdowell", - "Eakins, Benjamin", - "Bregler, Charles", - "Bregler, Charles", - "Library", - "McDowell family", - "Manuscripts", - "Private collections", - "Pennsylvania Philadelphia" - ], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Original record", - "mimeType": "text/html", - "snapshot": false - } - ], - "ISBN": "0812282248", - "title": "Charles Bregler's Thomas Eakins collection", - "place": "Philadelphia, PA", - "publisher": "University of Pennsylvania Press", - "date": "1989", - "numPages": "37", - "callNumber": "mfc 000652", - "libraryCatalog": "siris-libraries.si.edu Library Catalog" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Library Catalog (GEAC).js b/translators/Library Catalog (GEAC).js @@ -1,105 +0,0 @@ -{ - "translatorID":"c0e6fda6-0ecd-e4f4-39ca-37a4de436e15", - "translatorType":4, - "label":"Library Catalog (GEAC)", - "creator":"Simon Kornblith", - "target":"/(?:GeacQUERY|GeacFETCH[\\:\\?].*[&:]next=html/(?:record\\.html|geacnffull\\.html))", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2006-12-15 15:11:00" -} - -function detectWeb(doc, url) { - if(doc.location.href.indexOf("/GeacQUERY") > 0) { - return "multiple"; - } else { - return "book"; - } -} - -function doWeb(doc, url) { - var uri = doc.location.href; - - var uris = new Array(); - - if(uri.indexOf("/GeacQUERY") > 0) { - var items = Zotero.Utilities.getItemArray(doc, doc, "(?:Geac)?FETCH[\:\?].*[&:]next=html/(?:record\.html|geacnffull\.html)"); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var uris = new Array(); - for(var i in items) { - var newUri = i.replace(/([:&])next=html\/geacnffull.html/, "$1next=html/marc.html"); - newUri = newUri.replace(/([:&])next=html\/record.html/, "$1next=html/marc.html"); - uris.push(newUri); - } - } else { - var newUri = uri.replace(/([:&])next=html\/geacnffull.html/, "$1next=html/marc.html"); - newUri = newUri.replace(/([:&])next=html\/record.html/, "$1next=html/marc.html"); - uris.push(newUri); - } - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - - Zotero.Utilities.processDocuments(uris, function(newDoc) { - var uri = newDoc.location.href; - - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var record = new marc.record(); - - var elmts = newDoc.evaluate('//pre/text()', newDoc, nsResolver, - XPathResult.ANY_TYPE, null); - var elmt, tag, content; - var ind = ""; - - while(elmt = elmts.iterateNext()) { - var line = elmt.nodeValue; - - if(line.substring(0, 6) == " ") { - content += " "+line.substring(6); - continue; - } else { - if(tag) { - record.addField(tag, ind, content); - } - } - - line = line.replace(/[_\t\xA0]/g," "); // nbsp - - tag = line.substr(0, 3); - if(tag[0] != "0" || tag[1] != "0") { - ind = line.substr(4, 2); - content = line.substr(7).replace(/\$([a-z])(?: |$)/g, marc.subfieldDelimiter+"$1"); - } else { - if(tag == "000") { - tag = undefined; - record.leader = "00000"+line.substr(4); - } else { - content = line.substr(4); - } - } - - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - }, function() { Zotero.done(); }, null); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Library Catalog (InnoPAC).js b/translators/Library Catalog (InnoPAC).js @@ -1,277 +0,0 @@ -{ - "translatorID": "4fd6b89b-2316-2dc4-fd87-61a97dd941e8", - "label": "Library Catalog (InnoPAC)", - "creator": "Simon Kornblith and Michael Berkowitz", - "target": "(search~|\\/search\\?|(a|X|t|Y|w)\\?|\\?(searchtype|searchscope)|frameset&FF|record=b[0-9]+(~S[0-9])?|/search/q\\?)", - "minVersion": "1.0.0b3.r1", - "maxVersion": "", - "priority": 200, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-22 17:52:39" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - -//*********** -// URL MATCHING - translator should detect the following urls... -// First page results -// http://bearcat.baylor.edu/search~S7/?searchtype=t&searcharg=test&searchscope=7&sortdropdown=-&SORT=D&extended=0&SUBMIT=Search&searchlimits=&searchorigarg=tone+hundred+years+of+solitude -// http://innopac.cooley.edu/search~S0/?searchtype=X&searcharg=test&SORT=DZ&extended=0&SUBMIT=Search&searchlimits=&searchorigarg=Xtest -// TODO: get it working for this: http://opac.library.usyd.edu.au/search -// n page results -// http://bearcat.baylor.edu/search~S7?/ttest/ttest/1837%2C1838%2C2040%2CB/browse/indexsort=- -// http://innopac.cooley.edu/search~S0?/Xtest&SORT=DZ/Xtest&SORT=DZ&SUBKEY=test/1%2C960%2C960%2CB/browse -// Individual item from search -// http://bearcat.baylor.edu/search~S7?/ttest/ttest/1837%2C1838%2C2040%2CB/frameset&FF=ttestteori+english&1%2C1%2C/indexsort=- -// http://innopac.cooley.edu/search~S0?/Xtest&SORT=DZ/Xtest&SORT=DZ&SUBKEY=test/1%2C960%2C960%2CB/frameset&FF=Xtest&SORT=DZ&1%2C1%2C -// Persistent URL for item -// http://bearcat.baylor.edu/record=b1540169~S7 -// http://innopac.cooley.edu/record=b507916~S0 -// Persistent URL for item, without suffix -// http://luna.wellesley.edu/record=b2398784 -// Specific search parameters -// http://library.cooley.edu/search/q?author=shakespeare&title=hamlet -//*********** - -// Central Michigan University fix - var xpath = '//div[@class="bibRecordLink"]'; - var elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(elmt) { - return "book"; - } - - // Regular expression to reduce false positives - if (!url.match(/SEARCH=/) && !url.match(/searchargs?=/) && !url.match(/&FF/) && !url.match(/search~S[0-9]/) && !url.match(/\/search\/q\?/) && !url.match(/record=/)) return false; - // First, check to see if the URL alone reveals InnoPAC, since some sites don't reveal the MARC button - var matchRegexp = new RegExp('^https?://[^/]+/search[^/]*\\??/[^/]+/[^/]+/[^/]+\%2C[^/]+/frameset(.+)$'); - if(matchRegexp.test(doc.location.href)) { - if (!url.match("SEARCH") && !url.match("searchtype")) { - return "book"; - } - } - // Next, look for the MARC button - xpath = '//a[img[@src="/screens/marc_display.gif" or @src="/screens/ico_marc.gif" or @src="/screens/marcdisp.gif" or starts-with(@alt, "MARC ") or @src="/screens/regdisp.gif" or @alt="REGULAR RECORD DISPLAY"]] | //a[span/img[@src="/screens/marc_display.gif" or @src="/screens/ico_marc.gif" or @src="/screens/marcdisp.gif" or starts-with(@alt, "MARC ") or @src="/screens/regdisp.gif" or @alt="REGULAR RECORD DISPLAY"]]'; - elmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(elmt) { - return "book"; - } - // Also, check for links to an item display page - var tags = doc.getElementsByTagName("a"); - for(var i=0; i<tags.length; i++) { - if(matchRegexp.test(tags[i].href) || tags[i].href.match(/^https?:\/\/([^/]+\/(?:search\??\/|record=?|search%7e\/)|frameset&FF=)/)) { - return "multiple"; - } - } - - return false; -} - -function scrape(marc, newDoc) { - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//pre/text()'; - if (newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var elmts = newDoc.evaluate(xpath, newDoc, null, XPathResult.ANY_TYPE, null); - var useNodeValue = true; - } else { - var elmts = newDoc.evaluate('//pre', newDoc, nsResolver, XPathResult.ANY_TYPE, null); - var useNodeValue = false; - } - var elmt; - while(elmt = elmts.iterateNext()) { - if (useNodeValue) { - var text = elmt.nodeValue; - } else { - var text = elmt.textContent; - } - var newItem = new Zotero.Item(); - var record = new marc.record(); - - var linee = text.split("\n"); - for (var i=0; i<linee.length; i++) { - if(!linee[i]) { - continue; - } - - linee[i] = linee[i].replace(/[\xA0_\t]/g, " "); - var value = linee[i].substr(7); - - if(linee[i].substr(0, 6) == " ") { - // add this onto previous value - tagValue += value; - } else { - if(linee[i].substr(0, 6) == "LEADER") { - // trap leader - record.leader = value; - } else { - if(tagValue) { // finish last tag - tagValue = tagValue.replace(/\|(.)/g, marc.subfieldDelimiter+"$1"); - if(tagValue[0] != marc.subfieldDelimiter) { - tagValue = marc.subfieldDelimiter+"a"+tagValue; - } - - // add previous tag - record.addField(tag, ind, tagValue); - } - - var tag = linee[i].substr(0, 3); - var ind = linee[i].substr(4, 2); - var tagValue = value; - } - } - } - if(tagValue) { - tagValue = tagValue.replace(/\|(.)/g, marc.subfieldDelimiter+"$1"); - if(tagValue[0] != marc.subfieldDelimiter) { - tagValue = marc.subfieldDelimiter+"a"+tagValue; - } - - // add previous tag - record.addField(tag, ind, tagValue); - } - - record.translate(newItem); - - var domain = newDoc.location.href.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - } -} - -function pageByPage(marc, urls) { - Zotero.Utilities.processDocuments(urls, function(newDoc) { - scrape(marc, newDoc); - }, function() { Zotero.done() }); -} - -function doWeb(doc, url) { - var uri = doc.location.href; - var newUri; - // load translator for MARC - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (detectWeb(doc, url) == "book") { - var matchRegexp = new RegExp('^(.*)frameset(.+)$'); - var m = matchRegexp.exec(uri); - if (m) { - newUri = uri.replace(/frameset/, "marc"); - } else { - var xpath = '//a[img[@src="/screens/marc_display.gif" or @src="/screens/ico_marc.gif" or @src="/screens/marcdisp.gif" or starts-with(@alt, "MARC ") or @src="/screens/regdisp.gif" or @alt="REGULAR RECORD DISPLAY"]] | //a[span/img[@src="/screens/marc_display.gif" or @src="/screens/ico_marc.gif" or @src="/screens/marcdisp.gif" or starts-with(@alt, "MARC ") or @src="/screens/regdisp.gif" or @alt="REGULAR RECORD DISPLAY"]]'; - newUri = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href.replace(/frameset/, "marc"); - } - pageByPage(marc, [newUri]); - } else { // Search results page - // Require link to match this - var tagRegexp = new RegExp(); - tagRegexp.compile('^https?://[^/]+/search\\??/[^/]+/[^/]+/[0-9]+\%2C[^/]+/frameset'); - - var urls = new Array(); - var availableItems = new Array(); - var firstURL = false; - - var tableRows = doc.evaluate('//table[@class="browseScreen"]//tr[@class="browseEntry" or @class="briefCitRow" or td/input[@type="checkbox"] or td[contains(@class,"briefCitRow")]]', - doc, nsResolver, XPathResult.ANY_TYPE, null); - // Go through table rows - var i = 0; - while(tableRow = tableRows.iterateNext()) { - // get link - var links = doc.evaluate('.//span[@class="briefcitTitle"]/a', tableRow, nsResolver, XPathResult.ANY_TYPE, null); - var link = links.iterateNext(); - if(!link) { - var links = doc.evaluate(".//a", tableRow, nsResolver, XPathResult.ANY_TYPE, null); - link = links.iterateNext(); - } - - if(link) { - if(availableItems[link.href]) { - continue; - } - - - // Go through links - while(link) { - if (link.textContent.match(/\w+/)) availableItems[link.href] = link.textContent; - link = links.iterateNext(); - } - i++; - } - }; - - var items = Zotero.selectItems(availableItems); - - if(!items) { - return true; - } - - var newUrls = new Array(); - for(var url in items) { - newUrls.push(url.replace("frameset", "marc")); - } - pageByPage(marc, newUrls); - } - - Zotero.wait(); -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://books.luther.edu/record=b2115431~S9", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "G. W", - "lastName": "Kimura", - "creatorType": "contributor" - }, - { - "lastName": "ebrary, Inc", - "fieldMode": true - } - ], - "notes": [], - "tags": [ - "Alaska", - "History", - "Alaska", - "Anniversaries, etc", - "Alaska", - "Social conditions", - "Alaska", - "Economic conditions", - "Electronic books" - ], - "seeAlso": [], - "attachments": [], - "title": "Alaska at 50 the past, present, and next fifty years of statehood", - "place": "Fairbanks", - "publisher": "University of Alaska Press", - "date": "2009", - "numPages": "285", - "callNumber": "F904 .A477 2009eb", - "libraryCatalog": "books.luther.edu Library Catalog" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Library Catalog (SIRSI).js b/translators/Library Catalog (SIRSI).js @@ -1,376 +0,0 @@ -{ - "translatorID": "add7c71c-21f3-ee14-d188-caf9da12728b", - "label": "Library Catalog (SIRSI)", - "creator": "Sean Takats, Hicham El Kasmi", - "target": "/uhtbin/(?:cgisirsi|quick_keyword)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-25 13:01:08" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - var xpath = '//tr[th[@class="viewmarctags"]][td[@class="viewmarctags"]]'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI detectWeb: viewmarctags"); - return "book"; - } - var xpath = '//input[@name="VOPTIONS"]'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI detectWeb: VOPTIONS"); - return "book"; - } - var elmts = doc.evaluate('/html/body/form//text()', doc, nsResolver, - XPathResult.ANY_TYPE, null); - while(elmt = elmts.iterateNext()) { - if(Zotero.Utilities.superCleanString(elmt.nodeValue) == "Viewing record") { - Zotero.debug("SIRSI detectWeb: Viewing record"); - return "book"; - } - } - - var xpath = '//td[@class="searchsum"]/table'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI detectWeb: searchsum"); - return "multiple"; - } - var xpath = '//form[@name="hitlist"]/table/tbody/tr'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI detectWeb: hitlist"); - return "multiple"; - } -} - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//tr[th[@class="viewmarctags"]][td[@class="viewmarctags"]]'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - if(!elmt) { - return false; - } - - var newItem = new Zotero.Item("book"); - newItem.extra = ""; - - authors = []; - while(elmt) { - try { - var node = doc.evaluate('./TD[1]/A[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(!node) { - var node = doc.evaluate('./TD[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - } - - if(node) { - var casedField = Zotero.Utilities.superCleanString(doc.evaluate('./TH[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - field = casedField.toLowerCase(); - field = field.replace(/:./,""); - var value = Zotero.Utilities.superCleanString(node.nodeValue); - if(field == "publisher" || field == "éditeur" ) { - newItem.publisher = value; - } else if(field == "physical descrip" || field == "description physique" ) { - newItem.physicaldescription = value; - } else if(field == "pub date" || field == "année") { - var re = /[0-9]+/; - var m = re.exec(value); - newItem.date = m[0]; - } else if(field == "isbn") { - var re = /^[0-9](?:[0-9X]+)/; - var m = re.exec(value); - newItem.ISBN = m[0]; - } else if(field == "issn") { - newItem.ISSN = value; - } else if(field == "title" || field == "titre") { - var titleParts = value.split(" / "); - newItem.title = Zotero.Utilities.capitalizeTitle(titleParts[0]); - } else if(field == "series title" || field == "titre de série" || field == "collection") { - newItem.seriestitle = value.substr(1, value.length-2); - } else if(field == "publication info" || field == "publication") { - var pubParts = value.split(" : "); - newItem.place = pubParts[0]; - if (pubParts[1].match(/\d+/)) { - newItem.date = pubParts[1].match(/\d+/)[0]; - newItem.publisher = pubParts[1].match(/(.*),/)[1]; - } - } else if(field == "personal author" || field == "autor personal" || field == "auteur") { - if(authors.indexOf(value) == -1) { - value = value.replace(/(\(|\)|\d+|\-)/g, ""); - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); - authors.push(value); - } - } else if(field == "author" || field == "auteur"){ - if(authors.indexOf(value) == -1) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); - authors.push(value); - } - } else if(field == "added author" || field == "organisme") { - if(authors.indexOf(value) == -1) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "contributor", true)); - authors.push(value); - } - } else if(field == "corporate author") { - if(authors.indexOf(value) == -1) { - newItem.creators.push({lastName:value, fieldMode:true}); - authors.push(value); - } - } else if(field == "general note" || field == "note") { - newItem.generalnote = value; - } else if(field == "edition" || field == "édition") { - newItem.edition = value; - } else if(field == "additional formats" || field == "autres supports") { - newItem.additionalformats = value; - } else if(field == "continued by" || field == "devient") { - newItem.continuedby = value; - } else if(field == "subject term" || field == "corporate subject" || field == "geographic term" || field == "subject" || field == "sujet" || field == "sujet géographique") { - var subjects = value.split("--"); - for(var i=0; i<subjects.length; i++) { - if(newItem.tags.indexOf(subjects[i]) == -1) { - newItem.tags.push(subjects[i]); - } - } - } else if(field == "personal subject" || field == " personne sujet") { - var subjects = value.split(", "); - var tag = value[0]+", "+value[1]; - if(newItems.tag.indexOf(tag) == -1) { - newItem.tags.push(tag); - } - } else if(field == "contents" || field == "contient") { - var contents = value.split("--"); - for(var i=0; i<contents.length; i++) { - if(newItem.tags.indexOf(contents[i]) == -1) { - newItem.tags.push(contents[i]); - } - } - } else if(value && field != "http") { - newItem.extra += casedField+": "+value+"\n"; - } - } - } catch (e) {} - - elmt = elmts.iterateNext(); - } - - if(newItem.extra) { - newItem.extra = newItem.extra.substr(0, newItem.extra.length-1); - } - - var callNumber = doc.evaluate('//tr/td[1][@class="holdingslist"]/text()', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(callNumber && callNumber.nodeValue) { - newItem.callNumber = callNumber.nodeValue.trim(); - } - - // UVA has the call number separately, in the next field - // http://virgo.lib.virginia.edu - callNumber = doc.evaluate('//tr/td[2][@class="holdingslist"]/text()', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - // The regex here is looking for something like an LOC call number - if(callNumber && callNumber.nodeValue.trim().match(/^[A-Z]{1,2}[0-9]+/)) { - newItem.callNumber += " " + callNumber.nodeValue.trim(); - } - - var domain = doc.location.href.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - return true; -} - -function doWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var sirsiNew = true; //toggle between SIRSI -2003 and SIRSI 2003+ - var xpath = '//td[@class="searchsum"]/table'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: searchsum"); - sirsiNew = true; - } else if (doc.evaluate('//form[@name="hitlist"]/table/tbody/tr', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: hitlist"); - sirsiNew = false; - } else if (doc.evaluate('//tr[th[@class="viewmarctags"]][td[@class="viewmarctags"]]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: viewmarctags"); - sirsiNew = true; - } else if (doc.evaluate('//input[@name="VOPTIONS"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: VOPTIONS"); - sirsiNew = false; - } else { - var elmts = doc.evaluate('/html/body/form//text()', doc, nsResolver, - XPathResult.ANY_TYPE, null); - while(elmt = elmts.iterateNext()) { - if(Zotero.Utilities.superCleanString(elmt.nodeValue) == "Viewing record") { - Zotero.debug("SIRSI doWeb: Viewing record"); - sirsiNew = false; - } - } - } - - if (sirsiNew) { //executes Simon's SIRSI 2003+ scraper code - Zotero.debug("Running SIRSI 2003+ code"); - if(!scrape(doc)) { - - var checkboxes = new Array(); - var urls = new Array(); - var availableItems = new Array(); - //begin IUCAT fixes by Andrew Smith - var iuRe = /^https?:\/\/www\.iucat\.iu\.edu/; - var iu = iuRe.exec(url); - //IUCAT fix 1 of 2 - if (iu){ - var tableRows = doc.evaluate('//td[@class="searchsum"]/table[//input[@class="submitLink"]]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } else{ - var tableRows = doc.evaluate('//td[@class="searchsum"]/table[//input[@value="Details"]]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - var tableRow = tableRows.iterateNext(); // skip first row - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - //IUCAT fix 2 of 2 - if (iu){ - var input = doc.evaluate('.//input[@class="submitLink"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var text = doc.evaluate('.//label/span', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - var input = doc.evaluate('.//input[@value="Details"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var text = doc.evaluate('.//label/strong', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - //end IUCAT fixes by Andrew Smith - if(text) { - availableItems[input.name] = text; - } - } - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - var hostRe = new RegExp("^http(?:s)?://[^/]+"); - var m = hostRe.exec(doc.location.href); - Zotero.debug("href: " + doc.location.href); - var hitlist = doc.forms.namedItem("hitlist"); - var baseUrl = m[0]+hitlist.getAttribute("action")+"?first_hit="+hitlist.elements.namedItem("first_hit").value+"&last_hit="+hitlist.elements.namedItem("last_hit").value; - var uris = new Array(); - for(var i in items) { - uris.push(baseUrl+"&"+i+"=Details"); - } - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc); }, - function() { Zotero.done(); }, null); - Zotero.wait(); - } - } else{ //executes Simon's SIRSI -2003 translator code - Zotero.debug("Running SIRSI -2003 code"); - var uri = doc.location.href; - var recNumbers = new Array(); - var xpath = '//form[@name="hitlist"]/table/tbody/tr'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - if(elmt) { // Search results page - var uriRegexp = /^http:\/\/[^\/]+/; - var m = uriRegexp.exec(uri); - var postAction = doc.forms.namedItem("hitlist").getAttribute("action"); - var newUri = m[0]+postAction.substr(0, postAction.length-1)+"40"; - var titleRe = /<br>\s*(.*[^\s])\s*<br>/i; - var items = new Array(); - do { - var checkbox = doc.evaluate('.//input[@type="checkbox"]', elmt, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - // Collect title - var title = doc.evaluate("./td[2]", elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if(checkbox && title) { - items[checkbox.name] = Zotero.Utilities.trimInternal(title); - } - } while(elmt = elmts.iterateNext()); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - for(var i in items) { - recNumbers.push(i); - } - } else { // Normal page - // this regex will fail about 1/100,000,000 tries - var uriRegexp = /^((.*?)\/([0-9]+?))\//; - var m = uriRegexp.exec(uri); - var newUri = m[1]+"/40"; - - var elmts = doc.evaluate('/html/body/form', doc, nsResolver, - XPathResult.ANY_TYPE, null); - while(elmt = elmts.iterateNext()) { - var initialText = doc.evaluate('.//text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(initialText && initialText.nodeValue && Zotero.Utilities.superCleanString(initialText.nodeValue) == "Viewing record") { - recNumbers.push(doc.evaluate('./b[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - break; - } - } - // begin Emory compatibility - var elmts = doc.evaluate('//input[@name="first_hit"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - while (elmt = elmts.iterateNext()) { - recNumbers.length = 0; - var recNumber = elmt.value; - recNumbers.push(recNumber); - break; - } - // end Emory compatibility - } - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.loadDocument(newUri+'?marks='+recNumbers.join(",")+'&shadow=NO&format=FLAT+ASCII&sort=TITLE&vopt_elst=ALL&library=ALL&display_rule=ASCENDING&duedate_code=l&holdcount_code=t&DOWNLOAD_x=22&DOWNLOAD_y=12&address=&form_type=', function(doc) { - var pre = doc.getElementsByTagName("pre"); - var text = pre[0].textContent; - var documents = text.split("*** DOCUMENT BOUNDARY ***"); - for(var j=1; j<documents.length; j++) { - var uri = newUri+"?marks="+recNumbers[j]+"&shadow=NO&format=FLAT+ASCII&sort=TITLE&vopt_elst=ALL&library=ALL&display_rule=ASCENDING&duedate_code=l&holdcount_code=t&DOWNLOAD_x=22&DOWNLOAD_y=12&address=&form_type="; - var lines = documents[j].split("\n"); - var record = new marc.record(); - var tag, content; - var ind = ""; - for(var i=0; i<lines.length; i++) { - var line = lines[i]; - if(line[0] == "." && line.substr(4,2) == ". ") { - if(tag) { - content = content.replace(/\|([a-z])/g, marc.subfieldDelimiter+"$1"); - record.addField(tag, ind, content); - } - } else { - content += " "+line.substr(6); - continue; - } - tag = line.substr(1, 3); - if(tag[0] != "0" || tag[1] != "0") { - ind = line.substr(6, 2); - content = line.substr(8); - } else { - content = line.substr(7); - if(tag == "000") { - tag = undefined; - record.leader = "00000"+content; - Zotero.debug("the leader is: "+record.leader); - } - } - } - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - } - Zotero.done(); - }); - Zotero.wait(); - } -} diff --git a/translators/Library Catalog (TLCYouSeeMore).js b/translators/Library Catalog (TLCYouSeeMore).js @@ -1,106 +0,0 @@ -{ - "translatorID": "0f9fc2fc-306e-5204-1117-25bca009dffc", - "label": "Library Catalog (TLC/YouSeeMore)", - "creator": "Simon Kornblith", - "target": "TLCScripts/interpac\\.dll\\?(?:.*LabelDisplay.*RecordNumber=[0-9]|Search|ItemTitles)", - "minVersion": "1.0.0b3.r1", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-11 08:58:37" -} - -function detectWeb(doc, url) { - var detailRe = new RegExp("TLCScripts/interpac\.dll\?.*LabelDisplay.*RecordNumber=[0-9]"); - if(detailRe.test(doc.location.href)) { - return "book"; - } else { - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var detailRe = new RegExp("TLCScripts/interpac\.dll\?.*LabelDisplay.*RecordNumber=[0-9]"); - var uri = doc.location.href; - var newUris = new Array(); - - if(detailRe.test(uri)) { - newUris.push(uri.replace("LabelDisplay", "MARCDisplay")); - } else { - var items = Zotero.Utilities.getItemArray(doc, doc, 'TLCScripts/interpac\.dll\?.*LabelDisplay.*RecordNumber=[0-9]'); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - for(var i in items) { - newUris.push(i.replace("LabelDisplay", "MARCDisplay")); - } - } - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - - Zotero.Utilities.processDocuments(newUris, function(newDoc) { - var uri = newDoc.location.href; - - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var record = new marc.record(); - - var elmts = newDoc.evaluate('/html/body/table/tbody/tr[td[4]]', newDoc, nsResolver, - XPathResult.ANY_TYPE, null); - var tag, ind, content, elmt; - - while(elmt = elmts.iterateNext()) { - tag = newDoc.evaluate('./td[2]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var inds = newDoc.evaluate('./td[3]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - tag = tag.replace(/[\r\n]/g, ""); - inds = inds.replace(/[\r\n\xA0]/g, ""); - - var children = newDoc.evaluate('./td[4]//text()', elmt, nsResolver, - XPathResult.ANY_TYPE, null); - var subfield = children.iterateNext(); - var fieldContent = children.iterateNext(); - - if(tag == "LDR") { - record.leader = "00000"+subfield.nodeValue; - } else { - content = ""; - if(!fieldContent) { - content = subfield.nodeValue; - } else { - while(subfield && fieldContent) { - content += marc.subfieldDelimiter+subfield.nodeValue.substr(1, 1)+fieldContent.nodeValue; - var subfield = children.iterateNext(); - var fieldContent = children.iterateNext(); - } - } - - record.addField(tag, inds, content); - } - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - }, function() {Zotero.done(); }, null); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Library Catalog (VTLS).js b/translators/Library Catalog (VTLS).js @@ -1,136 +0,0 @@ -{ - "translatorID":"63a0a351-3131-18f4-21aa-f46b9ac51d87", - "translatorType":4, - "label":"Library Catalog (VTLS)", - "creator":"Simon Kornblith", - "target":"/chameleon(?:\\?|$)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var node = doc.evaluate('//tr[@class="intrRow"]/td/table/tbody/tr[th]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if(node) { - return "multiple"; - } - var node = doc.evaluate('//a[text()="marc"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if(node) { - return "book"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var uri = doc.location.href; - var newUris = new Array(); - - var marcs = doc.evaluate('//a[text()="marc"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var record = marcs.iterateNext(); - - if(record && !marcs.iterateNext()) { - newUris.push(record.href); - } else { - // Require link to match this - var tagRegexp = new RegExp(); - tagRegexp.compile("/chameleon\?.*function=CARDSCR"); - - var items = new Array(); - - var tableRows = doc.evaluate('//tr[@class="intrRow"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var tableRow; - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - var links = tableRow.getElementsByTagName("a"); - // Go through links - var url; - for(var j=0; j<links.length; j++) { - if(tagRegexp.test(links[j].href)) { - url = links[j].href; - break; - } - } - if(url) { - // Collect title information - var fields = doc.evaluate('./td/table/tbody/tr[th]', tableRow, - nsResolver, XPathResult.ANY_TYPE, null); - var field; - while(field = fields.iterateNext()) { - var header = doc.evaluate('./th/text()', field, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - if(header.nodeValue == "Title") { - var value = doc.evaluate('./td', field, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - if(value) { - items[url] = Zotero.Utilities.trimInternal(value.textContent); - } - } - } - } - } - - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - for(var i in items) { - Zotero.debug(i.replace(/function=[A-Z]{7}/, "function=MARCSCR")); - newUris.push(i.replace(/function=[A-Z]{7}/, "function=MARCSCR")); - } - } - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - - Zotero.Utilities.processDocuments(newUris, function(newDoc) { - var uri = newDoc.location.href - - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var record = new marc.record(); - -// var xpath = '//table[@class="outertable"]/tbody/tr[td[4]]'; //old xpath -// xpaths from virginia college of osteopathic medicine -// /html/body/table[@class="header2"]/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td/table[@class="marctable"]/tbody/tr/td[1][@class="marcTag"] -// /html/body/table[@class="header2"]/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td/table[@class="marctable"]/tbody/tr/td[2] -// /html/body/table[@class="header2"]/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td/table[@class="marctable"]/tbody/tr/td[3] -// /html/body/table[@class="header2"]/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr/td/table[@class="marctable"]/tbody/tr/td[4][@class="marcSubfields"] - var xpath = '//table[@class="marctable"]/tbody/tr[td[4]]'; - var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, - XPathResult.ANY_TYPE, null); - - while(elmt = elmts.iterateNext()) { - var field = newDoc.evaluate('./TD[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var ind1 = newDoc.evaluate('./TD[2]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var ind2 = newDoc.evaluate('./TD[3]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var value = newDoc.evaluate('./TD[4]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - value = value.replace(/\\([a-z]) /g, marc.subfieldDelimiter+"$1"); - - record.addField(field, ind1+ind2, value); - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - }, function(){ Zotero.done(); }, null); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Library Catalog (Voyager 7).js b/translators/Library Catalog (Voyager 7).js @@ -1,82 +0,0 @@ -{ - "translatorID":"a81243b5-a9fd-4921-8441-3142a518fdb7", - "translatorType":4, - "label":"Library Catalog (Voyager 7)", - "creator":"Sean Takats", - "target":"/vwebv/(holdingsInfo|search)", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-02-12 19:11:09" -} - -function detectWeb(doc, url){ - var bibIdRe = new RegExp("bibId=[0-9]+"); - if (bibIdRe.test(url)){ - return "book"; - } - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var titles = doc.evaluate('//div[@class="resultListTextCell"]//a', doc, nsResolver, XPathResult.ANY_TYPE, null); - if (titles.iterateNext()){ - return "multiple"; - } -} - -function doWeb(doc, url){ - var bibIdRe = new RegExp("bibId=([0-9]+)"); - var m = bibIdRe.exec(url); - var hostRegexp = new RegExp("^(https?://[^/]+)/"); - var hMatch = hostRegexp.exec(url); - var host = hMatch[1]; - - var urlPrefix = url.match("https?://[^/]*(/[^/]*/)?/?vwebv/")[1] ? host + url.match("https?://[^/]*(/[^/]*/)?/?vwebv/")[1] + "/vwebv/exportRecord.do?bibId=" : host + "/vwebv/exportRecord.do?bibId="; - - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newUris = new Array(); - - if (m){ //single item - newUris.push(urlPrefix + m[1] + "&format=utf-8"); - } - else { //search results - var items = new Object(); - var titles = doc.evaluate('//div[@class="resultListTextCell"]//a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - - while (title = titles.iterateNext()) { - var bibId = title.href.match(/bibId=([0-9]+)/)[1]; - items[bibId] = title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - newUris.push(urlPrefix + i + "&format=utf-8"); - } - } - - Zotero.Utilities.HTTP.doGet(newUris, function(text) { - // load translator for MARC - var marc = Zotero.loadTranslator("import"); - marc.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - marc.setString(text); - - var domain = url.match(/https?:\/\/([^/]+)/); - marc.setHandler("itemDone", function(obj, item) { - item.repository = domain[1]+" Library Catalog"; - item.complete(); - }); - - marc.translate(); - }, function() { Zotero.done() }) - - Zotero.wait(); -} diff --git a/translators/Library Catalog (Voyager).js b/translators/Library Catalog (Voyager).js @@ -1,260 +0,0 @@ -{ - "translatorID": "88915634-1af6-c134-0171-56fd198235ed", - "label": "Library Catalog (Voyager)", - "creator": "Simon Kornblith", - "target": "Pwebrecon\\.cgi", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-04 13:09:56" -} - -function detectWeb(doc, url) { - var export_options = ZU.xpath(doc, '//form[@name="frm"]//*[@name="RD"]'); - if(!export_options.length) return false; - export_options = export_options[0]; - - for(var i in export_options) { - if(export_options[i].text == 'Latin1 MARC' - || export_options[i].text == 'Raw MARC' - || export_options[i].text == 'MARC 8' - || export_options[i].text == 'MARC-8' - || export_options[i].text == 'UTF-8' - || export_options[i].text == 'MARC (Unicode/UTF-8)' - || export_options[i].text == 'MARC UTF-8' - || export_options[i].text == 'UTF-8 MARC (Unicode)' - || export_options[i].text == 'UTF8-Unicode' - || export_options[i].text == 'MARC (non-Unicode/MARC-8)' - || export_options[i].text == 'MARC communication format' - || export_options[i].text == 'MARC Record') { - // We have an exportable single record - if(ZU.xpath(doc, '//form[@name="frm"]//*[@name="RC"]').length) { - return "multiple"; - } else { - return "book"; - } - } - } -} - -function doWeb(doc, url) { - var postString = ''; - var form = ZU.xpath(doc, '//form[@name="frm"]')[0]; - var newUri = form.action; - var multiple = false; - - if(ZU.xpath(form, '//*[@name="RC"]').length) { - multiple = true; - - var availableItems = new Object(); // Technically, associative arrays are objects - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // Require link to match this - var tagRegexp = new RegExp(); - tagRegexp.compile('Pwebrecon\\.cgi\\?.*v1=[0-9]+\\&.*ti='); - // Do not allow text to match this - var rejectRegexp = new RegExp(); - rejectRegexp.compile('\[ [0-9]+ \]'); - - var checkboxes = new Array(); - var urls = new Array(); - - var tableRows = doc.evaluate('//form[@name="frm"]//table/tbody/tr[td/input[@type="checkbox" or @type="CHECKBOX"]]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - // Go through table rows - var tableRow; - var i = 0; - while(tableRow = tableRows.iterateNext()) { - i++; - // CHK is what we need to get it all as one file - var input = doc.evaluate('./td/input[@name="CHK"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - checkboxes[i] = input.value; - var links = tableRow.getElementsByTagName("a"); - // Go through links - for(var j=0; j<links.length; j++) { - if(tagRegexp.test(links[j].href)) { - var text = links[j].textContent; - if(text) { - text = Zotero.Utilities.trimInternal(text); - if(!rejectRegexp.test(text)) { - if(availableItems[i]) { - availableItems[i] += " "+text; - } else { - availableItems[i] = text; - } - } - } - } - } - // if no title, pull from second td - if(!availableItems[i]) { - availableItems[i] = Zotero.Utilities.trimInternal(doc.evaluate('./td[2]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - } - - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - - // add arguments for items we need to grab - for(var i in items) { - postString += "CHK="+checkboxes[i]+"&"; - } - } - - var raw, unicode, latin1; - - for(var i=0; i<form.elements.length; i++) { - if(form.elements[i].type && form.elements[i].type.toLowerCase() == 'hidden') { - postString += escape(form.elements[i].name)+'='+escape(form.elements[i].value)+'&'; - } - } - - var export_options = ZU.xpath(form, '//select[@name="RD"]/option'); - for(var i=0; i<export_options.length; i++) { - if(export_options[i].text == 'Raw MARC' - || export_options[i].text == 'MARC 8' - || export_options[i].text == 'MARC-8' - || export_options[i].text == 'MARC (non-Unicode/MARC-8)') { - raw = i; - } if(export_options[i].text == 'Latin1 MARC') { - latin1 = i; - } else if(export_options[i].text == 'UTF-8' - || export_options[i].text == 'UTF-8 MARC (Unicode)' - || export_options[i].text == 'UTF8-Unicode' - || export_options[i].text == 'MARC UTF-8' - || export_options[i].text == 'MARC (Unicode/UTF-8)' - || export_options[i].text == 'MARC communication format' - || export_options[i].text == 'MARC Record') { - unicode = i; - } - } - - var responseCharset = null; - - if(unicode) { - var rd = unicode; - responseCharset = 'UTF-8'; - } else if(latin1) { - var rd = latin1; - responseCharset = 'ISO-8859-1'; - } else if(raw) { - var rd = raw; - } else { - return false; - } - - postString += 'RD='+rd+'&MAILADDY=&SAVE=Press+to+SAVE+or+PRINT'; - - // No idea why this doesn't work as post - Zotero.Utilities.HTTP.doGet(newUri+'?'+postString, function(text) { - // load translator for MARC - var marc = Zotero.loadTranslator("import"); - marc.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - marc.setString(text); - - // if this is the LOC catalog, specify that in repository field - if(url.length > 23 && url.substr(0, 23) == "http://catalog.loc.gov/") { - marc.setHandler("itemDone", function(obj, item) { - item.repository = "Library of Congress Catalog"; - item.complete(); - }); - } else { - var domain = url.match(/https?:\/\/([^/]+)/); - marc.setHandler("itemDone", function(obj, item) { - item.repository = domain[1]+" Library Catalog"; - item.complete(); - }); - } - - marc.translate(); - - Zotero.done(); - }, null, responseCharset); - Zotero.wait(); -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?DB=local&Search_Arg=zotero&Search_Code=GKEY^*&CNT=100&hist=1&type=quick", - "items": "multiple" - }, - { - "type": "web", - "url": "https://i-share.carli.illinois.edu/nby/cgi-bin/Pwebrecon.cgi?DB=local&v1=1&BBRecID=790862", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Francisco", - "lastName": "Xarque", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Masseta, Simon", - "Cuellar y Mosquera, Gabriel de", - "Missions", - "Paraguay" - ], - "seeAlso": [], - "attachments": [], - "title": "Insignes missioneros de la Compañia de Jesus en la prouincia del Paraguay: estado presente de sus missiones en Tucuman, Paraguay, y Rio de la Plata, que comprehende su distrito", - "place": "En Pamplona", - "publisher": "Por Juan Micòn, Impressor", - "date": "1687", - "numPages": "24", - "callNumber": "F2681 .X3", - "libraryCatalog": "i-share.carli.illinois.edu Library Catalog", - "shortTitle": "Insignes missioneros de la Compañia de Jesus en la prouincia del Paraguay" - } - ] - }, - { - "type": "web", - "url": "http://catalog.loc.gov/cgi-bin/Pwebrecon.cgi?v1=1&ti=1,1&Search%5FArg=zotero&Search%5FCode=GKEY%5E%2A&CNT=100&type=quick&PID=UiW_ZKCUShsRhZ5pIpsx_-5hND3W&SEQ=20110704130645&SID=1", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Jason", - "lastName": "Puckett", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Zotero", - "Bibliographical citations", - "Computer programs", - "Citation of electronic information resources", - "Computer programs" - ], - "seeAlso": [], - "attachments": [], - "ISBN": "9780838985892", - "title": "Zotero: a guide for librarians, researchers, and educators", - "place": "Chicago", - "publisher": "Association of College and Research Libraries", - "date": "2011", - "callNumber": "PN171.F56 P83 2011", - "libraryCatalog": "Library of Congress Catalog", - "shortTitle": "Zotero" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Library Catalog (X-OPAC).js b/translators/Library Catalog (X-OPAC).js @@ -1,53 +0,0 @@ -{ - "translatorID":"f880bf79-d42f-4337-b0d2-7a7de4a48b7d", - "translatorType":4, - "label":"Library Catalog (X-OPAC)", - "creator":"Michael Berkowitz", - "target":"(xopac|hylib)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-02-06 21:00:00" -} - -function detectWeb(doc, url) { - if (url.indexOf("&nd=") != -1) { - return "book"; - } else if (url.indexOf("Aktion") != -1) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var ids = new Array(); - if (detectWeb(doc, url) == "multiple") { - var xpath = '//table/tbody/tr/td//a'; - var links = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var link = links.iterateNext(); - var items = new Object(); - while (link) { - if (link.href.match(/&nd=\d+/)) { - items[link.href.match(/&nd=(\d+)/)[1]] = Zotero.Utilities.trimInternal(link.textContent); - } - link = links.iterateNext(); - } - items = Zotero.selectItems(items); - for (var i in items) { - ids.push(i); - } - } else { - ids = [url.match(/&nd=(\d+)/)[1]]; - } - Zotero.debug(ids); - for (var i = 0 ; i < ids.length ; i++) { - var post = 'db=ubfr&nd=' + ids[i] + '&counter=0&Aktion=S&VomOLAF=0&links=1&gk=&format=ris'; - Zotero.Utilities.HTTP.doPost('http://www.ub.uni-freiburg.de/cgi-bin/refman', post, function(text) { - //Zotero.debug(text); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - }); - } -} -\ No newline at end of file diff --git a/translators/LiveJournal.js b/translators/LiveJournal.js @@ -1,544 +0,0 @@ -{ - "translatorID": "d49e3a67-e2c1-4217-825c-2b22cffd332a", - "label": "LiveJournal", - "creator": "Avram Lyon", - "target": "^https?://.*\\.livejournal\\.com/(?:$|[0-9]+\\.html)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport":"gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-19 21:11:50" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - - - - - - -/** - Copyright (c) 2011, 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 - <http://www.gnu.org/licenses/>. -*/ - -/* There are at least 4 major page structures on LJ, represented - by the scrapers and tests specified below. Additional structures - may need additional logic. */ - -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Url().match(/livejournal\.com\/?$/), -choices : { - titles : FW.Xpath('//a[@class="subj-link"]').text(), - urls : FW.Xpath('//a[@class="subj-link"]').key("href") -} -}); - -// http://kurgus.livejournal.com -FW.Scraper({ -itemType : "blogPost", -detect : FW.Xpath('//dt[@class="entry-title"]/text()[1]'), -title : FW.Xpath('//dt[@class="entry-title"]/text()[1]').text(), -date : FW.Xpath('//dt[@class="entry-title"]/following-sibling::dd[1]/dl/dd[@class="entry-date"]/abbr') - .key("title").remove(/T.*$/), -attachments : [{ url: FW.Url(), - title: "LiveJournal Snapshot", - type: "text/html" }], -creators : FW.Xpath('//dt[@class="entry-title"]/following-sibling::dd[1]/dl/dd[@class="username"]/span/a/b').text().cleanAuthor("author"), -blogTitle : FW.Xpath('//h2/span').text(), -tags : FW.Xpath('//div[@class="ljtags"]/a').text() -}); - -// http://ulr.livejournal.com -FW.Scraper({ -itemType : "blogPost", -detect : FW.Xpath('//div[@class="asset-header-content-inner"]'), -title : FW.Xpath('//div[@class="asset-header-content-inner"]/h2/a').text(), -date : FW.Xpath('//div[@class="asset-header-content-inner"]/div[@class="asset-meta"]//abbr') - .text().remove(/at.*$/), -attachments : [{ url: FW.Url(), - title: "LiveJournal Snapshot", - type: "text/html" }], -creators : FW.Xpath('//dd[@class="profile-username item"]/span[@class="ljuser ljuser-name_"]/a/b').text().cleanAuthor("author"), -blogTitle : FW.Xpath('//div[@id="header-name"]/a').text() -}); - -// http://shlyahtich.livejournal.com/ (Lanzelot design) -FW.Scraper({ -itemType : "blogPost", -detect : FW.Xpath('//table[@class="lanzelot-content"]'), -title : FW.Xpath('//div[@id="content-wrapper"]/div/font/i').text(), -date : FW.Xpath('//div[@id="content-wrapper"]/table//td[last()]') - .text().trimInternal().remove(/^.*@/), -attachments : [{ url: FW.Url(), - title: "LiveJournal Snapshot", - type: "text/html" }], -creators : FW.Xpath('//div[@id="content-wrapper"]/table//span[@class="ljuser ljuser-name_"]/preceding-sibling::text()').text().remove(/\(\s*$/).cleanAuthor("author"), -blogTitle : FW.Xpath('/html/head/title').text().remove(/:.*$/) -}); - - -// http://irek-murtazin.livejournal.com -FW.Scraper({ -itemType : "blogPost", -detect : FW.Xpath('//table[@class="entrybox"]//table[1]//td[@class="caption"]'), -title : FW.Xpath('//table[@class="entrybox"]//table[1]//td[@class="caption"]').text(), -date : FW.Xpath('//table[@class="entrybox"]//table[1]//td[@class="index"]') - .text().replace(/\[(.*)\|.*\]/, '$1'), -attachments : [{ url: FW.Url(), - title: "LiveJournal Snapshot", - type: "text/html" }], -creators : FW.Xpath('//form[@class="w-cs-search"]/input[@name="journal"]').key("value").cleanAuthor("author"), -blogTitle : FW.Xpath('//table[@id="topbox"]//div[@align="center"]').text() -}); - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://irek-murtazin.livejournal.com/487966.html", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "irek_murtazin", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://irek-murtazin.livejournal.com/487966.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://irek-murtazin.livejournal.com/487966.html", - "blogTitle": "Ирек Муртазин", - "date": "Jun. 12th, 2011", - "title": "12 июня 1991 года", - "libraryCatalog": "LiveJournal", - "accessDate": "CURRENT_TIMESTAMP", - "checkFields": "title" - } - ] - }, - { - "type": "web", - "url": "http://kurgus.livejournal.com/60523.html", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "apple", - "safari", - "zotero", - "Библиотеки" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/60523.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/60523.html", - "blogTitle": "kurgus", - "date": "2011-06-14", - "title": "Zotero, Mac, пожелания и разочарания", - "libraryCatalog": "LiveJournal", - "accessDate": "CURRENT_TIMESTAMP", - "checkFields": "title" - } - ] - }, - { - "type": "web", - "url": "http://ulr.livejournal.com/164941.html", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "ulr", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://ulr.livejournal.com/164941.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://ulr.livejournal.com/164941.html", - "blogTitle": "Лариса", - "date": "May. 18th, 2011 ", - "title": "Двойной праздник", - "libraryCatalog": "LiveJournal", - "accessDate": "CURRENT_TIMESTAMP", - "checkFields": "title" - } - ] - }, - { - "type": "web", - "url": "http://kurgus.livejournal.com/", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "apple", - "safari", - "zotero", - "Библиотеки" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/60523.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/60523.html", - "blogTitle": "kurgus", - "date": "2011-06-14", - "title": "Zotero, Mac, пожелания и разочарания", - "libraryCatalog": "LiveJournal" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/60348.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/60348.html", - "blogTitle": "kurgus", - "date": "2011-05-27", - "title": "Рейтинг-механизм в en.wikipedia", - "libraryCatalog": "LiveJournal" - }, - - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Обскурантизм", - "Разгильдяйство" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/60049.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/60049.html", - "blogTitle": "kurgus", - "date": "2011-05-26", - "title": "Многоклеточный шовинизм", - "libraryCatalog": "LiveJournal" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Жизнь", - "Природа" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/59586.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/59586.html", - "blogTitle": "kurgus", - "date": "2011-05-23", - "title": "Погладь сосну!", - "libraryCatalog": "LiveJournal" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Наука", - "Обскурантизм", - "Этнография современности" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/59247.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/59247.html", - "blogTitle": "kurgus", - "date": "2011-05-22", - "title": "О псевдонауке, \"точках зрения\" и прочем", - "libraryCatalog": "LiveJournal" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Жизнь", - "Наука" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/59082.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/59082.html", - "blogTitle": "kurgus", - "date": "2011-05-21", - "title": "Украинский фестиваль науки: облом в ИТФ", - "libraryCatalog": "LiveJournal", - "shortTitle": "Украинский фестиваль науки" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Википедия", - "Химия", - "Этнография современности" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/58859.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/58859.html", - "blogTitle": "kurgus", - "date": "2011-05-17", - "title": "Похвала японцам или о без(д)умии европеоидов.", - "libraryCatalog": "LiveJournal" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Википедия", - "Национал-лингвистика" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/58369.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/58369.html", - "blogTitle": "kurgus", - "date": "2011-05-16", - "title": "Дефиниционно: сакральные отличия", - "libraryCatalog": "LiveJournal", - "shortTitle": "Дефиниционно" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Криптолитература", - "Литература" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/58242.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/58242.html", - "blogTitle": "kurgus", - "date": "2011-05-11", - "title": "Эзоп и Аристофан", - "libraryCatalog": "LiveJournal" - }, - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "", - "lastName": "kurgus", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Фотоложество" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://kurgus.livejournal.com/58023.html", - "title": "LiveJournal Snapshot", - "type": "text/html" - } - ], - "url": "http://kurgus.livejournal.com/58023.html", - "blogTitle": "kurgus", - "date": "2011-05-10", - "title": "HDR на коленке", - "libraryCatalog": "LiveJournal" - } - ] - }, - { - "type": "web", - "url": "http://shlyahtich.livejournal.com/625326.html", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "Sergey", - "lastName": "Kalenik", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://shlyahtich.livejournal.com/625326.html", - "title": "LiveJournal Snapshot", - "type": "text/html", - "document": "[object]" - } - ], - "url": "http://shlyahtich.livejournal.com/625326.html", - "blogTitle": "shlyahtich", - "date": " 2011-06-14 16:34:00", - "title": "Новая Утиная Правда о Буданове", - "libraryCatalog": "LiveJournal", - "accessDate": "CURRENT_TIMESTAMP", - "checkFields": "title" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/MAB2.js b/translators/MAB2.js @@ -1,359 +0,0 @@ -{ - "translatorID":"91acf493-0de7-4473-8b62-89fd141e6c74", - "translatorType":1, - "label":"MAB2", - "creator":"Simon Kornblith. Adaptions for MAB2: Leon Krauthausen (FUB)", - "target":"mab2", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-06-12 19:00:00" -} - -function detectImport() { - var mab2RecordRegexp = /^[0-9]{3}[a-z ]{2}[a-z ]{3}$/ - var read = Zotero.read(8); - if(mab2RecordRegexp.test(read)) { - return true; - } -} - -var fieldTerminator = "\x1E"; -var recordTerminator = "\x1D"; -var subfieldDelimiter = "\x1F"; - -/* -* CLEANING FUNCTIONS -*/ - -// general purpose cleaning -function clean(value) { - value = value.replace(/^[\s\.\,\/\:;]+/, ''); - value = value.replace(/[\s\.\,\/\:;]+$/, ''); - value = value.replace(/<<+/g, ''); - value = value.replace(/>>+/g, ''); - value = value.replace(/ +/g, ' '); - - var char1 = value[0]; - var char2 = value[value.length-1]; - if((char1 == "[" && char2 == "]") || (char1 == "(" && char2 == ")")) { - // chop of extraneous characters - return value.substr(1, value.length-2); - } - - return value; -} - -function cleanTag(value) { - // Chop off Authority-IDs - value = value.slice(0, value.indexOf('|')); - return value; -} - -// number extraction -function pullNumber(text) { - var pullRe = /[0-9]+/; - var m = pullRe.exec(text); - if(m) { - return m[0]; - } -} - -// ISBN extraction -function pullISBN(text) { - var pullRe = /[0-9X\-]+/; - var m = pullRe.exec(text); - if(m) { - return m[0]; - } -} - -// corporate author extraction -function corpAuthor(author) { - return {lastName:author, fieldMode:true}; -} - -// regular author extraction -function author(author, type, useComma) { - return Zotero.Utilities.cleanAuthor(author, type, useComma); -} - -// MAB2 author extraction -// evaluates subfield $b and sets authType -function authorMab(author, authType, useComma) { - if(!authType) var authType='author'; - authType = authType.replace('[Hrsg.]', 'editor'); - authType = authType.replace('[Mitarb.]', 'contributor'); - authType = authType.replace('[Übers.]', 'translator'); - return Zotero.Utilities.cleanAuthor(author, authType, useComma); -} -/* -* END CLEANING FUNCTIONS -*/ - -var record = function() { - this.directory = new Object(); - this.leader = ""; - this.content = ""; - - // defaults - this.indicatorLength = 2; - this.subfieldCodeLength = 2; -} - -// import a binary MAB2 record into this record -record.prototype.importBinary = function(record) { - // get directory and leader - var directory = record.substr(0, record.indexOf(fieldTerminator)); - this.leader = directory.substr(0, 24); - var directory = directory.substr(24); - - // get various data - this.indicatorLength = parseInt(this.leader[10], 10); - this.subfieldCodeLength = parseInt(this.leader[11], 10); - var baseAddress = parseInt(this.leader.substr(12, 5), 10); - - // get record data - var contentTmp = record.substr(baseAddress); - - // MARC wants one-byte characters, so when we have multi-byte UTF-8 - // sequences, add null characters so that the directory shows up right. we - // can strip the nulls later. - this.content = ""; - for(i=0; i<contentTmp.length; i++) { - this.content += contentTmp[i]; - if(contentTmp.charCodeAt(i) > 0x00FFFF) { - this.content += "\x00\x00\x00"; - } else if(contentTmp.charCodeAt(i) > 0x0007FF) { - this.content += "\x00\x00"; - } else if(contentTmp.charCodeAt(i) > 0x00007F) { - this.content += "\x00"; - } - } - - // read directory - for(var i=0; i<directory.length; i+=12) { - var tag = parseInt(directory.substr(i, 3), 10); - var fieldLength = parseInt(directory.substr(i+3, 4), 10); - var fieldPosition = parseInt(directory.substr(i+7, 5), 10); - - if(!this.directory[tag]) { - this.directory[tag] = new Array(); - } - this.directory[tag].push([fieldPosition, fieldLength]); - } -} - -// add a field to this record -record.prototype.addField = function(field, indicator, value) { - field = parseInt(field, 10); - // make sure indicator is the right length - if(indicator.length > this.indicatorLength) { - indicator = indicator.substr(0, this.indicatorLength); - } else if(indicator.length != this.indicatorLength) { - indicator = Zotero.Utilities.lpad(indicator, " ", this.indicatorLength); - } - - // add terminator - value = indicator+value+fieldTerminator; - - // add field to directory - if(!this.directory[field]) { - this.directory[field] = new Array(); - } - this.directory[field].push([this.content.length, value.length]); - - // add field to record - this.content += value; -} - -// get all fields with a certain field number -record.prototype.getField = function(field) { - field = parseInt(field, 10); - var fields = new Array(); - - // make sure fields exist - if(!this.directory[field]) { - return fields; - } - - // get fields - for(var i in this.directory[field]) { - var location = this.directory[field][i]; - - // add to array, replacing null characters - fields.push([this.content.substr(location[0], this.indicatorLength), - this.content.substr(location[0]+this.indicatorLength, - location[1]-this.indicatorLength-1).replace(/\x00/g, "")]); - } - - return fields; -} - -// get subfields from a field -record.prototype.getFieldSubfields = function(tag) { // returns a two-dimensional array of values - var fields = this.getField(tag); - var returnFields = new Array(); - - for(var i in fields) { - returnFields[i] = new Object(); - - var subfields = fields[i][1].split(subfieldDelimiter); - if (subfields.length == 1) { - returnFields[i]["?"] = fields[i][1]; - } else { - for(var j in subfields) { - if(subfields[j]) { - var subfieldIndex = subfields[j].substr(0, this.subfieldCodeLength-1); - if(!returnFields[i][subfieldIndex]) { - returnFields[i][subfieldIndex] = subfields[j].substr(this.subfieldCodeLength-1); - } - } - } - } - } - - return returnFields; -} - -// add field to DB -record.prototype._associateDBField = function(item, fieldNo, part, fieldName, execMe, arg1, arg2) { - var field = this.getFieldSubfields(fieldNo); - Zotero.debug('MARC: found '+field.length+' matches for '+fieldNo+part); - if(field) { - for(var i in field) { - var value = false; - for(var j=0; j<part.length; j++) { - var myPart = part[j]; - if(field[i][myPart]) { - if(value) { - value += " "+field[i][myPart]; - } else { - value = field[i][myPart]; - } - } - } - if(value) { - value = clean(value); - - if(execMe) { - value = execMe(value, arg1, arg2); - } - - if(fieldName == "creator") { - item.creators.push(value); - } else { - item[fieldName] = value; - return; - } - } - } - } -} - -// add field to DB as tags -record.prototype._associateTags = function(item, fieldNo, part) { - var field = this.getFieldSubfields(fieldNo); - for(var i in field) { - for(var j=0; j<part.length; j++) { - var myPart = part[j]; - if(field[i][myPart]) { - item.tags.push(cleanTag(field[i][myPart])); - } - } - } -} - -// this function loads a MAB2 record into our database -record.prototype.translate = function(item) { - // get item type - if(this.leader) { - var marcType = this.leader[6]; - if(marcType == "g") { - item.itemType = "film"; - } else if(marcType == "k" || marcType == "e" || marcType == "f") { - item.itemType = "artwork"; - } else if(marcType == "t") { - item.itemType = "manuscript"; - } else { - item.itemType = "book"; - } - } else { - item.itemType = "book"; - } - - // Extract MAB2 fields - // FUB Added language, edition, pages, url, edition, series, ISBN, url - for (var i = 100; i <= 196; i++) { - if (this.getFieldSubfields(i)[0]) { - var field = this.getFieldSubfields(i)[0]['a']; - var authType = this.getFieldSubfields(i)[0]['b']; - this._associateDBField(item, i, "a", "creator", authorMab, authType, true); - } - } - - // if (this.getFieldSubfields("800")[0]) this._associateDBField(item, "800", "a", "creator", author, "author", true); - if (!item.language) this._associateDBField(item, "037b", "a", "language"); - this._associateDBField(item, "200", "a", "creator", corpAuthor); - if (!item.title) this._associateDBField(item, "331", "a", "title"); - this._associateDBField(item, "304", "a", "extra"); - if (this.getFieldSubfields("335")[0]) { - item.title = item.title + ": " + this.getFieldSubfields("335")[0]['a']; - } - if (!item.edition) this._associateDBField(item, "403", "a", "edition"); - if (!item.place) this._associateDBField(item, "410", "a", "place"); - if (!item.publisher) this._associateDBField(item, "412", "a", "publisher"); - if (!item.title) this._associateDBField(item, "1300", "a", "title"); - if (!item.date) this._associateDBField(item, "425", "a", "date", pullNumber); - if (!item.pages) this._associateDBField(item, "433", "a", "pages", pullNumber); - if (!item.series) this._associateDBField(item, "451", "a", "series"); - this._associateDBField(item, "501", "a", "extra"); - this._associateDBField(item, "519", "a", "extra"); - if (!item.edition) this._associateDBField(item, "523", "a", "edition"); - if (!item.ISBN) this._associateDBField(item, "540", "a", "ISBN", pullISBN); - if (!item.date) this._associateDBField(item, "595", "a", "date", pullNumber); - if (!item.url) this._associateDBField(item, "655e", "u", "url"); - - // Extract German subject headings (RSWK) as tags - this._associateTags(item, "902", "acfgpkstz"); - this._associateTags(item, "907", "acfgpkstz"); - this._associateTags(item, "912", "acfgpkstz"); - this._associateTags(item, "917", "acfgpkstz"); - this._associateTags(item, "922", "acfgpkstz"); - this._associateTags(item, "927", "acfgpkstz"); - this._associateTags(item, "932", "acfgpkstz"); - this._associateTags(item, "937", "acfgpkstz"); - this._associateTags(item, "942", "acfgpkstz"); - - -} - -function doImport() { - var text; - var holdOver = ""; // part of the text held over from the last loop - - Zotero.setCharacterSet("utf-8"); - - while(text = Zotero.read(4096)) { // read in 4096 byte increments - var records = text.split("\x1D"); - - if(records.length > 1) { - records[0] = holdOver + records[0]; - holdOver = records.pop(); // skip last record, since it's not done - - for(var i in records) { - var newItem = new Zotero.Item(); - - // create new record - var rec = new record(); - rec.importBinary(records[i]); - rec.translate(newItem); - - newItem.complete(); - } - } else { - holdOver += text; - } - } -} -\ No newline at end of file diff --git a/translators/MARC.js b/translators/MARC.js @@ -1,611 +0,0 @@ -{ - "translatorID": "a6ee60df-1ddc-4aae-bb25-45e0537be973", - "label": "MARC", - "creator": "Simon Kornblith, Sylvain Machefert", - "target": "marc", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 1, - "browserSupport": "gcsn", - "lastUpdated": "2011-08-22 23:29:49" -} - -function detectImport() { - var marcRecordRegexp = /^[0-9]{5}[a-z ]{3}$/ - var read = Zotero.read(8); - if(marcRecordRegexp.test(read)) { - return true; - } -} -//test -var fieldTerminator = "\x1E"; -var recordTerminator = "\x1D"; -var subfieldDelimiter = "\x1F"; - -/* - * CLEANING FUNCTIONS - */ - - - - -// general purpose cleaning -function clean(value) { - value = value.replace(/^[\s\.\,\/\:;]+/, ''); - value = value.replace(/[\s\.\,\/\:;]+$/, ''); - value = value.replace(/ +/g, ' '); - - var char1 = value[0]; - var char2 = value[value.length-1]; - if((char1 == "[" && char2 == "]") || (char1 == "(" && char2 == ")")) { - // chop of extraneous characters - return value.substr(1, value.length-2); - } - - return value; -} - -// number extraction -function pullNumber(text) { - var pullRe = /[0-9]+/; - var m = pullRe.exec(text); - if(m) { - return m[0]; - } -} - -// ISBN extraction -function pullISBN(text) { - var pullRe = /[0-9X\-]+/; - var m = pullRe.exec(text); - if(m) { - return m[0]; - } -} - -// corporate author extraction -function corpAuthor(author) { - return {lastName:author, fieldMode:true}; -} - -// regular author extraction -function author(author, type, useComma) { - return Zotero.Utilities.cleanAuthor(author, type, useComma); -} - -/* - * END CLEANING FUNCTIONS - */ - -var record = function() { - this.directory = new Object(); - this.leader = ""; - this.content = ""; - - // defaults - this.indicatorLength = 2; - this.subfieldCodeLength = 2; -} - -// import a binary MARC record into this record -record.prototype.importBinary = function(record) { - // get directory and leader - var directory = record.substr(0, record.indexOf(fieldTerminator)); - this.leader = directory.substr(0, 24); - var directory = directory.substr(24); - - // get various data - this.indicatorLength = parseInt(this.leader[10], 10); - this.subfieldCodeLength = parseInt(this.leader[11], 10); - var baseAddress = parseInt(this.leader.substr(12, 5), 10); - - // get record data - var contentTmp = record.substr(baseAddress); - - // MARC wants one-byte characters, so when we have multi-byte UTF-8 - // sequences, add null characters so that the directory shows up right. we - // can strip the nulls later. - this.content = ""; - for(i=0; i<contentTmp.length; i++) { - this.content += contentTmp[i]; - if(contentTmp.charCodeAt(i) > 0x00FFFF) { - this.content += "\x00\x00\x00"; - } else if(contentTmp.charCodeAt(i) > 0x0007FF) { - this.content += "\x00\x00"; - } else if(contentTmp.charCodeAt(i) > 0x00007F) { - this.content += "\x00"; - } - } - - // read directory - for(var i=0; i<directory.length; i+=12) { - var tag = parseInt(directory.substr(i, 3), 10); - var fieldLength = parseInt(directory.substr(i+3, 4), 10); - var fieldPosition = parseInt(directory.substr(i+7, 5), 10); - - if(!this.directory[tag]) { - this.directory[tag] = new Array(); - } - this.directory[tag].push([fieldPosition, fieldLength]); - } -} - -// add a field to this record -record.prototype.addField = function(field, indicator, value) { - field = parseInt(field, 10); - // make sure indicator is the right length - if(indicator.length > this.indicatorLength) { - indicator = indicator.substr(0, this.indicatorLength); - } else if(indicator.length != this.indicatorLength) { - indicator = Zotero.Utilities.lpad(indicator, " ", this.indicatorLength); - } - - // add terminator - value = indicator+value+fieldTerminator; - - // add field to directory - if(!this.directory[field]) { - this.directory[field] = new Array(); - } - this.directory[field].push([this.content.length, value.length]); - - // add field to record - this.content += value; -} - -// get all fields with a certain field number -record.prototype.getField = function(field) { - field = parseInt(field, 10); - var fields = new Array(); - - // make sure fields exist - if(!this.directory[field]) { - return fields; - } - - // get fields - for(var i in this.directory[field]) { - var location = this.directory[field][i]; - - // add to array, replacing null characters - fields.push([this.content.substr(location[0], this.indicatorLength), - this.content.substr(location[0]+this.indicatorLength, - location[1]-this.indicatorLength-1).replace(/\x00/g, "")]); - } - - return fields; -} - -// get subfields from a field -record.prototype.getFieldSubfields = function(tag) { // returns a two-dimensional array of values - var fields = this.getField(tag); - var returnFields = new Array(); - - for(var i in fields) { - returnFields[i] = new Object(); - - var subfields = fields[i][1].split(subfieldDelimiter); - if (subfields.length == 1) { - returnFields[i]["?"] = fields[i][1]; - } else { - for(var j in subfields) { - if(subfields[j]) { - var subfieldIndex = subfields[j].substr(0, this.subfieldCodeLength-1); - if(!returnFields[i][subfieldIndex]) { - returnFields[i][subfieldIndex] = subfields[j].substr(this.subfieldCodeLength-1); - } else { - // Duplicate subfield - Zotero.debug("Duplicate subfield '"+tag+" "+subfieldIndex+"="+subfields[j]); - returnFields[i][subfieldIndex] = returnFields[i][subfieldIndex] + " " + subfields[j].substr(this.subfieldCodeLength-1); - } - } - } - } - } - - return returnFields; -} - -// add field to DB -record.prototype._associateDBField = function(item, fieldNo, part, fieldName, execMe, arg1, arg2) { - var field = this.getFieldSubfields(fieldNo); - - Zotero.debug('MARC: found '+field.length+' matches for '+fieldNo+part); - if(field) { - for(var i in field) { - var value = false; - for(var j=0; j<part.length; j++) { - var myPart = part[j]; - if(field[i][myPart]) { - if(value) { - value += " "+field[i][myPart]; - } else { - value = field[i][myPart]; - } - } - } - if(value) { - value = clean(value); - - if(execMe) { - value = execMe(value, arg1, arg2); - } - - if(fieldName == "creator") { - item.creators.push(value); - } else { - item[fieldName] = value; - return; - } - } - } - } -} - -// add field to DB as note -record.prototype._associateNotes = function(item, fieldNo, part) { - var field = this.getFieldSubfields(fieldNo); - var texts = []; - - for(var i in field) { - for(var j=0; j<part.length; j++) { - var myPart = part[j]; - if(field[i][myPart]) { - texts.push(clean(field[i][myPart])); - } - } - } - var text = texts.join(' '); - if (text.trim() != "") - item.notes.push({note: text}); -} - -// add field to DB as tags -record.prototype._associateTags = function(item, fieldNo, part) { - var field = this.getFieldSubfields(fieldNo); - - for(var i in field) { - for(var j=0; j<part.length; j++) { - var myPart = part[j]; - if(field[i][myPart]) { - item.tags.push(clean(field[i][myPart])); - } - } - } -} - -// this function loads a MARC record into our database -record.prototype.translate = function(item) { - // get item type - if(this.leader) { - var marcType = this.leader[6]; - if(marcType == "g") { - item.itemType = "film"; - } else if(marcType == "e" || marcType == "f") { - item.itemType = "map"; - } else if(marcType == "k") { - item.itemType = "artwork"; - } else if(marcType == "t" || marcType == "b") { - // 20091210: in unimarc, the code for manuscript is b, unused in marc21. - item.itemType = "manuscript"; - } else { - item.itemType = "book"; - } - } else { - item.itemType = "book"; - } - - // Starting from there, we try to distinguish between unimarc and other marc flavours. - // In unimarc, the title is in the 200 field and this field isn't used in marc-21 (at least) - // In marc-21, the title is in the 245 field and this field isn't used in unimarc - // So if we have a 200 and no 245, we can think we are with an unimarc record. - // Otherwise, we use the original association. - if ( (this.getFieldSubfields("200")[0]) && (!(this.getFieldSubfields("245")[0])) ) - { - // If we've got a 328 field, we're on a thesis - if (this.getFieldSubfields("328")[0]) - { - item.itemType = "thesis"; - } - - // Extract ISBNs - this._associateDBField(item, "010", "a", "ISBN", pullISBN); - // Extract ISSNs - this._associateDBField(item, "011", "a", "ISSN", pullISBN); - - // Extract creators (700, 701 & 702) - for (var i = 700; i < 703; i++) - { - var authorTab = this.getFieldSubfields(i); - for (var j in authorTab) - { - var aut = authorTab[j]; - var authorText = ""; - if (aut.b) { - authorText = aut['a'] + ", " + aut['b']; - } - else - { - authorText = aut['a']; - } - - item.creators.push(Zotero.Utilities.cleanAuthor(authorText, "author", true)); - } - } - - // Extract corporate creators (710, 711 & 712) - for (var i = 710; i < 713; i++) - { - var authorTab = this.getFieldSubfields(i); - for (var j in authorTab) - { - if (authorTab[j]['a']) - { - item.creators.push({lastName:authorTab[j]['a'], creatorType:"contributor", fieldMode:true}); - } - } - } - - // Extract language. In the 101$a there's a 3 chars code, would be better to - // have a translation somewhere - this._associateDBField(item, "101", "a", "language"); - - // Extract abstractNote - this._associateDBField(item, "328", "a", "abstractNote"); - this._associateDBField(item, "330", "a", "abstractNote"); - - // Extract tags - // TODO : Ajouter les autres champs en 6xx avec les autorités construites. - // nécessite de reconstruire les autorités - this._associateTags(item, "610", "a"); - - // Extract scale (for maps) - this._associateDBField(item, "206", "a", "scale"); - - // Extract title - this._associateDBField(item, "200", "ae", "title"); - - // Extract edition - this._associateDBField(item, "205", "a", "edition"); - - // Extract place info - this._associateDBField(item, "210", "a", "place"); - - // Extract publisher/distributor - if(item.itemType == "film") - { - this._associateDBField(item, "210", "c", "distributor"); - } - else - { - this._associateDBField(item, "210", "c", "publisher"); - } - - // Extract year - this._associateDBField(item, "210", "d", "date", pullNumber); - // Extract pages. Not working well because 215$a often contains pages + volume informations : 1 vol () - // this._associateDBField(item, "215", "a", "pages", pullNumber); - - // Extract series - this._associateDBField(item, "225", "a", "series"); - // Extract series number - this._associateDBField(item, "225", "v", "seriesNumber"); - - // Extract call number - this._associateDBField(item, "686", "ab", "callNumber"); - this._associateDBField(item, "676", "a", "callNumber"); - this._associateDBField(item, "675", "a", "callNumber"); - this._associateDBField(item, "680", "ab", "callNumber"); - } - else - { - // Extract ISBNs - this._associateDBField(item, "020", "a", "ISBN", pullISBN); - // Extract ISSNs - this._associateDBField(item, "022", "a", "ISSN", pullISBN); - // Extract creators - this._associateDBField(item, "100", "a", "creator", author, "author", true); - this._associateDBField(item, "110", "a", "creator", corpAuthor, "author"); - this._associateDBField(item, "111", "a", "creator", corpAuthor, "author"); - this._associateDBField(item, "700", "a", "creator", author, "contributor", true); - this._associateDBField(item, "710", "a", "creator", corpAuthor, "contributor"); - this._associateDBField(item, "711", "a", "creator", corpAuthor, "contributor"); - if(item.itemType == "book" && !item.creators.length) { - // some LOC entries have no listed author, but have the author in the person subject field as the first entry - var field = this.getFieldSubfields("600"); - if(field[0]) { - item.creators.push(Zotero.Utilities.cleanAuthor(field[0]["a"], "author", true)); - } - } - - // Extract tags - // personal - this._associateTags(item, "600", "aqtxyz"); - // corporate - this._associateTags(item, "611", "abtxyz"); - // meeting - this._associateTags(item, "630", "acetxyz"); - // uniform title - this._associateTags(item, "648", "atxyz"); - // chronological - this._associateTags(item, "650", "axyz"); - // topical - this._associateTags(item, "651", "abcxyz"); - // geographic - this._associateTags(item, "653", "axyz"); - // uncontrolled - this._associateTags(item, "653", "a"); - // faceted topical term (whatever that means) - this._associateTags(item, "654", "abcyz"); - // genre/form - this._associateTags(item, "655", "abcxyz"); - // occupation - this._associateTags(item, "656", "axyz"); - // function - this._associateTags(item, "657", "axyz"); - // curriculum objective - this._associateTags(item, "658", "ab"); - // hierarchical geographic place name - this._associateTags(item, "662", "abcdfgh"); - - // Extract note fields - // http://www.loc.gov/marc/bibliographic/bd5xx.html - // general note - this._associateNotes(item, "500", "a"); - // formatted contents (table of contents) - this._associateNotes(item, "505", "art"); - // summary - this._associateNotes(item, "520", "ab"); - // biographical or historical data - this._associateNotes(item, "545", "ab"); - - // Extract title - this._associateDBField(item, "245", "ab", "title"); - // Extract edition - this._associateDBField(item, "250", "a", "edition"); - // Extract place info - this._associateDBField(item, "260", "a", "place"); - - // Extract publisher/distributor - if(item.itemType == "film") { - this._associateDBField(item, "260", "b", "distributor"); - } else { - this._associateDBField(item, "260", "b", "publisher"); - } - - // Extract year - this._associateDBField(item, "260", "c", "date", pullNumber); - // Extract pages - this._associateDBField(item, "300", "a", "numPages", pullNumber); - // Extract series and series number - // The current preference is 490 - this._associateDBField(item, "490", "a", "series"); - this._associateDBField(item, "490", "v", "seriesNumber"); - // 440 was made obsolete as of 2008; see http://www.loc.gov/marc/bibliographic/bd4xx.html - this._associateDBField(item, "440", "a", "series"); - this._associateDBField(item, "440", "v", "seriesNumber"); - // Extract call number - this._associateDBField(item, "084", "ab", "callNumber"); - this._associateDBField(item, "082", "a", "callNumber"); - this._associateDBField(item, "080", "ab", "callNumber"); - this._associateDBField(item, "070", "ab", "callNumber"); - this._associateDBField(item, "060", "ab", "callNumber"); - this._associateDBField(item, "050", "ab", "callNumber"); - this._associateDBField(item, "090", "a", "callNumber"); - this._associateDBField(item, "099", "a", "callNumber"); - this._associateDBField(item, "852", "khim", "callNumber"); - - //German - if (!item.place) this._associateDBField(item, "410", "a", "place"); - if (!item.publisher) this._associateDBField(item, "412", "a", "publisher"); - if (!item.title) this._associateDBField(item, "331", "a", "title"); - if (!item.title) this._associateDBField(item, "1300", "a", "title"); - if (!item.date) this._associateDBField(item, "425", "a", "date", pullNumber); - if (!item.date) this._associateDBField(item, "595", "a", "date", pullNumber); - if (this.getFieldSubfields("104")[0]) this._associateDBField(item, "104", "a", "creator", author, "author", true); - if (this.getFieldSubfields("800")[0]) this._associateDBField(item, "800", "a", "creator", author, "author", true); - - //Spanish - if (!item.title) this._associateDBField(item, "200", "a", "title"); - if (!item.place) this._associateDBField(item, "210", "a", "place"); - if (!item.publisher) this._associateDBField(item, "210", "c", "publisher"); - if (!item.date) this._associateDBField(item, "210", "d", "date"); - if (!item.creators) { - for (var i = 700; i < 703; i++) { - if (this.getFieldSubfields(i)[0]) { - Zotero.debug(i + " is AOK"); - Zotero.debug(this.getFieldSubfields(i.toString())); - var aut = this.getFieldSubfields(i)[0]; - if (aut.b) { - aut = aut['b'].replace(/,\W+/g, "") + " " + aut['a'].replace(/,\s/g, ""); - } else { - aut = aut['a'].split(", ").join(" "); - } - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } - } - if(item.title) { - item.title = Zotero.Utilities.capitalizeTitle(item.title); - } - if (this.getFieldSubfields("335")[0]) { - item.title = item.title + ": " + this.getFieldSubfields("335")[0]['a']; - } - } -} - -function doImport() { - var text; - var holdOver = ""; // part of the text held over from the last loop - - while(text = Zotero.read(4096)) { // read in 4096 byte increments - var records = text.split("\x1D"); - - if(records.length > 1) { - records[0] = holdOver + records[0]; - holdOver = records.pop(); // skip last record, since it's not done - - for(var i in records) { - var newItem = new Zotero.Item(); - - // create new record - var rec = new record(); - rec.importBinary(records[i]); - rec.translate(newItem); - - newItem.complete(); - } - } else { - holdOver += text; - } - } -} - -var exports = { - "record":record, - "fieldTerminator":fieldTerminator, - "recordTerminator":recordTerminator, - "subfieldDelimiter":subfieldDelimiter -}; - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "import", - "input": "01841cam a2200385Ma 45\u00020001000700000005001700007008004100024010001700065035002300082035001800105040003000123043001200153050001500165049001500180100003900195245028100234260005900515300006100574500019500635500014500830510003000975510002701005510004501032500002601077610004401103600004001147600004801187650004501235610004501280852005801325946003101383910001001414994001201424947001901436\u001e790862\u001e20080120004008.0\u001e880726s1687 sp bf 000 0cspa d\u001e \u001fa 03021876 \u001e \u001fa(OCoLC)ocm29051663\u001e \u001fa(NBYdb)790862\u001e \u001faMNU\u001fcMNU\u001fdOCL\u001fdDIBAM\u001fdIBV\u001e \u001fas-py---\u001e0 \u001faF2681\u001fb.X3\u001e \u001faIBVA\u001flbklr\u001e1 \u001faXarque, Francisco,\u001fdca. 1609-1691.\u001e10\u001faInsignes missioneros de la Compañia de Jesus en la prouincia del Paraguay :\u001fbestado presente de sus missiones en Tucuman, Paraguay, y Rio de la Plata, que comprehende su distrito /\u001fcpor el doct. d. Francisco Xarque, dean de la Catredral [sic] de Santa Maria de Albarrazin ...\u001e \u001faEn Pamplona :\u001fbPor Juan Micòn, Impressor,\u001fcaño 1687.\u001e \u001fa[24], 432 p., [1] folded leaf of plates :\u001fbmap ;\u001fc22 cm.\u001e \u001faBrunet and Graesse both mention a map of Paraguay; this copy has a map of Chile with title: Tabula geocraphica [sic] regni Chile / studio et labore P. Procuratoris Chilensis Societatis Jesu.\u001e \u001faIn 3 books; the first two are biographies of Jesuits, Simon Mazeta and Francisco Diaz Taño, the 3rd deals with Jesuit missions in Paraguay.\u001e4 \u001faNUC pre-1956,\u001fcNX0000604.\u001e4 \u001faSabin,\u001fc105716 (v.29).\u001e4 \u001faPalau y Dulcet (2nd ed.),\u001fc123233 (v.7).\u001e \u001faHead and tail pieces.\u001e20\u001faJesuits\u001fzParaguay\u001fvEarly works to 1800.\u001e10\u001faMasseta, Simon,\u001fdca. 1582-ca. 1656.\u001e10\u001faCuellar y Mosquera, Gabriel de,\u001fd1593-1677.\u001e 0\u001faMissions\u001fzParaguay\u001fvEarly works to 1800.\u001e20\u001faJesuits\u001fvBiography\u001fvEarly works to 1800.\u001e8 \u001fbvau,ayer\u001fkVAULT\u001fhAyer\u001fi1343\u001fi.J515\u001fiP211\u001fiX2\u001fi1687\u001ft1\u001e \u001faOCLC RECON PROJECT\u001farc3758\u001e \u001fa35535\u001e \u001fa02\u001fbIBV\u001e \u001faMARS\u001fa20071227\u001e\u001d", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Francisco", - "lastName": "Xarque", - "creatorType": "author" - } - ], - "notes": [ - { - "note": "Brunet and Graesse both mention a map of Paraguay; this copy has a map of Chile with title: Tabula geocraphica [sic] regni Chile / studio et labore P. Procuratoris Chilensis Societatis Jesu In 3 books; the first two are biographies of Jesuits, Simon Mazeta and Francisco Diaz Taño, the 3rd deals with Jesuit missions in Paraguay Head and tail pieces" - } - ], - "tags": [ - "Masseta, Simon", - "Cuellar y Mosquera, Gabriel de", - "Missions", - "Paraguay" - ], - "seeAlso": [], - "attachments": [], - "title": "Insignes missioneros de la Compañia de Jesus en la prouincia del Paraguay: estado presente de sus missiones en Tucuman, Paraguay, y Rio de la Plata, que comprehende su distrito", - "place": "En Pamplona", - "publisher": "Por Juan Micòn, Impressor", - "date": "1687", - "numPages": "24", - "callNumber": "VAULT Ayer 1343 .J515 P211 X2 1687" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/MIT Press Journals.js b/translators/MIT Press Journals.js @@ -1,123 +0,0 @@ -{ - "translatorID": "2e43f4a9-d2e2-4112-a6ef-b3528b39b4d2", - "label": "MIT Press Journals", - "creator": "Michael Berkowitz", - "target": "http://www.mitpressjournals.org/", - "minVersion": "1.0.0b4.r5", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:31:06" -} - -function detectWeb(doc, url) { - if (url.match(/action\/doSearch/) || url.match(/toc\//)) { - return "multiple"; - } else if (url.match(/doi\/abs\//)) { - return "journalArticle"; - } -} - -function getDOI(str) { - return str.match(/doi\/abs\/([^?]+)/)[1]; -} - -function doWeb(doc, url) { - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//table[@class="articleEntry"]/tbody/tr//a[text() = "First Page" or text() = "Citation" or text() = "Abstract"]', doc, null, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('//table[@class="articleEntry"]/tbody/tr//div[@class="arttitle"]', doc, null, XPathResult.ANY_TYPE, null); - var link, title; - while ((link = links.iterateNext()) && (title = titles.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push('http://www.mitpressjournals.org/doi/abs/' + getDOI(i)); - } - } else { - articles = ['http://www.mitpressjournals.org/doi/abs/' + getDOI(url)]; - } - Zotero.Utilities.processDocuments(articles, function(newDoc) { - if (newDoc.evaluate('//div[@class="abstractSection"]/p[contains(@class, "last") or contains(@class, "first")]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var abs = Zotero.Utilities.trimInternal(newDoc.evaluate('//div[@class="abstractSection"]/p[contains(@class, "last") or contains(@class, "first")]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - var doi = getDOI(newDoc.location.href); - var risurl = 'http://www.mitpressjournals.org/action/downloadCitation?doi=' + doi + '&include=cit&format=refman&direct=on&submit=Download+article+metadata'; - var pdfurl = newDoc.location.href.replace("/doi/abs/", "/doi/pdf/"); - Zotero.Utilities.HTTP.doGet(risurl, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if (item.notes[0]['note'].match(/doi:/)) { - item.DOI = item.notes[0]['note'].substr(5); - item.notes = new Array(); - } - item.attachments[0].title= item.publicationTitle + " Snapshot"; - item.attachments[0].mimeType = "text/html"; - item.attachments.push({url:pdfurl, title:item.publicationTitle + " Full Text PDF", mimeType:"application/pdf"}); - if (abs) item.abstractNote = abs; - item.complete(); - }); - translator.translate(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.mitpressjournals.org/toc/afar/43/4", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.mitpressjournals.org/doi/abs/10.1162/afar.2010.43.4.60", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Verswijver", - "firstName": "Gustaaf", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "African Arts Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "title": "African Arts Full Text PDF", - "mimeType": "application/pdf" - } - ], - "title": "Removable Hair Caps of Karamoja (Uganda)", - "date": "2011/07/13 2010", - "DOI": "i: 10.1162/afar.2010.43.4.60</p>", - "publicationTitle": "African Arts", - "pages": "60-71", - "volume": "43", - "issue": "4", - "publisher": "MIT Press", - "ISBN": "0001-9933", - "ISSN": "0001-9933", - "url": "http://dx.doi.org/10.1162/afar.2010.43.4.60", - "libraryCatalog": "MIT Press Journals" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/MODS.js b/translators/MODS.js @@ -1,995 +0,0 @@ -{ - "translatorID": "0e2235e7-babf-413c-9acf-f27cce5f059c", - "label": "MODS", - "creator": "Simon Kornblith and Richard Karnesky", - "target": "xml", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 50, - "configOptions": { - "dataMode": "xml/e4x" - }, - "displayOptions": { - "exportNotes": true - }, - "inRepository": true, - "translatorType": 3, - "browserSupport": "g", - "lastUpdated": "2011-07-18 13:49:58" -} - -function detectImport() { - var name = Zotero.getXML().name(); - if (!name) { - return false; - } - return name.uri == "http://www.loc.gov/mods/v3" && (name.localName == "modsCollection" || name.localName == "mods"); -} - -var partialItemTypes = ["bookSection", "journalArticle", "magazineArticle", "newspaperArticle"]; - -function doExport() { - Zotero.setCharacterSet("utf-8"); - var modsCollection = <modsCollection xmlns="http://www.loc.gov/mods/v3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-2.xsd" />; - - var item; - while(item = Zotero.nextItem()) { - var isPartialItem = partialItemTypes.indexOf(item.itemType) !== -1; - - var mods = <mods />; - - /** CORE FIELDS **/ - - // XML tag titleInfo; object field title - if(item.title) { - mods.titleInfo.title = item.title; - } - if(item.shortTitle) { - mods.titleInfo += <titleInfo type="abbreviated"><title>{item.shortTitle}</title></titleInfo>; - } - - // XML tag typeOfResource/genre; object field type - // - // The exact marcGenre of a book section can, perhaps, be debated; - // But it should have 'book' as the host's genre. - var modsType, marcGenre; - if(item.itemType == "book" || item.itemType == "bookSection") { - modsType = "text"; - marcGenre = "book"; - } else if(item.itemType == "journalArticle" || item.itemType == "magazineArticle") { - modsType = "text"; - marcGenre = "periodical"; - } else if(item.itemType == "newspaperArticle") { - modsType = "text"; - marcGenre = "newspaper"; - } else if(item.itemType == "thesis") { - modsType = "text"; - marcGenre = "thesis"; - } else if(item.itemType == "letter") { - modsType = "text"; - marcGenre = "letter"; - } else if(item.itemType == "manuscript") { - modsType = "text"; - mods.typeOfResource.@manuscript = "yes"; - } else if(item.itemType == "interview") { - modsType = "text"; - marcGenre = "interview"; - } else if(item.itemType == "film") { - modsType = "moving image"; - marcGenre = "motion picture"; - } else if(item.itemType == "artwork") { - modsType = "still image"; - marcGenre = "art original"; - } else if(item.itemType == "webpage") { - modsType = "multimedia"; - marcGenre = "web site"; - } else if(item.itemType == "note" || item.itemType == "attachment") { - continue; - } - mods.typeOfResource = modsType; - mods.genre += <genre authority="local">{item.itemType}</genre>; - if(marcGenre) { - mods.genre += <genre authority="marcgt">{marcGenre}</genre>; - } - - // XML tag genre; object field thesisType, type - if(item.thesisType) { - mods.genre += <genre>{item.thesisType}</genre>; - } else if(item.type) { - mods.genre += <genre>{item.type}</genre>; - } - - // XML tag name; object field creators - for(var j in item.creators) { - var roleTerm = ""; - if(item.creators[j].creatorType == "author") { - roleTerm = "aut"; - } else if(item.creators[j].creatorType == "editor") { - roleTerm = "edt"; - } else if(item.creators[j].creatorType == "translator") { - roleTerm = "trl"; - } else { - roleTerm = "ctb"; - } - - // FIXME - currently all names are personal - if(item.creators[j].creatorType != "seriesEditor") { - if(isPartialItem && item.creators[j].creatorType == "editor"){ - if(item.creators[j].fieldMode == 1) { - mods.relatedItem.name += <name type="personal"> - <namePart>{item.creators[j].lastName}</namePart> - <role><roleTerm type="code" authority="marcrelator">{roleTerm}</roleTerm></role> - </name>; - } else { - mods.relatedItem.name += <name type="personal"> - <namePart type="family">{item.creators[j].lastName}</namePart> - <namePart type="given">{item.creators[j].firstName}</namePart> - <role><roleTerm type="code" authority="marcrelator">{roleTerm}</roleTerm></role> - </name>; - } - } else { - if(item.creators[j].fieldMode == 1) { - mods.name += <name type="personal"> - <namePart>{item.creators[j].lastName}</namePart> - <role><roleTerm type="code" authority="marcrelator">{roleTerm}</roleTerm></role> - </name>; - } else { - mods.name += <name type="personal"> - <namePart type="family">{item.creators[j].lastName}</namePart> - <namePart type="given">{item.creators[j].firstName}</namePart> - <role><roleTerm type="code" authority="marcrelator">{roleTerm}</roleTerm></role> - </name>; - } - } - } - } - - // XML tag recordInfo.recordOrigin; used to store our generator note - //mods.recordInfo.recordOrigin = "Zotero for Firefox "+Zotero.Utilities.getVersion(); - - /** FIELDS ON NEARLY EVERYTHING BUT NOT A PART OF THE CORE **/ - - // XML tag recordInfo.recordContentSource; object field source - if(item.source) { - mods.recordInfo.recordContentSource = item.source; - } - // XML tag recordInfo.recordIdentifier; object field accessionNumber - if(item.accessionNumber) { - mods.recordInfo.recordIdentifier = item.accessionNumber; - } - - // XML tag accessCondition; object field rights - if(item.rights) { - mods.accessCondition = item.rights; - } - - /** SUPPLEMENTAL FIELDS **/ - - // Make part its own tag so we can figure out where it goes later - var part = new XML(); - - // XML tag detail; object field volume - if(item.volume) { - part += <detail type="volume"><number>{item.volume}</number></detail>; - } - - // XML tag detail; object field number - if(item.issue) { - part += <detail type="issue"><number>{item.issue}</number></detail>; - } - - // XML tag detail; object field section - if(item.section) { - part += <detail type="section"><number>{item.section}</number></detail>; - } - - // XML tag detail; object field pages - if(item.pages) { - var range = Zotero.Utilities.getPageRange(item.pages); - part += <extent unit="pages"><start>{range[0]}</start><end>{range[1]}</end></extent>; - } - - // Assign part if something was assigned - if(part.length() != 1) { - if(isPartialItem) { - // For a journal article, bookSection, etc., the part is the host - mods.relatedItem.part += <part>{part}</part>; - } else { - mods.part += <part>{part}</part>; - } - } - - // XML tag originInfo; object fields edition, place, publisher, year, date - var originInfo = new XML(); - if(item.edition) { - originInfo += <edition>{item.edition}</edition>; - } - if(item.place) { - originInfo += <place><placeTerm type="text">{item.place}</placeTerm></place>; - } - if(item.publisher) { - originInfo += <publisher>{item.publisher}</publisher>; - } else if(item.distributor) { - originInfo += <publisher>{item.distributor}</publisher>; - } - if(item.date) { - if(["book", "bookSection"].indexOf(item.itemType) !== -1) { - // Assume year is copyright date - var dateType = "copyrightDate"; - } else if(["journalArticle", "magazineArticle", "newspaperArticle"].indexOf(item.itemType) !== -1) { - // Assume date is date issued - var dateType = "dateIssued"; - } else { - // Assume date is date created - var dateType = "dateCreated"; - } - var tag = <{dateType}>{item.date}</{dateType}>; - originInfo += tag; - } - - if(item.numPages) { - mods.physicalDescription = <physicalDescription><extent unit="pages"><total>{item.numPages}</total></extent></physicalDescription>; - } - - if(originInfo.length() != 1) { - if(isPartialItem) { - // For a journal article, bookSection, etc., this goes under the host - mods.relatedItem.originInfo += <originInfo>{originInfo}</originInfo>; - } else { - mods.originInfo += <originInfo>{originInfo}</originInfo>; - } - } - - // eXist Solutions points out that most types are more often - // monographic than not & will use this internally. - // Perhaps comment this out in the main distribution, though. - mods.originInfo.issuance = "monographic"; - - if(isPartialItem) { - // eXist Solutions points out that these types are more often - // continuing than not & will use this internally. - // Perhaps comment this out in the main distribution, though. - if(item.itemType == "journalArticle" || item.itemType == "magazineArticle" || item.itemType == "newspaperArticle") { - mods.relatedItem.originInfo.issuance = "continuing"; - if(item.itemType == "journalArticle" || item.itemType == "magazineArticle") { - mods.relatedItem.genre += <genre authority="marcgt">periodical</genre>; - } else if (item.itemType == "newspaperArticle") { - mods.relatedItem.genre += <genre authority="marcgt">newspaper</genre>; - } - } - else if (item.itemType == "bookSection" || item.itemType == "conferencePaper" || item.itemType == "encyclopediaArticle") { - mods.relatedItem.originInfo.issuance = "monographic"; - if (item.itemType == "bookSection") { - mods.relatedItem.genre += <genre authority="marcgt">book</genre>; - } else if (item.itemType == "conferencePaper") { - mods.relatedItem.genre += <genre authority="marcgt">conference publication</genre>; - if (item.conferenceName) { - mods.relatedItem.name += <name type="conference"> - <namePart>{item.conferenceName}</namePart> - </name>; - } - } else if (item.itemType == "encyclopediaArticle") { - mods.relatedItem.genre += <genre authority="marcgt">encyclopedia</genre>; - } - } - } - - // XML tag identifier; object fields ISBN, ISSN - if(isPartialItem) { - var identifier = mods.relatedItem; - } else { - var identifier = mods; - } - if(item.ISBN) { - identifier.identifier += <identifier type="isbn">{item.ISBN}</identifier>; - } - if(item.ISSN) { - identifier.identifier += <identifier type="issn">{item.ISSN}</identifier>; - } - if(item.DOI) { - mods.identifier += <identifier type="doi">{item.DOI}</identifier>; - } - - // XML tag relatedItem.titleInfo; object field publication - if(item.publicationTitle) { - mods.relatedItem.titleInfo += <titleInfo><title>{item.publicationTitle}</title></titleInfo>; - } - - // XML tag classification; object field callNumber - if(item.callNumber) { - mods.classification = item.callNumber; - } - - // XML tag location.url; object field archiveLocation - if(item.url) { - mods.location.url += item.url; - if(item.accessDate) { - mods.location.url.@dateLastAccessed = item.accessDate; - } - } - - - // XML tag location.physicalLocation; object field archiveLocation - if(item.archiveLocation) { - mods.location += <location><physicalLocation>{item.archiveLocation}</physicalLocation></location>; - } - - // XML tag title.titleInfo; object field journalAbbreviation - if(item.journalAbbreviation) { - mods.relatedItem.titleInfo += <titleInfo type="abbreviated"><title>{item.journalAbbreviation}</title></titleInfo>; - } - - // XML tag abstract; object field abstractNote - if(item.abstractNote) { - mods.abstract = item.abstractNote; - } - - if(mods.relatedItem.length() == 1 && isPartialItem) { - mods.relatedItem.@type = "host"; - } - - /** NOTES **/ - - if(Zotero.getOption("exportNotes")) { - for(var j in item.notes) { - // Add note tag - var note = <note type="content">{item.notes[j].note}</note>; - mods.note += note; - } - } - - /** TAGS **/ - - for(var j in item.tags) { - mods.subject += <subject><topic>{item.tags[j].tag}</topic></subject>; - } - - /** LANGUAGE **/ - - if(item.language) { - mods.language.languageTerm = <languageTerm type="text">{item.language}</languageTerm>; - } - - /** EXTRA->NOTE **/ - if(item.extra) { - mods.note += <note>{item.extra}</note>; - } - - - // XML tag relatedItem.titleInfo; object field series - if(item.seriesTitle || item.series || item.seriesNumber || item.seriesText) { - var series = <relatedItem type="series"/>; - - // eXist Solutions points out that these types are more often - // continuing than not & will use this internally. - // Perhaps comment this out in the main distribution, though. - series.originInfo.issuance = "continuing"; - - if(item.series) { - series.titleInfo.title = item.series; - } - - if(item.seriesTitle) { - series.titleInfo.title += <title>{item.seriesTitle}</title>; - } - - if(item.seriesText) { - series.titleInfo.subTitle = item.seriesText; - } - - if(item.seriesNumber) { - series.part.detail = <detail type="volume"><number>{item.seriesNumber}</number></detail>; - } - - // handle series editors - for(var j in item.creators) { - var roleTerm = ""; - if(item.creators[j].creatorType == "seriesEditor") { - roleTerm = "pbd"; - if(item.creators[j].fieldMode == 1) { - series.name += <name type="personal"> - <namePart>{item.creators[j].lastName}</namePart> - <role><roleTerm type="code" authority="marcrelator">{roleTerm}</roleTerm></role> - </name>; - } else { - series.name += <name type="personal"> - <namePart type="family">{item.creators[j].lastName}</namePart> - <namePart type="given">{item.creators[j].firstName}</namePart> - <role><roleTerm type="code" authority="marcrelator">{roleTerm}</roleTerm></role> - </name>; - } - } - } - - // TODO: make this work in import - // - if(isPartialItem) { - mods.relatedItem.relatedItem = series; - } else { - mods.relatedItem += series; - } - } - - modsCollection.mods += mods; - } - - Zotero.write('<?xml version="1.0"?>'+"\n"); - Zotero.write(modsCollection.toXMLString()); -} - -function processIdentifiers(newItem, identifier) { - for each(var myIdentifier in identifier) { - if(myIdentifier.@type == "isbn") { - newItem.ISBN = myIdentifier.text().toString() - } else if(myIdentifier.@type == "issn") { - newItem.ISSN = myIdentifier.text().toString() - } else if(myIdentifier.@type == "doi") { - newItem.DOI = myIdentifier.text().toString() - } - } -} - -function doImport() { - var marcGenres = { -// "abstract or summary":XXX, -// "abstract":XXX, -// "summary":XXX, - "art reproduction":"artwork", - "article":"journalArticle", - "autobiography":"book", - "bibliography":"book", - "biography":"book", - "book":"book", -// "calendar":XXX, -// "catalog":XXX, - "chart":"artwork", - "comic or graphic novel":"book", - "comic":"book", - "graphic novel":"book", - "comic strip":"artwork", - "conference publication":"conferencePaper", -// "database":XXX, - "dictionary":"dictionaryEntry", - "diorama":"artwork", -// "directory":XXX, - "drama":"book", - "encyclopedia":"encyclopediaArticle", -// "essay":XXX, - "festschrift":"book", - "fiction":"book", -// "filmography":XXX, - "filmstrip":"videoRecording", -// "findingaid":XXX, -// "flash card":XXX, - "folktale":"book", -// "font":XXX, -// "game":XXX, - "government publication":"book", - "graphic":"artwork", - "globe":"map", - "handbook":"book", - "history":"book", - "hymnal":"book", - "humor,satire":"book", - "humor":"book", - "satire":"book", -// "index":XXX, -// "instruction":XXX, -// "interview":XXX, -// "issue":XXX, - "journal":"journalArticle", - "kit":"artwork", -// "language instruction":XXX, - "law report or digest":"journalArticle", - "law report":"journalArticle", - "digest":"journalArticle", - "law digest":"journalArticle", - "legal article":"journalArticle", - "legal case and case notes":"case", - "legal case":"case", - "case notes":"case", - "legislation":"statute", - "loose-leaf":"manuscript", - "map":"map", - "memoir":"book", - "microscope slide":"artwork", - "model":"artwork", -// "multivolume monograph":XXX, - "novel":"book", -// "numeric data":XXX, -// "offprint":XXX, - "online system or service":"webpage", - "online system":"webpage", - "service":"webpage", - "online service":"webpage", - "patent":"patent", - "periodical":"journalArticle", - "picture":"artwork", -// "poetry":XXX, -// "programmed text":XXX, - "realia":"artwork", -// "rehearsal":XXX, -// "remote sensing image":XXX, -// "reporting":XXX, -// "review":XXX, - "script":"book", -// "series":XXX, -// "short story":XXX, - "slide":"artwork", - "sound":"audioRecording", - "speech":"audioRecording", -// "standard or specification":XXX, -// "standard":XXX, -// "specification":XXX, -// "statistics":XXX, -// "survey of literature":XXX, - "technical report":"report", - "newspaper":"newspaperArticle", - "theses":"thesis", - "thesis":"thesis", -// "toy":XXX, - "transparency":"artwork", -// "treaty":XXX, - "videorecording":"videoRecording", - "letter":"letter", - "motion picture":"film", - "art original":"artwork", - "web site":"webpage", - "yearbook":"book" - }; - - var dctGenres = { - //"collection":XXX, - //"dataset":XXX, - //"event":XXX, - "image":"artwork", - "interactiveresource":"webpage", - //"model":XXX, - "movingimage":"videoRecording", - //"physical object":XXX, - //"place":XXX, - //"resource":XXX, - //"service":XXX, - "software":"computerProgram", - "sound":"audioRecording", - "stillimage":"artwork" - //"text":XXX - }; - - var modsTypeOfResources = { - //"text":XXX, - "cartographic":"map", - //"notated music":XXX, - "sound recording-musical":"audioRecording", - "sound recording-nonmusical":"audioRecording", - "sound recording":"audioRecording", - "still image":"artwork", - "moving image":"videoRecording", - //"three dimensional object":XXX, - "software, multimedia":"computerProgram" - }; - - // parse with E4X - var m = new Namespace("http://www.loc.gov/mods/v3"); - // why does this default namespace declaration not work!? - default xml namespace = m; - var xml = Zotero.getXML(); - - if(xml.m::mods.length()) { - var modsElements = xml.m::mods; - var nModsElements = modsElements.length(); - } else { - var modsElements = [xml]; - var nModsElements = 1; - } - - var i = 0; - for each(var mods in modsElements) { - var newItem = new Zotero.Item(); - - // title - for each(var titleInfo in mods.m::titleInfo) { - // dropping other title types so they don't overwrite the main title - // we have same behaviour in the MARC translator - if(!titleInfo.@type.toString()) { - if(titleInfo.m::title.length()) { - newItem.title = titleInfo.m::title.text().toString(); - if(titleInfo.m::subTitle.length()) { - newItem.title = newItem.title + ": " + titleInfo.m::subTitle.text().toString(); - } - } else { - newItem.title = titleInfo.*.text(); // including text from sub elements - } - } - } - // try to get genre from local genre - for each(var genre in mods.m::genre) { - if(genre.@authority == "local" && Zotero.Utilities.itemTypeExists(genre.text().toString())) { - newItem.itemType = genre.text().toString(); - } else if(!newItem.itemType && (genre.@authority == "marcgt" || genre.@authority == "marc")) { - // otherwise, look at the marc genre - newItem.itemType = marcGenres[genre.text().toString()]; - } else if(!newItem.itemType && (genre.@authority == "dct")) { - // otherwise, look at the dct genre - newItem.itemType = dctGenres[genre.text().toString().replace(/\s+/g,"")]; - } - } - - if(!newItem.itemType) { - //try to get type information from typeOfResource - for each(var typeOfResource in mods.m::typeOfResource) { - newItem.itemType = modsTypeOfResources[typeOfResource.text().toString()]; - } - if(!newItem.itemType) { - // try to get genre data from host - for each(var relatedItem in mods.m::relatedItem) { - if(relatedItem.@type == "host") { - for each(var genre in relatedItem.m::genre) { - if(genre.@authority == "marcgt" || genre.@authority == "marc") { - newItem.itemType = marcGenres[genre.text().toString()]; - break; - } - } - } - } - } - - if(!newItem.itemType) newItem.itemType = "document"; - } - - var isPartialItem = partialItemTypes.indexOf(newItem.itemType) !== -1; - - // TODO: thesisType, type - - for each(var name in mods.m::name) { - // TODO: institutional authors - var creator = {}; - creator.firstName = ""; - for each(var namePart in name.m::namePart) { - if(namePart.@type == "given") { - if(creator.firstName != "") - creator.firstName = creator.firstName + " "; - creator.firstName = creator.firstName + namePart.text().toString(); - } else if(namePart.@type == "family") { - creator.lastName = namePart.text().toString(); - } else if(namePart.@type == "date" || namePart.@type == "termsOfAddress") { - // ignore these non name types for now - } else { - var backupName = namePart.text().toString(); - } - } - - if(backupName && !creator.firstName && !creator.lastName) { - creator = Zotero.Utilities.cleanAuthor(backupName, "author", true); - creator.fieldMode = 1; - } - - // look for roles - for each(var role in name.m::role.m::roleTerm) { - if(role.@type == "code" && role.@authority == "marcrelator") { - if(role == "edt") { - creator.creatorType = "editor"; - } else if(role == "ctb") { - creator.creatorType = "contributor"; - } else if(role == "trl") { - creator.creatorType = "translator"; - } - } - } - if(!creator.creatorType) creator.creatorType = "author"; - - newItem.creators.push(creator); - } - - // source - newItem.source = mods.m::recordInfo.m::recordContentSource.text().toString(); - // accessionNumber - newItem.accessionNumber = mods.m::recordInfo.m::recordIdentifier.text().toString(); - // rights - newItem.rights = mods.m::accessCondition.text().toString(); - - /** SUPPLEMENTAL FIELDS **/ - - var part = false, originInfo = false; - - // series - for each(var relatedItem in mods.m::relatedItem) { - if(relatedItem.@type == "host") { - for each(var titleInfo in relatedItem.m::titleInfo) { - if(titleInfo.@type == "abbreviated") { - newItem.journalAbbreviation = titleInfo.m::title.text().toString(); - if(!newItem.publicationTitle) newItem.publicationTitle = newItem.journalAbbreviation; - } else { - newItem.publicationTitle = titleInfo.m::title.text().toString(); - } - } - part = relatedItem.m::part; - originInfo = relatedItem.m::originInfo; - processIdentifiers(newItem, relatedItem.m::identifier); - } else if(relatedItem.@type == "series") { - newItem.series = relatedItem.m::titleInfo.m::title.text().toString(); - newItem.seriesTitle = relatedItem.m::titleInfo.m::partTitle.text().toString(); - newItem.seriesText = relatedItem.m::titleInfo.m::subTitle.text().toString(); - newItem.seriesNumber = relatedItem.m::titleInfo.m::partNumber.text().toString(); - } - } - - // get part - if(!part) { - part = mods.m::part; - originInfo = mods.m::originInfo; - } - - if(part) { - for each(var detail in part.m::detail) { - // volume - if(detail.@type == "volume") { - newItem.volume = detail.m::number.text().toString(); - if(!newItem.volume) { - newItem.volume = detail.m::text.text().toString(); - } - } - - // number - if(detail.@type == "issue") { - newItem.issue = detail.m::number.text().toString(); - if(!newItem.issue) { - newItem.issue = detail.m::text.text().toString(); - } - } - - // section - if(detail.@type == "section") { - newItem.section = detail.m::number.text().toString(); - if(!newItem.section) { - newItem.section = detail.m::text.text().toString(); - } - } - } - - // pages - for each(var extent in part.m::extent) { - if(extent.@unit == "pages" || extent.@unit == "page") { - var pagesStart = extent.m::start.text().toString(); - var pagesEnd = extent.m::end.text().toString(); - if(pagesStart || pagesEnd) { - if(pagesStart == pagesEnd) { - newItem.pages = pagesStart; - } else if(pagesStart && pagesEnd) { - newItem.pages = pagesStart+"-"+pagesEnd; - } else { - newItem.pages = pagesStart+pagesEnd; - } - } - } - } - } - - // identifier - processIdentifiers(newItem, mods.m::identifier); - // edition - newItem.edition = originInfo.m::edition.text().toString(); - // place - for each(var placeTerm in originInfo.m::place.m::placeTerm) { - if(placeTerm.@type == "text") { - newItem.place = placeTerm.text().toString(); - } - } - // publisher/distributor - if(originInfo.m::publisher.length()) { - if(newItem.itemType == "webpage" || newItem.itemType == "website") { - newItem.publicationTitle = originInfo.m::publisher[0].text().toString(); - } else { - newItem.publisher = originInfo.m::publisher[0].text().toString(); - } - } - // date - if(originInfo.m::copyrightDate.length()) { - newItem.date = originInfo.m::copyrightDate[0].text().toString(); - } else if(originInfo.m::dateIssued.length()) { - newItem.date = originInfo.m::dateIssued[0].text().toString(); - } else if(originInfo.m::dateCreated.length()) { - newItem.date = originInfo.m::dateCreated[0].text().toString(); - } - // lastModified - newItem.lastModified = originInfo.m::dateModified.text().toString(); - // accessDate - newItem.accessDate = originInfo.m::dateCaptured.text().toString(); - - // call number - newItem.callNumber = mods.m::classification.text().toString(); - // archiveLocation - newItem.archiveLocation = mods.m::location.m::physicalLocation.text().toString(); - // attachments and url - for each(var url in mods.m::location.m::url) { - var value = url.text().toString(); - if (url.@access == "raw object") { - var filetitle; - if (url.@displayLabel){ - filetitle = url.@displayLabel.toString(); - } else { - filetitle = "Attachment"; - } - if (value.substr(-4,4)==".pdf") { - newItem.attachments.push({url:value, mimeType:"application/pdf", title:filetitle, downloadable:true}); - } else { - newItem.attachments.push({url:value, title:filetitle, downloadable:true}); - } - } else { - newItem.url = value; - } - } - // abstract - newItem.abstractNote = mods.m::abstract.text().toString(); - - /** NOTES **/ - for each(var note in mods.m::note) { - newItem.notes.push({note:note.text().toString()}); - } - - /** TAGS **/ - for each(var subject in mods.m::subject.m::topic) { - newItem.tags.push(subject.text().toString()); - } - - // Language - // create an array of languages - var languages = new Array(); - for each(var language in mods.m::language) { - var code = false; - for each(var term in language.m::languageTerm) { - if (term.@type == "text") { - languages.push(term.text().toString()); - code = false; - break; - // code authorities should be used, not ignored - // but we ignore them for now - } else if (term.@type == "code" || term.@authority) { - code = term.text().toString(); - } - } - // If we have a code or text content of the node - // (prefer the former), then we add that - if (code || (code = language.text().toString())) { - languages.push(code); - } - } - // join the list separated by semicolons & add it to zotero item - newItem.language = languages.join('; '); - - Zotero.setProgress(i++/nModsElements*100); - newItem.complete(); - } -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "import", - "input": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\u000a<modsCollection xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.loc.gov/mods/v3\" xsi:schemaLocation=\"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd\">\u000a<mods version=\"3.3\">\u000a <titleInfo>\u000a \u0009 \u0009<title>FranUlmer.com -- Home Page</title>\u000a \u0009</titleInfo>\u000a \u0009<titleInfo type=\"alternative\"><title>Fran Ulmer, Democratic candidate for Governor, Alaska, 2002</title>\u000a \u0009</titleInfo>\u000a \u0009<name type=\"personal\">\u000a \u0009 \u0009<namePart>Ulmer, Fran</namePart>\u000a \u0009</name>\u000a \u0009<genre>Web site</genre>\u000a \u0009<originInfo>\u000a \u0009 \u0009<dateCaptured point=\"start\" encoding=\"iso8601\">20020702 </dateCaptured>\u000a \u0009 \u0009<dateCaptured point=\"end\" encoding=\"iso8601\"> 20021203</dateCaptured>\u000a \u0009</originInfo>\u000a \u0009<language>\u000a \u0009 \u0009<languageTerm authority=\"iso639-2b\">eng</languageTerm>\u000a \u0009</language>\u000a \u0009<physicalDescription>\u000a \u0009 \u0009<internetMediaType>text/html</internetMediaType>\u000a \u0009 \u0009<internetMediaType>image/jpg</internetMediaType>\u000a \u0009</physicalDescription>\u000a \u0009<abstract>Web site promoting the candidacy of Fran Ulmer, Democratic candidate for Governor, Alaska, 2002. Includes candidate biography, issue position statements, campaign contact information, privacy policy and campaign news press releases. Site features enable visitors to sign up for campaign email list, volunteer, make campaign contributions and follow links to other internet locations. </abstract>\u000a \u0009<subject>\u000a \u0009 \u0009<topic>Elections</topic>\u000a \u0009 \u0009<geographic>Alaska</geographic>\u000a \u0009</subject>\u000a \u0009<subject>\u000a \u0009 \u0009<topic>Governors</topic>\u000a \u0009 \u0009<geographic>Alaska</geographic>\u000a \u0009 \u0009<topic>Election</topic>\u000a \u0009</subject>\u000a \u0009<subject>\u000a \u0009 \u0009<topic>Democratic Party (AK)</topic>\u000a \u0009</subject>\u000a \u0009<relatedItem type=\"host\">\u000a \u0009 \u0009<titleInfo>\u000a \u0009 \u0009 \u0009<title>Election 2002 Web Archive</title>\u000a \u0009 \u0009</titleInfo>\u000a \u0009 \u0009<location>\u000a \u0009 \u0009 \u0009<url>http://www.loc.gov/minerva/collect/elec2002/</url>\u000a \u0009 \u0009</location>\u000a \u0009</relatedItem>\u000a \u0009<location>\u000a \u0009 \u0009<url displayLabel=\"Active site (if available)\">http://www.franulmer.com/</url>\u000a \u0009</location>\u000a \u0009<location>\u000a \u0009 \u0009<url displayLabel=\"Archived site\">http://wayback-cgi1.alexa.com/e2002/*/http://www.franulmer.com/</url>\u000a \u0009</location>\u000a</mods>\u000a</modsCollection>", - "items": [ - { - "itemType": "document", - "creators": [ - { - "firstName": "Fran", - "lastName": "Ulmer", - "creatorType": "author", - "fieldMode": 1 - } - ], - "notes": [], - "tags": [ - "Elections", - "Governors", - "Election", - "Democratic Party (AK)" - ], - "seeAlso": [], - "attachments": [], - "title": "FranUlmer.com -- Home Page", - "publicationTitle": "Election 2002 Web Archive", - "url": "http://wayback-cgi1.alexa.com/e2002/*/http://www.franulmer.com/", - "abstractNote": "Web site promoting the candidacy of Fran Ulmer, Democratic candidate for Governor, Alaska, 2002. Includes candidate biography, issue position statements, campaign contact information, privacy policy and campaign news press releases. Site features enable visitors to sign up for campaign email list, volunteer, make campaign contributions and follow links to other internet locations.", - "language": "eng" - } - ] - }, - { - "type": "import", - "input": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\u000a<modsCollection xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.loc.gov/mods/v3\" xsi:schemaLocation=\"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd\">\u000a<mods version=\"3.3\">\u000a <titleInfo>\u000a \u0009 \u0009<title>At Gettysburg, or, What a Girl Saw and Heard of the Battle: A True Narrative</title>\u000a \u0009</titleInfo>\u000a \u0009<name type=\"personal\">\u000a \u0009 \u0009<namePart>Alleman, Tillie Pierce [1848-1914]</namePart>\u000a \u0009 \u0009<role>\u000a \u0009 \u0009 \u0009<roleTerm type=\"code\" authority=\"marcrelator\">aut</roleTerm>\u000a \u0009 \u0009 \u0009<roleTerm type=\"text\" authority=\"marcrelator\">Author</roleTerm>\u000a \u0009 \u0009</role>\u000a \u0009</name>\u000a \u0009<typeOfResource>text</typeOfResource>\u000a \u0009<originInfo>\u000a \u0009 \u0009<place>\u000a \u0009 \u0009 \u0009<placeTerm type=\"text\">New York</placeTerm>\u000a \u0009 \u0009</place>\u000a \u0009 \u0009<publisher>W. Lake Borland</publisher>\u000a \u0009 \u0009<dateIssued keyDate=\"yes\" encoding=\"w3cdtf\">1889</dateIssued>\u000a \u0009</originInfo>\u000a \u0009<language>\u000a \u0009 \u0009<languageTerm authority=\"iso639-2b\">eng</languageTerm>\u000a \u0009 \u0009<languageTerm type=\"text\">English</languageTerm>\u000a \u0009</language>\u000a \u0009<physicalDescription>\u000a \u0009 \u0009<internetMediaType>text/html</internetMediaType>\u000a \u0009 \u0009<digitalOrigin>reformatted digital</digitalOrigin>\u000a \u0009</physicalDescription>\u000a \u0009<subject authority=\"lcsh\">\u000a \u0009 \u0009<topic >Gettysburg, Battle of, Gettysburg, Pa., 1863</topic>\u000a \u0009</subject>\u000a \u0009<subject authority=\"lcsh\">\u000a \u0009 \u0009<topic>Gettysburg (Pa.) -- History -- Civil War, 1861-1865</topic>\u000a \u0009</subject>\u000a \u0009<subject authority=\"lcsh\">\u000a \u0009 \u0009<topic>United States -- History -- Civil War, 1861-1865 -- Campaigns</topic>\u000a \u0009</subject>\u000a \u0009<classification authority=\"lcc\">E475.53 .A42</classification>\u000a \u0009<relatedItem type=\"host\">\u000a \u0009 \u0009<titleInfo type=\"uniform\" authority=\"dlfaqcoll\">\u000a \u0009 \u0009 \u0009<title>A Celebration of Women Writers: Americana</title>\u000a \u0009 \u0009</titleInfo>\u000a \u0009</relatedItem>\u000a \u0009<location>\u000a \u0009 \u0009<url usage=\"primary display\" access=\"object in context\"> http://digital.library.upenn.edu/women/alleman/gettysburg/gettysburg.html\u000a</url>\u000a \u0009</location>\u000a \u0009<accessCondition> Personal, noncommercial use of this item is permitted in the United States of America. Please see http://digital.library.upenn.edu/women/ for other rights and restrictions that may apply to this resource.\u000a</accessCondition>\u000a<recordInfo>\u000a \u0009<recordSource>University of Pennsylvania Digital Library</recordSource>\u000a \u0009<recordOrigin> MODS auto-converted from a simple Online Books Page metadata record. For details, see http://onlinebooks.library.upenn.edu/mods.html </recordOrigin>\u000a \u0009<languageOfCataloging>\u000a \u0009 \u0009<languageTerm type=\"code\" authority=\"iso639-2b\">eng</languageTerm>\u000a \u0009</languageOfCataloging>\u000a</recordInfo>\u000a</mods>\u000a</modsCollection>", - "items": [ - { - "itemType": "document", - "creators": [ - { - "firstName": "Tillie Pierce [1848-1914", - "lastName": "Alleman", - "creatorType": "author", - "fieldMode": 1 - } - ], - "notes": [], - "tags": [ - "Gettysburg, Battle of, Gettysburg, Pa., 1863", - "Gettysburg (Pa.) -- History -- Civil War, 1861-1865", - "United States -- History -- Civil War, 1861-1865 -- Campaigns" - ], - "seeAlso": [], - "attachments": [], - "title": "At Gettysburg, or, What a Girl Saw and Heard of the Battle: A True Narrative", - "rights": "Personal, noncommercial use of this item is permitted in the United States of America. Please see http://digital.library.upenn.edu/women/ for other rights and restrictions that may apply to this resource.", - "publicationTitle": "A Celebration of Women Writers: Americana", - "callNumber": "E475.53 .A42", - "url": "http://digital.library.upenn.edu/women/alleman/gettysburg/gettysburg.html", - "language": "English" - } - ] - }, - { - "type": "import", - "input": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\u000a<modsCollection xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.loc.gov/mods/v3\" xsi:schemaLocation=\"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd\">\u000a<mods version=\"3.3\">\u000a <titleInfo>\u000a \u0009 \u0009<title>Telescope Peak from Zabriskie Point</title>\u000a \u0009</titleInfo>\u000a \u0009<titleInfo type=\"alternative\" >\u000a \u0009 \u0009<title>Telescope PK from Zabriskie Pt.</title>\u000a \u0009</titleInfo>\u000a \u0009<name type=\"personal\">\u000a \u0009 \u0009<namePart type=\"family\">Cushman</namePart>\u000a \u0009 \u0009<namePart type=\"given\">Charles Weever</namePart>\u000a \u0009 \u0009<namePart type=\"date\">1896-1972</namePart>\u000a \u0009 \u0009<role>\u000a \u0009 \u0009 \u0009<roleTerm type=\"code\" authority=\"marcrelator\">pht</roleTerm>\u000a \u0009 \u0009 \u0009<roleTerm type=\"text\" authority=\"marcrelator\">Photographer</roleTerm>\u000a \u0009 \u0009</role>\u000a \u0009</name>\u000a \u0009<typeOfResource>still image</typeOfResource>\u000a \u0009<genre authority=\"gmgpc\">Landscape photographs</genre>\u000a \u0009<originInfo>\u000a \u0009 \u0009<dateCreated encoding=\"w3cdtf\" keyDate=\"yes\">1955-03-22</dateCreated>\u000a \u0009 \u0009<copyrightDate encoding=\"w3cdtf\">2003</copyrightDate>\u000a \u0009</originInfo>\u000a \u0009<physicalDescription>\u000a \u0009 \u0009<internetMediaType>image/jpeg</internetMediaType>\u000a \u0009 \u0009<digitalOrigin>reformatted digital</digitalOrigin>\u000a \u0009 \u0009<note> Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available.</note>\u000a \u0009 \u0009<note>100 f 6.3 tl</note>\u000a \u0009</physicalDescription>\u000a \u0009<subject authority=\"lctgm\">\u000a \u0009 \u0009<topic>Mountains</topic>\u000a \u0009</subject>\u000a \u0009<subject authority=\"lctgm\">\u000a \u0009 \u0009<topic>Snow</topic>\u000a \u0009</subject>\u000a \u0009<subject>\u000a \u0009 \u0009<topic>Telescope Peak (Inyo County, Calif.)</topic>\u000a \u0009</subject>\u000a \u0009<subject>\u000a \u0009 \u0009<topic>Zabriskie Point (Calif.)</topic>\u000a \u0009</subject>\u000a \u0009<subject>\u000a \u0009 \u0009<hierarchicalGeographic>\u000a \u0009 \u0009 \u0009<country>United States</country>\u000a \u0009 \u0009 \u0009<state>California</state>\u000a \u0009 \u0009 \u0009<county>Inyo</county>\u000a \u0009 \u0009</hierarchicalGeographic>\u000a \u0009</subject>\u000a \u0009<relatedItem type=\"original\">\u000a \u0009 \u0009<originInfo>\u000a \u0009 \u0009 \u0009<dateCreated encoding=\"w3cdtf\" keyDate=\"yes\">1955-03-22</dateCreated>\u000a \u0009 \u0009</originInfo>\u000a \u0009 \u0009<physicalDescription>\u000a \u0009 \u0009 \u0009<form authority=\"gmd\">graphic</form>\u000a \u0009 \u0009 \u0009<extent>1 slide : col. ; 35mm</extent>\u000a \u0009 \u0009 \u0009<note>Original 35mm slide was digitized in 2003 as a TIFF image. Display versions in JPEG format in three sizes are available.</note>\u000a \u0009 \u0009</physicalDescription>\u000a \u0009 \u0009<location>\u000a \u0009 \u0009 \u0009<physicalLocation displayLabel=\"Original slide\"> Indiana University, Bloomington. University Archives P07803 </physicalLocation>\u000a \u0009 \u0009</location>\u000a \u0009</relatedItem>\u000a \u0009<relatedItem type=\"host\">\u000a \u0009 \u0009<titleInfo type=\"uniform\" authority=\"dlfaqcoll\">\u000a \u0009 \u0009 \u0009<title> Indiana University Digital Library Program: Charles W. Cushman Photograph Collection</title>\u000a \u0009 \u0009</titleInfo>\u000a \u0009</relatedItem>\u000a \u0009<identifier displayLabel=\"Cushman number\" type=\"local\">955.11</identifier>\u000a \u0009<identifier displayLabel=\"IU Archives number\" type=\"local\">P07803</identifier>\u000a \u0009<location>\u000a \u0009 \u0009<url>http://purl.dlib.indiana.edu/iudl/archives/cushman/P07803</url>\u000a \u0009 \u0009<url access=\"preview\">http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png</url>\u000a \u0009</location>\u000a \u0009<accessCondition> Copyright and reproduction rights for all Charles W. Cushman photographs are held by Indiana University and administered by the University Archives, Indiana University, Bloomington, IN 47405</accessCondition>\u000a \u0009<recordInfo>\u000a \u0009<recordContentSource>Indiana University Digital Library Program</recordContentSource>\u000a \u0009<recordCreationDate encoding=\"w3cdtf\">2004-09-09</recordCreationDate>\u000a \u0009<recordIdentifier>archives/cushman/P07803</recordIdentifier>\u000a \u0009</recordInfo>\u000a</mods>\u000a\u000a</modsCollection>", - "items": [ - { - "itemType": "artwork", - "creators": [ - { - "firstName": "Charles Weever", - "lastName": "Cushman", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Mountains", - "Snow", - "Telescope Peak (Inyo County, Calif.)", - "Zabriskie Point (Calif.)" - ], - "seeAlso": [], - "attachments": [], - "title": "Telescope Peak from Zabriskie Point", - "source": "Indiana University Digital Library Program", - "accessionNumber": "archives/cushman/P07803", - "rights": "Copyright and reproduction rights for all Charles W. Cushman photographs are held by Indiana University and administered by the University Archives, Indiana University, Bloomington, IN 47405", - "publicationTitle": "Indiana University Digital Library Program: Charles W. Cushman Photograph Collection", - "url": "http://quod.lib.umich.edu/m/mods/thumbs/Indiana/oai.dlib.indiana.edu/ archives/cushman/oai_3Aoai.dlib.indiana.edu_3Aarchives_5Ccushman_5CP07803.png" - } - ] - }, - { - "type": "import", - "input": "<modsCollection xmlns:xlink=\"http://www.w3.org/1999/xlink\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns=\"http://www.loc.gov/mods/v3\" xsi:schemaLocation=\"http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-3.xsd\">\u000a<mods version=\"3.3\">\u000a <titleInfo>\u000a \u0009 \u0009<title>Hiring and recruitment practices in academic libraries</title>\u000a \u0009</titleInfo>\u000a \u0009<name type=\"personal\">\u000a \u0009 \u0009<namePart>Raschke, Gregory K.</namePart>\u000a \u0009 \u0009<displayForm>Gregory K. Raschke</displayForm>\u000a \u0009</name>\u000a \u0009<typeOfResource>text</typeOfResource>\u000a \u0009<genre>journal article</genre>\u000a \u0009<originInfo>\u000a \u0009 \u0009<place>\u000a \u0009 \u0009 \u0009<text>Baltimore, Md.</text>\u000a \u0009 \u0009</place>\u000a \u0009 \u0009<publisher>Johns Hopkins University Press</publisher>\u000a \u0009 \u0009<dateIssued>2003</dateIssued>\u000a \u0009 \u0009<issuance>monographic</issuance>\u000a \u0009</originInfo>\u000a \u0009<language authority=\"iso639-2b\">eng</language>\u000a \u0009<physicalDescription>\u000a \u0009 \u0009<form authority=\"marcform\">print</form>\u000a \u0009 \u0009<extent>15 p.</extent>\u000a \u0009</physicalDescription>\u000a \u0009<abstract>\u000aAcademic libraries need to change their recruiting and hiring procedures to stay competitive in today's changing marketplace. By taking too long to find and to hire talented professionals in a tight labor market, academic libraries are losing out on top candidates and limiting their ability to become innovative and dynamic organizations. Traditional, deliberate, and risk-averse hiring models lead to positions remaining open for long periods, opportunities lost as top prospects find other positions, and a reduction in the overall talent level of the organization. To be more competitive and effective in their recruitment and hiring processes, academic libraries must foster manageable internal solutions, look to other professions for effective hiring techniques and models, and employ innovative concepts from modern personnel management literature. </abstract>\u000a \u0009<subject>\u000a \u0009 \u0009<topic>College librarians</topic>\u000a \u0009 \u0009<topic>Recruiting</topic>\u000a \u0009 \u0009<geographic>United States</geographic>\u000a \u0009</subject>\u000a \u0009<subject>\u000a \u0009 \u0009<topic>College librarians</topic>\u000a \u0009 \u0009<topic>Selection and appointment</topic>\u000a \u0009 \u0009<geographic>United States</geographic>\u000a \u0009</subject>\u000a \u0009<relatedItem type=\"host\">\u000a \u0009 \u0009<titleInfo>\u000a \u0009 \u0009 \u0009<title>portal: libraries and the academy</title>\u000a \u0009 \u0009</titleInfo>\u000a \u0009 \u0009<part>\u000a \u0009 \u0009 \u0009<detail type=\"volume\">\u000a \u0009 \u0009 \u0009 \u0009<number>3</number>\u000a \u0009 \u0009 \u0009 \u0009<caption>vol.</caption>\u000a \u0009 \u0009 \u0009</detail>\u000a \u0009 \u0009 \u0009<detail type=\"number\">\u000a \u0009 \u0009 \u0009 \u0009<number>1</number>\u000a \u0009 \u0009 \u0009 \u0009<caption>no.</caption>\u000a \u0009 \u0009 \u0009</detail>\u000a \u0009 \u0009 \u0009<extent unit=\"page\">\u000a \u0009 \u0009 \u0009 \u0009<start>53</start>\u000a \u0009 \u0009 \u0009 \u0009<end>57</end>\u000a \u0009 \u0009 \u0009</extent>\u000a \u0009 \u0009 \u0009<date>Jan. 2003</date>\u000a \u0009 \u0009</part>\u000a \u0009 \u0009<identifier type=\"issn\">1531-2542</identifier>\u000a \u0009</relatedItem>\u000a</mods>\u000a\u000a</modsCollection>", - "items": [ - { - "itemType": "document", - "creators": [ - { - "firstName": "Gregory K", - "lastName": "Raschke", - "creatorType": "author", - "fieldMode": 1 - } - ], - "notes": [], - "tags": [ - "College librarians", - "Recruiting", - "College librarians", - "Selection and appointment" - ], - "seeAlso": [], - "attachments": [], - "title": "Hiring and recruitment practices in academic libraries", - "publicationTitle": "portal: libraries and the academy", - "ISSN": "1531-2542", - "volume": "3", - "pages": "53-57", - "abstractNote": "Academic libraries need to change their recruiting and hiring procedures to stay competitive in today's changing marketplace. By taking too long to find and to hire talented professionals in a tight labor market, academic libraries are losing out on top candidates and limiting their ability to become innovative and dynamic organizations. Traditional, deliberate, and risk-averse hiring models lead to positions remaining open for long periods, opportunities lost as top prospects find other positions, and a reduction in the overall talent level of the organization. To be more competitive and effective in their recruitment and hiring processes, academic libraries must foster manageable internal solutions, look to other professions for effective hiring techniques and models, and employ innovative concepts from modern personnel management literature.", - "language": "eng" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Mainichi Daily News.js b/translators/Mainichi Daily News.js @@ -1,121 +0,0 @@ -{ - "translatorID":"b56f856e-934e-4b46-bc58-d61dccc9f32f", - "translatorType":4, - "label":"Mainichi Daily News", - "creator":"Frank Bennett", - "target":"^http://(?:search\\.)*mdn\\.mainichi\\.jp/(?:$|result\\?|mdnnews/|perspectives/|features/|arts/|travel/)", - "minVersion":"2.0b7", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-06-05 20:35:00" -} - -// ################################# -// #### Local utility functions #### -// ################################# - -var itemRe = new RegExp('.*/([0-9]{8})[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{2}[a-z]{1}[0-9]{1}[a-z]{2}[0-9]{6}c\.html'); - -var getResolver = function (doc) { - var namespace, resolver; - namespace = doc.documentElement.namespaceURI; - if (namespace) { - resolver = function(prefix) { - if (prefix == 'x') { - return namespace; - } else { - return null; - } - }; - } else { - resolver = null; - } - return resolver; -}; - -var cleanUp = function (str) { - var ret; - ret = str.replace("\u00a0", " ", "g").replace("\n", " ", "g"); - ret = ret.replace(/^\s+/, "").replace(/\s+$/, "").replace(/\s+/g, " "); - ret = ret.replace(/\|.*/, "").replace(/<[^>]+>/g, "");; - ret = Zotero.Utilities.unescapeHTML(ret); - return ret; -} - - -// ######################### -// ##### API functions ##### -// ######################### - -var detectWeb = function (doc, url) { - if (itemRe.test(doc.location.href)) { - return "newspaperArticle"; - } else { - return "multiple"; - } -} - -var doWeb = function (doc, url) { - var type, nsResolver, availableItems, xpath, found, nodes, headline, pos, myurl, m, items, title; - nsResolver = getResolver(doc); - type = detectWeb(doc, url); - if (type === "multiple") { - availableItems = {}; - if (url.match(/^http:\/\/search\.mdn\.mainichi\.jp\/result\?/)){ - xpath = '//div[@class="ResultTitle"]/a[contains(@href, "mdn.mainichi.jp")]'; - } else { - xpath = '//h2[@class="NewsTitle"]/a[@href]|//ul[@class="Mark"]/li/a[@href]'; - } - nodes = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - found = nodes.iterateNext(); - while (found) { - if (!itemRe.test(found.href)) { - found = nodes.iterateNext(); - continue; - } - headline = found.textContent; - headline = cleanUp(headline); - availableItems[found.href] = headline; - found = nodes.iterateNext(); - } - if (availableItems.__count__) { - items = Zotero.selectItems(availableItems); - for (myurl in items) { - if (items.hasOwnProperty(myurl)) { - scrapeAndParse(myurl, availableItems[myurl]); - } - } - } - } else if (type === "newspaperArticle") { - xpath = '//h2[@class="NewsTitle"]'; - nodes = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - title = nodes.iterateNext(); - if (title) { - title = cleanUp(title.textContent); - scrapeAndParse(url, title); - } - } -}; - -// ############################ -// ##### Scraper function ##### -// ############################ - -var scrapeAndParse = function (url, title) { - var item, mytxt, m, val; - item = new Zotero.Item("newspaperArticle"); - item.title = title; - item.publicationTitle = "Mainichi Daily News"; - item.edition = "online edition"; - item.url = url; - m = itemRe.exec(url); - if (m) { - var year = m[1].slice(0,4); - var month = m[1].slice(4,6); - var day = m[1].slice(6,8); - item.date = [year, month, day].join("-"); - } - item.attachments.push({title:"Mainichi Daily News snapshot", mimeType:"text/html", url:url}); - item.complete(); -}; diff --git a/translators/Matbugat.ru.js b/translators/Matbugat.ru.js @@ -1,70 +0,0 @@ -{ - "translatorID": "4f7c1422-2eef-4d22-a4be-8e1a78ef7bd2", - "label": "Matbugat.ru", - "creator": "Avram Lyon", - "target": "^https?:\\/\\/(www\\.)?matbugat\\.ru\\/", - "minVersion": "2.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-24 01:07:06" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};/* - Matbugat.ru 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 FW.detectWeb(doc, url); -} -function doWeb(doc, url) { return FW.doWeb(doc, url); } - - -/** Articles */ -FW.Scraper({ itemType : 'newspaperArticle', - detect : FW.Xpath('//td[@class="table_main_news_right"]/font[@class="news_title"]'), - title : FW.Xpath('//td[@class="table_main_news_right"]/font[@class="news_title"]').text().trim(), - attachments : [ - { - url : FW.Url(), - type : "text/html", - title : "Matbugat.ru Snapshot" - - }], - creators : FW.Xpath('//td[@class="table_news_author"]/text()[1]').text().cleanAuthor("author"), - date : FW.Xpath('//td[@class="table_news_author"]').text().match(/(\d{1,2}\.\d{1,2}\.\d{4})/,1), - edition : FW.Xpath('//td[@class="table_news_author"]').text().match(/(№\s+[^\s|]+)/,1), - section : FW.Xpath('//td[@class="table_news_subject"]').text().match(/(\d{1,2}\.\d{1,2}\.\d{4})\s+(.*)/,2), - publicationTitle : FW.Xpath('//td[@class="table_news_author"]/a[@class="paper_link"]').text(), - hooks : { "scraperDone": function (item,doc, url) { Zotero.debug("hi!"); - for (i in item.creators) { - if (item.creators[i].lastName == item.creators[i].lastName.toUpperCase()) { - item.creators[i].lastName = Zotero.Utilities.capitalizeTitle( - item.creators[i].lastName.toLowerCase(),true); - } - } - }} - }); - - -/** Search results */ -FW.MultiScraper({ itemType : "multiple", - detect : FW.Xpath('//a[@class="news_preview"]'), - choices : { titles : FW.Xpath('//a[@class="news_title"]').text(), - urls : FW.Xpath('//a[@class="news_title"]').key('href').text() } -}); diff --git a/translators/Max Planck Institute for the History of Science Virtual Laboratory Library.js b/translators/Max Planck Institute for the History of Science Virtual Laboratory Library.js @@ -1,75 +0,0 @@ -{ - "translatorID":"66928fe3-1e93-45a7-8e11-9df6de0a11b3", - "translatorType":4, - "label":"Max Planck Institute for the History of Science: Virtual Laboratory Library", - "creator":"Sean Takats", - "target":"http://vlp.mpiwg-berlin.mpg.de/library/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var elmt = doc.evaluate('//base[contains(@href, "/library/data/lit")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (elmt){ - return "book"; - } - elmt = doc.evaluate('//span[starts-with(@title, "lit")] | //a[starts-with(@title, "lit")] | //p[starts-with(@title, "lit")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (elmt){ - return "multiple"; - } -} - -function doWeb(doc, url){ - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var uris = new Array(); - var baseElmt = doc.evaluate('//base[contains(@href, "/library/data/lit")]/@href', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (baseElmt){ - var docID = baseElmt.nodeValue; - var idRe = /lit[0-9]+/; - var m = idRe.exec(docID); - uris.push("http://vlp.mpiwg-berlin.mpg.de/library/meta?id=" + m[0]); - } else { - var searchElmts = doc.evaluate('//span[starts-with(@title, "lit")] | //a[starts-with(@title, "lit")] | //p[starts-with(@title, "lit")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var searchElmt; - var links = new Array(); - var availableItems = new Array(); - var i = 0; - while (searchElmt = searchElmts.iterateNext()){ - availableItems[i] = Zotero.Utilities.trimInternal(searchElmt.textContent); - var docID = doc.evaluate('./@title', searchElmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - links.push("http://vlp.mpiwg-berlin.mpg.de/library/meta?id=" + docID); - i++; - } - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - var uris = new Array(); - for(var i in items) { - uris.push(links[i]); - } - } - Zotero.Utilities.HTTP.doGet(uris, function(text) { - // load Refer translator - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("881f60f2-0802-411a-9228-ce5f47b64c7d"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.type = undefined; - item.complete(); - }); - translator.translate(); - }, function() {Zotero.done();}, null); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Melvyl.js b/translators/Melvyl.js @@ -1,137 +0,0 @@ -{ - "translatorID":"5e3e6245-83da-4f55-a39b-b712df54a935", - "translatorType":4, - "label":"Melvyl", - "creator":"Sean Takats and Michael Berkowitz", - "target":"^https?://(?:melvyl.cdlib.org|melvyl-dev.cdlib.org:8162)/F(?:/[A-Z0-9\\-]+(?:\\?.*)?$|\\?func=find|\\?func=scan)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":90, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var singleRe = new RegExp("^https?://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=[0-9]{3}|func=direct)"); - - if(singleRe.test(doc.location.href)) { - return "book"; - } else { - var tags = doc.getElementsByTagName("a"); - for(var i=0; i<tags.length; i++) { - if(singleRe.test(tags[i].href)) { - return "multiple"; - } - } - } -} - -function doWeb(doc, url) { - var detailRe = new RegExp("^https?://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=[0-9]{3}|func=direct)"); - var uri = doc.location.href; - var newUris = new Array(); - - if(detailRe.test(uri)) { - newUris.push(uri.replace(/\&format=[0-9]{3}/, "&format=001")) - } else { - var itemRegexp = '^https?://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=999|func=direct)'; - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var reviewXpath = '//table/tbody/tr[td[@class="resultsDisplayWhite"]]' - - var reviewRows = doc.evaluate(reviewXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var reviewRow; - - var items = new Array(); - - if (reviewRow = reviewRows.iterateNext()){ - var xpath = './td[@class="resultsDisplayWhite"][2]/a[1]'; - var titleXpath = './td[@class="resultsDisplayWhite"][5]'; - var elmt; - var titleElmt; - do { - elmt = doc.evaluate(xpath, reviewRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - titleElmt = doc.evaluate(titleXpath, reviewRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - items[elmt.href] = Zotero.Utilities.trimInternal(titleElmt.textContent); - } while (reviewRow = reviewRows.iterateNext()); - - } else { - var xpath = '//td[2][@class="resultsBrief"]/a[1]'; // gets MELVYL links - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - var titleXpath = '//tr[td[@class="resultsBrief"][@id="bold"]/b[text()="Title"]]/td[4]'; // gets MELVYL results titles - var titleElmts = doc.evaluate(titleXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titleElmt; - while ((elmt = elmts.iterateNext()) && (titleElmt = titleElmts.iterateNext())){ - items[elmt.href] = Zotero.Utilities.trimInternal(titleElmt.textContent); - } - } - - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - for(var i in items) { - var newUri = i.replace(/\&format=[0-9]{3}/, "&format=001") - if(newUri == i) { - newUri += "&format=001"; - } - newUris.push(newUri); - } - } - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.processDocuments(newUris, function(newDoc) { - var uri = newDoc.location.href; - - var namespace = newDoc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '//tr[td[1][@class="contentSmall"][@id="bold"]/strong]'; - var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt; - - var record = new marc.record(); - while(elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.trimInternal(newDoc.evaluate('./TD[1]/strong/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - var value = newDoc.evaluate('./TD[2]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - if(field == "LDR") { - record.leader = value; - } else if(field != "FMT") { - - value = value.replace(/\|([a-z]) /g, marc.subfieldDelimiter+"$1"); - - var code = field.substring(0, 3); - var ind = ""; - if(field.length > 3) { - ind = field[3]; - if(field.length > 4) { - ind += field[4]; - } - } - record.addField(code, ind, value); - } - } - - var newItem = new Zotero.Item(); - record.translate(newItem); - - var domain = url.match(/https?:\/\/([^/]+)/); - newItem.repository = domain[1]+" Library Catalog"; - - newItem.complete(); - }, function() { Zotero.done(); }, null); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/MetaPress.js b/translators/MetaPress.js @@ -1,57 +0,0 @@ -{ - "translatorID":"62c0e36a-ee2f-4aa0-b111-5e2cbd7bb5ba", - "translatorType":4, - "label":"MetaPress", - "creator":"Michael Berkowitz", - "target":"https?://(.*).metapress.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-03-13 22:30:00" -} - -function detectWeb(doc, url) { - if (doc.title.indexOf("Search Results") != -1) { - return "multiple"; - } else if (url.match(/content\/[^?/]/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var host = doc.location.host; - var artids = new Array(); - if (detectWeb(doc, url) == "multiple") { - - } else { - artids.push(url.match(/content\/([^/]+)/)[1]); - } - for (var i in artids) { - var newurl = 'http://' + host + '/content/' + artids[i]; - Zotero.Utilities.processDocuments([newurl], function(newDoc) { - var tagsx = '//td[@class="mainPageContent"]/div[3]'; - if (doc.evaluate(tagsx, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var tags = Zotero.Utilities.trimInternal(doc.evaluate(tagsx, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent).split(","); - } - Zotero.Utilities.HTTP.doPost('http://' + host + '/export.mpx', 'code=' + artids[i] + '&mode=ris', function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var pdfurl = 'http://' + host + '/content/' + artids[i] + '/fulltext.pdf'; - item.attachments = [ - {url:item.url, title:"MetaPress Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"MetaPress Full Text PDF", mimeType:"application/pdf"} - ]; - if (tags) item.tags = tags; - if (item.abstractNote.substr(0, 8) == "Abstract") item.abstractNote = Zotero.Utilities.trimInternal(item.abstractNote.substr(8)); - item.complete(); - }); - translator.translate(); - Zotero.done(); - }); - }, function() {}); - } -} -\ No newline at end of file diff --git a/translators/Musee du Louvre.js b/translators/Musee du Louvre.js @@ -1,163 +0,0 @@ -{ - "translatorID":"22d17fb9-ae32-412e-bcc4-7650ed3359bc", - "translatorType":4, - "label":"Musee du Louvre", - "creator":"Adam Crymble", - "target":"http://www.louvre.fr", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "browserSupport":"g", - "inRepository":true, - "lastUpdated":"2011-08-22 22:44:24" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("recherche")) { - return "multiple"; - } else if (doc.evaluate('//div[@class="alignRight"]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "artwork"; - } - -} - -//Translator Musee du Louvre. Code by Adam Crymble - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - - var newItem = new Zotero.Item("artwork"); - - //tags - var metaTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < metaTagHTML.length ; i++) { - dataTags[metaTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content")); - } - - newItem.abstractNote = dataTags["description"]; - - if (dataTags["keywords"]) { - if (dataTags["keywords"].match(", ")) { - tagsContent = tagsContent = dataTags["keywords"].split(", "); - } else if (dataTags["keywords"].split("、")) { - tagsContent = dataTags["keywords"].split("、"); - } - } - - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - - //date - var xPathDate = '//td[@class="txtContent"]/span[@class="txtContentSmall"]'; - - if (doc.evaluate(xPathDate, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - newItem.date = doc.evaluate(xPathDate, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - //creator - var xPathCreator = '//td[@class="txtContent"]/strong'; - if (doc.evaluate(xPathCreator, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var creator = doc.evaluate(xPathCreator, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.toLowerCase(); - - var comma = 0; - var parenthesis = 0; - var commaSpot; - var parenthesisSpot; - - if (creator.match(", ")) { - comma = 1; - commaSpot = creator.indexOf(","); - } - - if (creator.match(/\(/)) { - parenthesis = 1; - parenthesisSpot = creator.indexOf(" ("); - } - - if (comma == 1 && parenthesis == 1) { - if (commaSpot < parenthesisSpot) { - creator = creator.substr(0, commaSpot); - } else { - creator = creator.substr(0, parenthesisSpot); - } - } else if (comma == 1 && parenthesis == 0) { - creator = creator.substr(0, commaSpot); - } else if (comma == 0 && parenthesis == 1) { - creator = creator.substr(0, parenthesisSpot); - } - - var words = creator.split(" "); - - for (var j in words) { - if (words[j] != "" && words[j] != ' ') { - if (words[j].match("-")) { - Zotero.debug(words[j]); - var hyphen = words[j].split("-"); - hyphen[0] = hyphen[0][0].toUpperCase() + hyphen[0].substr(1).toLowerCase() + "-"; - hyphen[1] = hyphen[1][0].toUpperCase() + hyphen[1].substr(1).toLowerCase(); - words[j] = hyphen[0] + hyphen[1]; - } else { - words[j] = words[j][0].toUpperCase() + words[j].substr(1).toLowerCase(); - } - } - } - creator = words.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(creator, "artist")); - } - - - //title - var title1 = doc.title.split(" |"); - Zotero.debug(title1[0]); - newItem.title = title1[0]; - - //extra - if (doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var collection1 = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.extra = collection1.replace(/^\s*|\s*$/g, ''); - } - - newItem.repository = "Musée du Louvre"; - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var links = doc.evaluate('//td[4][@class="alignTop"]/a[@class="lkContent"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('//h4', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[links.iterateNext().href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/NASA ADS.js b/translators/NASA ADS.js @@ -1,81 +0,0 @@ -{ - "translatorID":"7987b420-e8cb-4bea-8ef7-61c2377cd686", - "translatorType":4, - "label":"NASA ADS", - "creator":"Asa Kusuma and Ramesh Srigiriraju", - "target":"http://(ukads|cdsads|ads|adsabs|esoads|adswww|www.ads)\\.(inasan|iucaa.ernet|nottingham.ac|harvard|eso|u-strasbg|nao.ac|astro.puc|bao.ac|on|kasi.re|grangenet|lipi.go|mao.kiev)\\.(edu|org|net|fr|jp|cl|id|uk|cn|ua|in|ru|br|kr)/(?:cgi-bin|abs)/", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var singXpath = '//input[@name="bibcode"][@type="hidden"]'; - var multXpath = '//input[@name="bibcode"][@type="checkbox"]'; - - if (doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate(singXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "journalArticle"; - } -} - -function parseRIS(bibcodes, hostname){ - var getURL = "http://" + hostname + "/cgi-bin/nph-bib_query?" - + bibcodes + "data_type=REFMAN&nocookieset=1"; - Zotero.Utilities.HTTP.doGet(getURL, function(text){ - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - Zotero.done(); - }, function() {}); - Zotero.wait(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var singXpath = '//input[@name="bibcode"][@type="hidden"]'; - var multXpath = '//input[@name="bibcode"][@type="checkbox"]'; - var titleXpath = '//table/tbody/tr/td[4]'; //will find scores and titles - var hostname = doc.location.host - var bibElmts = doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titleElmts = doc.evaluate(titleXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titleElmt; - var bibElmt; - - if ((bibElmt = bibElmts.iterateNext()) && (titleElmt = titleElmts.iterateNext())) { - - var items = new Array(); - - do { - titleElmt = titleElmts.iterateNext(); //iterate a second time to avoid score - items[bibElmt.value] = Zotero.Utilities.trimInternal(titleElmt.textContent); - } while((bibElmt = bibElmts.iterateNext()) && (titleElmt = titleElmts.iterateNext())); - items = Zotero.selectItems(items); - if(!items) return true; - - var bibcodes=""; - for(var bibcode in items) { - bibcodes = bibcodes + "bibcode="+encodeURIComponent(bibcode) + "&"; - } - parseRIS(bibcodes, hostname); - - } else if (bibElmt = doc.evaluate(singXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - var bibcode = bibElmt.value; - var bibcodes = "bibcode="+encodeURIComponent(bibcode) + "&"; - parseRIS(bibcodes, hostname); - } -} -\ No newline at end of file diff --git a/translators/NCBI PubMed.js b/translators/NCBI PubMed.js @@ -1,359 +0,0 @@ -{ - "translatorID":"fcf41bed-0cbc-3704-85c7-8062a0068a7a", - "translatorType":13, - "label":"NCBI PubMed", - "creator":"Simon Kornblith, Michael Berkowitz, Avram Lyon, and Rintze Zelle", - "target":"https?://[^/]*(www|preview)\\.ncbi\\.nlm\\.nih\\.gov[^/]*/(pubmed|sites/pubmed|sites/entrez|entrez/query\\.fcgi\\?.*db=PubMed)", - "minVersion":"2.1.9", - "maxVersion":"", - "priority":100, - "browserSupport":"gcs", - "configOptions":{"dataMode":"block"}, - "inRepository":true, - "lastUpdated":"2011-07-01 04:22:03" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var items = doc.evaluate('//input[@name="EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_ResultsController.ResultCount"]', doc, - nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (items) { - Zotero.debug("Have ResultCount " + items.value); - if (items.value > 1) { - return "multiple"; - } else if (items.value == 1) { - return "journalArticle"; - } - } - - var uids = doc.evaluate('//input[@type="checkbox" and @name="EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_RVDocSum.uid"]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - if(uids.iterateNext()) { - if (uids.iterateNext()){ - return "multiple"; - } - return "journalArticle"; - } -} - -function getPMID(co) { - var coParts = co.split("&"); - for each(part in coParts) { - if(part.substr(0, 7) == "rft_id=") { - var value = unescape(part.substr(7)); - if(value.substr(0, 10) == "info:pmid/") { - return value.substr(10); - } - } - } -} - -function detectSearch(item) { - if(item.contextObject) { - if(getPMID(item.contextObject)) { - return "journalArticle"; - } - } - return false; -} - - -function lookupPMIDs(ids, doc) { - var newUri = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=PubMed&tool=Zotero&retmode=xml&rettype=citation&id="+ids.join(","); - Zotero.debug(newUri); - Zotero.Utilities.HTTP.doGet(newUri, doImportFromText, function () {Zotero.done()}); - Zotero.wait(); -} - -function doImport() { - var text = ""; - var line; - while((line = Zotero.read(4096)) !== false) { - text += line; - } - return doImportFromText(text); -} - -function detectImport() { - Zotero.debug("Detecting Pubmed content...."); - var text = ""; - var line; - while(line = Zotero.read(1000)) { - text += line; - // Look for the PubmedArticle tag in the first 1000 characters - if (text.match(/<PubmedArticle>/)) return "journalArticle"; - else if (text.length > 1000) return false; - } - return false; -} - -function doImportFromText(text) { - if (!text.substr(0,1000).match(/<PubmedArticleSet>/)) { - // Pubmed data in the wild, perhaps copied from the web site's search results, - // can be missing the <PubmedArticleSet> root tag. Let's add a pair! - Zotero.debug("No root <PubmedArticleSet> tag found, wrapping in a new root tag."); - text = "<PubmedArticleSet>" + text + "</PubmedArticleSet>"; - } - - // parse XML with DOMParser - var parser = new DOMParser(); - var doc = parser.parseFromString(text, "text/xml"); - - var articles = ZU.xpath(doc, '/PubmedArticleSet/PubmedArticle'); - for(var i in articles) { - var newItem = new Zotero.Item("journalArticle"); - - var citation = ZU.xpath(articles[i], 'MedlineCitation'); - var PMID = ZU.xpathText(citation, 'PMID'); - newItem.url = "http://www.ncbi.nlm.nih.gov/pubmed/" + PMID; - newItem.extra = "PMID: "+PMID; - - var article = ZU.xpath(citation, 'Article'); - var title = ZU.xpathText(article, 'ArticleTitle'); - if(title) { - if(title.substr(-1) == ".") { - title = title.substring(0, title.length-1); - } - newItem.title = title; - } - - var fullPageRange = ZU.xpathText(article, 'Pagination/MedlinePgn'); - if(fullPageRange) { - var pageRange = fullPageRange.match(/\d+-\d+/g); - for (var j in pageRange) { - var pageRangeStart = pageRange[j].match(/^\d+/)[0]; - var pageRangeEnd = pageRange[j].match(/\d+$/)[0]; - if (pageRangeStart.length > pageRangeEnd.length) { - pageRangeEnd = pageRangeStart.substring(0,pageRangeStart.length-pageRangeEnd.length) + pageRangeEnd; - fullPageRange = fullPageRange.replace(pageRange[j],pageRangeStart+"-"+pageRangeEnd); - } - } - newItem.pages = fullPageRange; - } - - var journal = ZU.xpath(article, 'Journal'); - if(journal.length) { - newItem.ISSN = ZU.xpathText(journal, 'ISSN'); - - var abbreviation; - if((abbreviation = ZU.xpathText(journal, 'ISOAbbreviation'))) { - newItem.journalAbbreviation = abbreviation; - } else if((abbreviation = ZU.xpathText(journal, 'MedlineTA'))) { - newItem.journalAbbreviation = abbreviation; - } - - var title = ZU.xpathText(journal, 'Title'); - if(title) { - newItem.publicationTitle = title; - } else if(newItem.journalAbbreviation) { - newItem.publicationTitle = newItem.journalAbbreviation; - } - - var journalIssue = ZU.xpath(journal, 'JournalIssue'); - if(journalIssue.length) { - newItem.volume = ZU.xpathText(journalIssue, 'Volume'); - newItem.issue = ZU.xpathText(journalIssue, 'Issue'); - var pubDate = ZU.xpath(journalIssue, 'PubDate'); - if(pubDate.length) { // try to get the date - var day = ZU.xpathText(pubDate, 'Day'); - var month = ZU.xpathText(pubDate, 'Month'); - var year = ZU.xpathText(pubDate, 'Year'); - - if(day) { - newItem.date = month+" "+day+", "+year; - } else if(month) { - newItem.date = month+" "+year; - } else if(year) { - newItem.date = year; - } else { - newItem.date = ZU.xpathText(pubDate, 'MedlineDate'); - } - } - } - } - - var authors = ZU.xpath(article, 'AuthorList/Author'); - for(var j in authors) { - var author = authors[j]; - - var lastName = ZU.xpathText(author, 'LastName'); - var firstName = ZU.xpathText(author, 'FirstName'); - if(!firstName) { - firstName = ZU.xpathText(author, 'ForeName'); - } - var suffix = ZU.xpathText(author, 'Suffix'); - if(suffix && firstName) { - firstName += ", " + suffix - } - if(firstName || lastName) { - newItem.creators.push({lastName:lastName, firstName:firstName}); - } - } - - - var keywords = ZU.xpath(citation, 'MeshHeadingList/MeshHeading'); - for(var k in keywords) { - newItem.tags.push(ZU.xpathText(keywords[k], 'DescriptorName')); - } - - var abstractSections = ZU.xpath(article, 'Abstract/AbstractText'); - var abstractNote = []; - for(var j in abstractSections) { - var abstractSection = abstractSections[j]; - if(abstractSection.hasAttribute("Label")) { - abstractNote.push(abstractSection.getAttribute("Label")); - } - abstractNote.push(abstractSection.textContent+"\n"); - } - - newItem.abstractNote = abstractNote.join("\n\n"); - newItem.DOI = ZU.xpathText(articles[i], 'PubmedData/ArticleIdList/ArticleId[@IdType="doi"]'); - // (do we want this?) - if(newItem.publicationTitle) { - newItem.publicationTitle = Zotero.Utilities.capitalizeTitle(newItem.publicationTitle); - } - newItem.complete(); - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var ids = new Array(); - var uids = doc.evaluate('//input[@name="EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_RVDocSum.uid"]', doc, //edited for new PubMed - nsResolver, XPathResult.ANY_TYPE, null); - var uid = uids.iterateNext(); - if(uid) { - if (uids.iterateNext()){ - var items = {}; - var tablex = '//div[@class="rprt"]'; - if (!doc.evaluate(tablex, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var tablex = '//div[@class="ResultSet"]/dl'; - var other = true; - } - var tableRows = doc.evaluate(tablex, doc, nsResolver, XPathResult.ANY_TYPE, null); - var tableRow; - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - uid = doc.evaluate('.//input[@type="checkbox"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (other) { - var article = doc.evaluate('.//h2', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - } else { - var article = doc.evaluate('.//p[@class="title"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - } - items[uid.value] = article.textContent; - } - - Zotero.selectItems(items, function(items) { - if(!items) { - return true; - } - - for(var i in items) { - ids.push(i); - } - - lookupPMIDs(ids); - }); - } else { - ids.push(uid.value); - lookupPMIDs(ids, doc); - } - } else { - // Here, account for some articles and search results using spans for PMID - var uids= doc.evaluate('//p[@class="pmid"]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - var uid = uids.iterateNext(); - if (!uid) { - // Fall back on span - uids = doc.evaluate('//span[@class="pmid"]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - uid = uids.iterateNext(); - } - if (!uid) { - // Fall back on <dl class="rprtid"> - // See http://www.ncbi.nlm.nih.gov/pubmed?term=1173[page]+AND+1995[pdat]+AND+Morton[author]&cmd=detailssearch - // Discussed http://forums.zotero.org/discussion/17662 - uids = doc.evaluate('//dl[@class="rprtid"]/dd[1]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - uid = uids.iterateNext(); - } - if (uid) { - ids.push(uid.textContent.match(/\d+/)[0]); - Zotero.debug("Found PMID: " + ids[ids.length - 1]); - lookupPMIDs(ids, doc); - } else { - var uids= doc.evaluate('//meta[@name="ncbi_uidlist"]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - var uid = uids.iterateNext()["content"].split(' '); - if (uid) { - ids.push(uid); - Zotero.debug("Found PMID: " + ids[ids.length - 1]); - lookupPMIDs(ids, doc); - } - } - } -} - -function doSearch(item) { - // pmid was defined earlier in detectSearch - lookupPMIDs([getPMID(item.contextObject)]); -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.ncbi.nlm.nih.gov/pubmed/20729678", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Coar", - "firstName": "Jaekea T" - }, - { - "lastName": "Sewell", - "firstName": "Jeanne P" - } - ], - "notes": [], - "tags": [ - "Bibliography as Topic", - "Database Management Systems", - "Humans" - ], - "seeAlso": [], - "attachments": [], - "url": "http://www.ncbi.nlm.nih.gov/pubmed/20729678", - "extra": "PMID: 20729678", - "title": "Zotero: harnessing the power of a personal bibliographic manager", - "pages": "205-207", - "ISSN": "1538-9855", - "journalAbbreviation": "Nurse Educ", - "publicationTitle": "Nurse Educator", - "volume": "35", - "issue": "5", - "date": "2010 Sep-Oct", - "abstractNote": "Zotero is a powerful free personal bibliographic manager (PBM) for writers. Use of a PBM allows the writer to focus on content, rather than the tedious details of formatting citations and references. Zotero 2.0 (http://www.zotero.org) has new features including the ability to synchronize citations with the off-site Zotero server and the ability to collaborate and share with others. An overview on how to use the software and discussion about the strengths and limitations are included.\u000a", - "DOI": "10.1097/NNE.0b013e3181ed81e4", - "libraryCatalog": "NCBI PubMed", - "shortTitle": "Zotero" - } - ] - }, - { - "type": "web", - "url": "http://www.ncbi.nlm.nih.gov/pubmed?term=zotero", - "items": "multiple" - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/NYTimes.com.js b/translators/NYTimes.com.js @@ -1,214 +0,0 @@ -{ - "translatorID": "ce7a3727-d184-407f-ac12-52837f3361ff", - "label": "NYTimes.com", - "creator": "Simon Kornblith", - "target": "^https?://(?:query\\.nytimes\\.com/search/(?:alternate/)?|(?:select\\.|www\\.)?nytimes\\.com/.)", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-04 01:09:00" -} - -function detectWeb(doc, url) { - // Check for search results - var searchResults = doc.evaluate('//div[@id="search_results"] | //div[@id="srchContent"]', doc, null, - XPathResult.ANY_TYPE, null).iterateNext(); - if(searchResults) return "multiple"; - - // Check for article meta tags - var metaTags = doc.getElementsByTagName("meta"); - var haveHdl = false; - var haveByl = false; - for(var i in metaTags) { - if(metaTags[i].name === "hdl") { - haveHdl = true; - } else if(metaTags[i].name == "byl") { - haveByl = true; - } - if(haveHdl && haveByl) return "newspaperArticle"; - } - return false; -} - -function associateMeta(newItem, metaTags, field, zoteroField) { - if(metaTags[field]) { - newItem[zoteroField] = metaTags[field]; - } -} - -function scrape(doc, url) { - var namespace = null; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "The New York Times"; - newItem.ISSN = "0362-4331"; - - var metaTags = new Object(); - if(url != undefined) { - newItem.url = url; - var metaTagRe = /<meta[^>]*>/gi; - var nameRe = /name="([^"]+)"/i; - var contentRe = /content="([^"]+)"/i; - var m = doc.match(metaTagRe); - - if(!m) { - return; - } - - for(var i=0; i<m.length; i++) { - var name = nameRe.exec(m[i]); - var content = contentRe.exec(m[i]); - if(name && content) { - metaTags[name[1]] = content[1]; - } - } - - if(!metaTags["hdl"]) { - return; - } - // We want to get everything on one page - newItem.attachments.push({url:url.replace(/\.html\??([^/]*)(pagewanted=[^&]*)?([^/]*)$/,".html?pagewanted=all&$1$2"), title:"New York Times Snapshot", - mimeType:"text/html"}); - } else { - newItem.url = doc.location.href; - var metaTagHTML = doc.getElementsByTagName("meta"); - for(var i=0; i<metaTagHTML.length; i++) { - var key = metaTagHTML[i].getAttribute("name"); - var value = metaTagHTML[i].getAttribute("content"); - if(key && value) { - metaTags[key] = value; - } - } - // Get everything on one page is possible - var singlePage = false; - if (!newItem.url.match(/\?pagewanted=all/) - && (singlePage = doc.evaluate('//ul[@id="toolsList"]/li[@class="singlePage"]/a', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext())) { - newItem.attachments.push({url:singlePage.href, title:"New York Times Snapshot", - mimeType:"text/html"}); - } else { - newItem.attachments.push({document:doc, title:"New York Times Snapshot"}); - } - } - - associateMeta(newItem, metaTags, "dat", "date"); - associateMeta(newItem, metaTags, "hdl", "title"); - associateMeta(newItem, metaTags, "dsk", "section"); - associateMeta(newItem, metaTags, "articleid", "accessionNumber"); - - if (metaTags["pdate"]) { - newItem.date = metaTags["pdate"].replace(/(\d{4})(\d{2})(\d{2})/,"$1-$2-$3"); - } - - if(metaTags["byl"]) { - var author = Zotero.Utilities.trimInternal(metaTags["byl"]); - if(author.substr(0, 3).toLowerCase() == "by ") { - author = author.substr(3); - } - - var authors = author.split(" and "); - for each(var author in authors) { - // fix capitalization - var words = author.split(" "); - for(var i in words) { - words[i] = words[i][0].toUpperCase()+words[i].substr(1).toLowerCase(); - } - author = words.join(" "); - - if(words[0] == "The") { - newItem.creators.push({lastName:author, creatorType:"author", fieldMode:true}); - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - } - - if(metaTags["keywords"]) { - var keywords = metaTags["keywords"]; - newItem.tags = keywords.split(","); - for(var i in newItem.tags) { - newItem.tags[i] = newItem.tags[i].replace(" ", ", "); - } - } - - // Remove pagewanted from URL in item (keeping other pieces, in case they might matter) - newItem.url = newItem.url.replace(/\?([^/]*)pagewanted=[^&]*/,''); - - newItem.complete(); -} - -function doWeb(doc, url) { - var searchResults = doc.evaluate('//div[@id="search_results"] | //div[@id="srchContent"]', doc, null, - XPathResult.ANY_TYPE, null).iterateNext(); - if(searchResults) { - var items = Zotero.Utilities.getItemArray(doc, searchResults, '^http://(?:select\.|www\.)nytimes.com/.*\.html(\\?|$)'); - - Zotero.selectItems(items, function (items) { - if(!items) return true; - - var urls = []; - for(var i in items) urls.push(i); - - Zotero.Utilities.HTTP.doGet(urls, function(text, response, url) { scrape(text, url) }, function() { Zotero.done(); }, null); - Zotero.wait(); - }); - } else { - scrape(doc); - } -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "https://www.nytimes.com/2010/08/21/education/21harvard.html?scp=1&sq=marc%20hauser&st=cse&gwh=4B8CBC2383B24F22FED81E754DFA960B", - "items": [ - { - "itemType": "newspaperArticle", - "creators": [ - { - "firstName": "Nicholas", - "lastName": "Wade", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Science and Technology", - "Research", - "Ethics", - "Hauser, Marc D", - "Harvard University" - ], - "seeAlso": [], - "attachments": [ - { - "document": "[object]", - "title": "New York Times Snapshot" - } - ], - "publicationTitle": "The New York Times", - "ISSN": "0362-4331", - "url": "https://www.nytimes.com/2010/08/21/education/21harvard.html?scp=1&sq=marc%20hauser&st=cse&gwh=4B8CBC2383B24F22FED81E754DFA960B", - "date": "2010-08-20", - "title": "Harvard Finds Marc Hauser Guilty of Scientific Misconduct", - "section": "Education", - "accessionNumber": "1248068890906", - "libraryCatalog": "NYTimes.com", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - }, - { - "type": "web", - "url": "http://query.nytimes.com/search/query?frow=0&n=10&srcht=a&query=marc+hauser&srchst=nyt&submit.x=18&submit.y=12&hdlquery=&bylquery=&daterange=period&mon1=01&day1=01&year1=2010&mon2=01&day2=18&year2=2011", - "items": "multiple" - } -] -/** END TEST CASES **/ diff --git a/translators/NZZ.ch.js b/translators/NZZ.ch.js @@ -1,146 +0,0 @@ -{ - "translatorID":"61ffe600-55e0-11df-bed9-0002a5d5c51b", - "label":"nzz.ch", - "creator":"ibex", - "target":"^http://((www\\.)?nzz\\.ch/.)", - "minVersion":"2.0", - "maxVersion":"", - "priority":100, - "inRepository":"0", - "translatorType":4, - "lastUpdated":"2010-12-20 11:17:03" -} - -/* - NZZ Translator - Parses NZZ articles and creates Zotero-based metadata. - Copyright (C) 2010 ibex - - 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/>. -*/ - -/* Get the first xpath element from doc, if not found return null. */ -function getXPath(xpath, doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - return doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); -} - -/* Zotero API */ -function detectWeb(doc, url) { - //Zotero.debug("ibex detectWeb URL= " + url); - if (doc.title.substr(0, 6) == "Suche " && getXPath('//ul[@class = "berichte"]', doc)) { - return "multiple"; - } else if (doc.location.href.match(/\.\d+\.html/) && getXPath('/html/body[@class = "artikel"]', doc)) { - return "newspaperArticle"; - } -} - -/* Zotero API */ -function doWeb(doc, url) { - //Zotero.debug("ibex doWeb URL= " + url); - var urls = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc.getElementById("content").getElementsByClassName('berichte'), '\\.\\d+\\.html'); - if (!items || countObjectProperties(items) == 0) { - return true; - } - items = Zotero.selectItems(items); - if (!items) { - return true; - } - - for (var i in items) { - urls.push(i); - } - } else { - urls.push(doc.location.href); - } - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); } ); - Zotero.wait(); -} - -/* Three types of articles: "Neue Zürcher Zeitung", "NZZ Online" and "NZZ am Sonntag" */ -function scrape(doc) { - //Zotero.debug("ibex scrape URL = " + doc.location.href); - var newItem = new Zotero.Item('newspaperArticle'); - newItem.url = doc.location.href; - newItem.title = Zotero.Utilities.trimInternal(getXPath('//div[@id = "content"]//h1', doc).textContent); - - var publ = Zotero.Utilities.trimInternal(getXPath('//div[@id = "content"]//p[@class = "dachzeile"]', doc).textContent); - publ = publ.split(','); - newItem.date = Zotero.Utilities.trimInternal(publ[0]); - - newItem.publicationTitle = Zotero.Utilities.trimInternal(publ[publ.length - 1]); - if (newItem.publicationTitle.match(/^\d/)) { - //set a publication title if there is only a number (date) - newItem.publicationTitle = "NZZ"; - } else if (newItem.publicationTitle == "Neue Zürcher Zeitung") { - newItem.ISSN = "0376-6829"; - } else if (newItem.publicationTitle == "NZZ am Sonntag") { - newItem.ISSN = "1660-0851"; - } - - var subtitle = getXPath('//div[@id = "content"]//h2', doc); - if ((subtitle != null) && (Zotero.Utilities.trimInternal(subtitle.textContent) != "")) { - newItem.shortTitle = newItem.title; - newItem.title += ": " + Zotero.Utilities.trimInternal(subtitle.textContent); - } - - var teaser = getXPath('//div[@id = "content"]//h3', doc); - if ((teaser != null) && (Zotero.Utilities.trimInternal(teaser.textContent) != "")) { - newItem.abstractNote = Zotero.Utilities.trimInternal(teaser.textContent); - } - - var authorline = getXPath('//div[@id = "content"]//p[@class = "autor"]', doc); - if (authorline != null) { - authorline = Zotero.Utilities.trimInternal(authorline.textContent); - //assumption of authorline: "[Interview:|Von ]name1[, name2] [und Name3][, location]" - authorline = authorline.replace(/^Von /, ""); - authorline = authorline.replace(/^Interview: /, ""); - authorline = authorline.replace(/vor Ort /i, ""); - //remove ", location" - authorline = Zotero.Utilities.trim(authorline.replace(/, \S*$/, "")); - - var authors = authorline.split(/,|und/); - for (var i = 0; i < authors.length && authorline.length > 0; i++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } - - var section = getXPath('//ul[@id="navi"]//ul[@id="submenu1"]/li[@class="selected"]/a', doc); - if (section != null) { - newItem.section = Zotero.Utilities.trimInternal(section.textContent); - } - - var source = getXPath('//div[@id = "content"]//span[@class="quelle"]', doc); - if (source != null) { - newItem.extra = Zotero.Utilities.trimInternal(source.textContent).replace(/^\(/,"").replace(/\)$/,""); - } - - newItem.attachments.push({title:"NZZ Online Article Snapshot", mimeType:"text/html", url:doc.location.href, snapshot:true}); - - newItem.complete(); -} - -/* There is no built-in function to count object properties which often are used as associative arrays.*/ -function countObjectProperties(obj) { - var size = 0; - for (var key in obj) { - if (obj.hasOwnProperty(key)) size++; - } - return size; -} diff --git a/translators/Nagoya University OPAC.js b/translators/Nagoya University OPAC.js @@ -1,300 +0,0 @@ -{ - "translatorID":"b56d756e-814e-4b46-bc58-d61dccc9f32f", - "translatorType":4, - "label":"Nagoya University OPAC", - "creator":"Frank Bennett", - "target":"^http://opac.nul.nagoya-u.ac.jp/webopac/(catdbl.do|ctlsrh.do)", - "minVersion":"2.0b7", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-23 02:17:07" -} - -// ####################### -// ##### Sample URLs ##### -// ####################### - -/* - * The site is session-based, with page content negotiated - * in POST calls. The starting point for an OPAC search is - * the URL below. In testing, I tried the following: - * - * - A search listing of books - * - A search listing of journals (no icon) - * - A mixed search listing of books and journals - * - A journal page (no icon) - * - A book page - */ -// http://opac.nul.nagoya-u.ac.jp/webopac/catsrk.do - - - -// ##################### -// ##### Constants ##### -// ##################### - -/* - * Strings corresponding to variables -*/ -var pageStrings = { - title: ['タイトル / 著者','Title / Author'], - year: ['出版・頒布','Publication'], - isbn: ['ISBN','ISBN'], - authors: ['著者名リンク','Author link'], - series: ['シリーズ情報','Series information'] -}; - -var itemUrlBase = "http://opac.nul.nagoya-u.ac.jp/webopac/catdbl.do"; - -// ############################ -// ##### String functions ##### -// ############################ - -/* - * Chop a semicolon-delimited string of authors out of a raw title string, - * check it for Japanese characters, and save the raw string for each author - * to an array. If no Japanese authors were found, save directly to the item - * object. - */ -var parseRomanAuthors = function (item,data) { - var datastring = data['title'][0]; - // don't bother if there is no author info - if ( ! datastring.match(/.*\/.*/) ) { - return true; - } - // cut off the title - datastring = datastring.replace(/.*\//, ""); - // raise flag if there are japanese characters - var japanese_check = datastring.match(/.*[^- &0-9()\[\];:,.a-zA-Z].*/); - // replace comma with semicolon in certain cases, to prepare for split - datastring = datastring.replace(/,(\s+[a-zA-Z]{3,})/, ";$1"); - datastring = datastring.replace(/,(\s+[a-zA-Z]{1}[^a-zA-Z])/, ";$1"); - datastring = datastring.replace(/(\s+and\s+)/, "; "); - datastring = datastring.replace(/(\s+&\s+)/, "; "); - // split the authors - var authors = datastring.replace(/\|.*/, "").split(";"); - // this is parsing the authors for a single work. if there is a special byline, we - // assume that it applies to all subsequent entries until overridden. - var authortype = 'author'; - for (i in authors) { - item.authorstrings.push(authors[i]); - var authortypehint = authors[i].replace(/^([ ,.:a-z]*).*/, "$1"); - if ( authortypehint.match(/.*(edit|organiz).*/) ) { - authortype = "editor"; - } else if ( authortypehint.match(/.*trans.*/) ) { - authortype = "translator"; - } - var author = authors[i].replace(/^[ a-z]*/, "").replace( /\.\.\..*/, "" ); - // need to test for length because the replacement of commas with semicolons - // can cause a short split at the end of a byline that originally ended in a comma - if ( ! japanese_check && author.length ) { - item.creators.push(Zotero.Utilities.cleanAuthor(author, authortype)); - } - } - return japanese_check; -} - -/* - * For each author link, attempt to find a hint that the person - * is an editor or translator, first in the link text itself, then in - * the list of raw author strings captured by parseRomanAuthors. - * Clean out cruft, reverse the order of each name, and save - * directly to the item object. - */ -var parseJapaneseAuthors = function (item, data) { - var authortype = author; - var authors = data['authors']; - for (i in authors ) { - if ( authors[i].match(/.*編.*/) ) { - authortype = 'editor'; - } else if ( authors[i].match(/.*訳.*/) ) { - authortype = 'translator'; - } else { - authortype = 'author'; - } - var author = authors[i].replace(/[*]/g,"").replace(/[0-9<()|].*/, "").replace(/(.*?),(.*)/, "$2 $1"); - // If we claim to be an author, double-check in the English entries for a translator hint. - // This is an enormous pain, but the original records are a mess, with different conventions - // for Japanese and foreign records, sometimes mixed up in the same entry. What are you - // going to do. - for ( x in item.authorstrings ) { - var authorstring = item.authorstrings[x]; - var name = author.split(" "); - name.reverse(); - if ( authorstring.indexOf( name[0] ) > -1 && authorstring.match(/.*(訳|譯|譯註)$/) ) { - authortype = 'translator'; - break; - } else if ( authorstring.indexOf( name[0] ) > -1 && authorstring.match(/.*(編|編著)$/) ) { - authortype = 'editor'; - break; - } - } - delete item.authorstrings; - item.creators.push(Zotero.Utilities.cleanAuthor(author, authortype)); - } -} - -/* - * Split extracted title field. This always starts as a single list item, - * but can contain entries for several works, as in an omnibus volume of - * translated works, for example. Such records separate the elements of - * the omnibus with periods that have no trailing space, so we use that as - * the split point. We discard the phonetic information appended to the end - * of the string in Japanese records. - */ -function splitTitle(data) { - // split in data array - var titlestring = data['title'][0].replace(/\|.*/, ""); - data['title'] = titlestring.split(" . "); -} - -// ########################## -// ##### Page functions ##### -// ########################## - -/* - * When getlist argument is nil, return a value when the target - * index DOM contains at least one book entry, otherwise - * return false. - * - * When getlist argument is true, return a list of - * array items for book entries in the DOM. - */ -var sniffIndexPage = function(doc,getlist){ - var check = doc.evaluate("//td[div[@class='lst_value' and contains(text(),'Books')]]/following-sibling::td", doc, null, XPathResult.ANY_TYPE, null); - var node = check.iterateNext(); - if (getlist){ - var ret = new Object(); - while (node){ - var myitems = Zotero.Utilities.getItemArray( - doc, - node, - "document\\.catsrhform\\.pkey.value="); - for (var r in myitems){ - ret[r] = myitems[r]; - } - node = check.iterateNext(); - } - return ret; - } else { - return node; - } -}; - -/* - * Invoke sniffIndexPage to generate a list of book - * items in the target DOM. - */ -var getBookItems = function(doc){ - return sniffIndexPage(doc,true); -}; - -/* - * Extract data from the DOM using the var-string pairs in - * pageStrings as a guide to navigation. - */ -var scrapePage = function(doc, spec) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var data = new Object(); - for (key in spec) { - var check = doc.evaluate("//th[div[contains(text(),'"+spec[key][0]+"') or contains(text(),'"+spec[key][1]+"')]]/following-sibling::td/div", doc, nsResolver, XPathResult.ANY_TYPE, null); - var c = check.iterateNext(); - while (c) { - if (!data[key] ) { - data[key] = new Array(); - } - data[key].push(Zotero.Utilities.trimInternal(c.textContent)); - c = check.iterateNext(); - } - } - return data; -}; - -/* - * Bring it all together. - */ -function scrapeAndParse(doc,url) { - if (!detectWeb(doc,url)){ - return false; - } - var item = new Zotero.Item("book"); - item.authorstrings = new Array(); - var data = scrapePage(doc, pageStrings); - splitTitle(data); - - if (data['title']) { - var titles = new Array(); - for (i in data['title']) { - titles.push( data['title'][i].replace(/\s+\/.*/, "") ); - } - item.title = titles.join(", "); - var jse_authors = parseRomanAuthors( item, data ); - if ( jse_authors ) { - parseJapaneseAuthors( item, data ); - } - } - - if (data['year']) { - // sometimes there are multiple "date" fields, some of which are filled - // with other random information - for (i in data['year']) { - var year = data['year'][i]; - if ( year.match(/.*[0-9]{3}.*/) ) { - item.date = year.replace(/.*?([0-9][.0-9][0-9]+).*/, "$1"); - item.place = year.replace(/:.*/, "").replace(/[\[\]]/g, ""); - item.publisher = year.replace(/.*:(.*),.*/, "$1"); - break; - } - } - } - - if (data['series']) { - item.series = data['series'][0].replace(/[/|<].*/, ""); - } - - if (data['isbn']) { - item.ISBN = data['isbn'][0].replace(/[^0-9]*([0-9]+).*/, "$1"); - } - item.complete(); -} - -// ######################### -// ##### API functions ##### -// ######################### - -function detectWeb(doc, url) { - if (url.match(/.*\/webopac\/catdbl.do/)) { - var journal_test = doc.evaluate( '//th[div[contains(text(),"Frequency of publication") or contains(text(),"刊行頻度") or contains(text(),"巻号") or contains(text(),"Volumes")]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (!journal_test) { - return "book"; - } - } else if (url.match(/.*\/webopac\/ctlsrh.do/)){ - if (sniffIndexPage(doc)){ - return "multiple"; - } - } - return false; -} - -function doWeb(doc, url) { - var format = detectWeb(doc, url); - if (format == "multiple") { - var items = {}; - for (var u in Zotero.selectItems( getBookItems(doc) )){ - var m = u.match(/.*document\.catsrhform\.pkey\.value=\'([^\']+)\'.*/); - items[itemUrlBase+"?pkey="+m[1]+"&initFlg=_RESULT_SET_NOTBIB"] = true; - } - if (items.__count__){ - for (var u in items){ - var d = Zotero.Utilities.retrieveDocument(u); - scrapeAndParse(d, u); - } - } - } else if (format == "book"){ - scrapeAndParse(doc, url); - } -} diff --git a/translators/National Archives of Australia.js b/translators/National Archives of Australia.js @@ -1,251 +0,0 @@ -{ - "translatorID":"50a4cf3f-92ef-4e9f-ab15-815229159b16", - "label":"National Archives of Australia", - "creator":"Tim Sherratt", - "target":"^http://[^/]*naa\\.gov\\.au/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "translatorType":4, - "lastUpdated":"2010-09-03 06:10:00" -} - -function detectWeb(doc, url) { - //RecordSearch - items and series - or Photosearch results - if (url.match(/SeriesListing.asp/i) || url.match(/ItemsListing.asp/i) || url.match(/PhotoSearchSearchResults.asp/i)) { - return "multiple"; - } else if (url.match(/SeriesDetail.asp/i) || url.match(/ItemDetail.asp/i) || url.match(/PhotoSearchItemDetail.asp/i) || url.match(/imagine.asp/i)) { - return "manuscript"; - } -} -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - // If it's a single page of a digitised file, then send it to be processed directly. - // This is because digitised pages, after the first, are retrieved via POST, thus if you feed the url to processDocuments - // you'll only ever get the first page. - if (url.match(/imagine.asp/i)) { - processFolio(doc); - Zotero.done(); - // Everything else can be handled normally. - } else { - // To avoid cross domain errors find baseurl - var baseURL = doc.location.href.match(/(http:\/\/[a-z0-9]+\.naa\.gov\.au)/)[1]; - var records = new Array(); - var titles, links, title, link; - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - // Files - if (url.match(/ItemsListing.asp/i)) { - titles = doc.evaluate('//td[4][@title="Go to Item details"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - links = doc.evaluate('//td[4][@title="Go to Item details"]/@onclick', doc, nsResolver, XPathResult.ANY_TYPE, null); - // Photos - } else if (url.match(/PhotoSearchSearchResults.asp/i)) { - titles = doc.evaluate('//td[b="Title :"]/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - links = doc.evaluate('//td[b="Title :"]/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - //Series - } else if (url.match(/SeriesListing.asp/i)) { - titles = doc.evaluate('//td[3][@title="Go to Series details"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - links = doc.evaluate('//td[3][@title="Go to Series details"]/@onclick', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - while ((title = titles.iterateNext()) && (link = links.iterateNext())) { - if (url.match(/PhotoSearchSearchResults.asp/i)) { - items[link.href] = Zotero.Utilities.trimInternal(title.lastChild.textContent); - } else { - items[baseURL + '/SearchNRetrieve/Interface' + link.textContent.match(/window\.location = '\.\.(.+?)'/)[1]] = Zotero.Utilities.trimInternal(title.firstChild.textContent); - } - } - items = Zotero.selectItems(items); - for (var i in items) { - records.push(i); - } - } else { - records = [url]; - } - Zotero.Utilities.processDocuments(records, scrape, function(){Zotero.done();}); - Zotero.wait(); - } -} -function processFolio(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - // To avoid cross-domain problems, find the base url - var baseURL = doc.location.href.match(/(http:\/\/[a-z0-9]+\.naa\.gov\.au)/)[1]; - var item = new Zotero.Item("manuscript"); - item.archive = "National Archives of Australia"; - item.libraryCatalog = "RecordSearch"; - var barcode, page, numPages; - // Using my Greasemonkey interface - if (doc.body.innerHTML.match(/Digital copy of NAA:/)) { - doc.evaluate('//img[@id="fileimage"]/@src', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent.match(/B=(\d+)&S=(\d+)&/); - barcode = RegExp.$1; - page = RegExp.$2; - numPages = Zotero.Utilities.trimInternal(doc.evaluate('//input[@id="printto"]/@value', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - // Using the original RS interface - } else { - barcode = Zotero.Utilities.trimInternal(doc.evaluate('//input[@id="Hidden1"]/@value', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - page = Zotero.Utilities.trimInternal(doc.evaluate('//input[@id="Text1"]/@value', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - numPages = Zotero.Utilities.trimInternal(doc.evaluate('//input[@id="Hidden3"]/@value', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - } - item.manuscriptType = 'folio'; - item.pages = page; - item.numPages = numPages; - // The link to the image file - there's no way to link to the image in the context of the file - item.url = 'http://recordsearch.naa.gov.au/NaaMedia/ShowImage.asp?B=' + barcode + '&S=' + item.pages + '&T=P'; - // Retrieve file details and extract reference details - var itemURL = baseURL + '/SearchNRetrieve/Interface/DetailsReports/ItemDetail.aspx?Barcode=' + barcode; - var itemDoc = Zotero.Utilities.retrieveDocument(itemURL); - var series = Zotero.Utilities.trimInternal(itemDoc.evaluate('//td[@class="field"][. ="Series number"]/following-sibling::td/a', itemDoc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - var control = Zotero.Utilities.trimInternal(itemDoc.evaluate('//td[@class="field"][. ="Control symbol"]/following-sibling::td', itemDoc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - var refNumber = series + ", " + control; - item.title = 'Page ' + page + ' of NAA: ' + refNumber; - item.archiveLocation = refNumber; - // Save a copy of the image - item.attachments = [{url:item.url, title:'Digital copy of NAA: ' + refNumber + ', p. ' + page, mimeType:"image/jpeg" }]; - // MACHINE TAGS - // The file of which this page is a part. - item.tags.push('dcterms:isPartOf="http://www.naa.gov.au/cgi-bin/Search?O=I&Number=' + barcode + '"'); - // Citation - item.tags.push('dcterms:bibliographicCitation="NAA: ' + refNumber + ', p. ' + page + '"'); - item.tags.push('xmlns:dcterms="http://purl.org/dc/terms/"'); - item.complete(); - Zotero.wait(); -} -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - // To avoid cross-domain problems, find the base url - var baseURL = doc.location.href.match(/(http:\/\/[a-z0-9]+\.naa\.gov\.au)/)[1]; - var item = new Zotero.Item("manuscript"); - item.archive = "National Archives of Australia"; - // Photosearch item - if (doc.location.href.match(/PhotoSearchItemDetail.asp/i)) { - var tags = new Array(); - item.libraryCatalog = "PhotoSearch"; - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Title :"]/following-sibling::text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - item.manuscriptType = "photograph"; - var barcode = Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Barcode : "]/following-sibling::text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - var series = Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Find other items in this series :"]/following-sibling::a/text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - var refNumber = Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Image no. :"]/following-sibling::text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - item.archiveLocation = refNumber; - item.url = "http://www.naa.gov.au/cgi-bin/Search?O=PSI&Number=" + barcode; - if (doc.evaluate('//b[. ="Date :"]/following-sibling::text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null) { - item.date = Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Date :"]/following-sibling::text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - } - if (doc.evaluate('//b[. ="Location : "]/following-sibling::text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null) { - item.place = Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Location : "]/following-sibling::text()[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - } - // Save subjects as tags - subjects = new Array(); - subjects.push(Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Primary subject :"]/following-sibling::*[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent).toLowerCase()); - subjects.push(Zotero.Utilities.trimInternal(doc.evaluate('//b[. ="Secondary subject :"]/following-sibling::*[1]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent).toLowerCase()); - for (var i in subjects) { - if (subjects[i] != '') { - item.tags.push(subjects[i]); - } - } - // Citation - item.tags.push('dcterms:bibliographicCitation="NAA: ' + refNumber + '"'); - // Save barcode as identifier - item.tags.push('dcterms:identifier="' + barcode + '"'); - // Series of which this is a member - item.tags.push('dcterms:isPartOf="http://www.naa.gov.au/cgi-bin/Search?Number=' + series + '"'); - // Same file in RecordSearch - item.tags.push('owl:sameAs="http://www.naa.gov.au/cgi-bin/Search?O=I&Number=' + barcode + '"'); - // Namespace declarations - item.tags.push('xmlns:dcterms="http://purl.org/dc/terms/"'); - item.tags.push('xmlns:owl="http://www.w3.org/2002/07/owl#"'); - // Attach copy of photo as attachment - var imgURL = "http://recordsearch.naa.gov.au/NaaMedia/ShowImage.asp?B=" + barcode + "&S=1&T=P"; - item.attachments = [{url:imgURL, title:"Digital image of NAA: "+ item.archiveLocation, mimeType:"image/jpeg" }]; - } else if (doc.location.href.match(/SeriesDetail.asp/i)) { - item.libraryCatalog = "RecordSearch"; - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Title"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - var refNumber = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Series number"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - item.archiveLocation = refNumber; - item.manuscriptType = "series"; - // Link into RecordSearch - item.url = "http://www.naa.gov.au/cgi-bin/Search?Number=" + refNumber; - // Contents dates - item.date = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Contents dates "]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - // Agencies recording into this series - var agencies = doc.evaluate('//div[@id="provenanceRecording"]/ul/li/div[@class="linkagesInfo"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (agency = agencies.iterateNext()) { - item.creators.push({lastName: agency.textContent, creatorType: "creator"}); - } - // Save series note as abstract - if (doc.evaluate('//div[@id="notes"]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null) { - item.abstractNote = Zotero.Utilities.cleanTags(Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="notes"]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent)); - } - // MACHINE TAGS - // Format - if (doc.evaluate('//td[@class="field"][div="Predominant physical format"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ANY_TYPE, null) != null) { - item.tags.push('dcterms:format="' + Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][div="Predominant physical format"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent) + '"'); - } - // Number of items described on RecordSearch - if (doc.evaluate('//td[@class="field"][. ="Items in this series on RecordSearch"]/following-sibling::td/a', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent != '') { - item.tags.push('dcterms:extent="' + Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Items in this series on RecordSearch"]/following-sibling::td/a', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent) + ' items described"'); - } - // Quantities and locations - var quantities = doc.evaluate('//td[@class="field"][. ="Quantity and location"]/following-sibling::td/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (quantity = quantities.iterateNext()) { - item.tags.push('dcterms:extent="' +quantity.textContent + '"'); - } - // Citation - item.tags.push('dcterms:bibliographicCitation="NAA: ' + refNumber + '"'); - // Declare dcterms namespace - item.tags.push('xmlns:dcterms="http://purl.org/dc/terms/"'); - } else if (doc.location.href.match(/ItemDetail.asp/i)) { - item.manuscriptType = 'file'; - item.libraryCatalog = "RecordSearch"; - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Title"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - var series = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Series number"]/following-sibling::td/a', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - var control = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Control symbol"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - var refNumber = series + ', ' + control; - item.archiveLocation = refNumber; - var barcode = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Item barcode"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - // Link into RecordSearch - item.url = "http://www.naa.gov.au/cgi-bin/Search?O=I&Number=" + barcode; - // Contents dates - item.date = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Contents date range"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - // Location - if (doc.evaluate('//td[@class="field"][. ="Location"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null) { - item.place = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Location"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent); - } - // Save item note as abstract - if (doc.evaluate('//div[@id="notes"]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null) { - item.abstractNote = Zotero.Utilities.cleanTags(Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="notes"]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent)); - } - // MACHINE TAGS - // The series this item belongs to - item.tags.push('dcterms:isPartOf="http://www.naa.gov.au/cgi-bin/Search?Number=' + series + '"'); - // Citation - item.tags.push('dcterms:bibliographicCitation="NAA: ' + refNumber + '"'); - // Save the barcode as an identifier - item.tags.push('dcterms:identifier="' + barcode + '"'); - // Access status - item.tags.push('dcterms:accessRights="' + Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][. ="Access status"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent) + '"'); - // Format - if (doc.evaluate('//td[@class="field"][div="Physical format"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null) { - item.tags.push('dcterms:format="' + Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="field"][div="Physical format"]/following-sibling::td', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.lastChild.textContent) + '"'); - } - // Is there a digital copy? - if so find the number of pages in the digitised file - if (doc.evaluate('//a[. ="View digital copy "]', doc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue != null) { - itemURL = baseURL + "/scripts/Imagine.asp?B=" + barcode; - // Retrieve the digitised file - itemDoc = Zotero.Utilities.retrieveDocument(itemURL); - item.numPages =Zotero.Utilities.trimInternal(itemDoc.evaluate('//input[@id="Hidden3"]/@value', itemDoc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.textContent); - } - // Declare dcterms namespace - item.tags.push('xmlns:dcterms="http://purl.org/dc/terms/"'); - } - item.complete(); -} - diff --git a/translators/National Archives of South Africa.js b/translators/National Archives of South Africa.js @@ -1,127 +0,0 @@ -{ - "translatorID":"5b02e8d4-d8fb-4143-af3d-3576d4c1b49c", - "translatorType":4, - "label":"National Archives of South Africa", - "creator":"Adam Crymble", - "target":"http://www.national.archsrch.gov.za", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-07-17 05:25:00" -} - -function detectWeb(doc, url) { - if (doc.title.match("Results Summary")) { - return "multiple"; - } else if (doc.title.match("Results Detail")) { - return "book"; - } -} - -//National Archives of South Africa Translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - - - var headers = doc.evaluate('//td[2]/pre/b', doc, nsResolver,XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//td[2]/pre/b)', doc,nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//td[2]/pre', doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var headersArray = new Array(); - var oneHeader = ''; - - if (xPathCount.numberValue > 1) { - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent; - headersArray.push(fieldTitle); - } - } else { - oneHeader = (headers.iterateNext().textContent); - } - - var contentsArray = new Array(); - var j = 0; - - if (oneHeader.length<1) { - - for (var i = headersArray.length-1; i> -1; i--) { - - var fieldIndex = contents.indexOf(headersArray[i]); - var shorten = headersArray[i].length; - - contentsArray.push(contents.substr(fieldIndex)); - contents = contents.substr(0, fieldIndex); - fieldTitle = headersArray[i].replace(/\s+/g, ''); - - dataTags[fieldTitle] = contentsArray[j].substr(shorten).replace(/^\s*|\s+$/g, ''); - j++; - } - } - - associateData (newItem, dataTags, "DEPOT", "repository"); - associateData (newItem, dataTags, "REFERENCE", "callNumber"); - associateData (newItem, dataTags, "STARTING", "date"); - associateData (newItem, dataTags, "ENDING", "date"); - associateData (newItem, dataTags, "VOLUME_NO", "volume"); - associateData (newItem, dataTags, "REMARKS", "extra"); - associateData (newItem, dataTags, "SUMMARY", "abstractNote"); - associateData (newItem, dataTags, "SOURCE", "series"); - if (dataTags["DESCRIPTION"]) { - associateData (newItem, dataTags, "DESCRIPTION", "title"); - } else { - newItem.title = "No Title Found"; - } - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var lastLink; - var next_title; - while (next_title = titles.iterateNext()) { - - if (!next_title.textContent.match(/^\d\d\d\d/) && !next_title.textContent.match(/\\/) && next_title.textContent.length>3 && next_title.textContent.match(/\w/)) { - Zotero.debug(next_title.textContent); - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/National Bureau of Economic Research.js b/translators/National Bureau of Economic Research.js @@ -1,73 +0,0 @@ -{ - "translatorID":"99f958ab-0732-483d-833f-6bd8e42f6277", - "translatorType":4, - "label":"National Bureau of Economic Research", - "creator":"Michael Berkowitz", - "target":"^https?://(?:papers\\.|www\\.)?nber\\.org/(papers|s|new)", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-05 07:45:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (doc.evaluate('//a[contains(text(), "RIS")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } else if (doc.evaluate('//div[@class="maintd"][@id="maine"]/table/tbody/tr/td[1]//a[contains(@href, "papers/w")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function parseRIS(uris){ - - Zotero.Utilities.HTTP.doGet(uris, function(text){ - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - Zotero.done(); - }, function() {}); - Zotero.wait(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//div[@class="maintd"][@id="maine"]/table/tbody/tr/td[1]//a[contains(@href, "papers/w")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - if (!link.href.match(/\.pdf$/)) items[link.href] = link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i + '.ris'); - } - } else { - arts = [url + '.ris']; - } - Zotero.Utilities.HTTP.doGet(arts, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - if (text.match(/AB\s+\-\s+/)) item.abstractNote = text.match(/AB\s+\-\s+((.|\s)+)\n([A-Z]{2})/)[1]; - item.notes = new Array(); - item.complete(); - }); - translator.translate(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/National Gallery of Art - U.S.A..js b/translators/National Gallery of Art - U.S.A..js @@ -1,169 +0,0 @@ -{ - "translatorID":"ed28758b-9c39-4e1c-af89-ce1c9202b70f", - "translatorType":4, - "label":"National Gallery of Art - U.S.A.", - "creator":"Adam Crymble", - "target":"http://www.nga.gov/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-21 15:45:00" -} - -function detectWeb(doc, url) { - var single = 0; - - if (doc.evaluate('//div[@class="content"]/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext()){ - var pageType = doc.evaluate('//div[@class="content"]/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src; - } - - if (doc.location.href.match("tinfo") || doc.title.match("timage")) { - single = "1"; - } - - - - if (doc.title.match("Image") && doc.location.href.match("fcgi")) { - return "artwork"; - } - - if (pageType.match("search_test")) { - return "multiple"; - } else if (doc.location.href.match("artistid")) { - return "multiple"; - } else if (single == "1" && pageType.match("collections_test")) { - return "artwork"; - } -} - -//National Gallery USA translator. Code by Adam Crymble - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var style = 0; - var title1; - var newItem = new Zotero.Item("artwork"); - - //determines page layout type - - //single entry with thumbnail - if (doc.evaluate('//div[@class="BodyText"]/table/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var content = doc.evaluate('//div[@class="BodyText"]/table/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\n/); - style = 1; - - //single entry without thumbnail (2 variations) - } else if (doc.evaluate('//div[@class="BodyText"]/table/tbody/tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var content = doc.evaluate('//div[@class="BodyText"]/table/tbody/tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\n/); - - if (content[1].match("Rendered")) { - style = 3; - } else { - style = 1; - } - - //single entry with large image. - } else if (doc.evaluate('//tr[2]/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var content = doc.evaluate('//tr[2]/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\n/); - style = 2; - } - - if (style == 1) { - - newItem.creators.push(Zotero.Utilities.cleanAuthor(content[1], "artist")); - - - var titleDate = content[3].split(", "); - title1 = titleDate[0]; - - if (titleDate.length>2) { - for (var j = 1; j < titleDate.length-1; j++) { - title1 = (title1 + ", " + titleDate[j]); - } - } - newItem.title = title1; - - if (titleDate.length > 1) { - newItem.date = titleDate[titleDate.length-1]; - } - - newItem.extra = ("Aquisition: " + content[content.length-3]); - newItem.callNumber = content[content.length-2]; - - } else if (style == 2) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(content[0], "artist")); - - var date = content[1].split(", "); - - title1 = date[0]; - - if (date.length>2) { - for (var j = 1; j < date.length-1; j++) { - title1 = (title1 + ", " + date[j]); - } - } - - newItem.title = title1; - - newItem.date = date[date.length-1]; - - var acquisition = content[2].split(/\d/); - newItem.extra = ("Aquisition: " + acquisition[0]); - - } else if (style == 3) { - - var titleAuthor = content[1].split("Rendered by "); - - newItem.title = titleAuthor[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(titleAuthor[1], "artist")); - - newItem.callNumber = content[content.length-2]; - - } - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - if (doc.location.href.match("artistid")) { - var titles = doc.evaluate('//ul/li/b/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - } else { - var titles = doc.evaluate('//ul/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.textContent.match("image available")) { - next_title = titles.iterateNext(); - } - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/National Library of Australia (new catalog).js b/translators/National Library of Australia (new catalog).js @@ -1,147 +0,0 @@ -{ - "translatorID":"54ac4ec1-9d07-45d3-9d96-48bed3411fb6", - "translatorType":4, - "label":"National Library of Australia (new catalog)", - "creator":"Mark Triggs, Steve McPhillips and Matt Burton", - "target":"catalogue.nla.gov.au", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-11-13 07:10:00" -} - -function detectWeb(doc, url) { - if (url.match("/Record/[0-9]+")) { - var format = doc.getElementById("myformat").textContent; - return computeFormat(format); - - } else if (url.match ("/Search/Home") && doc.getElementById ("resultItemLine1")) { - return "multiple"; - } -} - -// map the nla formats to zotero formats -function computeFormat(format){ - // clean up whitespace and remove commas from items with multiple formats - format = Zotero.Utilities.trimInternal(format.replace(',', '')); - - if (format == "Audio") { - return "audioRecording"; - } - else if (format == "Book") { - return "book"; - } - else if (format == "Journal/Newspaper") { - return "journalArticle"; - } - else if (format == "Manuscript") { - return "manuscript"; - } - else if (format == "Map") { - return "map"; - } - else if (format == "Music") { - return "audioRecording"; - } - else if (format == "Online") { - return "webpage"; - } - else if (format == "Picture") { - return "artwork"; - } - else if (format == "Video") { - return "videoRecording"; - } - else { - return "book"; - } - -} - -// TODO: Remove this when we drop support for Fx3 -if (!JSON) { - var JSON = new function() { - this.parse = function (arg) { - var j; - if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(arg. - replace(/\\./g, '@'). - replace(/"[^"\\\n\r]*"/g, ''))) { - // Friendly AMO reviewer: This is the official json.org library and is safe. - j = eval('(' + arg + ')'); - return j; - } - throw new SyntaxError('parseJSON'); - } - } -} - -function load_item(responseText, url, format) { - var metadata = JSON.parse(Zotero.Utilities.trimInternal(responseText)); - var bibid = url.match("^.*\/Record/([0-9]+)")[1]; - var newItem = new Zotero.Item(format[bibid]); - - /* load in our authors */ - if (metadata.authors) { - for (var i=0; i< metadata.authors.length ; i++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor - (metadata.authors[i], "author", true)); - } - } - - /* and our tags */ - if (metadata.tags) { - for (var i=0; i< metadata.tags.length ; i++) { - newItem.tags.push(metadata.tags[i]); - } - } - - /* and our summary */ - if (metadata.notes) { - newItem.notes.push ({"note": metadata.notes}); - } - - /* and everything else */ - for (var attr in metadata) { - if (!newItem[attr]) { - newItem[attr] = metadata[attr]; - } - } - newItem.repository = "National Library of Australia"; - newItem.complete(); -} - -function doWeb(doc, url) { - var format = detectWeb(doc, url); - var items = {}; - // does javascript have an easy way to test if object has properties? - var itemsHasProperties = false; - if (format == "multiple") { - for (var url in Zotero.selectItems((Zotero.Utilities.getItemArray - (doc, doc, "/Record/[0-9]+")))) { - var bibid = url.match("^.*\/Record/([0-9]+)")[1]; - // grab the item type for that bibid so we don't have to make a processDocuments call for each - var xpath = "//div[contains(./div/a/@href, '"+bibid+"')]/div[@id = 'resultItemLine3']/span/text()"; - var nlaFormat = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - // populate an associative array with bibid -> format for the doGet - items[bibid] = computeFormat(nlaFormat); - itemsHasProperties = true; // items has stuff - } - } else { - var bibid = url.match("^.*\/Record/([0-9]+)")[1]; - items[bibid] = format; - itemsHasProperties = true; // items has stuff - } - // only continue if there are items to create - if (itemsHasProperties) { - var urls = []; - for (var bibid in items) { - urls.push("http://catalogue.nla.gov.au/Record/" + bibid + "/Export?style=zotero"); - } - // the bibid->format associative array prevents the need for a doGet nested in processDocs - Zotero.Utilities.HTTP.doGet(urls, - function(text, obj, url) { load_item(text, url, items);}, - function(){ Zotero.done();}); - Zotero.wait(); - } -} diff --git a/translators/National Library of Australia - Australian Newspapers.js b/translators/National Library of Australia - Australian Newspapers.js @@ -1,166 +0,0 @@ -{ - "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 <http://www.gnu.org/licenses/>. -*/ - -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/National Library of Australia.js b/translators/National Library of Australia.js @@ -1,65 +0,0 @@ -{ - "translatorID":"fc410e64-0252-4cd3-acb1-25e584775fa2", - "translatorType":4, - "label":"National Library of Australia", - "creator":"Michael Berkowitz", - "target":"http://librariesaustralia.nla.gov.au/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match("action=Search")) { - return "multiple"; - } else if (url.match("action=Display")) { - return "book"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, 'action=Display&'); - items = Zotero.selectItems(items); - for (var i in items) { - books.push(i); - } - } else { - books = [url]; - } - Zotero.Utilities.processDocuments(books, function(doc) { - var table = doc.evaluate('//tbody/tr[td[1][@class="CellAlignRight"]/strong]', doc, ns, XPathResult.ANY_TYPE, null); - var row; - var data = new Object(); - while (row = table.iterateNext()) { - var heading = doc.evaluate('./td[1]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var value = doc.evaluate('./td[2]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - data[Zotero.Utilities.trimInternal(heading)] = value; - } - item = new Zotero.Item("book"); - item.title = Zotero.Utilities.trimInternal(data['Title:'].match(/^[^/]+/)[0]); - if (data['Author:']) item.creators.push(Zotero.Utilities.cleanAuthor(data['Author:'], "author", true)); - if (data['Published:'].match(/\w+/)) { - var pub = data['Published:'].match(/^([^:]+):(.*)\s+([^\s]+)$/); - item.location = Zotero.Utilities.trimInternal(pub[1]); - item.publisher = Zotero.Utilities.trimInternal(pub[2]); - item.date = Zotero.Utilities.trimInternal(pub[3].replace(/\D/g, "")); - } - if (data['Subjects:']) { - var kws = data['Subjects:'].split("."); - for each (var key in kws) { - if (key.match(/\w+/)) item.tags.push(key); - } - } - if (data['ISBN:']) item.ISBN = Zotero.Utilities.trimInternal(data['ISBN:'].match(/^[^(]+/)[0]); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/National Library of New Zealand.js b/translators/National Library of New Zealand.js @@ -1,166 +0,0 @@ -{ - "translatorID":"45763818-8530-49c6-a069-34acdee1a096", - "translatorType":4, - "label":"National Library of New Zealand", - "creator":"Adam Crymble", - "target":"http://nlnzcat.natlib", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-11 20:40:00" -} - -function detectWeb(doc, url) { - - if (doc.title.match("Quick Record View")) { - return "book"; - } else if (doc.title.match("Details Record View")) { - return "book"; - } else if (doc.title.match("Catalogue Titles")) { - return "multiple"; - } -} - -//National Library of New Zealand translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var headersArray = new Array(); - var contentsArray = new Array(); - var fieldTitle; - var j = 0; - - var newItem = new Zotero.Item("book"); - - var headers = doc.evaluate('//form/table/tbody/tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//form/table/tbody/tr/th)', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//table[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent; - if (fieldTitle.match(/\w/)) { - headersArray.push(fieldTitle); - } - } - - for (var i = headersArray.length-1; i> -1; i--) { - - var fieldIndex = contents.lastIndexOf(headersArray[i]); - contentsArray.push(contents.substr(fieldIndex)); - contents = contents.substr(0, fieldIndex); - - fieldTitle = headersArray[i].replace(/\s+/g, ''); - - dataTags[fieldTitle] = contentsArray[j].substr(headersArray[i].length).replace(/^\s*|\s+$/g, ''); - j++; - } - - if (dataTags["Author:"]) { - var author = dataTags["Author:"]; - if (author.match(", ")) { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - - if (dataTags["Publisher:"]) { - if (dataTags["Publisher:"].match(": ")) { - var place1 = dataTags["Publisher:"].indexOf(": "); - newItem.place = dataTags["Publisher:"].substr(0, place1); - var publisher1 = dataTags["Publisher:"].substr(place1 + 2); - - if (publisher1.match(", ")) { - var date1 = publisher1.lastIndexOf(", "); - newItem.date = publisher1.substr(date1 +2); - newItem.publisher = publisher1.substr(0, date1); - } else { - newItem.publisher = publisher1; - } - } else { - newItem.publisher = publisher1; - } - } - - if (dataTags["Subject:"]) { - if (dataTags["Subject:"].match(/\n/)) { - tagsContent = dataTags["Subject:"].split(/\n/) - for (var i = 0; i < tagsContent.length; i++) { - if (tagsContent[i].match(/\w/)) { - newItem.tags[i] = tagsContent[i]; - } - } - } else { - newItem.tags = dataTags["Subject:"] - } - } - - if (dataTags["LCSubject:"]) { - if (dataTags["LCSubject:"].match(/\n/)) { - tagsContent = dataTags["LCSubject:"].split(/\n/) - var k = 0; - for (var i = 0; i < tagsContent.length; i++) { - if (tagsContent[i].match(/\w/)) { - newItem.tags[k] = tagsContent[i]; - k++; - } - } - } else { - newItem.tags = dataTags["LCSubject:"] - } - } - - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "Description:", "pages"); - associateData (newItem, dataTags, "CallNumber:", "callNumber"); - associateData (newItem, dataTags, "Location:", "repository"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//form/table/tbody/tr/td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.textContent.match(/\w/)) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/National Post.js b/translators/National Post.js @@ -1,123 +0,0 @@ -{ - "translatorID":"1c5b122c-7e58-4cd5-932b-93f5ca0b7e1a", - "translatorType":4, - "label":"National Post", - "creator":"Adam Crymble", - "target":"http://www.(national|financial)post.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-11 20:40:00" -} - -function detectWeb(doc, url) { - - if (doc.title.match("Search Results")) { - return "multiple"; - } else if (doc.location.href.match("story")) { - return "newspaperArticle"; - } else if (doc.location.href.match("blog")) { - return "blogPost"; - } - -} - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var dataTags = new Object(); - var author = new Array(); - - var mediaType = detectWeb(doc,doc.location.href); - if (mediaType == "newspaperArticle") { - var newItem = new Zotero.Item("newspaperArticle"); - - //metadata - var dataTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < dataTagHTML.length ; i++) { - dataTags[dataTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(dataTagHTML[i].getAttribute("content")); - } - - associateData (newItem, dataTags, "Description", "abstractNote"); - associateData (newItem, dataTags, "PubDate", "date"); - - //author - if (dataTags["Author"]) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Author"], "author")); - } else { - - author = doc.evaluate('//strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(","); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[0], "author")); - } - - } else if (mediaType == "blogPost") { - - var newItem = new Zotero.Item("blogPost"); - - var blog = doc.evaluate('//div[@class="entryviewfooter"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - blog = blog.replace("Posted:", '').split("by"); - newItem.date = blog[0].replace(/^\s*|\s*$/g, ''); - - var author = doc.evaluate('//span[@class="MoreRecentPostsAuthor"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("by ", ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - - Zotero.debug(doc.location.href); - newItem.url = doc.location.href; - - // This is ACTUALLY returning This URL: http://www.nationalpost.com/components/npemail.aspx?id=591742&ref=http://www.nationalpost.com/story.html - - - var title1 = doc.title; - Zotero.debug(title1); - - newItem.title = title1; - newItem.publication = "The National Post"; - newItem.ISSN = "1486-8008"; - - newItem.complete(); -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//h3[@class="alt"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.href.match("nationalpost")) { - items[next_title.href] = next_title.textContent; - Zotero.debug(next_title.href); - Zotero.debug(next_title.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(); - - - -} -\ No newline at end of file diff --git a/translators/Nature.js b/translators/Nature.js @@ -1,253 +0,0 @@ -{ - "translatorID": "6614a99-479a-4524-8e30-686e4d66663e", - "label": "Nature", - "creator": "Simon Kornblith", - "target": "https?://www\\.nature\\.com[^/]*/(?:[^/]+/journal/v[^/]+/n[^/]+/(?:(?:full|abs)/.+\\.html|index.html)|search/executeSearch)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-03 04:20:14" -} - -var articleRe = /(https?:\/\/[^\/]+\/[^\/]+\/journal\/v[^\/]+\/n[^\/]+\/)(full|abs)(\/.+)\.html/; - -function detectWeb(doc, url) { - if (articleRe.test(url)) { - if (doc.evaluate('//a[contains(@href, ".ris")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } else { - return false; - } - } else { - var links = doc.evaluate('//ol[@class="results-list"]//h2[@class="atl"]/a', doc, null, XPathResult.ANY_TYPE, null); - - if(links.iterateNext()) { - return "multiple"; - } - } - - return false; -} - -function doWeb(doc, url) { - var m = articleRe.exec(url); - - if(!m) { - // search page - var items = new Array(); - - var links = doc.evaluate('//ol[@class="results-list"]//h2[@class="atl"]/a', doc, null, XPathResult.ANY_TYPE, null); - var link; - while((link = links.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - - Zotero.selectItems(items, function(items) { - if(!items) return true; - - var urls = new Array(); - for(var url in items) { - urls.push(url); - } - processArticles(urls); - }); - } else { - processArticles([url]); - } - - Zotero.wait(); -} - -function processArticles(urls) { - var RIS = new Array(); - var regexps = new Array(); - - for each(var item in urls) { - var m = articleRe.exec(item); - if(m[3][m[3].length-2] == "_") { - m[3] = m[3].substr(0, m[3].length-2); - } - RIS.push(m[1]+"ris"+m[3]+".ris"); - regexps.push(m); - } - - Zotero.Utilities.HTTP.doGet(RIS, function(text) { - var url = urls.shift(); - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var m = regexps.shift(); - item.attachments = [ - {url:m[0], title:"Nature Snapshot", mimeType:"text/html"}, - {url:m[1]+"pdf"+m[3]+".pdf", title:"Nature Full Text PDF", mimeType:"application/pdf"} - ] - - item.notes = new Array(); - if (item.date) item.date = item.date.replace("print ", ""); - - item.complete(); - }); - translator.translate(); - }, function() { Zotero.done(); }); -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.nature.com/emboj/journal/vaop/ncurrent/full/emboj2011212a.html", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Huang", - "firstName": "Jian", - "creatorType": "author" - }, - { - "lastName": "Yao", - "firstName": "Ling", - "creatorType": "author" - }, - { - "lastName": "Xu", - "firstName": "Rongting", - "creatorType": "author" - }, - { - "lastName": "Wu", - "firstName": "Huacheng", - "creatorType": "author" - }, - { - "lastName": "Wang", - "firstName": "Min", - "creatorType": "author" - }, - { - "lastName": "White", - "firstName": "Brian S", - "creatorType": "author" - }, - { - "lastName": "Shalloway", - "firstName": "David", - "creatorType": "author" - }, - { - "lastName": "Zheng", - "firstName": "Xinmin", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Nature Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "title": "Nature Full Text PDF", - "mimeType": "application/pdf" - } - ], - "title": "Activation of Src and transformation by an RPTP[alpha] splice mutant found in human tumours", - "journalAbbreviation": "EMBO J", - "date": "online July 01, 2011", - "volume": "advance online publication", - "publisher": "European Molecular Biology Organization", - "ISBN": "1460-2075", - "ISSN": "1460-2075", - "url": "http://dx.doi.org/10.1038/emboj.2011.212", - "DOI": "10.1038/emboj.2011.212", - "publicationTitle": "EMBO J", - "libraryCatalog": "Nature" - } - ] - }, - { - "type": "web", - "url": "http://www.nature.com/nrn/journal/v12/n7/abs/nrn3042.html", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Heinz", - "firstName": "Adrienne J.", - "creatorType": "author" - }, - { - "lastName": "Beck", - "firstName": "Anne", - "creatorType": "author" - }, - { - "lastName": "Meyer-Lindenberg", - "firstName": "Andreas", - "creatorType": "author" - }, - { - "lastName": "Sterzer", - "firstName": "Philipp", - "creatorType": "author" - }, - { - "lastName": "Heinz", - "firstName": "Andreas", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Nature Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "title": "Nature Full Text PDF", - "mimeType": "application/pdf" - } - ], - "title": "Cognitive and neurobiological mechanisms of alcohol-related aggression", - "journalAbbreviation": "Nat Rev Neurosci", - "date": "July 2011", - "volume": "12", - "issue": "7", - "pages": "400-413", - "publisher": "Nature Publishing Group, a division of Macmillan Publishers Limited. All Rights Reserved.", - "ISBN": "1471-003X", - "ISSN": "1471-003X", - "url": "http://dx.doi.org/10.1038/nrn3042", - "DOI": "10.1038/nrn3042", - "publicationTitle": "Nat Rev Neurosci", - "libraryCatalog": "Nature" - } - ] - }, - { - "type": "web", - "url": "http://www.nature.com/search/executeSearch?sp-q-1=&sp-q=nature&sp-p=all&sp-c=25&sp-m=0&sp-s=date_descending&include-collections=journals_nature%2Ccrawled_content&exclude-collections=journals_palgrave%2Clab_animal&sp-a=sp1001702d&sp-sfvl-field=subject%7Cujournal&sp-x-1=ujournal&sp-p-1=phrase&submit=go", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.nature.com/search/executeSearch?sp-q-1=NRN&sp-q=visual+search&sp-c=25&sp-m=0&sp-s=date_descending&include-collections=journals_nature%2Ccrawled_content&exclude-collections=journals_palgrave%2Clab_animal&sp-a=sp1001702d&sp-sfvl-field=subject%7Cujournal&sp-x-1=ujournal&sp-p-1=phrase&sp-p=all&submit=go", - "items": "multiple" - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/New Zealand Herald.js b/translators/New Zealand Herald.js @@ -1,154 +0,0 @@ -{ - "translatorID" : "c7830593-807e-48cb-99f2-c3bed2b148c2", - "label" : "New Zealand Herald", - "creator" : "Sopheak Hean, Michael Berkowitz", - "target" : "^http://www\\.nzherald\\.co\\.nz", - "minVersion" : "1.0", - "maxVersion" : "", - "priority" : 100, - "inRepository" : "1", - "translatorType":4, - "lastUpdated":"2010-08-03 10:49:18" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - -/* If the address bar has /news in it then its a newspaper article*/ - - if (doc.location.href.indexOf("/search/results.cfm") !=-1){ - return "multiple"; - } else if (doc.location.href.indexOf("/news/article.cfm") !=-1){ - return "newspaperArticle"; - } -} - -function associateData (newItem, items, field, zoteroField) { - if (items[field]){ - newItem[zoteroField] = items[field]; - } -} - -function scrape(doc, url){ - var authorTemp; - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var articleLanguage = "English"; - - var newItem = new Zotero.Item('newspaperArticle'); - newItem.url = doc.location.href; - - newItem.publicationTitle = "New Zealand Herald"; - newItem.ISSN = "1170-0777"; - - //Get title of the news via xpath - var myXPath = '//h1'; - var myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var headers; - var items = new Object(); - var authorsTemp; - var blankCell; - var contents; - var authorArray = new Array(); - - /* - Get authors of the article - Remove "By " then replace "and " with ", " - - Put the string into an array then split the array and loop all - authors then push author to Zotero. Possible with more than 1 author - on an article. - */ - var authorXPath = '//span[@class="credits"]'; - var authorXPathObject = doc.evaluate(authorXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if (authorXPathObject) { - var authorString = authorXPathObject.textContent.replace(/\bBy\W+/g, ''); - if (authorString.match(/\W\band\W+/g)){ - authorTemp = authorString.replace(/\W\band\W+/g, ', '); - authorArray = authorTemp.split(", "); - } else if (!authorString.match(/\W\band\W+/g)){ - authorArray = authorString; - } - if( authorArray instanceof Array ) { - for (var i in authorArray){ - var author; - author = authorArray[i]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } else { - if (authorString.match(/\W\bof\W+/g)){ - authorTemp = authorString.replace (/\W\bof\W(.*)/g, ''); - authorArray = authorTemp; - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorTemp, "author")); - - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorArray, "author")); - } - } - } - //date-Year - var dateXPath = '//div[@class="tools"]/span'; - var dateXPathObject = doc.evaluate(dateXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/\d{1,2}:\d{1,2} (AM|PM) (\w)+ /g, ''); - - //If the original Xpath1 is equal to Updated then go to XPath2 - if ((dateXPathObject =="Updated")|| (dateXPathObject =="New")){ - var dateXPath = '//div[@class="tools"]/span[2]'; - var dateXPathObject = doc.evaluate(dateXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/\d{1,2}:\d{1,2} (AM|PM) (\w)+ /g, ''); - newItem.date = dateXPathObject ; - } else { //great found the date just push it to Zotero. - var dateXPath = '//div[@class="tools"]/span'; - var dateXPathObject = doc.evaluate(dateXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/\d{1,2}:\d{1,2} (AM|PM) (\w)+ /g, ''); - newItem.date = dateXPathObject ; - } - - //Get Section of the news - var sectionXPath = '//div[@class="sectionHeader"]/span/a[1]'; - var sectionXPathObject = doc.evaluate(sectionXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.section = sectionXPathObject; - - //Get news title - headers =myXPathObject; - newItem.title = headers; - - newItem.language= articleLanguage; - - //grab abstract from meta data - var a= "//meta[@name='description']"; - newItem.abstractNote = doc.evaluate(a, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.complete(); -} - -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"){ - var titles = doc.evaluate('//p[@class="results"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - while (nextTitle = titles.iterateNext()){ - 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(); -} diff --git a/translators/Newsnetz.js b/translators/Newsnetz.js @@ -1,139 +0,0 @@ -{ - "translatorID":"caecaea0-5d06-11df-a08a-0800200c9a66", - "translatorType":4, - "label":"tagesanzeiger.ch/Newsnetz", - "creator":"ibex", - "target":"^http://((www\\.)?(tagesanzeiger|bernerzeitung|bazonline|derbund|thurgauerzeitung)\\.ch/.)", - "minVersion":"2.0", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2010-09-08 12:00:00" -} - -/* - Tagesanzeiger.ch Translator - Parses tagesanzeiger.ch, bernerzeitung.ch, - bazonline.ch, derbund.ch, thurgauerzeitung.ch articles from to the - Newsnetz and creates Zotero-based metadata. - Copyright (C) 2010 ibex - - 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/>. -*/ - -/* Get the first xpath element from doc, if not found return null. */ -function getXPath(xpath, doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - return doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); -} - -/* Zotero API */ -function detectWeb(doc, url) { - //Zotero.debug("ibex detectWeb URL= "+ url); - if (doc.location.href.indexOf("suche.html?") != -1 && doc.getElementById("panelArticleItems")) { - return "multiple"; - } else if (doc.location.href.indexOf("/story/") != -1 - && getXPath('//div[@id = "singlePage"]/div[@id = "singleLeft"]/h2', doc)) { - return "newspaperArticle"; - } -} - -/* Zotero API */ -function doWeb(doc, url) { - //Zotero.debug("ibex doWeb URL= "+ url); - var urls = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc.getElementById("panelArticleItems").getElementsByTagName("h3"), '/story/\\d+'); - if (!items || countObjectProperties(items) == 0) { - return true; - } - items = Zotero.selectItems(items); - if (!items) { - return true; - } - - for (var i in items) { - urls.push(i); - } - } else { - urls.push(doc.location.href); - } - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); } ); - Zotero.wait(); -} - -function scrape(doc) { - //Zotero.debug("ibex scrape URL = " + doc.location.href); - var newArticle = new Zotero.Item('newspaperArticle'); - newArticle.url = doc.location.href; - newArticle.title = Zotero.Utilities.trimInternal(getXPath('//div[@id = "singleLeft"]/h2', doc).textContent); - - var date = Zotero.Utilities.trimInternal(getXPath('//div[@id = "singleLeft"]/p[@class = "publishedDate"]', doc).textContent); - newArticle.date = Zotero.Utilities.trimInternal(date.split(/[:,] */)[1]); - - var authorline = getXPath('//div[@id = "singleLeft"]/div[@id = "metaLine"]/h5', doc); - if (authorline != null && authorline.textContent.length > 0) { - authorline = Zotero.Utilities.trimInternal(authorline.textContent); - //remove script code "//<![CDATA[ ... //]]>" - authorline = authorline.replace(/\/\/<!\[CDATA\[.*\/\/\]\]>/, ""); - //assumption of authorline: "[Interview:|Von name1 [und Name2][, location].] [Aktualisiert ...]" - authorline = authorline.replace(/Von /, ""); - authorline = authorline.replace(/Interview: /, ""); - authorline = authorline.replace(/Aktualisiert .*$/, ""); - authorline = authorline.replace(/, .*$/, ""); - authorline = Zotero.Utilities.trim(authorline.replace(/\. .*$/, "")); - - var authors = authorline.split(" und "); - for (var i = 0; i < authors.length && authorline.length > 0; i++) { - newArticle.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } - - var teaser = getXPath('//div[@id = "singleLeft"]/p[@class = "teaser"]', doc); - if (teaser != null) { - newArticle.abstractNote = Zotero.Utilities.trimInternal(teaser.textContent); - } - - var publicationTitle = getXPath('//div[@id = "singleLeft"]//span[@class = "idcode"]', doc); - newArticle.publicationTitle = doc.location.host.replace(/^www./,""); - if (publicationTitle != null) { - publicationTitle = Zotero.Utilities.trimInternal(publicationTitle.textContent); - newArticle.publicationTitle += ": " + publicationTitle; - if (publicationTitle == '(Tages-Anzeiger)') { - newArticle.publicationTitle = "Tages-Anzeiger"; - newArticle.ISSN = "1422-9994"; - } - } - - var section = getXPath('//div[@id = "singleHeader"]/h1/span', doc); - if (section != null) { - newArticle.section = Zotero.Utilities.trimInternal(section.textContent); - } - - newArticle.attachments.push({title:"tagesanzeiger.ch Article Snapshot", mimeType:"text/html", url:doc.location.href + "/print.html", snapshot:true}); - - newArticle.complete(); -} - -/* There is no built-in function to count object properties which often are used as associative arrays.*/ -function countObjectProperties(obj) { - var size = 0; - for (var key in obj) { - if (obj.hasOwnProperty(key)) size++; - } - return size; -} -\ No newline at end of file diff --git a/translators/OAIster.js b/translators/OAIster.js @@ -1,90 +0,0 @@ -{ - "translatorID":"4afb932d-9211-4c0b-a31c-cfa984d62b66", - "translatorType":4, - "label":"OAIster", - "creator":"Michael Berkowitz", - "target":"http://quod.lib.umich.edu/cgi/b/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-20 19:10:00" -} - -function detectWeb(doc, url) { - if (doc.title.indexOf("OAIster") != -1) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var items = new Array(); - var titlex = '/html/body/table/tbody/tr/td[2]/table/tbody/tr/td/table/tbody/tr[1]/td[4]/font'; - var titles = doc.evaluate(titlex, doc, null, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - items.push(Zotero.Utilities.trimInternal(title.textContent)); - } - items = Zotero.selectItems(items); - titles = new Array(); - for each (var title in items) { - titles.push(title); - } - Zotero.debug(titles); - var xpath = '//table/tbody/tr/td/table/tbody//table/tbody[tr/td[4]]'; - var arts = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var art; - while (art = arts.iterateNext()) { - var data = new Object(); - var rows = doc.evaluate('./tr[td[4]]', art, null, XPathResult.ANY_TYPE, null); - var row; - while (row = rows.iterateNext()) { - var tag = Zotero.Utilities.trimInternal(doc.evaluate('./td[2]', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var value = Zotero.Utilities.trimInternal(doc.evaluate('./td[4]', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if (tag == "Note") { - if (!data['Note']) { - data[tag] = Zotero.Utilities.unescapeHTML(value); - } - } else { - data[tag] = Zotero.Utilities.unescapeHTML(value); - } - - } - var item = new Zotero.Item(); - if (data['Resource Type']) { - var itemType = data['Resource Type']; - } else { - var itemType = "journalArticle"; - } - if (itemType == "journalArticle" || itemType.match(/(A|a)rticle/) || itemType.match(/text/)) { - item.itemType = "journalArticle"; - } else if (itemType.match(/(T|t)hesis/)) { - item.itemType = "thesis"; - } else if (itemType == "image") { - item.itemType = "artwork"; - } - item.title = data['Title']; - if (data['Author/Creator']) { - var authors = data['Author/Creator'].split(/;/); - for each (var aut in authors) { - if (aut.match(/,/)) { - aut = aut.split(/,\s+/); - aut = aut[1] + " " + aut[0]; - } - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } - item.date = data['Year']; //.match(/\d{4}\-\d{2}\-\d{2}/)[0]; - item.url = data['URL']; - if (data['Note']) item.abstractNote = Zotero.Utilities.trimInternal(data['Note']); - if (data['Subject']) { - var keys = data['Subject'].split(/;/); - for each (var kw in keys) { - if (kw.match(/\w+/)) item.tags.push(kw); - } - } - for (var i in titles) { - if (item.title == titles[i]) item.complete(); - } - } -} -\ No newline at end of file diff --git a/translators/OCLC WorldCat FirstSearch.js b/translators/OCLC WorldCat FirstSearch.js @@ -1,207 +0,0 @@ -{ - "translatorID":"838d8849-4ffb-9f44-3d0d-aa8a0a079afe", - "translatorType":4, - "label":"OCLC WorldCat FirstSearch", - "creator":"Simon Kornblith", - "target":"https?://[^/]*firstsearch\\.oclc\\.org[^/]*/WebZ/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var detailRe = /FirstSearch: [\w ]+ Detailed Record/; - var searchRe = /FirstSearch: [\w ]+ List of Records/; - - if(detailRe.test(doc.title)) { - return "book"; - } else if(searchRe.test(doc.title)) { - return "multiple"; - } -} - -function processURLs(urls) { - if(!urls.length) { // last url - Zotero.done(); - return; - } - - var newUrl = urls.shift(); - - Zotero.Utilities.HTTP.doPost(newUrl, - 'exportselect=record&exporttype=plaintext', function(text) { - var lineRegexp = new RegExp(); - lineRegexp.compile("^([\\w() ]+): *(.*)$"); - - var newItem = new Zotero.Item("book"); - newItem.extra = ""; - - var lines = text.split('\n'); - for(var i=0;i<lines.length;i++) { - var testMatch = lineRegexp.exec(lines[i]); - if(testMatch) { - var match = newMatch; - var newMatch = testMatch - } else { - var match = false; - } - - if(match) { - // is a useful match - if(match[1] == 'Title') { - var title = match[2]; - if(!lineRegexp.test(lines[i+1])) { - i++; - title += ' '+lines[i]; - } - if(title.substring(title.length-2) == " /") { - title = title.substring(0, title.length-2); - } - newItem.title = Zotero.Utilities.capitalizeTitle(title); - } else if(match[1] == "Series") { - newItem.series = match[2]; - } else if(match[1] == "Description") { - var pageMatch = /([0-9]+) p\.?/ - var m = pageMatch.exec(match[2]); - if(m) { - newItem.pages = m[1]; - } - } else if(match[1] == 'Author(s)' || match[1] == "Corp Author(s)") { - var yearRegexp = /[0-9]{4}-([0-9]{4})?/; - - var authors = match[2].split(';'); - if(authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[0], "author", true)); - for(var j=1; j<authors.length; j+=2) { - if(authors[j-1].substring(0, 1) != '(' && !yearRegexp.test(authors[j])) { - // ignore places where there are parentheses - newItem.creators.push({lastName:authors[j], creatorType:"author", fieldMode:true}); - } - } - } else { - newItem.creators.push(Zotero.Utilities.trimInternal(match[2])); - } - } else if(match[1] == 'Publication') { - match[2] = Zotero.Utilities.trimInternal(match[2]); - if(match[2].substring(match[2].length-1) == ',') { - match[2] = match[2].substring(0, match[2].length-1); - } - - // most, but not all, WorldCat publisher/places are - // colon delimited - var parts = match[2].split(/ ?: ?/); - if(parts.length == 2) { - newItem.place = parts[0]; - newItem.publisher = parts[1]; - } else { - newItem.publisher = match[2]; - } - } else if(match[1] == 'Institution') { - newItem.publisher = match[2]; - } else if(match[1] == 'Standard No') { - var ISBNRe = /ISBN:\s*([0-9X]+)/ - var m = ISBNRe.exec(match[2]); - if(m) newItem.ISBN = m[1]; - } else if(match[1] == 'Year') { - newItem.date = match[2]; - } else if(match[1] == "Descriptor") { - if(match[2][match[2].length-1] == ".") { - match[2] = match[2].substr(0, match[2].length-1); - } - - var tags = match[2].split("--"); - for(var j in tags) { - newItem.tags.push(Zotero.Utilities.trimInternal(tags[j])); - } - } else if(match[1] == "Accession No") { - newItem.accessionNumber = Zotero.Utilities.superCleanString(match[2]); - } else if(match[1] == "Degree") { - newItem.itemType = "thesis"; - newItem.thesisType = match[2]; - } else if(match[1] == "DOI") { - newItem.DOI = match[2]; - } else if(match[1] == "Database") { - if(match[2].substr(0, 8) != "WorldCat") { - newItem.itemType = "journalArticle"; - } - } else if(match[1] != "Availability" && - match[1] != "Find Items About" && - match[1] != "Document Type") { - newItem.extra += match[1]+": "+match[2]+"\n"; - } - } else { - if(lines[i] != "" && lines[i] != "SUBJECT(S)") { - newMatch[2] += " "+lines[i]; - } - } - } - - if(newItem.extra) { - newItem.extra = newItem.extra.substr(0, newItem.extra.length-1); - } - - newItem.complete(); - processURLs(urls); - }, false, 'iso-8859-1'); -} - -function doWeb(doc, url) { - var sessionRegexp = /(?:\?|\:)sessionid=([^?:]+)(?:\?|\:|$)/; - var numberRegexp = /(?:\?|\:)recno=([^?:]+)(?:\?|\:|$)/; - var resultsetRegexp = /(?:\?|\:)resultset=([^?:]+)(?:\?|\:|$)/; - var hostRegexp = new RegExp("^(https?://[^/]+)/"); - - var sMatch = sessionRegexp.exec(url); - var sessionid = sMatch[1]; - - var hMatch = hostRegexp.exec(url); - var host = hMatch[1]; - - var newUri, exportselect; - - var detailRe = /FirstSearch: [\w ]+ Detailed Record/; - if(detailRe.test(doc.title)) { - var publisherRegexp = /^(.*), (.*?),?$/; - - var nMatch = numberRegexp.exec(url); - if(nMatch) { - var number = nMatch[1]; - } else { - number = 1; - } - - var rMatch = resultsetRegexp.exec(url); - if(rMatch) { - var resultset = rMatch[1]; - } else { - // It's in an XPCNativeWrapper, so we have to do this black magic - resultset = doc.forms.namedItem('main').elements.namedItem('resultset').value; - } - - urls = [host+'/WebZ/DirectExport?numrecs=10:smartpage=directexport:entityexportnumrecs=10:entityexportresultset=' + resultset + ':entityexportrecno=' + number + ':sessionid=' + sessionid + ':entitypagenum=35:0']; - } else { - var items = Zotero.Utilities.getItemArray(doc, doc, '/WebZ/FSFETCH\\?fetchtype=fullrecord', '^(See more details for locating this item|Detailed Record)$'); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - - for(var i in items) { - var nMatch = numberRegexp.exec(i); - var rMatch = resultsetRegexp.exec(i); - if(rMatch && nMatch) { - var number = nMatch[1]; - var resultset = rMatch[1]; - urls.push(host+'/WebZ/DirectExport?numrecs=10:smartpage=directexport:entityexportnumrecs=10:entityexportresultset=' + resultset + ':entityexportrecno=' + number + ':sessionid=' + sessionid + ':entitypagenum=35:0'); - } - } - } - - processURLs(urls); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/OSTI Energy Citations.js b/translators/OSTI Energy Citations.js @@ -1,50 +0,0 @@ -{ - "translatorID":"0cdc6a07-38cf-4ec1-b9d5-7a3c0cc89b15", - "translatorType":4, - "label":"OSTI Energy Citations", - "creator":"Michael Berkowitz", - "target":"http://www.osti.gov/energycitations", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-20 15:20:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//table[@class="searchresults"]//a[@class="citation"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("product.biblio.jsp") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var urls = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath = '//table[@class="searchresults"]//a[@class="citation"]'; - var links = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_link; - while (next_link = links.iterateNext()) { - items[next_link.href] = next_link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - urls.push(i.match(/osti_id=\d+/)[0]); - } - } else { - urls = [url.match(/osti_id=\d+/)[0]]; - } - for (var i = 0 ; i < urls.length ; i++) { - var getstr = 'http://www.osti.gov/energycitations/endnote?' + urls[i]; - Zotero.Utilities.HTTP.doGet(getstr, function(text) { - Zotero.debug(text); - text = text.replace(/(%.)/g, "$1 "); - var trans = Zotero.loadTranslator("import"); - trans.setTranslator("881f60f2-0802-411a-9228-ce5f47b64c7d"); - trans.setString(text); - trans.translate(); - }); - } -} -\ No newline at end of file diff --git a/translators/Old Bailey Online.js b/translators/Old Bailey Online.js @@ -1,183 +0,0 @@ -{ - "translatorID":"b10bf941-12e9-4188-be04-f6357fa594a0", - "translatorType":4, - "label":"Old Bailey Online", - "creator":"Adam Crymble", - "target":"^http://www\\.oldbaileyonline\\.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-10 21:20:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("search")) { - return "multiple"; - } else if (doc.location.href.match("browse")) { - return "case"; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("case"); - - var headers = doc.evaluate('//div[@class="apparatus"]/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//div[@class="apparatus"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var xPathCount = doc.evaluate('count (//div[@class="apparatus"]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var headersArray = new Array(); - var oneHeader = ''; - - if (xPathCount.numberValue > 1) { - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent; - headersArray.push(fieldTitle); - } - } else { - oneHeader = (headers.iterateNext().textContent); - } - - var contentsArray = new Array(); - var j = 0; - - if (oneHeader.length<1) { - - for (var i = headersArray.length-1; i> -1; i--) { - - var fieldIndex = contents.indexOf(headersArray[i]); - - contentsArray.push(contents.substr(fieldIndex)); - contents = contents.substr(0, fieldIndex); - fieldTitle = headersArray[i].replace(/\s+/g, ''); - - if (fieldTitle != "ReferenceNumber:") { - tagsContent.push(contentsArray[j]); - } else { - refNum = contentsArray[j]; - newItem.extra = refNum; - } - j++; - } - } else { - - if (oneHeader.match("Reference")) { - newItem.extra = contents; - } else { - newItem.tags = contents; - var noMoreTags = 1; - } - } - - if (noMoreTags != 1) { - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - } - - newItem.title = doc.evaluate('//div[@class="sessionsPaperTitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.url = doc.location.href; - - newItem.complete(); -} - -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 onlyResultSet = false; - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//li/p[@class="srchtitle"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - // add option to save search URL as single item - items["resultSet"] = "Save search URL as item"; - - items = Zotero.selectItems(items); - - for (var i in items) { - articles.push(i); - } - // if option to save result set is selected - if (items["resultSet"]) { - if (articles.length == 1) { - onlyResultSet = true; - } - var newItem = new Zotero.Item("case"); - - newItem.title = 'Old Bailey Search Result Set'; - - var searchURL = doc.location.href; - newItem.url = searchURL; - - // define dictionary for easier reading - var defs = { - "_divs_fulltext": "Keywords", - "_persNames_surname": "Surname", - "_persNames_given": "Given name", - "_persNames_alias": "Alias", - "_offences_offenceCategory_offenceSubcategory": "Offence", - "_verdicts_verdictCategory_verdictSubcategory": "Verdicts", - "_punishments_punishmentCategory_punishmentSubcategory": "Punishment", - "_divs_div0Type_div1Type": "Corpus", - "fromMonth": "From month", - "fromYear": "From year", - "toMonth": "To month", - "toYear": "To year" - }; - - // parse URL into human-readable elements - var noteText = '<b>Search Parameters</b><br/>'; - var re = /(?:\?|&(?:amp;)?)([^=]+)=?([^&]*)?/g; - var match; - var key=''; - while (match = re.exec(searchURL)) { - if (defs[match[1]] != null) { - key = defs[match[1]]; - noteText += key + ": " + unescape(match[2]) + "<br/>"; - } - } - - // save them in the notes field - newItem.notes.push({note: noteText}); - newItem.complete(); - - // remove dummy url for result set from articles list - articles.pop(); - } - } - else if (doc.evaluate('//div[@id="main2"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var xmlOrText = doc.evaluate('//div[@id="main2"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if (xmlOrText.textContent.match("Text")) { - articles = [xmlOrText.href]; - } - else { - articles = [url]; - } - } - - if (!onlyResultSet) { - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } -} diff --git a/translators/Open WorldCat.js b/translators/Open WorldCat.js @@ -1,131 +0,0 @@ -{ - "translatorID":"c73a4a8c-3ef1-4ec8-8229-7531ee384cc4", - "translatorType":12, - "label":"Open WorldCat", - "creator":"Simon Kornblith", - "target":"^http://www\\.worldcat\\.org/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-06-05 20:35:00" -} - -/** - * Gets Zotero item from a WorldCat icon src - */ -function getZoteroType(iconSrc) { - // only specify types not specified in COinS - if(iconSrc.indexOf("icon-rec") != -1) { - return "audioRecording"; - } if(iconSrc.indexOf("icon-com") != -1) { - return "computerProgram"; - } if(iconSrc.indexOf("icon-map") != -1) { - return "map"; - } - return false; -} - -/** - * Generates a Zotero item from a single item WorldCat page, or the first item on a multiple item - * page - */ -function generateItem(doc, node) { - var item = new Zotero.Item(); - Zotero.Utilities.parseContextObject(node.nodeValue, item); - - // if only one, first check for special types (audio & video recording) - var type = false; - try { - type = doc.evaluate('//img[@class="icn"][contains(@src, "icon-")]/@src', doc, null, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - } catch(e) {} - - if(type) { - type = getZoteroType(type); - if(type) item.itemType = type; - } - - return item; -} - -function detectWeb(doc) { - var xpath = doc.evaluate('//span[@class="Z3988"]/@title', doc, null, XPathResult.ANY_TYPE, null); - var node = xpath.iterateNext(); - if(!node) return false; - - // see if there is more than one - if(xpath.iterateNext()) { - multiple = true; - return "multiple"; - } - - // generate item and return type - return generateItem(doc, node).itemType; -} - -function detectSearch(item) { - return !!item.ISBN; -} - -function doWeb(doc) { - // otherwise, we need to get context objects and display select items dialog - var elems = []; - - // accumulate OpenURL contextObject nodes - var xpath = doc.evaluate('//span[@class="Z3988"]/@title', doc, null, XPathResult.ANY_TYPE, null); - while(elem = xpath.iterateNext()) { - elems.push(elem); - } - - if(elems.length > 1) { // multiple items - var items = []; - var titles = []; - for(var i in elems) { - var item = new Zotero.Item(); - Zotero.Utilities.parseContextObject(elems[i].nodeValue, item); - items.push(item); - titles.push(item.title); - } - - titles = Zotero.selectItems(titles); - if(!titles) return true; - - // accumulate appropriate types - var i = 0; - try { - var xpath = doc.evaluate('//div/img[@class="icn"][contains(@src, "icon-")][1]/@src', doc, null, XPathResult.ANY_TYPE, null); - while(elem = xpath.iterateNext()) { - var type = getZoteroType(elem.nodeValue); - if(type) items[i].itemType = type; - i++; - } - } catch(e) {} - - // complete items - for(var i in titles) { - items[i].complete(); - } - } else { // single item - generateItem(doc, elems[0]).complete(); - } -} - -function doSearch(item) { - if(item.contextObject) { - var co = item.contextObject; - } else { - var co = Zotero.Utilities.createContextObject(item); - } - - Zotero.Utilities.loadDocument("http://www.worldcat.org/search?q=isbn%3A"+item.ISBN+"&=Search&qt=results_page", function(doc) { - var node = doc.evaluate('//span[@class="Z3988"]/@title', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if(!node) Zotero.done(false); - - var item = generateItem(doc, node); - item.complete(); - - Zotero.done(); - }, null); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/OpenJudis - Indian Supreme Court cases.js b/translators/OpenJudis - Indian Supreme Court cases.js @@ -1,100 +0,0 @@ -{ - "translatorID":"fe39e97d-7397-4f3f-a5f3-396a1a79213c", - "translatorType":4, - "label":"OpenJudis - Indian Supreme Court cases", - "creator":"Prashant Iyengar and Michael Berkowitz", - "target":"http://(www.)?openarchive.in/(judis|newcases)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@id="footer"]/dl/dt/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.match(/\d+\.htm/)) { - return "case"; - } -} - -function regexMeta(stuff, item) { - if (stuff) { - if (stuff[0] == "Origlink") { - item.source = stuff[1].split(/\s+/)[0]; - } - if (stuff[0] == "Acts") { - if (stuff[1].indexOf("|")!=-0) { - echts=stuff[1].split(" | "); - for (i=0;i<echts.length;i++) { - item.tags.push(echts[i]); - } - } else { - item.tags.push(stuff[1]); - } - } - if (stuff[0] == "Citations" && stuff[1].length > 1) { - item.reporter=stuff[1]; - } - if (stuff[0] == "Judges") { - if (stuff[1].indexOf(";")!=-0) { - jedges=stuff[1].split(" ; "); - for (i=0;i<jedges.length;i++) { - item.creators.push(Zotero.Utilities.cleanAuthor(jedges[i], "author")); - } - } else { - item.creators.push(Zotero.Utilities.cleanAuthor(stuff[1], "author")); - } - } - if (stuff[0] == "Jday") { - item.dateDecided= stuff[1]; - } - } -} - - - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, "^http:\/\/openarchive\.in\/[^/]+\/[0-9]+.htm$"); - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { arts = [url]; } - Zotero.debug(arts); - for each (var art in arts) { - var newurl = art; - Zotero.Utilities.HTTP.doGet(art, function(text) { - var newItem = new Zotero.Item("case"); - newItem.publicationTitle = "OpenJudis - http://judis.openarchive.in"; - newItem.url = url; - - //title - var t = /\<title\>([\w\W]*?)<\/title/; - newItem.title = Zotero.Utilities.trimInternal(t.exec(text)[1]); - newItem.caseName = newItem.title; - newItem.url = newurl; - newItem.court="The Supreme Court of India"; - - newItem.websiteTitle="OpenJudis - http://judis.openarchive.in"; - newItem.edition="Online"; - - var metareg = /<META NAME[^>]+\>/g; - var tags = text.match(metareg); - for each (var tag in tags) { - var stuff = tag.match(/NAME=\"([^"]+)\"\s+CONTENT=\"([^"]+)\"/); - regexMeta([stuff[1], stuff[2]], newItem); - } - pdfurl = 'http://judis.openarchive.in/makepdf.php?filename=' + newItem.url; - newItem.attachments = [ - {url:newItem.url, title:"OpenJudis Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"OpenJudis PDF", mimeType:"application/pdf"} - ]; - newItem.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); - } -} diff --git a/translators/Optical Society of America.js b/translators/Optical Society of America.js @@ -1,91 +0,0 @@ -{ - "translatorID":"a1a97ad4-493a-45f2-bd46-016069de4162", - "translatorType":4, - "label":"Optical Society of America", - "creator":"Michael Berkowitz and Eli Osherovich", - "target":"https?://[^.]+\\.(opticsinfobase|osa)\\.org", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var searchpath = '//div[@id="col2"]/p/strong/a'; - if (doc.evaluate(searchpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("abstract.cfm") != -1) { - 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 = doc.location.host; - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath = '//div[@id="col2"]/p/strong/a'; - var arts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_art; - while (next_art = arts.iterateNext()) { - items[next_art.href] = Zotero.Utilities.trimInternal(next_art.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - Zotero.Utilities.processDocuments(articles, function(newDoc) { - var osalink = newDoc.evaluate('//div[@id="abstract-header"]/p/a[contains(text(), "opticsinfobase")]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - var pdfpath = '//div[@id="abstract-header"]/p/a[contains(text(), "Full Text")]'; - var pdflink = newDoc.evaluate(pdfpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var abstractblock = newDoc.evaluate('//meta[@name="dc.description"]', newDoc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - var identifierblock = newDoc.evaluate('//meta[@name="dc.identifier"]', newDoc, nsResolver, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; - Zotero.Utilities.HTTP.doGet(osalink, function(text) { - var action = text.match(/select\s+name=\"([^"]+)\"/)[1]; - var id = text.match(/input\s+type=\"hidden\"\s+name=\"articles\"\s+value=\"([^"]+)\"/)[1]; - var get = 'http://' + host + '/custom_tags/IB_Download_Citations.cfm'; - var post = 'articles=' + id + '&ArticleAction=save_endnote2&' + action + '=save_endnote2'; - Zotero.Utilities.HTTP.doPost(get, post, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var pubName; - if (item.journalAbbreviation) { - pubName = item.journalAbbreviation; - } else { - pubName = item.publicationTitle; - } - if (identifierblock) { - if (/doi:(.*)$/.test(identifierblock.getAttribute('content'))) { - item.DOI = RegExp.$1; - } - } - item.attachments = [{url:osalink, title:pubName + " Snapshot", mimeType:"text/html"}]; - if (pdflink) { - item.attachments.push({url:pdflink.href, title:"OSA Journals PDF", mimeType:"application/pdf"}); - } - - if (abstractblock) { - item.abstractNote = abstractblock.getAttribute('content'); - } - item.complete(); - }); - translator.translate(); - }); - }); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/Optics Express.js b/translators/Optics Express.js @@ -1,78 +0,0 @@ -{ - "translatorID":"8a07dd43-2bce-47bf-b4bf-c0fc441b79a9", - "translatorType":4, - "label":"Optics Express", - "creator":"Michael Berkowitz", - "target":"http://(www.)?opticsexpress\\.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-15 19:40:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var searchpath = '//div[@id="col2"]/p/strong/a'; - if (doc.evaluate(searchpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("abstract.cfm") != -1) { - 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 articles = new Array(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath = '//div[@id="col2"]/p/strong/a'; - var art = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_art; - while (next_art = art.iterateNext()) { - items[next_art.href] = Zotero.Utilities.trimInternal(next_art.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - for (var a in articles) { - var link = articles[a]; - Zotero.Utilities.HTTP.doGet(link, function(text) { - if (text.match(/doi:.*\"/)) var doi = text.match(/doi:(.*)\"/)[1]; - var id = text.match(/name=\"articles\"\s+value=\"([^"]+)\"/)[1]; - var action = text.match(/select\s+name=\"([^"]+)\"/)[1]; - var get = 'http://www.opticsinfobase.org/custom_tags/IB_Download_Citations.cfm'; - var post = 'articles=' + id + '&ArticleAction=save_endnote2&' + action + '=save_endnote2'; - Zotero.Utilities.HTTP.doPost(get, post, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var pubName; - if (item.journalAbbreviation) { - pubName = item.journalAbbreviation; - } else { - pubName = item.publicationTitle; - } - if (doi) item.DOI = doi; - item.attachments = [{url:articles[a], title:pubName + " Snapshot", mimeType:"text/html"}]; - item.complete(); - }); - translator.translate(); - }); - }); - } -} -\ No newline at end of file diff --git a/translators/Osterreichischer Bibliothekenverbund.js b/translators/Osterreichischer Bibliothekenverbund.js @@ -1,52 +0,0 @@ -{ - "translatorID":"e1140aa1-3bcf-4226-9099-78ef0b63bb3e", - "translatorType":4, - "label":"Osterreichischer Bibliothekenverbund", - "creator":"Michael Berkowitz", - "target":"http://meteor.bibvb.ac.at/F", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//td[@class="bar"]/a[@class="blue"]/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } else if (doc.title.indexOf("Ergebnisliste") != -1) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var itemRegexp = '^https?://[^/]+/F/[A-Z0-9\-]+\?.*(?:func=full-set-set.*\&format=999|func=direct)' - var items = Zotero.Utilities.getItemArray(doc, doc, itemRegexp, '^[0-9]+$'); - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(newDoc) { - var link = newDoc.evaluate('//td[@class="bar"]/a[@class="blue"][2]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - link = link.replace(/full\-mail[^&]+&/, "full-mail&") + "&option_type=&format=777&encoding=UTF_TO_WEB_MAIL+++++&SUBJECT=&NAME=&EMAIL=&x=17&y=7"; - Zotero.Utilities.loadDocument([link], function(newDoc2) { - var newest = newDoc2.evaluate('/html/body/p[@class="text3"]/a', newDoc2, null, XPathResult.ANY_TYPE, null).iterateNext().href; - Zotero.Utilities.HTTP.doGet(newest, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.itemType = "book"; - item.complete(); - }); - translator.translate(); - }); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Ovid.js b/translators/Ovid.js @@ -1,206 +0,0 @@ -{ - "translatorID":"cde4428-5434-437f-9cd9-2281d14dbf9", - "translatorType":4, - "label":"Ovid", - "creator":"Simon Kornblith and Michael Berkowitz", - "target":"/(gw2|sp[^\\/]+)/ovidweb\\.cgi", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var rmXPath = '//span['; - var rmText = [ - "Results Manager", - "Gestionnaire des résultats", - "Ergebnismanager", - "檢索結果管理員", - "Administrador de resultados", - "检索结果管理员" - ]; - var contains = []; - for each(var str in rmText) { - contains.push('contains(./text(), "' + str + '")'); - } - rmXPath += contains.join(' or ') + ']' - if(!doc.evaluate(rmXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return false; - } - - var results = doc.evaluate('//div[@class="bibheader-resultsrange"]/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var first = results.iterateNext(); - if(first) { - first = Zotero.Utilities.trimInternal(first.textContent); - var second = results.iterateNext(); - second = Zotero.Utilities.trimInternal(second.textContent); - if(first.indexOf("-") != -1 || second.indexOf("-") != -1) { - return "multiple"; - } else { - return "journalArticle"; - } - } - - return false; -} - -function senCase(string) { - var words = string.split(/\b/); - for (var i = 0 ; i < words.length ; i++) { - if (words[i].match(/[A-Z]/)) { - words[i] = words[i][0] + words[i].substring(1).toLowerCase(); - } - } - return words.join(""); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var results = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="bibheader-resultsrange"]/b', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var post = "S="+doc.evaluate('.//input[@name="S"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value; - - if(results.indexOf("-") != -1) { - var items = new Object(); - - // Go through table rows - if (doc.evaluate('/html/body/form/div[substring(@class, 1, 10)="titles-row"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var tableRows = doc.evaluate('/html/body/form/div[substring(@class, 1, 10)="titles-row"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } else if (doc.evaluate('//div[@id="titles-records"]/table[@class="titles-row"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var tableRows = doc.evaluate('//div[@id="titles-records"]/table[@class="titles-row"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - var tableRow; - while(tableRow = tableRows.iterateNext()) { - var id = doc.evaluate('.//input[@name="R"]', tableRow, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().value; - items[id] = Zotero.Utilities.trimInternal(doc.evaluate('.//span[@class="titles-title"]', tableRow, - nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - var items = Zotero.selectItems(items); - if(!items) return true; - - for(var i in items) { - post += "&R="+i; - } - } else { - var id = doc.evaluate('.//input[@name="R"]', doc, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().value; - post += "&R="+id; - } - - if (detectWeb(doc, url) == "multiple") { - var selectvar = doc.evaluate('.//input[@name="SELECT"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextselect = selectvar.iterateNext().value; - if (next = selectvar.iterateNext()) { - post += "&SELECT=" + next.value; - } else { - post += "&SELECT="+ nextselect; - } - } else { - post += "&SELECT=" + doc.evaluate('.//input[@name="SELECT"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value; - } - post += "&CitMan="+doc.evaluate('.//input[@name="CitMan"]', doc, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().value; - post += "&CitManPrev="+doc.evaluate('.//input[@name="CitManPrev"]', doc, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().value; - post += "&cmRecordSelect=SELECTED&cmFields=ALL&cmFormat=export&cmsave.x=12&cmsave.y=7&doSave=1"; - - Zotero.Utilities.HTTP.doPost(url, post, function(text) { - var lines = text.split("\n"); - var haveStarted = false; - var newItemRe = /^<[0-9]+>/; - - var newItem = new Zotero.Item("journalArticle"); - - for(var i in lines) { - if(lines[i].substring(0,3) == "<1>") { - haveStarted = true; - } else if(newItemRe.test(lines[i])) { - newItem.complete(); - - newItem = new Zotero.Item("journalArticle"); - } else if(lines[i].substr(2, 4) == " - " && haveStarted) { - var fieldCode = lines[i].substr(0, 2); - var fieldContent = Zotero.Utilities.trimInternal(lines[i].substr(6)); - if(fieldCode == "TI") { - newItem.title = fieldContent.replace(/\. \[\w+\]$/, ""); - } else if(fieldCode == "AU") { - var names = fieldContent.split(", "); - - if(names.length >= 2) { - // get rid of the weird field codes - if(names.length == 2) { - names[1] = names[1].replace(/ [\+\*\S\[\]]+$/, ""); - } - names[1] = names[1].replace(/ (?:MD|PhD|[BM]Sc|[BM]A|MPH|MB)$/i, ""); - - newItem.creators.push({firstName:names[1], lastName:names[0], creatorType:"author"}); - } else if (fieldContent.match(/^(.*) [A-Z]{1,3}$/)) { - names = fieldContent.match(/^(.*) ([A-Z]{1,3})$/); - newItem.creators.push({firstName:names[2], lastName:names[1], creatorType:"author"}); - } else { - newItem.creators.push({lastName:names[0], isInstitution:true, creatorType:"author"}); - } - } else if(fieldCode == "SO") { - if (fieldContent.match(/\d{4}/)) { - newItem.date = fieldContent.match(/\d{4}/)[0]; - } - if (fieldContent.match(/(\d+)\((\d+)\)/)) { - var voliss = fieldContent.match(/(\d+)\((\d+)\)/); - newItem.volume = voliss[1]; - newItem.issue = voliss[2]; - } - if (fieldContent.match(/vol\.\s*(\d+)/)) { - newItem.volume = fieldContent.match(/vol\.\s*(\d+)/)[1]; - } - if (fieldContent.match(/vol\.\s*\d+\s*,\s*no\.\s*(\d+)/)) { - newItem.issue = fieldContent.match(/vol\.\s*\d+\s*,\s*no\.\s*(\d+)/)[1]; - } - if (fieldContent.match(/\d+\-\d+/)) - newItem.pages = fieldContent.match(/\d+\-\d+/)[0]; - if (fieldContent.match(/pp\.\s*(\d+\-\d+)/)) - newItem.pages = fieldContent.match(/pp\.\s*(\d+\-\d+)/)[1]; - if (fieldContent.match(/[J|j]ournal/)) { - newItem.publicationTitle = fieldContent.match(/[J|j]ournal[-\s\w]+/)[0]; - } else { - newItem.publicationTitle = Zotero.Utilities.trimInternal(fieldContent.split(/(\.|;|(,\s*vol\.))/)[0]); - } - } else if(fieldCode == "SB") { - newItem.tags.push(Zotero.Utilities.superCleanString(fieldContent)); - } else if(fieldCode == "KW") { - newItem.tags.push(fieldContent.split(/; +/)); - } else if(fieldCode == "DB") { - newItem.repository = "Ovid ("+fieldContent+")"; - } else if(fieldCode == "DI") { - newItem.DOI = fieldContent; - } else if(fieldCode == "DO") { - newItem.DOI = fieldContent; - } else if(fieldCode == "DP") { - newItem.date = fieldContent; - } else if(fieldCode == "IS") { - newItem.ISSN = fieldContent; - } else if(fieldCode == "AB") { - newItem.abstractNote = fieldContent; - } - } - } - - // last item is complete - if(haveStarted) { - newItem.complete(); - } - Zotero.done(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Oxford Music and Art Online.js b/translators/Oxford Music and Art Online.js @@ -1,59 +0,0 @@ -{ - "translatorID":"f203db7f-7b7b-4dc4-b018-115b7885fe3b", - "translatorType":4, - "label":"Oxford Music and Art Online", - "creator":"Michael Berkowitz", - "target":"http://[^/]*www.oxford(music|art)online.com[^/]*/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-10 06:15:00" -} - -function detectWeb(doc, url) { - if (url.match(/search_results/)) { - return "multiple"; - } else if (url.match(/\/article\//)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var host = doc.location.host; - var site = host.match(/oxford(.*)online/)[1]; - var ids = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//ul[@class="search_result_list"]/li/p/a', doc, null, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - ids.push(i.match(/(music|art)\/([^?]+)/)[2]); - } - } else { - ids = [url.match(/(music|art)\/([^?]+)/)[2]]; - } - Zotero.debug(ids); - for each (var id in ids) { - var get = 'http://' + host + '/subscriber/article_export_citation/grove/' + site + '/' + id; - Zotero.Utilities.HTTP.doGet(get, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var authors = new Array(); - for (var i in item.creators) { - names = item.creators[i].lastName.match(/(.*)\s([^\s]+)$/); - authors.push({firstName:names[1], lastName:names[2], creatorType:"author"}); - } - item.creators = authors; - item.complete(); - }); - translator.translate(); - }); - } -} -\ No newline at end of file diff --git a/translators/PEI Archival Information Network.js b/translators/PEI Archival Information Network.js @@ -1,173 +0,0 @@ -{ - "translatorID":"6871e8c5-f935-4ba1-8305-0ba563ce3941", - "translatorType":4, - "label":"PEI Archival Information Network", - "creator":"Adam Crymble", - "target":"http://www.archives.pe.ca", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-11 20:40:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (doc.evaluate('//td[2]/table/tbody/tr/td/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match("Search")) { - return "multiple"; - - } else if (doc.evaluate('//td[2]/table/tbody/tr/td/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match("Display")){ - return "book"; - } -} - -//PEI Archival Information Network translator: Code by Adam Crymble - -var authors; - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function authors1() { - for (var k = 0; k< authors.length; k++) { - if (authors[k].match(", ")) { - var author = authors[k].split(", "); - authors[k] = (author[1] + (" ") + author[0].replace(/^\s*|\s*$/g, '')); - - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[k], "author")); - - } else { - - newItem.creators.push({lastName: authors[k], creatorType: "creator"}); - } - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - var contents; - var tagsContent = new Array(); - - newItem = new Zotero.Item("book"); - - var xPathHeadings = doc.evaluate('//small/b', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathContents = doc.evaluate('//dd', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//small/b)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue; i++) { - - fieldTitle = xPathHeadings.iterateNext().textContent.replace(/\s+/g, ''); - contents = xPathContents.iterateNext().textContent; - - if (fieldTitle == "AccessPoints") { - - //creates Author - dataTags["Author"] = (contents.substr(11).replace(/^\s*|\s*$/g, '')); - contents = xPathContents.iterateNext().textContent; - - authors = dataTags["Author"].split(/\n/); - authors1(); - - //creates Other Authors (if any) - dataTags["OtherAuthor"] = (contents.substr(13).replace(/^\s*|\s*$/g, '')); - contents = xPathContents.iterateNext().textContent; - - if (dataTags["OtherAuthor"].match("no Other Author access points found")) { - - } else { - - authors = dataTags["OtherAuthor"].split(/\n/); - authors1(); - } - - //creates tags - dataTags["subject"] = (contents); - var tags; - - var tagLinks = doc.evaluate('//dd/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var tagsLinksCount = doc.evaluate('count (//dd/a)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (j = 0; j < tagsLinksCount.numberValue; j++) { - - tags = tagLinks.iterateNext(); - if (tags.href.match("subject")) { - tagsContent.push(tags.textContent); - } - } - } else { - - dataTags[fieldTitle] = (contents.replace(/^\s*|\s*$/g, '')); - } - } - - for (var i = 0; i < tagsContent.length; i++) { - newItem.tags[i] = tagsContent[i]; - } - - associateData (newItem, dataTags, "NameofRepository", "repository"); - associateData (newItem, dataTags, "DatesofCreation", "date"); - associateData (newItem, dataTags, "Identifier", "callNumber"); - associateData (newItem, dataTags, "PhysicalDescription", "extra"); - associateData (newItem, dataTags, "ScopeAndContent", "abstractNote"); - associateData (newItem, dataTags, "Title/StmntofResponsibility", "title"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var xPathTitles = doc.evaluate('//td/ul', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var linkContent = xPathTitles.iterateNext().textContent.split(/\n/); - - - var linkContent1; - var linkHref = new Array(); - - var xPathLinks= doc.evaluate('//ul/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathLinksCount = doc.evaluate('count (//ul/a)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i< xPathLinksCount.numberValue; i++) { - linkHref.push(xPathLinks.iterateNext().href); - - var y = (i + 1); - linkContent1 = linkContent[y].split("- "); - - - items[linkHref[i]] = linkContent1[1]; - } - - - 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(); -} -\ No newline at end of file diff --git a/translators/PEP Web.js b/translators/PEP Web.js @@ -1,115 +0,0 @@ -{ - "translatorID":"32ad4782-b106-4ccb-8ae1-ff102ba93eef", - "translatorType":4, - "label":"PEP Web", - "creator":"Akilesh Ayyar", - "target":"^https?://www\\.pep-web\\.org", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2011-02-15 04:50:00" -} - -//Only works for journal articles, and only for single entries. -//Author names sometimes omit periods after the first initials. - -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(/document/)) - return "journalArticle"; -} - - -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"); - newItem.url = doc.location.href; - - var xPathString = "//span[@id='maincite']"; - - var xPathString2 = '//p[@class="title"]/a'; - - var myXPathObject = doc.evaluate(xPathString, doc, nsResolver, XPathResult.ANY_TYPE, null); - var myXPathObject2 = doc.evaluate(xPathString2, doc, nsResolver, XPathResult.ANY_TYPE, null); - - var citeString = myXPathObject.iterateNext().textContent; - var titleString = myXPathObject2.iterateNext().textContent; - - //authors - var authors = citeString.match(/(^.*)\(/)[1].toString(); - if (authors == ' ') { - authors = "Unknown"; - } - - var currentauthor; - - //grab all but last author, if there are more than one - while (authors.match(/^(.*?)(\,)(\s)([A-Z]\.)*\,\s/)) { - currentauthor = authors.match(/^(.*?)(\,)(\s)([A-Z]\.)*/)[0].toString(); - newItem.creators.push(Zotero.Utilities.cleanAuthor(currentauthor, "author", true)); - authors = authors.replace(/^(.*?)(\,)(\s)([A-Z]\.)*\,\s/, ''); - } - - //grab remaining author, or sole author if there's only one - if (authors != null) { - currentauthor = authors; - newItem.creators.push(Zotero.Utilities.cleanAuthor(currentauthor, "author", true)); - } - - //title - newItem.title = titleString; - - //year - var year = citeString.match(/\([0-9][0-9][0-9][0-9]\)/).toString(); - year = year.replace(/\(/, ''); - year = year.replace(/\)/, ''); - newItem.date = year; - - //publication name - var pubname = citeString.match(/(\)\.\s)(.*)(\,)/)[0].toString(); - var pubminus = citeString.match(/(\)\.\s)(.*?)(\.)/)[0].toString(); - pubname = pubname.replace(pubminus, ''); - pubname = pubname.replace(/\,/, ''); - pubname = pubname.replace(/\.*/, ''); - pubname = pubname.replace(/^\s*/, ''); - pubname = pubname.replace(/\s*$/, '') - newItem.publicationTitle = pubname; - - //volume - var volumeandpages = citeString.match(/[0-9]*\:([0-9]*(\-?)[0-9]*)\.$/)[0].toString(); - var volume = volumeandpages.match(/[0-9]*\:/)[0].toString(); - volume = volume.replace(":", ''); - newItem.volume = volume; - - //pages - var pages = volumeandpages.match(/\:([0-9]*)(\-?)([0-9]*)/)[0].toString(); - pages = pages.replace(":", ''); - pages = pages.replace(".", ''); - newItem.pages = pages; - - newItem.attachments.push({url:doc.location.href, title:"PEP Web Snapshot", mimeType:"text/html"}); - - newItem.complete(); -} - - -function doWeb(doc, url) { - - var articles = new Array(); - - articles = [url]; - - Zotero.Utilities.processDocuments(articles, scrape, function(){Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/PLoS Biology and Medicine.js b/translators/PLoS Biology and Medicine.js @@ -1,87 +0,0 @@ -{ - "translatorID":"bdae838b-3a58-461f-9e8a-142ed9de61dc", - "translatorType":4, - "label":"PLoS Biology and Medicine", - "creator":"Michael Berkowitz", - "target":"http://[^.]+\\.plosjournals\\.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="search"][@id="browseResults"]/ul/li/span/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || - doc.evaluate('//div[@id="toclist"]/dl/dt/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("get-document") != -1) { - return "journalArticle"; - } -} - -function unescape(text) { - var specialreg=new RegExp("&#[^;]+;"); - var specials=specialreg.exec(text); - while(specials) { - text=text.replace(specials[0], String.fromCharCode(parseInt(specials[0].substring(2, specials[0].length-1), 10))); - specials=specialreg.exec(text); - } - return text; -} - -function doWeb(doc, url) { - var URLs = new Array(); - var items = new Object(); - if (detectWeb(doc, url) == "multiple") { - if (doc.evaluate('//div[@class="search"][@id="browseResults"]/ul/li/span/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@class="search"][@id="browseResults"]/ul/li/span/a'; - } else if (doc.evaluate('//div[@id="toclist"]/dl/dt/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="toclist"]/dl/dt/a'; - } - var articles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_article = articles.iterateNext(); - while (next_article) { - items[next_article.href] = Zotero.Utilities.trimInternal(next_article.textContent); - next_article = articles.iterateNext(); - } - items = Zotero.selectItems(items); - - if (!items) { - return true; - } - - for (var i in items) { - URLs.push(i); - } - } else { - URLs.push(url); - } - - - Zotero.Utilities.processDocuments(URLs, function(doc, url) { - var bits = doc.location.href.match(/(^.*\?request=).*(doi=.*$)/); - var RISurl = bits[1] + 'download-citation&t=refman&' + bits[2]; - Zotero.Utilities.HTTP.doGet(RISurl, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - trans.setString(text); - trans.setHandler("itemDone", function(obj, newItem) { - var urlstring= bits[1]+ 'get-pdf&' +bits[2].replace("doi=", "file=").replace("/", "_").replace("%2F", "_") + '-S.pdf'; - newItem.attachments.push({url:urlstring, title:newItem.title, mimeType:"application/pdf"}); - - var urlRE = /http:\/\/dx.doi.org\/(.*)$/; - if (newItem.url) { - newItem.DOI = newItem.url.match(urlRE)[1].replace("%2F", "/"); - } - - newItem.complete(); - }); - trans.translate(); - Zotero.done(); - }); - Zotero.wait(); - }, function() {Zotero.done();}); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/PLoS Journals.js b/translators/PLoS Journals.js @@ -1,273 +0,0 @@ -{ - "translatorID": "9575e804-219e-4cd6-813d-9b690cbfc0fc", - "label": "PLoS Journals", - "creator": "Michael Berkowitz And Rintze Zelle", - "target": "^http://www\\.plos(one|ntds|compbiol|pathogens|genetics|medicine|biology)\\.org/(search|article)/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-08-22 22:31:21" -} - -function detectWeb(doc, url) { - if (url.indexOf("Search.action") != -1 || url.indexOf("browse.action") != -1 || url.indexOf("browseIssue.action") != -1) { - return "multiple"; - } else if (url.indexOf("article/info") != -1) { - return "journalArticle"; - } -} - - -function getSelectedItems(doc, articleRegEx) { - var items = {}; - var texts = []; - var articles = doc.evaluate(articleRegEx, doc, null, XPathResult.ANY_TYPE, null); - var next_art = articles.iterateNext(); - while (next_art) { - items[next_art.href] = next_art.textContent; - next_art = articles.iterateNext(); - } - Zotero.selectItems(items, function(items) { - for (var i in items) { - texts.push(i); - } - processTexts(texts); - }); -} - -function doWeb(doc, url) { - if (url.indexOf("Search.action") != -1 || url.indexOf("browse.action") != -1) { - var articlex = '//span[@class="article"]/a'; - getSelectedItems(doc, articlex); - } else if (url.indexOf("browseIssue.action") != -1) { - var articlex = '//div[@class="article"]/h3/a'; - getSelectedItems(doc, articlex); - } else { - processTexts([url]); - } - - Zotero.wait(); -} - -function processTexts(texts) { - var risLinks = []; - for (var i in texts) { - texts[i]=texts[i].replace(/;jsessionid[^;]+/, "");//Strip sessionID string - texts[i]=texts[i].replace(/\?.*/, "");//Strip referrer messes - var risLink = texts[i].replace("info", "getRisCitation.action?articleURI=info"); - risLinks.push(risLink); - } - - Zotero.Utilities.HTTP.doGet(risLinks, function(text) { - var risLink = texts.shift(); - var pdfURL = risLink.replace("info", "fetchObjectAttachment.action?uri=info") + '&representation=PDF'; - var doi = risLink.match(/doi(\/|%2F)(.*)$/)[2]; - text = text.replace(text.match(/(ER[^\n]*)([^\0]*)/)[2],"");//Remove stray M3-tag at the end of the RIS record - text = text.replace("%2F","/");//Replace %2F characters by forward slashes in url - doi = doi.replace("%2F","/");//Replace %2F characters by forward slashes in doi - - // grab the UR link for a snapshot then blow it away - var snapshot = text.match(/UR\s+\-\s+(.*)/)[1]; - text = text.replace(/UR\s+\-(.*)/, ""); - - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.url = snapshot; - item.attachments.push({url:pdfURL, title:"PLoS Full Text PDF", mimeType:"application/pdf"}); - item.attachments.push({url:snapshot, title:"PLoS Snapshot", mimeType:"text/html", snapshot:true}); - item.DOI = doi; - item.repository = item.publicationTitle; - item.complete(); - }); - translator.translate(); - }, function() {Zotero.done();}); -} - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.plosbiology.org/article/info%3Adoi%2F10.1371%2Fjournal.pbio.1001090", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Tauzin", - "firstName": "Sébastien ", - "creatorType": "author" - }, - { - "lastName": "Chaigne-Delalande", - "firstName": "Benjamin ", - "creatorType": "author" - }, - { - "lastName": "Selva", - "firstName": "Eric ", - "creatorType": "author" - }, - { - "lastName": "Khadra", - "firstName": "Nadine ", - "creatorType": "author" - }, - { - "lastName": "Daburon", - "firstName": "Sophie ", - "creatorType": "author" - }, - { - "lastName": "Contin-Bordes", - "firstName": "Cécile ", - "creatorType": "author" - }, - { - "lastName": "Blanco", - "firstName": "Patrick ", - "creatorType": "author" - }, - { - "lastName": "Le Seyec", - "firstName": "Jacques ", - "creatorType": "author" - }, - { - "lastName": "Ducret", - "firstName": "Thomas ", - "creatorType": "author" - }, - { - "lastName": "Counillon", - "firstName": "Laurent ", - "creatorType": "author" - }, - { - "lastName": "Moreau", - "firstName": "Jean-François ", - "creatorType": "author" - }, - { - "lastName": "Hofman", - "firstName": "Paul ", - "creatorType": "author" - }, - { - "lastName": "Vacher", - "firstName": "Pierre ", - "creatorType": "author" - }, - { - "lastName": "Legembre", - "firstName": "Patrick ", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "PLoS Full Text PDF", - "mimeType": "application/pdf" - }, - { - "url": false, - "title": "PLoS Snapshot", - "mimeType": "text/html", - "snapshot": true - } - ], - "title": "The Naturally Processed CD95L Elicits a c-Yes/Calcium/PI3K-Driven Cell Migration Pathway", - "date": "June 21, 2011", - "abstractNote": "The “death receptor” CD95 (also known as Fas) plays an essential role in ensuring immune tolerance of self antigens as well as in the elimination of the body's cells that have been infected or transformed. This receptor is engaged by the membrane-bound ligand CD95L, which can be released into blood circulation after cleavage by metalloproteases. Hitherto, most of the studies on the CD95 signal have been performed with chimeric CD95Ls that mimic the membrane-bound ligand and exhibit a level of aggregation beyond that described for the metalloprotease-cleaved ligand. Multi-aggregated CD95L elicits a caspase-driven apoptotic signal. In this study, we observe that levels of soluble and naturally processed CD95L in sera of patients suffering from lupus correlate with disease severity. Strikingly, although this soluble CD95L fails to trigger cell death unlike its chimeric version, it induces a “non-canonical” Ca2+/c-yes/PI3K-dependent signaling pathway that promotes the transmigration of T-lymphocytes across the endothelial barrier. These findings shed light on an entirely new role for the soluble CD95L that may contribute to local or systemic tissue damage by enhancing the infiltration of activated T-lymphocytes. Overall, these findings underline the importance of revisiting the role of this “apoptotic cytokine” in the context of chronic inflammatory disorders.", - "publicationTitle": "PLoS Biol", - "journalAbbreviation": "PLoS Biol", - "volume": "9", - "issue": "6", - "pages": "e1001090", - "publisher": "Public Library of Science", - "url": "http://dx.doi.org/10.1371/journal.pbio.1001090", - "DOI": "10.1371/journal.pbio.1001090", - "libraryCatalog": "PLoS Biol" - } - ] - }, - { - "type": "web", - "url": "http://www.plosbiology.org/search/simpleSearch.action?from=globalSimpleSearch&filterJournals=PLoSBiology&query=amygdala&x=0&y=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.plosmedicine.org/article/info%3Adoi%2F10.1371%2Fjournal.pmed.1000098", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Chiasson", - "firstName": "T. Carter ", - "creatorType": "author" - }, - { - "lastName": "Manns", - "firstName": "Braden J. ", - "creatorType": "author" - }, - { - "lastName": "Stelfox", - "firstName": "Henry Thomas ", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "PLoS Full Text PDF", - "mimeType": "application/pdf" - }, - { - "url": false, - "title": "PLoS Snapshot", - "mimeType": "text/html", - "snapshot": true - } - ], - "title": "An Economic Evaluation of Venous Thromboembolism Prophylaxis Strategies in Critically Ill Trauma Patients at Risk of Bleeding", - "date": "June 23, 2009", - "abstractNote": "Using decision analysis, Henry Stelfox and colleagues estimate the cost-effectiveness of three venous thromboembolism prophylaxis strategies in patients with severe traumatic injuries who were also at risk for bleeding complications.", - "publicationTitle": "PLoS Med", - "journalAbbreviation": "PLoS Med", - "volume": "6", - "issue": "6", - "pages": "e1000098", - "publisher": "Public Library of Science", - "url": "http://dx.doi.org/10.1371/journal.pmed.1000098", - "DOI": "10.1371/journal.pmed.1000098", - "libraryCatalog": "PLoS Med" - } - ] - }, - { - "type": "web", - "url": "http://www.plosmedicine.org/search/simpleSearch.action?from=globalSimpleSearch&filterJournals=PLoSMedicine&query=hematoma&x=0&y=0", - "items": "multiple" - }, - { - "type": "web", - "url": "http://www.plosmedicine.org/article/browseIssue.action", - "items": "multiple" - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/Papers Past.js b/translators/Papers Past.js @@ -1,171 +0,0 @@ -{ - "translatorID":"1b052690-16dd-431d-9828-9dc675eb55f6", - "label":"Papers Past", - "creator":"staplegun", - "target":"^http://paperspast\\.natlib\\.govt\\.nz", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-09-14 19:04:32" -} - -/* - Papers Past Translator - Parses historic digitised newspaper articles and creates Zotero-based metadata - Copyright (C) 2010 staplegun - - 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) { - - // a results parameter in URL means search hitlist - if (url.match(/results=/) ) { - return "multiple"; - - } else { - - // init variables - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - var myXPath; - var myXPathObject; - - // publication title in meta tags means have an article - myXPath = '//meta[@name="newsarticle_publication"]/@content'; - myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var meta = myXPathObject.iterateNext().textContent; - if (meta.length > 0) { - return "newspaperArticle"; - } - } -} - -function doWeb(doc, url) { - - // init variables - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - // hitlist page: compile hitlist titles, user selects which are wanted - // (add &zto=1 to URL for usage tracking) - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var titlesXPath = '//div[@class="search-results"]/p/a'; - var titles = doc.evaluate(titlesXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextTitle; - var items = new Array(); - while (nextTitle = titles.iterateNext()) { - items[nextTitle.href+"&zto=1"] = nextTitle.textContent; - } - // presented to user - who reduces list to those selected - items = Zotero.selectItems(items); - // transfer this list to articles array - for (var i in items) { - articles.push(i); - } - - // article page: just continue with single (current) page URL - } else { - articles = [url+"&zto=1"]; - } - - // process each selected article page URL - Zotero.Utilities.processDocuments(articles, scrape, function(){Zotero.done();}); - Zotero.wait(); -} - -function scrape(doc) { - - // init variables - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - var myXPath; - var myXPathObject; - - // basic item details - var newItem = new Zotero.Item('newspaperArticle'); - newItem.url = doc.location.href; - newItem.archive = 'Papers Past'; - - // publication title - myXPath = '//meta[@name="newsarticle_publication"]/@content'; - myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - newItem.publicationTitle = myXPathObject.iterateNext().textContent; - Zotero.debug(newItem.publicationTitle); - - // article title (convert to sentence case) - // NB: THE CONVERSION SEEMS TO FAIL IF HAS SPECIAL CHARS - myXPath = '//meta[@name="newsarticle_headline"]/@content'; - myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var title = myXPathObject.iterateNext().textContent; - var words = title.split(/\s/); - var titleFixed = ''; - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - titleFixed = titleFixed + words[i] + ' '; - } - titleFixed = Zotero.Utilities.trim(titleFixed); - newItem.title = titleFixed; - - // publication date (is preformatted to ISO 8601) - myXPath = '//meta[@name="dc_date"]/@content'; - myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - newItem.date = myXPathObject.iterateNext().textContent; - - // pagination - myXPath = '//meta[@name="newsarticle_firstpage"]/@content'; - myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var pages = myXPathObject.iterateNext().textContent; - - myXPath = '//meta[@name="newsarticle_otherpages"]/@content'; - myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - pages = pages + ' ' + myXPathObject.iterateNext().textContent; - - newItem.pages = Zotero.Utilities.trim(pages); - - // save copy of entire web page as attachment - var attachments = new Array(); - attachments.push({ - title:titleFixed + " : Article webpage", - mimeType:"text/html", - url:doc.location.href - }); - - // find image scans and add as attachments - myXPath = '//img[@class="veridianimage"]/@src'; - myXPathObject = doc.evaluate(myXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var imgSrc; - var imgUrl; - var imgNo = 0; - while (imgSrc = myXPathObject.iterateNext() ) { - imgUrl = "http://paperspast.natlib.govt.nz" + imgSrc.textContent; - attachments.push({ - title: titleFixed + " : Scan image part " + ++imgNo, - mimeType: "image/gif", - url: imgUrl - }); - } - newItem.attachments = attachments; - - // finish - newItem.complete(); -} diff --git a/translators/Paris Review.js b/translators/Paris Review.js @@ -1,116 +0,0 @@ -{ - "translatorID":"b24ee183-58a6-443d-b8f9-c5cd5a3a0f73", - "label":"Paris Review", - "creator":"Avram Lyon", - "target":"^http://www\\.theparisreview\\.org/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "translatorType":4, - "lastUpdated":"2010-10-31 21:49:18" -} - -/* - Paris Review Translator - Copyright (C) 2010 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){ - if (url.match(/\/(interviews|poetry|fiction|letters-essays)\/\d+\//)) { - return "magazineArticle"; - } else if (url.match(/\/blog\/\d+\//)) { - return "blogPost"; - } else if (url.match(/\/(blog|interviews|current-issue|letters-essays|poetry|fiction)($|\/)/)|| url.match(/\/search\?/) ){ - return "multiple"; - } else return false; -} - -function doWeb(doc, url){ - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Array(); - - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - var type = detectWeb(doc,aTags[i].href); - if(type && type != "multiple") { - items[aTags[i].href]=aTags[i].textContent; - } - } - - items = Zotero.selectItems(items); - if(!items) return true; - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - } else { - scrape(doc,url); - } - - Zotero.wait(); -} - -function scrape (doc,url) { - if (!url) url = doc.location.href; - switch (detectWeb(doc,url)) { - case "blogPost": blogPost(doc, url); break; - case "magazineArticle":magazineArticle(doc,url);break; - } -} - -function magazineArticle(doc,url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - var item = new Zotero.Item("magazineArticle"); - item.title = doc.evaluate('//div[@id="left"]//h3[1]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (url.match(/\/interviews\//)) { - item.creators.push(Zotero.Utilities.cleanAuthor(item.title.match(/.*?,/)[0],"contributor")); - item.creators.push(Zotero.Utilities.cleanAuthor(doc.evaluate('//div[@id="left"]//p[1]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/Interviewed by (.*)/)[1],"author")); - } else { - item.creators.push(Zotero.Utilities.cleanAuthor(doc.evaluate('//div[@id="left"]/div/p', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent,"author")); - } - item.date = doc.evaluate('//div[@class="moreonissue-right"]/h3/text()[1]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.issue = doc.evaluate('//div[@class="moreonissue-right"]/h3/text()[2]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/[0-9]+/)[0]; - item.publicationTitle = "Paris Review"; - item.url = url; - item.ISSN="0031-2037"; - item.attachments.push({url:url}) - item.complete(); -} - -function blogPost(doc,url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - var item = new Zotero.Item("blogPost"); - item.title = doc.evaluate('//h2[@class="blog-title"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.creators.push(Zotero.Utilities.cleanAuthor(doc.evaluate('//p[@class="blog-date"]/a', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent,"author")); - item.date = doc.evaluate('//p[@class="blog-date"]/text()[1]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/(.*)\|/)[1]; - item.blogTitle = "Paris Review Daily"; - item.url = url; - item.attachments.push({url:url}) - item.complete(); -} diff --git a/translators/Patents - USPTO.js b/translators/Patents - USPTO.js @@ -1,144 +0,0 @@ -{ - "translatorID":"232e24fe-2f68-44fc-9366-ecd45720ee9e", - "translatorType":4, - "label":"Patents - USPTO", - "creator":"Bill McKinney", - "target":"^http://patft\\.uspto\\.gov/netacgi/nph-Parser.+", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var re = new RegExp("^http://patft\.uspto\.gov/netacgi/nph-Parser"); - if(re.test(doc.location.href)) { - return "book"; - } else { - return "multiple"; - } -} - -function get_nextsibling(n) - { - var x=n.nextSibling; - while (x.nodeType!=1) - { - x=x.nextSibling; - } - return x; -} - -function scrape(doc) { - - var newItem = new Zotero.Item("patent"); - newItem.url = doc.location.href; - var extraText = new String(); - var tmpStr = new String(); - var tmpRefs = ""; - var tmpTitle = doc.title; - - var fontTags = doc.getElementsByTagName("font"); - for(var i=0; i<fontTags.length; i++) { - if (fontTags[i].getAttribute("size") == "+1") { - tmpTitle = tmpTitle + " - " + fontTags[i].innerHTML; - } - } - tmpTitle = Zotero.Utilities.trimInternal(tmpTitle); - tmpTitle = tmpTitle.replace(/<[^>]+>/g, ""); - newItem.title = tmpTitle; - - var cellTags = doc.getElementsByTagName("td"); - for(var i=0; i<cellTags.length; i++) { - - var s = new String(cellTags[i].innerHTML); - if (s.indexOf("United States Patent") > -1) { - - tmpStr = cellTags[i+1].childNodes[0].innerHTML; - tmpStr = tmpStr.replace(/<[^>]+>/gi, ""); - tmpStr = tmpStr.replace(/,/gi, ""); - newItem.patentNumber = tmpStr; - - tmpStr = cellTags[i+3].innerHTML; - tmpStr = tmpStr.replace(/<[^>]+>/gi, ""); - newItem.issueDate = tmpStr; - continue; - } - if (s.indexOf("Assignee") > -1) { - tmpStr = cellTags[i+1].innerHTML; - tmpStr = tmpStr.replace(/<\/?\w+>/gi, ""); - newItem.assignee = tmpStr; - continue; - } - if (s.indexOf("Inventors") > -1) { - tmpStr = cellTags[i+1].innerHTML; - - var inventors = tmpStr.split(/<b>,/ig); - for (var j=0; j<inventors.length; j++) { - var tmpInventor = inventors[j]; - tmpInventor = tmpInventor.replace(/<\/?\w+>/gi, ""); - tmpInventor = tmpInventor.replace(/\([^\)]+\)/gi, ""); - tmpInventor = tmpInventor.replace(/^\s+/gi, ""); - - var names = tmpInventor.split(";"); - if (names) { - var lname = names[0]; - var fname = names[1]; - lname = lname.replace(/^\s+/gi, ""); - lname = lname.replace(/\s+$/gi, ""); - fname= fname.replace(/^\s+/gi, ""); - fname= fname.replace(/\s+$/gi, ""); - newItem.creators.push({lastName:lname, firstName:fname, creatorType:"inventor"}); - } - } - continue; - } - - // references - if (s.indexOf("<a href=\"/netacgi/nph-Parser?Sect2") > -1) { - tmpRefs = tmpRefs + cellTags[i].childNodes[0].innerHTML + " "; - } - if (s.indexOf("<a href=\"http://appft1.uspto.gov/netacgi/nph-Parser?TERM1") > -1) { - tmpRefs = tmpRefs + cellTags[i].childNodes[0].innerHTML + " "; - } - } - - var centerTags = doc.getElementsByTagName("center"); - for(var i=0; i<centerTags.length; i++) { - var s = new String(centerTags[i].innerHTML); - if (s.indexOf("Abstract") > -1) { - //newItem.extra = "ok"; - var el = get_nextsibling(centerTags[i]); - newItem.abstractNote = el.innerHTML; - } - - } - - newItem.references = tmpRefs; - newItem.complete(); -} - -function doWeb(doc, url) { - var re = new RegExp("^http://patft\.uspto\.gov/netacgi/nph-Parser.+"); - if(re.test(doc.location.href)) { - scrape(doc); - } else { - var items = Zotero.Utilities.getItemArray(doc, doc, "^http://patft\.uspto\.gov/netacgi/nph-Parser.+"); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var uris = new Array(); - for(var i in items) { - uris.push(i); - } - - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, - function() { Zotero.done(); }, null); - - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/Philosopher's Imprint.js b/translators/Philosopher's Imprint.js @@ -1,88 +0,0 @@ -{ - "translatorID":"b0abb562-218c-4bf6-af66-c320fdb8ddd3", - "translatorType":4, - "label":"Philosopher's Imprint", - "creator":"Michael Berkowitz", - "target":"http://quod.lib.umich.edu/cgi/t/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div/span[text() = "Search Results"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.match(/\d+\.\d+\.\d+/)) { - return "journalArticle"; - } -} - -function getID(str) { - return str.match(/\d+\.\d+\.\d+/)[0]; -} -function doWeb(doc, url) { - var ids = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var titles = doc.evaluate('//div[@class="itemcitation"]//a', doc, null, XPathResult.ANY_TYPE, null); - var title; - while (title = titles.iterateNext()) { - items[title.href] = title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - ids.push('http://quod.lib.umich.edu/cgi/t/text/text-idx?c=phimp;view=text;rgn=main;idno=' + getID(i)); - } - } else { - ids = ['http://quod.lib.umich.edu/cgi/t/text/text-idx?c=phimp;view=text;rgn=main;idno=' + getID(url)]; - } - Zotero.Utilities.processDocuments(ids, function(newDoc) { - var rows = newDoc.evaluate('//tr[td[@id="labelcell"]]', newDoc, null, XPathResult.ANY_TYPE, null); - var row; - var data = new Object(); - while (row = rows.iterateNext()) { - var heading = newDoc.evaluate('./td[1]', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var value = newDoc.evaluate('./td[2]', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - data[heading.replace(/[\s:]/g, "")] = value; - } - var item = new Zotero.Item("journalArticle"); - item.title = Zotero.Utilities.trimInternal(data['Title']); - if (data['Author']) { - item.creators.push(Zotero.Utilities.cleanAuthor(data['Author'], "author")); - } else if (data['Authors']) { - var authors = data['Authors'].split(","); - for each (var a in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(a, "author")); - } - } - if (data['Keywords']) { - var kws = data['Keywords'].split(/\n/); - for each (var kw in kws) { - if (kw != "") item.tags.push(kw); - } - } - var voliss = data['Source'].replace(item.title, ""); - if (item.creators.length > 1) { - voliss = voliss.replace(data['Authors'], ""); - } else if (item.creators.length == 1) { - voliss = voliss.replace(data['Author'], ""); - } - Zotero.debug(voliss); - item.volume = voliss.match(/vol\.\s+(\d+)/)[1]; - item.issue = voliss.match(/no\.\s+(\d+)/)[1]; - item.pages = voliss.match(/pp\.\s+([\d\-]+)/)[1]; - item.date = Zotero.Utilities.trimInternal(voliss.match(/[^,]+$/)[0]); - item.place = "Ann Arbor, MI"; - item.publisher = "University of Michigan"; - item.abstractNote = data['Abstract']; - item.url = data['URL']; - item.attachments = [ - {url:item.url, title:item.title + " Snapshot", mimeType:"text/html"}, - {url:'http://quod.lib.umich.edu/p/phimp/images/' + getID(item.url) + '.pdf', title:"Philosopher's Imprint Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Pion Journals.js b/translators/Pion Journals.js @@ -1,67 +0,0 @@ -{ - "translatorID":"291934d5-36ec-4b81-ac9c-c5ad5313dba4", - "translatorType":4, - "label":"Pion Journals", - "creator":"Michael Berkowitz", - "target":"http://(www.)?(hthpweb|envplan|perceptionweb).com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/search\.cgi/) || url.match(/ranking/) || url.match(/volume=/)) { - return "multiple"; - } else if (url.match(/abstract\.cgi/)) { - 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 arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, "abstract.cgi\\?id="); - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.debug(arts); - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.publicationTitle = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="footer"]/div[@class="left"]/i', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[2]/font/b', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var authors = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[3]/b', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent).split(/,\s*/); - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - if (doc.evaluate('//div[@id="title"]/div[@class="left"]/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/\d+/)) { - var voliss = doc.evaluate('//div[@id="title"]/div[@class="left"]/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/(\d+)\s+volume\s+(\d+)\s*\((\d+)\)\s+(pages\s+(.*))?$/); - Zotero.debug(voliss); - item.date = voliss[1]; - item.volume = voliss[2]; - item.issue = voliss[3]; - if (voliss[5]) item.pages = voliss[5]; - } else { - item.date = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[4]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent).match(/(\d+)$/)[1]; - } - item.DOI = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="title"]/div[@class="right"]/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent).substr(4); - - if (doc.evaluate('//a[contains(@href, ".pdf")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - item.url = doc.location.href; - var pub = item.publicationTitle; - item.attachments = [{url:item.url, title:pub + " Snapshot", mimeType:"text/html"}]; - if (pdfurl) item.attachments.push({url:pdfurl, title:pub + " Full Text PDF", mimeType:"application/pdf"}); - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="total"]/p[5]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent).substr(10); - item.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/Pleade.js b/translators/Pleade.js @@ -1,264 +0,0 @@ -{ - "translatorID":"ce68b0ed-3137-4e38-b691-f3bc49bc1497", - "label":"Pleade", - "creator":"DIA Modou", - "target":"base=ead|ead\\.html|list-results\\.html", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "translatorType":4, - "lastUpdated":"2011-03-03 20:46:08" -} - -/* -Pleade: Publishing Tool for finding, authority records -and a series of digitized images. -Copyright (C) 2003-2011 AJLSM - -AJLSM -17, rue Vital Carles -33000 Bordeaux, France -info@ajlsm.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 2 -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, write to the -Free Software Foundation, Inc. -59 Temple Place - Suite 330, Boston, MA 02111-1307, USA -or connect to: -http://www.fsf.org/copyleft/gpl.html -*/ - -/* Example URLs: - - http://jubilotheque.upmc.fr/results.html?base=ead&champ1=fulltext&op1=AND&search_type=simple&query1=pau&ssearch-submit-npt.x=0&ssearch-submit-npt.y=0 - - http://jubilotheque.upmc.fr/ead.html?id=BG_000007_002#!{%22content%22:[%22BG_000007_002_e0000002%22,true,%22%22]} - - http://jubilotheque.upmc.fr/list-results.html?mode=subset&champ1=subsetall&query1=physique&cop1=AND - */ - -/** - * Function provided by zotero. It permit to detect web page which are compatible with this translator - */ -function detectWeb(doc, url) { - if (url.match("id=") && url.match("ead.html")) { - return "book"; - } - else if (url.match("base=ead") && url.match("results.html")) { - return "multiple"; - } - else if (url.match("list-results.html") && url.match("mode=")) { - return "multiple"; - } -} - -/** - * Function find-replace - * @param expr : string to check - * @param a : string to find - * @param b : string to use for replacing @a - */ -function Remplace(expr,a,b) { - var i=0 - while (i!=-1) { - i=expr.indexOf(a,i); - if (i>=0) { - expr=expr.substring(0,i)+b+expr.substring(i+a.length); - i+=b.length; - } - } - return expr -} - -/** - * Get an author from Pleade and decide if it can be published in zotero or not. - * This function permit to resolv lot of bug in zotero beacuse some "string author" - * in pleade was not normalized. - * @param newItem : zotero variable which contain field to publish - * @param author : "string author" - * @param managed : this field is provided by Pleade and permit to now if the @author is normalized - */ -function getAuthors(newItem, author, managed) { - if(managed=="true") newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); -} - -/** - * This function take raw data from pleade and it extract field "Tags" for zotero - * @param newItem : zotero variable which contain field to publish - * @param book : raw data; actualy a xml tree - */ -function getTag(newItem, book) { - var Tags = new Array(); - - for(var i=0; i<book.subject.length(); i++) { - Tags.push(Zotero.Utilities.superCleanString(book.subject[i].text().toString())); - } - - newItem.abstractNote = Tags; -} - -/** -* If a web web page that describe book is matched, this function call Pleade for getting metadatas. And then -* it scrape them to zotero. -* @param url : the url to give to pleade for getting metadatas. -*/ -function scrape(url) { - - // Debug mode - Zotero.debug("Getting a term : " + url); - - Zotero.Utilities.HTTP.doGet(url, function(text) { - - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - text = text.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) {return str.replace(/-/gm, "");}); - text = text.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) {return str.replace(/:/gm, "");}); - text = Zotero.Utilities.trim(text); - - XML.prettyPrinting = false; - XML.ignoreWhitespace = false; - var xml = new XML(text); - - for(var i=0 ; i <xml.book.length() ; i++) { - var newItem = new Zotero.Item("book"); - var book = xml.book[i]; - - newItem.url = Zotero.Utilities.superCleanString(book.link.text().toString()); - newItem.title = Zotero.Utilities.superCleanString(book.title.text().toString()); - //newItem.seriesNumber = Zotero.Utilities.superCleanString(book.num.text().toString()); - for(var j=0; j<book.author.length(); j++) getAuthors(newItem, Zotero.Utilities.superCleanString(book.author[j].text().toString()),Zotero.Utilities.superCleanString(book.managed[j].text().toString())); - newItem.date = Zotero.Utilities.superCleanString(book.date.text().toString()); - newItem.publisher = Zotero.Utilities.superCleanString(book.publisher.text().toString()); - newItem.place = Zotero.Utilities.superCleanString(book.publisherAddr.text().toString()); - newItem.language = Zotero.Utilities.superCleanString(book.lang.text().toString()); - newItem.rights = Zotero.Utilities.superCleanString(book.rights.text().toString()); - //getTag(newItem, book); - //newItem.extra.push({url: Zotero.Utilities.superCleanString(book.doclink.@href.text().toString()), title: Zotero.Utilities.superCleanString(book.doclink.text().toString()), mimeType: Zotero.Utilities.superCleanString(book.doclink.@mime-type.text().toString()), snapshot: false}); - //newItem.archiveLocation = Zotero.Utilities.superCleanString(book.archLoc.text().toString()); - //newItem.libraryCatalog = Zotero.Utilities.superCleanString(book.serverName.text().toString()); - newItem.callNumber = Zotero.Utilities.superCleanString(book.cote.text().toString()); - - newItem.complete(); - } - - Zotero.done(); - }) - Zotero.wait(); -} - -/** -* If a web page that describe multiple is matched, this function give the number of different field. -* @param text : variable provided by Pleade wich describe the actual page -*/ -function getNbrTerms(text) -{ - var temp1 = text.substr(text.indexOf("nb")+4,10); - var nbr = temp1.substring(0,temp1.indexOf("\"")); - - return parseInt(nbr); -} - -/** -* If a web page that describe multiple is matched, this function call Pleade for getting the terms in that page. And then, it call the -* zotero.selectItem function and finaly it scrape the selected items in zotero. -* @param doc : the javascript doc var -* @param url : url to give to Pleade for getting informations in that page. -*/ -function getMultipleQid(doc,url) -{ - var qId; - - Zotero.Utilities.HTTP.doGet(url, function(text) { - - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - text = Zotero.Utilities.trim(text); - - var temp1; - - if(url.match("base=ead") && url.match("results.html")) { - temp1 = text.substr(text.indexOf("var oid")+11,30); - qId = temp1.substring(0,temp1.indexOf("\"")); - } - else if(url.match("list-results.html") && url.match("mode=")) { - temp1 = text.substr(text.indexOf("var _qid")+12,30); - qId = temp1.substring(0,temp1.indexOf("\"")); - //qId = temp1; - } - - Zotero.debug("qId : " + qId); - - var newURL = url.substring(url.indexOf("http"), url.indexOf("results.html"))+"functions/zotero/results/"+qId; - Zotero.debug("Getting terms : " + newURL); - - // Getting field.title - Zotero.Utilities.HTTP.doGet(newURL, function(text2) { - - text2 = text2.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) {return str.replace(/-/gm, "");}); - text2 = text2.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) {return str.replace(/:/gm, "");}); - text2 = Zotero.Utilities.trim(text2); - - - var temp = text2.substring(text2.indexOf("\<title\>"),text2.lastIndexOf("\<\/pleadeId\>")+11); - var pids = new Array(); - - var max=text2.substring(text2.indexOf("nbrresult\>")+20, text2.lastIndexOf("\<nbrresult")); - max=parseInt(max.substring(max.indexOf("\>")+1, max.lastIndexOf("\<"))); - - //this loop get fields from Pleade - for(var i=0; i< max; i++) - { - var title = temp.substring(temp.indexOf("\<title\>")+7,temp.indexOf("\<\/title\>")); - var pleadeId = temp.substring(temp.indexOf("\<pleadeId\>")+10,temp.indexOf("\<\/pleadeId\>")); - temp = temp.substring(temp.indexOf("\<result\>")+8,temp.lastIndexOf("\<\/pleadeId\>")+11); - - pids[pleadeId] = title; - } - - var newURL2 = url.substring(url.indexOf("http"), url.indexOf("results.html"))+"functions/zotero/"; - - var tpids = Zotero.selectItems(pids); - - for(var i in tpids) { - scrape(newURL2+i+".xml?fragment=null"); - } - - }) - - Zotero.done(); - }) - Zotero.wait(); -} - -/** -* Function provided by zotero -*/ -function doWeb(doc, url) { - var pleadeId; - var fragmentId; - var text; - - if (detectWeb(doc, url) == "multiple") { - getMultipleQid(doc,url); - } - else if (detectWeb(doc, url) == "book") { - - // Building the Pleade id of the actual document - if(url.indexOf("\&") != -1) pleadeId = url.substring(url.indexOf("id=")+3,url.indexOf("\&")); - else if(url.indexOf("\&") == -1) pleadeId = url.substring(url.indexOf("id=")+3,url.indexOf("#")); - else pleadeId = url.substring(url.indexOf("id=")+3,url.length); - - // Building the Pleade fragment id of the actual document - var temp1 = url.substring(url.indexOf("#"),url.length); - var temp2 = temp1.substring(temp1.indexOf(pleadeId), temp1.length); - fragmentId = temp2.substring(0,temp2.indexOf("%")); - - scrape(url.substring(url.indexOf("http"), url.indexOf("ead.html"))+"functions/zotero/"+pleadeId+".xml?fragment="+fragmentId); - } -} diff --git a/translators/Potsdamer Neueste Nachrichten.js b/translators/Potsdamer Neueste Nachrichten.js @@ -1,143 +0,0 @@ -{ - "translatorID": "9405db4b-be7f-42ab-86ca-430226be9b35", - "label": "Potsdamer Neueste Nachrichten", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.pnn\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-05-06 11:34:44" -} - -/* -Potsdamer Neueste Nachrichten Translator 1.1 -Copyright (C) 2011 Martin Meyerhoff - -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/>. -*/ - -/* - -Test it with: -http://www.pnn.de/ -http://www.pnn.de/zeitung/ -http://www.pnn.de/zeitung/12.01.2011/ -http://www.pnn.de/titelseite/364860/ -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var PNN_Article_XPath = ".//div[contains (@class, 'um-article')]/h1"; //only articles have a print button. - var PNN_Multiple_XPath = "//div[contains(@class, 'um-teaser')]/h2/a" - - if (doc.evaluate(PNN_Article_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.evaluate(PNN_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - return "multiple"; - } -} - -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("newspaperArticle"); - newItem.url = doc.location.href; - - // Title - var title_XPath = "//div[contains (@class, 'um-article')]/h1" - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - title = title.replace(/\s+|\n/g, ' '); - newItem.title = title; - - // Summary - var summary_XPath = "//div[contains (@class, 'um-article')]/p[@class='um-first']"; - if (doc.evaluate(summary_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = summary; - } - - // Date - var date_XPath = "//div[contains (@class, 'um-article')]/div[@class='um-metabar']/ul/li[contains(@class, 'um-first')]"; - var date = doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.date = date.replace(/(\d+)\.(\d+).(\d+)/, '$3-$2-$1');; - - - // Authors - var author_XPath = "//div[contains (@class, 'um-article')]/span[@class='um-author']"; - if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var author = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - author =author.replace(/^von\s|^\s*|\s*$/g, ''); - author =author.split(/\sund\s|\su\.\s|\,\s/); - for (var i in author) { - if (author[i].match(/\s/)) { // only names that contain a space! - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - } - - newItem.attachments.push({url:doc.location.href, title:doc.title, mimeType:"text/html"}); - newItem.publicationTitle = "Potsdamer Neueste Nachrichten" - - // section - var section_XPath = "//div[@class='um-mainnav']/ul/li[@class='um-selected']/a"; - if (doc.evaluate(section_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var section = doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.section = section.replace(/^\s*|\s*$/g, ''); - } - - newItem.complete(); -} - - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate("//div[contains(@class, 'um-teaser')]/h2/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent.replace(/\s+/g, ' '); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - } else { - scrape(doc, url); - } - Zotero.wait(); -} diff --git a/translators/Primo.js b/translators/Primo.js @@ -1,822 +0,0 @@ -{ - "translatorID":"1300cd65-d23a-4bbf-93e5-a3c9e00d1066", - "translatorType":4, - "label":"Primo", - "creator":"Matt Burton, Avram Lyon, Etienne Cavalié", - "target":"/primo_library/", - "minVersion":"2.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-06-08 07:15:00" -} - -/* -Supports Primo 2: -Université de Nice, France (http://catalogue.unice.fr/) -Supports Primo 3 -Boston College (http://www.bc.edu/supersleuth), -Oxford Libraries (http://solo.ouls.ox.ac.uk/) -*/ - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (doc.evaluate('//span[@class="results_corner EXLResultsTitleCorner"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - return 'multiple'; - } - else if (doc.evaluate('//div[@class="EXLContent EXLBriefDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - return 'multiple'; - } - else if (doc.evaluate('//div[@class="results2 EXLFullResultsHeader"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - return 'book'; - } - else if (doc.evaluate('//div[@class="EXLContent EXLFullDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - return 'book'; - } -} - -// There is code for handling RIS, but let's stick with PNX for now. - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var links = new Array(); - - if (detectWeb(doc,url) == 'multiple') { - var items = new Object(); - - var linkIterator = ""; - var titleIterator = ""; - if (doc.evaluate('//h2[contains(@class, "EXLResultTitle")]/a/@href', doc, nsResolver, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null).snapshotLength == 0) - { - // Primo v2 - linkIterator = doc.evaluate('//div[contains(@class, "title")]/a/@href', doc, nsResolver, XPathResult.ANY_TYPE, null); - titleIterator = doc.evaluate('//div[contains(@class, "title")]/a/span', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - else - { - // Primo v3 - linkIterator = doc.evaluate('//h2[contains(@class, "EXLResultTitle")]/a/@href', doc, nsResolver, XPathResult.ANY_TYPE, null); - titleIterator = doc.evaluate('//h2[contains(@class, "EXLResultTitle")]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - - // try/catch for the case when there are no search results, let doc.evealuate fail quietly - try { - while (link = linkIterator.iterateNext(), title = titleIterator.iterateNext()) { - - // create an array containing the links and add '&showPnx=true' to the end - var xmlLink = Zotero.Utilities.trimInternal(link.textContent)+'&showPnx=true'; - Zotero.debug(xmlLink); - var title = Zotero.Utilities.trimInternal(title.textContent); - items[xmlLink] = title; - } - items = Zotero.selectItems(items); - for(var link in items) { - links.push(link); - } - } catch(e) { - Zotero.debug("Search results contained zero items. "+e); - return; - } - - } else { - links.push(url+'&showPnx=true'); - } - - Zotero.Utilities.HTTP.doGet(links, function(text) { - - text = text.replace(/^<\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?>/, ""); //because E4X is full of FAIL - var xmldoc = new XML(text); - - if (xmldoc.display.type.toString() == 'book') { - var item = new Zotero.Item("book"); - } else if (xmldoc.display.type.toString() == 'audio') { - var item = new Zotero.Item("audioRecording"); - } else if (xmldoc.display.type.toString() == 'video') { - var item = new Zotero.Item("videoRecording"); - } else { - var item = new Zotero.Item("document"); - } - item.title = xmldoc.display.title.toString(); - - var creators = xmldoc.display.creator.toString().replace(/\d{4}-(\d{4})?/, '').split("; "); - var contributors = xmldoc.display.contributor.toString().replace(/\d{4}-(\d{4})?/, '').split("; "); - - if (!creators[0]) { // <contributor> not available using <contributor> as author instead - creators = contributors; - contributors = null; - } - for (creator in creators) { - if (creators[creator]) { - item.creators.push(Zotero.Utilities.cleanAuthor(creators[creator], "author")); - } - } - - for (contributor in contributors) { - if (contributors[contributor]) { - item.creators.push(Zotero.Utilities.cleanAuthor(contributors[contributor], "contributor")); - } - } - - var pubplace = xmldoc.display.publisher.toString().split(" : "); - if (pubplace) { - item.place = pubplace[0]; - item.publisher = pubplace[1]; - } - - var date = xmldoc.display.creationdate.toString(); - if (date) item.date = date.match(/\d+/)[0]; - - var language = xmldoc.display.language.toString(); - // We really hope that Primo always uses ISO 639-2 - // This looks odd, but it just means that we're using the verbatim - // content if it isn't in our ISO 639-2 hash. - if (language) - if(!(item.language = iso6392(language))) - item.language = language; - - - var pages = xmldoc.display.format.toString().match(/(\d+)\sp\./); - if (pages) item.pages = pages[1]; - - // The identifier field is supposed to have standardized format, but - // the super-tolerant idCheck should be better than a regex. - // (although note that it will reject invalid ISBNs) - var locators = idCheck(xmldoc.display.identifier.toString()); - if (locators.isbn10) item.ISBN = locators.isbn10; - if (locators.isbn13) item.ISBN = locators.isbn13; - if (locators.issn) item.ISSN = locators.issn; - - var edition = xmldoc.display.edition.toString(); - if (edition) item.edition = edition; - - for each (subject in xmldoc.search.subject) { - item.tags.push(subject.toString()); - } - // does callNumber get stored anywhere else in the xml? - item.callNumber = xmldoc.enrichment.classificationlcc[0]; - - item.complete(); - - }, function() {Zotero.done();}); - Zotero.wait(); - -} - -/* The next two functions are logic that could be bundled away into the translator toolkit. */ - -// Implementation of ISBN and ISSN check-digit verification -// Based on ISBN Users' Manual (http://www.isbn.org/standards/home/isbn/international/html/usm4.htm) -// and the Wikipedia treatment of ISBN (http://en.wikipedia.org/wiki/International_Standard_Book_Number) -// and the Wikipedia treatment of ISSN (http://en.wikipedia.org/wiki/International_Standard_Serial_Number) - -// This will also check ISMN validity, although it does not distinguish from their -// neighbors in namespace, ISBN-13. It does not handle pre-2008 M-prefixed ISMNs; see -// http://en.wikipedia.org/wiki/International_Standard_Music_Number - -// This does not validate multiple identifiers in one field, -// but it will gracefully ignore all non-number detritus, -// such as extraneous hyphens, spaces, and comments. - -// It currently maintains hyphens in non-initial and non-final position, -// discarding consecutive ones beyond the first as well. - -// It also adds the customary hyphen to valid ISSNs. - -// Takes the first 8 valid digits and tries to read an ISSN, -// takes the first 10 valid digits and tries to read an ISBN 10, -// and takes the first 13 valid digits to try to read an ISBN 13 -// Returns an object with three attributes: -// "issn" -// "isbn10" -// "isbn13" -// Each will be set to a valid identifier if found, and otherwise be a -// boolean false. - -// There could conceivably be a valid ISBN-13 with an ISBN-10 -// substring; this should probably be interpreted as the latter, but it is a -// client UI issue. -idCheck = function(isbn) { - // For ISBN 10, multiple by these coefficients, take the sum mod 11 - // and subtract from 11 - var isbn10 = [10, 9, 8, 7, 6, 5, 4, 3, 2]; - - // For ISBN 13, multiple by these coefficients, take the sum mod 10 - // and subtract from 10 - var isbn13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]; - - // For ISSN, multiply by these coefficients, take the sum mod 11 - // and subtract from 11 - var issn = [8, 7, 6, 5, 4, 3, 2]; - - // We make a single pass through the provided string, interpreting the - // first 10 valid characters as an ISBN-10, and the first 13 as an - // ISBN-13. We then return an array of booleans and valid detected - // ISBNs. - - var j = 0; - var sum8 = 0; - var num8 = ""; - var sum10 = 0; - var num10 = ""; - var sum13 = 0; - var num13 = ""; - var chars = []; - - for (var i=0; i < isbn.length; i++) { - if (isbn.charAt(i) == " ") { - // Since the space character evaluates as a number, - // it is a special case. - } else if (j > 0 && isbn.charAt(i) == "-" && isbn.charAt(i-1) != "-") { - // Preserve hyphens, except in initial and final position - // Also discard consecutive hyphens - if(j < 7) num8 += "-"; - if(j < 10) num10 += "-"; - if(j < 13) num13 += "-"; - } else if (j < 7 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum8 += isbn.charAt(i) * issn[j]; - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num8 += isbn.charAt(i); - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } else if (j == 7 && - (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || - ((isbn.charAt(i) - 0) == isbn.charAt(i)))) { - // In ISSN, an X represents the check digit "10". - if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") { - var check8 = 10; - num8 += "X"; - } else { - var check8 = isbn.charAt(i); - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num8 += isbn.charAt(i); - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } - } else if (j < 9 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } else if (j == 9 && - (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || - ((isbn.charAt(i) - 0) == isbn.charAt(i)))) { - // In ISBN-10, an X represents the check digit "10". - if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") { - var check10 = 10; - num10 += "X"; - } else { - var check10 = isbn.charAt(i); - sum13 += isbn.charAt(i) * isbn13[j]; - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } - } else if(j < 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum13 += isbn.charAt(i) * isbn13[j]; - num13 += isbn.charAt(i); - j++; - } else if (j == 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - var check13 = isbn.charAt(i); - num13 += isbn.charAt(i); - } - } - var valid8 = ((11 - sum8 % 11) % 11) == check8; - var valid10 = ((11 - sum10 % 11) % 11) == check10; - var valid13 = (10 - sum13 % 10 == check13); - var matches = false; - - // Since ISSNs have a standard hyphen placement, we can add a hyphen - if (valid8 && (matches = num8.match(/([0-9]{4})([0-9]{3}[0-9Xx])/))) { - num8 = matches[1] + '-' + matches[2]; - } - - if(!valid8) {num8 = false}; - if(!valid10) {num10 = false}; - if(!valid13) {num13 = false}; - return {"isbn10" : num10, "isbn13" : num13, "issn" : num8}; -} - -// This function should be replaced by a lookup from the multilingual machinery in multilingual builds of Zotero -// Gives name for three-letter code -function iso6392(code) { -MAP_ISO6391_ISO6392 = {'aar' : 'Afar', -'abk' : 'Abkhazian', -'ace' : 'Achinese', -'ach' : 'Acoli', -'ada' : 'Adangme', -'ady' : 'Adyghe; Adygei', -'afa' : 'Afro-Asiatic languages', -'afh' : 'Afrihili', -'afr' : 'Afrikaans', -'ain' : 'Ainu', -'aka' : 'Akan', -'akk' : 'Akkadian', -'alb' : 'Albanian', -'ale' : 'Aleut', -'alg' : 'Algonquian languages', -'alt' : 'Southern Altai', -'amh' : 'Amharic', -'ang' : 'English, Old (ca.450-1100)', -'anp' : 'Angika', -'apa' : 'Apache languages', -'ara' : 'Arabic', -'arc' : 'Official Aramaic (700-300 BCE); Imperial Aramaic (700-300 BCE)', -'arg' : 'Aragonese', -'arm' : 'Armenian', -'arn' : 'Mapudungun; Mapuche', -'arp' : 'Arapaho', -'art' : 'Artificial languages', -'arw' : 'Arawak', -'asm' : 'Assamese', -'ast' : 'Asturian; Bable; Leonese; Asturleonese', -'ath' : 'Athapascan languages', -'aus' : 'Australian languages', -'ava' : 'Avaric', -'ave' : 'Avestan', -'awa' : 'Awadhi', -'aym' : 'Aymara', -'aze' : 'Azerbaijani', -'bad' : 'Banda languages', -'bai' : 'Bamileke languages', -'bak' : 'Bashkir', -'bal' : 'Baluchi', -'bam' : 'Bambara', -'ban' : 'Balinese', -'baq' : 'Basque', -'bas' : 'Basa', -'bat' : 'Baltic languages', -'bej' : 'Beja; Bedawiyet', -'bel' : 'Belarusian', -'bem' : 'Bemba', -'ben' : 'Bengali', -'ber' : 'Berber languages', -'bho' : 'Bhojpuri', -'bih' : 'Bihari languages', -'bik' : 'Bikol', -'bin' : 'Bini; Edo', -'bis' : 'Bislama', -'bla' : 'Siksika', -'bnt' : 'Bantu languages', -'tib' : 'Tibetan', -'bos' : 'Bosnian', -'bra' : 'Braj', -'bre' : 'Breton', -'btk' : 'Batak languages', -'bua' : 'Buriat', -'bug' : 'Buginese', -'bul' : 'Bulgarian', -'bur' : 'Burmese', -'byn' : 'Blin; Bilin', -'cad' : 'Caddo', -'cai' : 'Central American Indian languages', -'car' : 'Galibi Carib', -'cat' : 'Catalan; Valencian', -'cau' : 'Caucasian languages', -'ceb' : 'Cebuano', -'cel' : 'Celtic languages', -'cze' : 'Czech', -'cha' : 'Chamorro', -'chb' : 'Chibcha', -'che' : 'Chechen', -'chg' : 'Chagatai', -'chi' : 'Chinese', -'chk' : 'Chuukese', -'chm' : 'Mari', -'chn' : 'Chinook jargon', -'cho' : 'Choctaw', -'chp' : 'Chipewyan; Dene Suline', -'chr' : 'Cherokee', -'chu' : 'Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic', -'chv' : 'Chuvash', -'chy' : 'Cheyenne', -'cmc' : 'Chamic languages', -'cop' : 'Coptic', -'cor' : 'Cornish', -'cos' : 'Corsican', -'cpe' : 'Creoles and pidgins, English based', -'cpf' : 'Creoles and pidgins, French-based', -'cpp' : 'Creoles and pidgins, Portuguese-based', -'cre' : 'Cree', -'crh' : 'Crimean Tatar; Crimean Turkish', -'crp' : 'Creoles and pidgins', -'csb' : 'Kashubian', -'cus' : 'Cushitic languages', -'wel' : 'Welsh', -'cze' : 'Czech', -'dak' : 'Dakota', -'dan' : 'Danish', -'dar' : 'Dargwa', -'day' : 'Land Dayak languages', -'del' : 'Delaware', -'den' : 'Slave (Athapascan)', -'ger' : 'German', -'dgr' : 'Dogrib', -'din' : 'Dinka', -'div' : 'Divehi; Dhivehi; Maldivian', -'doi' : 'Dogri', -'dra' : 'Dravidian languages', -'dsb' : 'Lower Sorbian', -'dua' : 'Duala', -'dum' : 'Dutch, Middle (ca.1050-1350)', -'dut' : 'Dutch; Flemish', -'dyu' : 'Dyula', -'dzo' : 'Dzongkha', -'efi' : 'Efik', -'egy' : 'Egyptian (Ancient)', -'eka' : 'Ekajuk', -'gre' : 'Greek, Modern (1453-)', -'elx' : 'Elamite', -'eng' : 'English', -'enm' : 'English, Middle (1100-1500)', -'epo' : 'Esperanto', -'est' : 'Estonian', -'baq' : 'Basque', -'ewe' : 'Ewe', -'ewo' : 'Ewondo', -'fan' : 'Fang', -'fao' : 'Faroese', -'per' : 'Persian', -'fat' : 'Fanti', -'fij' : 'Fijian', -'fil' : 'Filipino; Pilipino', -'fin' : 'Finnish', -'fiu' : 'Finno-Ugrian languages', -'fon' : 'Fon', -'fre' : 'French', -'fre' : 'French', -'frm' : 'French, Middle (ca.1400-1600)', -'fro' : 'French, Old (842-ca.1400)', -'frr' : 'Northern Frisian', -'frs' : 'Eastern Frisian', -'fry' : 'Western Frisian', -'ful' : 'Fulah', -'fur' : 'Friulian', -'gaa' : 'Ga', -'gay' : 'Gayo', -'gba' : 'Gbaya', -'gem' : 'Germanic languages', -'geo' : 'Georgian', -'ger' : 'German', -'gez' : 'Geez', -'gil' : 'Gilbertese', -'gla' : 'Gaelic; Scottish Gaelic', -'gle' : 'Irish', -'glg' : 'Galician', -'glv' : 'Manx', -'gmh' : 'German, Middle High (ca.1050-1500)', -'goh' : 'German, Old High (ca.750-1050)', -'gon' : 'Gondi', -'gor' : 'Gorontalo', -'got' : 'Gothic', -'grb' : 'Grebo', -'grc' : 'Greek, Ancient (to 1453)', -'gre' : 'Greek, Modern (1453-)', -'grn' : 'Guarani', -'gsw' : 'Swiss German; Alemannic; Alsatian', -'guj' : 'Gujarati', -'gwi' : 'Gwich\'in', -'hai' : 'Haida', -'hat' : 'Haitian; Haitian Creole', -'hau' : 'Hausa', -'haw' : 'Hawaiian', -'heb' : 'Hebrew', -'her' : 'Herero', -'hil' : 'Hiligaynon', -'him' : 'Himachali languages; Western Pahari languages', -'hin' : 'Hindi', -'hit' : 'Hittite', -'hmn' : 'Hmong', -'hmo' : 'Hiri Motu', -'hrv' : 'Croatian', -'hsb' : 'Upper Sorbian', -'hun' : 'Hungarian', -'hup' : 'Hupa', -'arm' : 'Armenian', -'iba' : 'Iban', -'ibo' : 'Igbo', -'ice' : 'Icelandic', -'ido' : 'Ido', -'iii' : 'Sichuan Yi; Nuosu', -'ijo' : 'Ijo languages', -'iku' : 'Inuktitut', -'ile' : 'Interlingue; Occidental', -'ilo' : 'Iloko', -'ina' : 'Interlingua (International Auxiliary Language Association)', -'inc' : 'Indic languages', -'ind' : 'Indonesian', -'ine' : 'Indo-European languages', -'inh' : 'Ingush', -'ipk' : 'Inupiaq', -'ira' : 'Iranian languages', -'iro' : 'Iroquoian languages', -'ice' : 'Icelandic', -'ita' : 'Italian', -'jav' : 'Javanese', -'jbo' : 'Lojban', -'jpn' : 'Japanese', -'jpr' : 'Judeo-Persian', -'jrb' : 'Judeo-Arabic', -'kaa' : 'Kara-Kalpak', -'kab' : 'Kabyle', -'kac' : 'Kachin; Jingpho', -'kal' : 'Kalaallisut; Greenlandic', -'kam' : 'Kamba', -'kan' : 'Kannada', -'kar' : 'Karen languages', -'kas' : 'Kashmiri', -'geo' : 'Georgian', -'kau' : 'Kanuri', -'kaw' : 'Kawi', -'kaz' : 'Kazakh', -'kbd' : 'Kabardian', -'kha' : 'Khasi', -'khi' : 'Khoisan languages', -'khm' : 'Central Khmer', -'kho' : 'Khotanese; Sakan', -'kik' : 'Kikuyu; Gikuyu', -'kin' : 'Kinyarwanda', -'kir' : 'Kirghiz; Kyrgyz', -'kmb' : 'Kimbundu', -'kok' : 'Konkani', -'kom' : 'Komi', -'kon' : 'Kongo', -'kor' : 'Korean', -'kos' : 'Kosraean', -'kpe' : 'Kpelle', -'krc' : 'Karachay-Balkar', -'krl' : 'Karelian', -'kro' : 'Kru languages', -'kru' : 'Kurukh', -'kua' : 'Kuanyama; Kwanyama', -'kum' : 'Kumyk', -'kur' : 'Kurdish', -'kut' : 'Kutenai', -'lad' : 'Ladino', -'lah' : 'Lahnda', -'lam' : 'Lamba', -'lao' : 'Lao', -'lat' : 'Latin', -'lav' : 'Latvian', -'lez' : 'Lezghian', -'lim' : 'Limburgan; Limburger; Limburgish', -'lin' : 'Lingala', -'lit' : 'Lithuanian', -'lol' : 'Mongo', -'loz' : 'Lozi', -'ltz' : 'Luxembourgish; Letzeburgesch', -'lua' : 'Luba-Lulua', -'lub' : 'Luba-Katanga', -'lug' : 'Ganda', -'lui' : 'Luiseno', -'lun' : 'Lunda', -'luo' : 'Luo (Kenya and Tanzania)', -'lus' : 'Lushai', -'mac' : 'Macedonian', -'mad' : 'Madurese', -'mag' : 'Magahi', -'mah' : 'Marshallese', -'mai' : 'Maithili', -'mak' : 'Makasar', -'mal' : 'Malayalam', -'man' : 'Mandingo', -'mao' : 'Maori', -'map' : 'Austronesian languages', -'mar' : 'Marathi', -'mas' : 'Masai', -'may' : 'Malay', -'mdf' : 'Moksha', -'mdr' : 'Mandar', -'men' : 'Mende', -'mga' : 'Irish, Middle (900-1200)', -'mic' : 'Mi\'kmaq; Micmac', -'min' : 'Minangkabau', -'mis' : 'Uncoded languages', -'mac' : 'Macedonian', -'mkh' : 'Mon-Khmer languages', -'mlg' : 'Malagasy', -'mlt' : 'Maltese', -'mnc' : 'Manchu', -'mni' : 'Manipuri', -'mno' : 'Manobo languages', -'moh' : 'Mohawk', -'mon' : 'Mongolian', -'mos' : 'Mossi', -'mao' : 'Maori', -'may' : 'Malay', -'mul' : 'Multiple languages', -'mun' : 'Munda languages', -'mus' : 'Creek', -'mwl' : 'Mirandese', -'mwr' : 'Marwari', -'bur' : 'Burmese', -'myn' : 'Mayan languages', -'myv' : 'Erzya', -'nah' : 'Nahuatl languages', -'nai' : 'North American Indian languages', -'nap' : 'Neapolitan', -'nau' : 'Nauru', -'nav' : 'Navajo; Navaho', -'nbl' : 'Ndebele, South; South Ndebele', -'nde' : 'Ndebele, North; North Ndebele', -'ndo' : 'Ndonga', -'nds' : 'Low German; Low Saxon; German, Low; Saxon, Low', -'nep' : 'Nepali', -'new' : 'Nepal Bhasa; Newari', -'nia' : 'Nias', -'nic' : 'Niger-Kordofanian languages', -'niu' : 'Niuean', -'dut' : 'Dutch; Flemish', -'nno' : 'Norwegian Nynorsk; Nynorsk, Norwegian', -'nob' : 'Bokmål, Norwegian; Norwegian Bokmål', -'nog' : 'Nogai', -'non' : 'Norse, Old', -'nor' : 'Norwegian', -'nqo' : 'N\'Ko', -'nso' : 'Pedi; Sepedi; Northern Sotho', -'nub' : 'Nubian languages', -'nwc' : 'Classical Newari; Old Newari; Classical Nepal Bhasa', -'nya' : 'Chichewa; Chewa; Nyanja', -'nym' : 'Nyamwezi', -'nyn' : 'Nyankole', -'nyo' : 'Nyoro', -'nzi' : 'Nzima', -'oci' : 'Occitan (post 1500)', -'oji' : 'Ojibwa', -'ori' : 'Oriya', -'orm' : 'Oromo', -'osa' : 'Osage', -'oss' : 'Ossetian; Ossetic', -'ota' : 'Turkish, Ottoman (1500-1928)', -'oto' : 'Otomian languages', -'paa' : 'Papuan languages', -'pag' : 'Pangasinan', -'pal' : 'Pahlavi', -'pam' : 'Pampanga; Kapampangan', -'pan' : 'Panjabi; Punjabi', -'pap' : 'Papiamento', -'pau' : 'Palauan', -'peo' : 'Persian, Old (ca.600-400 B.C.)', -'per' : 'Persian', -'phi' : 'Philippine languages', -'phn' : 'Phoenician', -'pli' : 'Pali', -'pol' : 'Polish', -'pon' : 'Pohnpeian', -'por' : 'Portuguese', -'pra' : 'Prakrit languages', -'pro' : 'Provençal, Old (to 1500);Occitan, Old (to 1500)', -'pus' : 'Pushto; Pashto', -'qaa' : 'Reserved for local use', -'que' : 'Quechua', -'raj' : 'Rajasthani', -'rap' : 'Rapanui', -'rar' : 'Rarotongan; Cook Islands Maori', -'roa' : 'Romance languages', -'roh' : 'Romansh', -'rom' : 'Romany', -'rum' : 'Romanian; Moldavian; Moldovan', -'rum' : 'Romanian; Moldavian; Moldovan', -'run' : 'Rundi', -'rup' : 'Aromanian; Arumanian; Macedo-Romanian', -'rus' : 'Russian', -'sad' : 'Sandawe', -'sag' : 'Sango', -'sah' : 'Yakut', -'sai' : 'South American Indian languages', -'sal' : 'Salishan languages', -'sam' : 'Samaritan Aramaic', -'san' : 'Sanskrit', -'sas' : 'Sasak', -'sat' : 'Santali', -'scn' : 'Sicilian', -'sco' : 'Scots', -'sel' : 'Selkup', -'sem' : 'Semitic languages', -'sga' : 'Irish, Old (to 900)', -'sgn' : 'Sign Languages', -'shn' : 'Shan', -'sid' : 'Sidamo', -'sin' : 'Sinhala; Sinhalese', -'sio' : 'Siouan languages', -'sit' : 'Sino-Tibetan languages', -'sla' : 'Slavic languages', -'slo' : 'Slovak', -'slo' : 'Slovak', -'slv' : 'Slovenian', -'sma' : 'Southern Sami', -'sme' : 'Northern Sami', -'smi' : 'Sami languages', -'smj' : 'Lule Sami', -'smn' : 'Inari Sami', -'smo' : 'Samoan', -'sms' : 'Skolt Sami', -'sna' : 'Shona', -'snd' : 'Sindhi', -'snk' : 'Soninke', -'sog' : 'Sogdian', -'som' : 'Somali', -'son' : 'Songhai languages', -'sot' : 'Sotho, Southern', -'spa' : 'Spanish; Castilian', -'alb' : 'Albanian', -'srd' : 'Sardinian', -'srn' : 'Sranan Tongo', -'srp' : 'Serbian', -'srr' : 'Serer', -'ssa' : 'Nilo-Saharan languages', -'ssw' : 'Swati', -'suk' : 'Sukuma', -'sun' : 'Sundanese', -'sus' : 'Susu', -'sux' : 'Sumerian', -'swa' : 'Swahili', -'swe' : 'Swedish', -'syc' : 'Classical Syriac', -'syr' : 'Syriac', -'tah' : 'Tahitian', -'tai' : 'Tai languages', -'tam' : 'Tamil', -'tat' : 'Tatar', -'tel' : 'Telugu', -'tem' : 'Timne', -'ter' : 'Tereno', -'tet' : 'Tetum', -'tgk' : 'Tajik', -'tgl' : 'Tagalog', -'tha' : 'Thai', -'tib' : 'Tibetan', -'tig' : 'Tigre', -'tir' : 'Tigrinya', -'tiv' : 'Tiv', -'tkl' : 'Tokelau', -'tlh' : 'Klingon; tlhIngan-Hol', -'tli' : 'Tlingit', -'tmh' : 'Tamashek', -'tog' : 'Tonga (Nyasa)', -'ton' : 'Tonga (Tonga Islands)', -'tpi' : 'Tok Pisin', -'tsi' : 'Tsimshian', -'tsn' : 'Tswana', -'tso' : 'Tsonga', -'tuk' : 'Turkmen', -'tum' : 'Tumbuka', -'tup' : 'Tupi languages', -'tur' : 'Turkish', -'tut' : 'Altaic languages', -'tvl' : 'Tuvalu', -'twi' : 'Twi', -'tyv' : 'Tuvinian', -'udm' : 'Udmurt', -'uga' : 'Ugaritic', -'uig' : 'Uighur; Uyghur', -'ukr' : 'Ukrainian', -'umb' : 'Umbundu', -'und' : 'Undetermined', -'urd' : 'Urdu', -'uzb' : 'Uzbek', -'vai' : 'Vai', -'ven' : 'Venda', -'vie' : 'Vietnamese', -'vol' : 'Volapük', -'vot' : 'Votic', -'wak' : 'Wakashan languages', -'wal' : 'Wolaitta; Wolaytta', -'war' : 'Waray', -'was' : 'Washo', -'wel' : 'Welsh', -'wen' : 'Sorbian languages', -'wln' : 'Walloon', -'wol' : 'Wolof', -'xal' : 'Kalmyk; Oirat', -'xho' : 'Xhosa', -'yao' : 'Yao', -'yap' : 'Yapese', -'yid' : 'Yiddish', -'yor' : 'Yoruba', -'ypk' : 'Yupik languages', -'zap' : 'Zapotec', -'zbl' : 'Blissymbols; Blissymbolics; Bliss', -'zen' : 'Zenaga', -'zha' : 'Zhuang; Chuang', -'chi' : 'Chinese', -'znd' : 'Zande languages', -'zul' : 'Zulu', -'zun' : 'Zuni', -'zxx' : 'No linguistic content; Not applicable', -'zza' : 'Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki'}; - var lang; - return ((lang = MAP_ISO6391_ISO6392[code]) !== null) ? lang : false; -} diff --git a/translators/ProMED.js b/translators/ProMED.js @@ -1,51 +0,0 @@ -{ - "translatorID":"3e9dbe21-10f2-40be-a921-f6ec82760927", - "translatorType":4, - "label":"ProMED", - "creator":"Brandon Minich", - "target":"http://www.promedmail.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-03-19 17:15:00" -} - -function detectWeb(doc, url) { - if (url.toLowerCase().indexOf("f2400_p") != -1) { - return "email"; - } -} -function doWeb(doc, url) { - Zotero.debug(doc.title); - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item('email'); - - if (doc.evaluate('//span[@id="F2400_P1001_SUBJECT"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title= doc.evaluate('//span[@id="F2400_P1001_SUBJECT"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//span[@id="F2400_P1202_SUBJECT"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//span[@id="F2400_P1202_SUBJECT"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - - if (doc.evaluate('//span[@id="F2400_P1001_PUBLISHED_DATE"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.date = doc.evaluate('//span[@id="F2400_P1001_PUBLISHED_DATE"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//span[@id="F2400_P1202_PUBLISHED_DATE"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.date = doc.evaluate('//span[@id="F2400_P1202_PUBLISHED_DATE"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - if (doc.evaluate('//span[@id="F2400_P1001_ARCHIVE_NUMBER"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.extra = "Archive Number: " + doc.evaluate('//span[@id="F2400_P1001_ARCHIVE_NUMBER"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//span[@id="F2400_P1202_ARCHIVE_NUMBER"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.extra = "Archive Number: " + doc.evaluate('//span[@id="F2400_P1202_ARCHIVE_NUMBER"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - newItem.url = doc.location.href; - - newItem.complete(); -} diff --git a/translators/ProQuest Legacy.js b/translators/ProQuest Legacy.js @@ -1,218 +0,0 @@ -{ - "translatorID":"a77690cf-c5d1-8fc4-110f-d1fc765dcf88", - "translatorType":4, - "label":"ProQuest Legacy", - "creator":"Simon Kornblith", - "target":"^https?://[^/]+/pqdweb\\?((?:.*\\&)?did=.*&Fmt=[0-9]|(?:.*\\&)Fmt=[0-9].*&did=|(?:.*\\&)searchInterface=|(?:.*\\&)TS=[0-9])", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-07-24 07:55:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.evaluate('//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]', - doc, nsResolver, XPathResult.ANY_TYPE, null)) { - - - var xpath = '//table[@id="tableIndexTerms"]/tbody/tr/td[@class="textSmall"]'; - var data= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var aitem; - var source; - while(aitem = data.iterateNext()) { - source=aitem.textContent; - if(source=="Source type:") { - source=data.iterateNext().textContent; - Zotero.debug("Item Source Type: "+source); - break; - } - } - - if(doc.title.match("Results")) { - return "multiple"; - } else if(doc.title.match("Document View")) { - switch (source) { - case 'Dissertation': - return "thesis"; - - case 'Historical Newspaper': - case 'Newspaper': - return "newspaperArticle"; - - default: - return "journalArticle"; - } - - } - } -} - -//^https?://[^/]+/pqdweb\?((?:.*\&)?did=.*&Fmt=[0-9]|(?:.*\&)Fmt=[0-9].*&did=|(?:.*\&)searchInterface=) - -function parseRIS(uris) { - Zotero.Utilities.HTTP.doGet(uris, function(text, xmlhttp, url){ - // load translator for RIS - if(url.match("exportFormat=1")=="exportFormat=1") { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - - // Put AB note in abstract field - text = text.replace(/^AB \-/gm, 'N2 -'); - - // Strip lines with just whitespace, which mess up RIS parsing - text = text.replace(/^\s*$\n/gm, ''); - - translator.setString(text); - - //Set Handler fixes anomaly in Proquest RIS format. Properly formats author name as [last name], [first name] - translator.setHandler("itemDone", function(obj, item) { - var cre = new Array(); - cre = item.creators; - - for each(var e in cre) { - - if(!e['firstName']) { - // Rather than parse, change creator to a single field. - e.fieldMode = 1; - } - } - - if (item.publicationTitle) item.publicationTitle = Zotero.Utilities.trimInternal(item.publicationTitle.replace(/\([\d\-]+\)/g, "")); - - // Don't save database page as URL - item.url = undefined; - - item.complete(); - }); - - translator.translate(); - Zotero.done(); - } - - }, function() {}); - Zotero.wait(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var hostRegexp = new RegExp("^(https?://[^/]+)/"); - var hMatch = hostRegexp.exec(url); - var host = hMatch[1]; - - - - if(doc.evaluate('//img[substring(@src, string-length(@src)-32) = "/images/common/logo_proquest.gif" or substring(@src, string-length(@src)-38) = "/images/common/logo_proquest_small.gif"]', - doc, nsResolver, XPathResult.ANY_TYPE, null)) { - if(doc.title.match("Results")) { - - //Get Client ID - var xpath = '//a'; - var data= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var aitem; - var clientID; - while(aitem = data.iterateNext()) { - clientID=aitem.href; - if(clientID.indexOf("clientId")!=-1) { - clientID = clientID.substr(clientID.indexOf("clientId")+9,clientID.length); - break; - } - } - - var multXpath = '//input[@name="chk"][@type="checkbox"]'; - var titleXpath = '//a[@class="bold"]'; - var mInfos = doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titleElmts = doc.evaluate(titleXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titleElmt; - var mInfo; - mInfo = mInfos.iterateNext(); - titleElmt = titleElmts.iterateNext(); - - var items = new Array(); - - do { - //Get item ID - - var str= mInfo.value; - str= str.replace("retrieveGroup", "sid"); - var url = host+"/pqdweb?RQT=530&markedListInfo="+str+"1"; - items[url] = Zotero.Utilities.trimInternal(titleElmt.textContent); - - } while((mInfo = mInfos.iterateNext()) && (titleElmt = titleElmts.iterateNext())); - - items = Zotero.selectItems(items); - if(!items) return true; - - - //Array of URLs for the doGet - var uris = new Array(); - - //Clear Basket - uris.push(host+"/pqdweb?RQT=531&clientId="+clientID); - uris.push(host+"/pqdweb?RQT=532&clientId="+clientID); - - //Add URLS to the basket - for(var bibcode in items) { - uris.push(bibcode); - } - - //Export basket as a RIS file - uris.push(host+"/pqdweb?RQT=532&clientId="+clientID); - uris.push(host+"/pqdweb?RQT=562&MRR=M&clientId="+clientID); - uris.push(host+"/pqdweb?RQT=562&exportFormat=1&clientId="+clientID); - - parseRIS(uris); - - } else { - - //Get Client ID - var xpath = '//a'; - var data= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var aitem; - var clientID; - while(aitem = data.iterateNext()) { - clientID=aitem.href; - if(clientID.indexOf("clientId")!=-1) { - clientID = clientID.substr(clientID.indexOf("clientId")+9,clientID.length); - break; - } - } - - //Get item ID - var xpath = '//input[@name="marked"][@type="checkbox"]'; - var str= doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().value; - str= str.replace("retrieveGroup", "sid"); - - //Array of URLs for the doGet - var uris = new Array(); - - //Clear Basket - uris.push(host+"/pqdweb?RQT=531&clientId="+clientID); - uris.push(host+"/pqdweb?RQT=532&clientId="+clientID); - - //Create URL to add item to basket - url = host+"/pqdweb?RQT=530&markedListInfo="+str+"1"; - Zotero.debug("RIS URL: "+url); - - uris.push(url); - - //Export basket as a RIS file - uris.push(host+"/pqdweb?RQT=532&clientId="+clientID); - uris.push(host+"/pqdweb?RQT=562&MRR=M&clientId="+clientID); - uris.push(host+"/pqdweb?RQT=562&exportFormat=1&clientId="+clientID); - - parseRIS(uris); - - } - } - -} diff --git a/translators/ProQuest.js b/translators/ProQuest.js @@ -1,354 +0,0 @@ -{ - "translatorID": "fce388a6-a847-4777-87fb-6595e710b7e7", - "label": "ProQuest", - "creator": "Avram Lyon", - "target": "^https?://search\\.proquest\\.com[^/]*(/pqrl|/pqdt|/hnp[a-z]*)?/(docview|publication|publicationissue|results)", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:32:08" -} - -/* - ProQuest 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) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var record_rows = doc.evaluate('//div[@class="display_record_indexing_row"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - if (record_rows.iterateNext()) { - type = doc.evaluate('//div[@class="display_record_indexing_fieldname" and contains(text(),"Document Type")]/following-sibling::div[@class="display_record_indexing_data"]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (type) { - type = type.textContent.trim(); - type = mapToZotero(type); - if (type) return type; - } - // Fall back on journalArticle-- even if we couldn't guess the type - return "journalArticle"; - } - - if (url.indexOf("/results/") === -1) { - var abstract_link = doc.evaluate('//a[@class="formats_base_sprite format_abstract"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - if (abstract_link.iterateNext()) { - return "journalArticle"; - } - } - var resultitem = doc.evaluate('//li[@class="resultItem" or contains(@class, "resultItem ")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - if (resultitem.iterateNext()) { - return "multiple"; - } - return false; -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var detected = detectWeb(doc,url); - if (detected && detected != "multiple") { - scrape(doc,url); - } else if (detected) { - var articles = new Array(); - var results = doc.evaluate('//li[@class="resultItem" or contains(@class, "resultItem ")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var items = new Array(); - var result; - while(result = results.iterateNext()) { - var link = doc.evaluate('.//a[contains(@class,"previewTitle") or contains(@class,"resultTitle")]', result, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var title = link.textContent; - var url = link.href; - items[url] = title; - } - Zotero.selectItems(items, function (items) { - if(!items) return true; - for (var i in items) { - articles.push(i); - } - 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 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; - } - var url = doc.location.href; - - // ProQuest provides us with two different data sources; we can pull the RIS - // (which is nicely embedded in each page!), or we can scrape the Display Record section - // We're going to prefer the latter, since it gives us richer data. - // But since we have it without an additional request, we'll see about falling back on RIS for missing data - - var item = new Zotero.Item(); - var record_rows = doc.evaluate('//div[@class="display_record_indexing_row"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var record_row; - item.place = []; - item.thesisType = []; - var account_id; - while (record_row = record_rows.iterateNext()) { - var field = doc.evaluate('./div[@class="display_record_indexing_fieldname"]', record_row, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() - if (!field) continue; - field = field.textContent.trim(); - var value = doc.evaluate('./div[@class="display_record_indexing_data"]', record_row, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.trim(); - // Separate values in a single field are generally wrapped in <a> nodes; pull a list of them - var valueAResult = doc.evaluate('./div[@class="display_record_indexing_data"]/a', record_row, nsResolver, XPathResult.ANY_TYPE, null); - var valueA; - var valueAArray = []; - // We would like to get an array of the text for each <a> node - if (valueAResult) { - while(valueA = valueAResult.iterateNext()) { - valueAArray.push(valueA.textContent); - } - } - switch (field) { - case "Title": - item.title = value; break; - case "Authors": - item.creators = valueAArray.map( - function(author) { - return Zotero.Utilities.cleanAuthor(author, - "author", - author.indexOf(',') !== -1); // useComma - }); - break; - case "Publication title": - item.publicationTitle = value; break; - case "Volume": - item.volume = value; break; - case "Issue": - item.issue = value; break; - case "Pages": - case "First Page": - item.pages = value; break; - case "Number of pages": - item.numPages = value; break; - case "Publication year": - case "Year": - item.date = (item.date) ? item.date : value; break; - case "Publication Date": - item.date = value; break; - case "Publisher": - item.publisher = value; break; - case "Place of Publication": // TODO Change to publisher-place when schema changes - item.place[0] = value; break; - case "Dateline": // TODO Change to event-place when schema changes - item.place[0] = value; break; - case "School location": // TODO Change to publisher-place when schema changes - item.place[0] = value; break; - // blacklisting country-- ProQuest regularly gives us Moscow, United States - //case "Country of publication": - // item.place[1] = value; break; - case "ISSN": - item.ISSN = value; break; - case "ISBN": - item.ISBN = value; break; - case "DOI": - item.DOI = value; break; - case "School": - item.university = value; break; - case "Degree": - item.thesisType[0] = value; break; - case "Department": - item.thesisType[1] = value; break; - case "Advisor": // TODO Map when exists in Zotero - break; - case "Source type": - case "Document Type": - item.itemType = (mapToZotero(value)) ? mapToZotero(value) : item.itemType; break; - 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]+$/,'')+"/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": - item.section = value; break; - case "Identifiers / Keywords": - item.tags = value.split(', '); break; - case "Subjects": - item.tags = valueAArray; break; - default: Zotero.debug("Discarding unknown field '"+field+"' => '" +value+ "'"); - } - } - - var abs = doc.evaluate('//div[@id="abstract_field" or @id="abstractSummary"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abs) { - item.abstractNote = abs.textContent - .replace(/\[\s*[Ss]how all\s*\].*/,"") - .replace(/\[\s*[Ss]how less\s*\].*/,"") - .replace(/\[\s*PUBLICATION ABSTRACT\s*\]/,"") - .trim(); - } - - item.place = item.place.join(', '); - item.thesisType = item.thesisType.join(', '); - - item.proceedingsTitle = item.publicationTitle; - - // On historical newspapers, we see: - // Rights: Copyright New York Times Company Dec 1, 1852 - // Date: 1852 - // We can improve on this, so we do. - var fullerDate = item.rights.match(/([A-Z][a-z]{2} \d{1,2}, \d{4}$)/); - if (!item.date || - (item.date.match(/^\d{4}$/) && fullerDate)) { - item.date = fullerDate[1]; - } - - if (!item.itemType && item.libraryCatalog && item.libraryCatalog.match(/Historical Newspapers/)) - item.itemType = "newspaperArticle"; - - if(!item.itemType) item.itemType="journalArticle"; - - // Ok, now we'll pull the RIS and run it through the translator. And merge with the temporary item. - // RIS LOGIC GOES HERE - - // Sometimes the PDF is right on this page - var realLink = doc.evaluate('//div[@id="pdffailure"]/div[@class="body"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (realLink) { - item.attachments.push({url:realLink.href, - title:"ProQuest PDF", - mimeType:"application/pdf"}); - item.complete(); - } else { - // The PDF link requires two requests-- we fetch the PDF full text page - var pdf = doc.evaluate('//a[@class="formats_base_sprite format_pdf"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (pdf) { - Zotero.Utilities.processDocuments(pdf.href, function(pdfDoc){ - // This page gives a beautiful link directly to the PDF, right in the HTML - realLink = pdfDoc.evaluate('//div[@id="pdffailure"]/div[@class="body"]/a', pdfDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (realLink) { - item.attachments.push({url:realLink.href, - title:"ProQuest PDF", - mimeType:"application/pdf"}); - } - item.complete(); - }, function () {}); - } else { - item.complete(); - } - } -} - -// This map is not complete. See debug output to catch unassigned types -function mapToZotero (type) { - var map = { - "Scholarly Journals" : "journalArticle", - "Book Review-Mixed" : false, // FIX AS NECESSARY - "Reports" : "report", - "REPORT" : "report", - "Historical Newspapers" : "newspaperArticle", - "Newspapers" : "newspaperArticle", - //"News" : "newspaperArticle", // Otherwise Foreign Policy is treated as a newspaper http://search.proquest.com/docview/840433348 - "Magazines" : "magazineArticle", - "Dissertations & Theses" : "thesis", - "Dissertation/Thesis" : "thesis", - "Conference Papers & Proceedings" : "conferencePaper", - "Wire Feeds": "newspaperArticle", // Good enough? - "WIRE FEED": "newspaperArticle" // Good enough? - } - if (map[type]) return map[type]; - Zotero.debug("No mapping for type: "+type); - return false; -} -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://search.proquest.com/docview/213445241", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Gerald F", - "lastName": "Powers", - "creatorType": "author" - }, - { - "firstName": "Drew", - "lastName": "Christiansen", - "creatorType": "author" - }, - { - "firstName": "Robert T", - "lastName": "Hennemeyer", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Peace", - "Book reviews" - ], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "ProQuest Record", - "mimeType": "text/html" - } - ], - "place": "Winnipeg", - "title": "Peacemaking: moral & policy challenges for a new world // Review", - "publicationTitle": "Peace Research", - "volume": "27", - "issue": "2", - "pages": "90-100", - "numPages": "0", - "date": "May 1995", - "publisher": "Menno Simons College", - "ISSN": "00084697", - "language": "English", - "callNumber": "213445241", - "rights": "Copyright Peace Research May 1995", - "proceedingsTitle": "Peace Research", - "libraryCatalog": "ProQuest", - "shortTitle": "Peacemaking" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Probing the Past.js b/translators/Probing the Past.js @@ -1,102 +0,0 @@ -{ - "translatorID":"095239e7-c18c-4f45-a932-bcf4a9e48c08", - "translatorType":4, - "label":"Probing the Past", - "creator":"Adam Crymble", - "target":"http://chnm.gmu.edu/probateinventory/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-11 20:40:00" -} - -function detectWeb(doc, url) { - - if (doc.evaluate('//td/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.location.href.match("document")) { - return "book"; - } - -} - -//Probing the Past translator; Code by Adam Crymble - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - - var newItem = new Zotero.Item("book"); - - var title = doc.evaluate('//h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var author = title.split(", "); - author = author[1] + " " + author[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - - newItem.title = "Probate of " + author; - - var citation = doc.evaluate('//table[@id="browseinfo"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var citation = citation.split(": "); - citation[1] = citation[1].replace("County/City", ''); - - - citation[2] = citation[2].replace("State", ''); - for (var i = 0; i < citation.length; i++) { - citation[i] = citation[i].replace(/^\s*|\s*$/g, ''); - } - Zotero.debug(citation); - - newItem.date = citation[1]; - newItem.place = citation[2] + ", " + citation[3]; - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var titlesCount = doc.evaluate('count (//td/a)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_date; - var next_title; - var next_town; - - for (var i = 0; i < titlesCount.numberValue/3; i++) { - - next_date = titles.iterateNext(); - next_title = titles.iterateNext(); - - items[next_title.href] = next_title.textContent; - - next_town = titles.iterateNext(); - } - - 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(); -} -\ No newline at end of file diff --git a/translators/Progress of Theoretical Physics.js b/translators/Progress of Theoretical Physics.js @@ -1,89 +0,0 @@ -{ - "translatorID":"0b356cb6-7fa1-4662-b6e8-7ffc9ca2cd4a", - "translatorType":4, - "label":"Progress of Theoretical Physics", - "creator":"Michael Berkowitz", - "target":"http://ptp.ipap.jp/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-12-31 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.title.match(/search result/) || doc.title.match(/Table of Contents/)) { - return "multiple"; - } else if (url.match(/getarticle\?/) || url.match(/link\?/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.title.toLowerCase().match(/search result/)) { - var titles = doc.evaluate('/html/body//li//b', doc, null, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('/html/body//li/a', doc, null, XPathResult.ANY_TYPE, null); - var title; - var link; - while ((title = titles.iterateNext()) && (link = links.iterateNext())) { - items[link.href] = Zotero.Utilities.trimInternal(title.textContent); - } - } else if (doc.title.toLowerCase().match(/table of contents/)) { - var xpath = doc.evaluate('/html/body/ul/li/a', doc, null, XPathResult.ANY_TYPE, null); - var text; - while (text = xpath.iterateNext()) { - items[text.href] = Zotero.Utilities.trimInternal(text.textContent); - } - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//h2[@class="title"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if (doc.evaluate('//h2[@class="subtitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - item.title = item.title + ": " + Zotero.Utilities.trimInternal(doc.evaluate('//h2[@class="subtitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//p[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var authors = doc.evaluate("//p[@class='author']/a", doc, null, XPathResult.ANY_TYPE, null); - var aut; - while(aut = authors.iterateNext()) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut.textContent, "author")); - } - var info = Zotero.Utilities.trimInternal(doc.evaluate('//h4[@class="info"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if (m = info.match(/Vol\.\s+(\d+)\s+No\.\s+(\d+)\s+\((\d+)\)\s+pp\.\s+([\d-]+)\s+URL\s+:\s+(.*)\s+DOI\s+:\s+(.*)$/)){ - item.ISSN = '0033-068X'; - item.publicationTitle = "Progress of Theoretical Physics"; - item.journalAbbreviation = "Prog. Theor. Phys."; - item.volume = m[1]; - item.issue = m[2]; - item.date = m[3]; - item.pages = m[4]; - item.url = m[5]; - item.DOI = m[6]; - } else if (m = info.match(/Supplement\s+No\.\s+(\d+)\s+\((\d+)\)\s+pp\.\s+([\d-]+)\s+URL\s+:\s+(.*)\s+DOI\s+:\s+(.*)$/)){ - item.ISSN = '0375-9687'; - item.publicationTitle = "Progress of Theoretical Physics Supplement"; - item.journalAbbreviation = "Prog. Theor. Phys. Suppl."; - item.volume = m[1]; - item.date = m[2]; - item.pages = m[3]; - item.url = m[4]; - item.DOI = m[5]; - } - var pdfurl = doc.evaluate('//a[contains(text(), "PDF")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - item.attachments = [ - {url:item.url, title:"PTP Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"PTP Full Text PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Project Gutenberg.js b/translators/Project Gutenberg.js @@ -1,194 +0,0 @@ -{ - "translatorID":"d770e7d2-106c-4396-8c32-b35cdc46376c", - "translatorType":4, - "label":"Project Gutenberg", - "creator":"Adam Crymble, Avram Lyon", - "target":"^http://www\\.gutenberg\\.org", - "minVersion":"2.1", - "maxVersion":"", - "priority":100, - "browserSupport":"gcs", - "inRepository":true, - "lastUpdated":"2011-08-22 22:31:32" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("etext")||doc.location.href.match("ebooks")) { - return "book"; - } else if (doc.location.href.match("catalog")) { - return "multiple"; - } -} - -//Project Gutenberg translator. Code by Adam Crymble. - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var creatorType = new Array(); - var creatorField = new Array(); - var creatorContent = new Array(); - - var newItem = new Zotero.Item("book"); - - var headings = doc.evaluate('//table[@class="bibrec"]//tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var content = doc.evaluate('//table[@class="bibrec"]//tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null); - var i; - - while (i = headings.iterateNext()) { - fieldTitle = i.textContent; - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(content.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - //Zotero.debug(i.textContent); - if (fieldTitle == "Creator") { - creatorType.push("author"); - creatorField.push("Creator"); - creatorContent.push(dataTags[fieldTitle]); - } else if (fieldTitle == "Author") { - creatorType.push("author"); - creatorField.push("Author"); - creatorContent.push(dataTags[fieldTitle]); - } else if (fieldTitle == "Illustrator") { - creatorType.push("illustrator"); - creatorField.push("Illustrator"); - creatorContent.push(dataTags[fieldTitle]); - } else if (fieldTitle == "Translator") { - creatorType.push("translator"); - creatorField.push("Translator"); - creatorContent.push(dataTags[fieldTitle]); - } else if (fieldTitle == "Editor") { - creatorType.push("editor"); - creatorField.push("Editor"); - creatorContent.push(dataTags[fieldTitle]); - } else if (fieldTitle == "Commentator") { - creatorType.push("commentator"); - creatorField.push("Commentator"); - creatorContent.push(dataTags[fieldTitle]); - } else if (fieldTitle == "Contributor") { - creatorType.push("contributor"); - creatorField.push("Contributor"); - creatorContent.push(dataTags[fieldTitle]); - } else if (fieldTitle == "Imprint") { - var place = dataTags["Imprint"].split(":"); - newItem.place = place[0]; - //Zotero.debug(place); - } else if (fieldTitle == "Subject") { - newItem.tags.push(dataTags["Subject"]); - } else { - //Zotero.debug("Have: " + fieldTitle + "=>" + dataTags[fieldTitle]); - } - } - - for (var i = 0; i < creatorType.length; i++) { - if (creatorContent[i].match(", ")) { - - var author = creatorContent[i].split(", "); - var author = author[1] + " " + author[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, creatorType[i])); - } else { - - newItem.creators.push(Zotero.Utilities.cleanAuthor(creatorContent[i], creatorType[i])); - } - } - - - if (dataTags["EText-No."]) { - newItem.callNumber = "EText-No. " + dataTags["EText-No."]; - } - - if (dataTags["ReleaseDate"]) { - newItem.date = "Release Date " + dataTags["ReleaseDate"]; - } - - if (dataTags["LoCClass"]) { - newItem.extra = "LoC Class " + dataTags["LoCClass"]; - } - - associateData (newItem, dataTags, "Title", "title"); - associateData (newItem, dataTags, "Language", "language"); - associateData (newItem, dataTags, "CopyrightStatus", "rights"); - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var allLinks = doc.evaluate('//td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count(//td/a)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - for (var i = 0; i < xPathCount.numberValue; i++) { - next_title = allLinks.iterateNext(); - if (next_title.href.match("etext")) { - items[next_title.href] = next_title.textContent; - } - } - - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.gutenberg.org/ebooks/20321", - "items": [ - { - "itemType": "book", - "creators": [ - { - "firstName": "Bartolomé de las", - "lastName": "Casas", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Indians, Treatment of -- Latin America", - "Spain -- Colonies -- America" - ], - "seeAlso": [], - "attachments": [], - "date": "Release Date Jan 9, 2007", - "extra": "LoC Class F1401: Latin America local history: General", - "title": "A Brief Account of the Destruction of the Indies\u000aOr, a faithful NARRATIVE OF THE Horrid and Unexampled Massacres, Butcheries, and all manner of Cruelties, that Hell and Malice could invent, committed by the Popish Spanish Party on the inhabitants of West-India, TOGETHER With the Devastations of several Kingdoms in America by Fire and Sword, for the space of Forty and Two Years, from the time of its first Discovery by them.", - "language": "English", - "rights": "Public domain in the USA.", - "url": "http://www.gutenberg.org/ebooks/20321", - "libraryCatalog": "Project Gutenberg" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/Project MUSE.js b/translators/Project MUSE.js @@ -1,176 +0,0 @@ -{ - "translatorID": "c54d1932-73ce-dfd4-a943-109380e06574", - "label": "Project MUSE", - "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": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-08-25 10:00:51" -} - -function detectWeb(doc, url) { - var searchRe = new RegExp("(^https?://[^/]+/search/results|/search/save|/toc/)"); - if(searchRe.test(url)) { - return "multiple"; - } else { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - - var searchRe = new RegExp("^https?://[^/]+/search/results|/search/save"); - if(detectWeb(doc, url) == "multiple") { - 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, 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, 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\//)) { - var results = doc.evaluate('//div[@class="article"]', - doc, null, XPathResult.ANY_TYPE, null); - var result; - while(result = results.iterateNext()) { - 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; - } - } - // 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, null, XPathResult.ANY_TYPE, null); - var article; - while (article = articles.iterateNext()) { - 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.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(); -} - -// Given an article page, get the RIS and open it -function scrapeOne(doc) { - var url = doc.location.href; - - var hostRe = new RegExp("^(http://[^/]+)/"); - var m = hostRe.exec(url); - var host = m[1]; - - 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, - null, XPathResult.ANY_TYPE, null).iterateNext(); - var abstract = doc.evaluate('//abstract', doc, - null, XPathResult.ANY_TYPE, null).iterateNext(); - - - 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); - translator.setHandler("itemDone", function(obj, item) { - if(item.notes && item.notes[0]) { - item.extra = item.notes[0].note; - delete item.notes; - item.notes = undefined; - } - item.attachments.splice(0); - item.attachments.push({document:doc, title:"Project MUSE Snapshot"}); - if(getPDF) { - item.attachments.push({title:"Project MUSE Full Text PDF", mimeType:"application/pdf", - url:getPDF.href}); - } - if(DOI) { - item.DOI = DOI.textContent.replace(/^DOI: /,""); - } - if(abstract) { - item.abstract = abstract.textContent; - } - item.complete(); - }); - 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": "<p>Number 191, May 2006</p>", - "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/Protein Data Bank.js b/translators/Protein Data Bank.js @@ -1,86 +0,0 @@ -{ - "translatorID":"e16095ae-986c-4117-9cb6-20f3b7a52f64", - "translatorType":4, - "label":"Protein Data Bank", - "creator":"Michael Berkowitz", - "target":"http://www.pdb.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.title.indexOf("Query Results") != -1) { - return "multiple"; - } else if (url.indexOf("structureId") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var proteins = new Array(); - if (detectWeb(doc, url) == "multiple") { - //search results - var items = new Object(); - var xpath = '//a[@class="qrb_title"]'; - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href.match(/structureId=(.*)/)[1]] = next_title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - proteins.push(i); - } - } else { - proteins = [url.match(/structureId=(.*)/)[1]]; - } - - Zotero.debug(proteins); - for (var p in proteins) { - var xmlstr = 'http://www.pdb.org/pdb/download/downloadFile.do?fileFormat=xml&headerOnly=YES&structureId=' + proteins[p]; - Zotero.debug(xmlstr); - - Zotero.Utilities.HTTP.doGet(xmlstr, function(text) { - var item = new Zotero.Item("journalArticle"); - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, "").replace(/PDBx\:/g, ""); - var article = text.split('<citation id="primary">'); - var art = article[1].split(/<\/citation>\n/); - art = "<citation>" + art[0] + "</citation>"; - var xml = new XML(art); - var info = text.split('<database_PDB_revCategory>')[1].split('</database_PDB_revCategory>')[0]; - var xml2 = new XML("<PDB_revCategory>" + info + "</PDB_revCategory>"); - var aus = text.split('<citation_authorCategory>')[1].split('</citation_authorCategory>')[0]; - aus = "<authors>" + aus + "</authors>"; - var xml3 = new XML(aus); - - item.title = xml..title.text().toString(); - item.publicationTitle = xml..journal_abbrev.text().toString(); - item.volume = xml..journal_volume.text().toString(); - item.pages = xml..page_first.text().toString() + "-" + xml..page_last.text().toString(); - item.ISSN = xml..journal_id_ISSN.text().toString(); - item.extra = "PubMed ID: " + xml..pdbx_database_id_PubMed.text().toString(); - if (xml..pdbx_database_id_DOI.length()) { - item.DOI = xml..pdbx_database_id_DOI.text().toString(); - } - item.date = xml2..date_original.text().toString(); - item.url = 'http://www.pdb.org/pdb/explore/explore.do?structureId=' + xml2..replaces.text().toString(); - - var authors = xml3..citation_author.toString().split(/\n/); - for (var i in authors) { - var name = authors[i].match(/name=\"([^"]+)\"/)[1].split(", ");; - Zotero.debug(name); - item.creators.push({firstName:name[1], lastName:name[0], creatorType:"author"}); - } - item.attachments = [ - {url:item.url, title:"PDB Snapshot", mimeType:"text/html"}, - {url:'http://www.pdb.org/pdb/download/downloadFile.do?fileFormat=pdb&compression=NO&structureId=' + proteins[p], title:"Protein Data Bank .pdb File", mimeType:"chemical/x-pdb"} - ] - item.complete(); - }); - Zotero.done(); - } - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/PubMed Central.js b/translators/PubMed Central.js @@ -1,188 +0,0 @@ -{ - "translatorID":"27ee5b2c-2a5a-4afc-a0aa-d386642d4eed", - "translatorType":4, - "label":"PubMed Central", - "creator":"Michael Berkowitz and Rintze Zelle", - "target":"https?://[^/]*.nih.gov/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-06-14 11:55:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - try {var pmid = url.match(/ncbi\.nlm\.nih\.gov\/pmc\/articles\/PMC([\d]+)/)[1];} catch (e) {} - if (pmid) { - return "journalArticle"; - } - - var uids = doc.evaluate('//div[@class="toc-pmcid"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - if(uids.iterateNext()) { - if (uids.iterateNext()){ - return "multiple"; - } - return "journalArticle"; - } -} - -function lookupPMCIDs(ids, doc) { - Zotero.wait(); - var newUri = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&retmode=xml&id=" + ids.join(","); - Zotero.debug(newUri); - Zotero.Utilities.HTTP.doGet(newUri, function (text) { - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); // Remove xml parse instruction and doctype - text = text.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) { - return str.replace(/-/gm, ""); - }); //Strip hyphens from element names, attribute names and attribute values - text = text.replace(/(<[^!>][^>]*>)/g, function replacer(str, p1, p2, offset, s) { - return str.replace(/:/gm, ""); - }); //Strip colons from element names, attribute names and attribute values - text = Zotero.Utilities.trim(text); - XML.prettyPrinting = false; - XML.ignoreWhitespace = false; - var xml = new XML(text); - - for (var i = 0; i < xml.article.length(); i++) { - var newItem = new Zotero.Item("journalArticle"); - - var journal = xml.article[i].front.journalmeta; - - if (journal.journalid.(@journalidtype == "nlmta").length()) { - newItem.journalAbbreviation = Zotero.Utilities.superCleanString(journal.journalid.(@journalidtype == "nlmta").text().toString()); - } - newItem.publicationTitle = Zotero.Utilities.superCleanString(journal.journaltitle.text().toString()); - - var issn = journal.issn.(@pubtype == "epub").text().toString(); - var issn = journal.issn.(@pubtype == "ppub").text().toString(); - if (issn) { - newItem.ISSN = issn; - } - - var article = xml.article[i].front.articlemeta; - - if (article.abstract.p.length()) { - newItem.abstractNote = Zotero.Utilities.unescapeHTML(article.abstract.p.toXMLString()); - } - - if (article.articleid.(@pubidtype == "doi").length()) { - newItem.DOI = article.articleid.(@pubidtype == "doi").text().toString(); - } - var PMID = article.articleid.(@pubidtype == "pmid").text().toString(); - if (PMID) { - newItem.extra = "PMID: " + PMID + "\n"; - } - newItem.extra = newItem.extra + "PMCID: " + ids[i]; - newItem.title = Zotero.Utilities.unescapeHTML(article.titlegroup.articletitle.toXMLString().split("<xref")[0]); - if (article.volume.length()) { - newItem.volume = article.volume.text().toString(); - } - if (article.issue.length()) { - newItem.issue = article.issue.text().toString(); - } - if (article.lpage.length()) { - newItem.pages = article.fpage.text().toString() + "-" + article.lpage.text().toString(); - } else if (article.fpage.length()) { - newItem.pages = article.fpage.text().toString() - } - - var pubdate = article.pubdate. (@pubtype == "ppub"); - if (!pubdate) { - var pubdate = article.pubdate. (@pubtype == "epub"); - } - if (pubdate) { - if (pubdate.day.text().toString() != "") { - newItem.date = pubdate.year.text().toString() + "-" + pubdate.month.text().toString() + "-" + pubdate.day.text().toString(); - } else if (pubdate.month.text().toString() != "") { - newItem.date = pubdate.year.text().toString() + "-" + pubdate.month.text().toString(); - } else if (pubdate.year.text().toString() != "") { - newItem.date = pubdate.year.text().toString(); - } - } - - if (article.contribgroup.contrib.length()) { - var authors = article.contribgroup.contrib. (@contribtype == "author"); - for (var j = 0; j < authors.length(); j++) { - var lastName = authors[j].name.surname.text().toString(); - var firstName = authors[j].name.givennames.text().toString(); - if (firstName || lastName) { - newItem.creators.push({ - lastName: lastName, - firstName: firstName - }); - } - } - } - - var linkurl = "http://www.ncbi.nlm.nih.gov/pmc/articles/PMC" + ids[i] + "/"; - newItem.attachments = [{ - url: linkurl, - title: "PubMed Central Link", - mimeType: "text/html", - snapshot: false - }]; - - if (article.selfuri.@xlinkhref.length()) { - var pdfFileName = article.selfuri.@xlinkhref.toXMLString(); - var pdfurl = "http://www.ncbi.nlm.nih.gov/pmc/articles/PMC" + ids[i] + "/pdf/" + pdfFileName; - newItem.attachments.push({ - title:"PubMed Central Full Text PDF", - mimeType:"application/pdf", - url:pdfurl - }); - } - - newItem.complete(); - } - - Zotero.done(); - }); -} - - - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? - function (prefix) { - if (prefix == 'x') return namespace; - else return null; - } : null; - - var ids = new Array(); - var pmcid; - var resultsCount = 0; - try { - pmcid = url.match(/ncbi\.nlm\.nih\.gov\/pmc\/articles\/PMC([\d]+)/)[1]; - } catch(e) {} - if (pmcid) { - ids.push(pmcid); - lookupPMCIDs(ids, doc); - } else { - var pmcids = doc.evaluate('//div[@class="toc-pmcid"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('//div[@class="toc-title"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - while (pmcid = pmcids.iterateNext()) { - title = titles.iterateNext(); - ids[pmcid.textContent.match(/PMC([\d]+)/)[1]] = title.textContent; - resultsCount = resultsCount + 1; - } - if (resultsCount > 1) { - ids = Zotero.selectItems(ids); - } - if (!ids) { - return true; - } - - var pmcids = new Array(); - for (var i in ids) { - pmcids.push(i); - } - lookupPMCIDs(pmcids, doc); - } -} -\ No newline at end of file diff --git a/translators/Pubget.js b/translators/Pubget.js @@ -1,62 +0,0 @@ -{ - "translatorID":"f520b141-9ce8-42f4-93ec-a39e375a9516", - "translatorType":4, - "label":"Pubget", - "creator":"Matt Burton", - "target":"https?://pubget\\.com/(search|journal|site/search)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-03-05 11:01:00" -} - - -function detectWeb (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var results = doc.evaluate("//div[@id = 'resultlist']", doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (results){ - if (doc.evaluate("//ul[@id='resultul']//li", doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } - - } -} - -function doWeb( doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var items = {}; - var titles = doc.evaluate("//a[@class='title']", doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmnt; - while(elmnt = titles.iterateNext()){ - items[elmnt.href] = elmnt.textContent; - } - - items = Zotero.selectItems(items); - var urls = []; - for (item in items) { - item = "http://pubget.com/site/send_medline/"+item.match(/paper\/(pgtmp_[a-z0-9]+|[0-9]+)/)[1]; - urls.push(item); - - - } - Zotero.Utilities.doGet(urls, function(text){ - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item){ - // do anything needing done to the item - item.complete(); - }); - translator.translate(); - }, function(){Zotero.done();}); - -} -\ No newline at end of file diff --git a/translators/RDF.js b/translators/RDF.js @@ -1,642 +0,0 @@ -{ - "translatorID":"5e3ad958-ac79-463d-812b-a86a9235c28f", - "translatorType":1, - "label":"RDF", - "creator":"Simon Kornblith", - "target":"rdf", - "minVersion":"2.1.9", - "maxVersion":"", - "priority":100, - "browserSupport":"gcsn", - "configOptions":{"dataMode":"rdf/xml"}, - "inRepository":true, - "lastUpdated":"2011-08-22 23:56:28" -} - -function detectImport() { - // Make sure there are actually nodes - - var nodes = Zotero.RDF.getAllResources(); - if(nodes) { - return true; - } -} - -var rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - -var n = { - bib:"http://purl.org/net/biblio#", - dc:"http://purl.org/dc/elements/1.1/", - dcterms:"http://purl.org/dc/terms/", - prism:"http://prismstandard.org/namespaces/1.2/basic/", - foaf:"http://xmlns.com/foaf/0.1/", - vcard:"http://nwalsh.com/rdf/vCard#", - vcard2:"http://www.w3.org/2006/vcard/ns#", // currently used only for NSF, but is probably - // very similar to the nwalsh vcard ontology in a - // different namespace - link:"http://purl.org/rss/1.0/modules/link/", - z:"http://www.zotero.org/namespaces/export#" -}; - -var callNumberTypes = [n.dcterms+"LCC", n.dcterms+"DDC", n.dcterms+"UDC"]; - -// gets the first result set for a property that can be encoded in multiple -// ontologies -function getFirstResults(node, properties, onlyOneString) { - for(var i=0; i<properties.length; i++) { - var result = Zotero.RDF.getTargets(node, properties[i]); - if(result) { - if(onlyOneString) { - // onlyOneString means we won't return nsIRDFResources, only - // actual literals - if(typeof(result[0]) != "object") { - return result[0]; - } - } else { - return result; - } - } - } - return; // return undefined on failure -} - -// adds creators to an item given a list of creator nodes -function handleCreators(newItem, creators, creatorType) { - if(!creators) { - return; - } - - if(typeof(creators[0]) != "string") { // see if creators are in a container - try { - var creators = Zotero.RDF.getContainerElements(creators[0]); - } catch(e) {} - } - - if(typeof(creators[0]) == "string") { // support creators encoded as strings - for(var i in creators) { - if(typeof(creators[i]) != "object") { - newItem.creators.push(Zotero.Utilities.cleanAuthor(creators[i], creatorType, true)); - } - } - } else { // also support foaf - for(var i in creators) { - var type = Zotero.RDF.getTargets(creators[i], rdf+"type"); - if(type) { - type = Zotero.RDF.getResourceURI(type[0]); - if(type == n.foaf+"Person") { // author is FOAF type person - var creator = new Array(); - creator.lastName = getFirstResults(creators[i], - [n.foaf+"surname", n.foaf+"family_name"], true); - creator.firstName = getFirstResults(creators[i], - [n.foaf+"givenname", n.foaf+"firstName"], true); - creator.creatorType = creatorType; - newItem.creators.push(creator); - } - } - } - } -} - -// processes collections recursively -function processCollection(node, collection) { - if(!collection) { - collection = new Array(); - } - collection.type = "collection"; - collection.name = getFirstResults(node, [n.dc+"title"], true); - collection.children = new Array(); - - // check for children - var children = getFirstResults(node, [n.dcterms+"hasPart"]); - for each(var child in children) { - var type = Zotero.RDF.getTargets(child, rdf+"type"); - if(type) { - type = Zotero.RDF.getResourceURI(type[0]); - } - - if(type == n.bib+"Collection" || type == n.z+"Collection") { - // for collections, process recursively - collection.children.push(processCollection(child)); - } else { - if(isPart(child)) { - Zotero.debug("Not adding child item <" + Zotero.RDF.getResourceURI(child) + "> to collection", 2); - continue; - } - - // all other items are added by ID - collection.children.push({id:Zotero.RDF.getResourceURI(child), type:"item"}); - } - } - return collection; -} - -function processSeeAlso(node, newItem) { - var relations; - newItem.itemID = Zotero.RDF.getResourceURI(node); - newItem.seeAlso = new Array(); - if(relations = getFirstResults(node, [n.dc+"relation"])) { - for each(var relation in relations) { - newItem.seeAlso.push(Zotero.RDF.getResourceURI(relation)); - } - } -} - -function processTags(node, newItem) { - var subjects; - newItem.tags = new Array(); - if(subjects = getFirstResults(node, [n.dc+"subject"])) { - for each(var subject in subjects) { - if(typeof(subject) == "string") { // a regular tag - newItem.tags.push(subject); - } else { - // a call number - var type = Zotero.RDF.getTargets(subject, rdf+"type"); - if(type) { - type = Zotero.RDF.getResourceURI(type[0]); - if(type == n.z+"AutomaticTag") { - newItem.tags.push({tag:getFirstResults(subject, [rdf+"value"], true), type:1}); - } - } - } - } - } -} - -// gets the node with a given type from an array -function getNodeByType(nodes, type) { - if(!nodes) { - return false; - } - - for each(var node in nodes) { - var nodeType = Zotero.RDF.getTargets(node, rdf+"type"); - if(nodeType) { - nodeType = Zotero.RDF.getResourceURI(nodeType[0]); - if(nodeType == type) { // we have a node of the correct type - return node; - } - } - } - return false; -} - -// returns true if this resource is part of another (related by any arc besides -// dc:relation or dcterms:hasPart) -// -// used to differentiate independent notes and files -function isPart(node) { - var arcs = Zotero.RDF.getArcsIn(node); - var skip = false; - for each(var arc in arcs) { - arc = Zotero.RDF.getResourceURI(arc); - if(arc != n.dc+"relation" && arc != n.dcterms+"hasPart") { - // related to another item by some arc besides see also - skip = true; - } - } - return skip; -} - -function importItem(newItem, node, type) { - var container = undefined; - - // also deal with type detection based on parts, so we can differentiate - // magazine and journal articles, and find container elements - var isPartOf = getFirstResults(node, [n.dcterms+"isPartOf"]); - - // get parts of parts, because parts are sections of wholes. - if(isPartOf) { - for(var i=0; i<isPartOf.length; i++) { - var subParts = getFirstResults(isPartOf[i], [n.dcterms+"isPartOf"]); - if(subParts) { - isPartOf = isPartOf.concat(subParts); - } - } - } - - if(type) { - if(type == n.bib+"Book") { - newItem.itemType = "book"; - } else if(type == n.bib+"BookSection") { - newItem.itemType = "bookSection"; - container = getNodeByType(isPartOf, n.bib+"Book"); - } else if(type == n.bib+"Article") { // choose between journal, - // newspaper, and magazine - // articles - // use of container = (not container ==) is intentional - if(container = getNodeByType(isPartOf, n.bib+"Journal")) { - newItem.itemType = "journalArticle"; - } else if(container = getNodeByType(isPartOf, n.bib+"Periodical")) { - newItem.itemType = "magazineArticle"; - } else if(container = getNodeByType(isPartOf, n.bib+"Newspaper")) { - newItem.itemType = "newspaperArticle"; - } - } else if(type == n.bib+"Thesis") { - newItem.itemType = "thesis"; - } else if(type == n.bib+"Letter") { - newItem.itemType = "letter"; - } else if(type == n.bib+"Manuscript") { - newItem.itemType = "manuscript"; - } else if(type == n.bib+"Interview") { - newItem.itemType = "interview"; - } else if(type == n.bib+"MotionPicture") { - newItem.itemType = "film"; - } else if(type == n.bib+"Illustration") { - newItem.itemType = "artwork"; - } else if(type == n.bib+"Document") { - if(container = getNodeByType(isPartOf, n.bib+"CourtReporter")) { - newItem.itemType = "case"; - } else { - newItem.itemType = "webpage"; - } - } else if(type == n.bib+"Memo") { - newItem.itemType = "note"; - } else if(type == n.z+"Attachment") { - // unless processing of independent attachment is intended, don't - // process - - // process as file - newItem.itemType = "attachment"; - - var path = getFirstResults(node, [rdf+"resource"]); - if(path) { - newItem.path = Zotero.RDF.getResourceURI(path[0]); - } - newItem.charset = getFirstResults(node, [n.link+"charset"], true); - newItem.mimeType = getFirstResults(node, [n.link+"type"], true); - } else if(type == n.bib+"Report") { - newItem.itemType = "report"; - } else if(type == n.bib+"Legislation") { - newItem.itemType = "statute"; - } else if(type == n.bib+"Patent") { - newItem.itemType = "patent"; - } else if(type == n.bib+"Image") { - newItem.itemType = "artwork"; - } else if(type == n.bib+"Recording") { - newItem.itemType = "audioRecording"; - } - } - - // check to see if we recognize the type in the fs or dc namespaces - var zoteroType = getFirstResults(node, [n.z+"itemType", n.z+"type", n.dc+"type"], true); - if(zoteroType && Zotero.Utilities.itemTypeExists(zoteroType)) { - newItem.itemType = zoteroType; - } - - if(newItem.itemType == "blogPost") { - container = getNodeByType(isPartOf, n.z+"Blog"); - } else if(newItem.itemType == "forumPost") { - container = getNodeByType(isPartOf, n.z+"Forum"); - } else if(newItem.itemType == "webpage") { - container = getNodeByType(isPartOf, n.z+"Website"); - } - - // title - newItem.title = getFirstResults(node, [n.dc+"title", n.vcard2+"fn"], true); - if(!newItem.itemType && !newItem.title) { // require the title - // (if not a known type) - return false; - } - - if(!newItem.itemType) { - newItem.itemType = exports.defaultUnknownType; - } - - // regular author-type creators - var possibleCreatorTypes = Zotero.Utilities.getCreatorsForType(newItem.itemType); - for each(var creatorType in possibleCreatorTypes) { - if(creatorType == "author") { - var creators = getFirstResults(node, [n.bib+"authors", n.dc+"creator"]); - } else if(creatorType == "editor" || creatorType == "contributor") { - var creators = getFirstResults(node, [n.bib+creatorType+"s"]); - } else { - var creators = getFirstResults(node, [n.z+creatorType+"s"]); - } - - if(creators) handleCreators(newItem, creators, creatorType); - } - - // source - newItem.source = getFirstResults(node, [n.dc+"source"], true); - - // rights - newItem.rights = getFirstResults(node, [n.dc+"rights"], true); - - // section - var section = getNodeByType(isPartOf, n.bib+"Part"); - if(section) { - newItem.section = getFirstResults(section, [n.dc+"title"], true); - } - - // publication - if(container) { - newItem.publicationTitle = getFirstResults(container, [n.dc+"title"], true); - // these fields mean the same thing - newItem.reporter = newItem.publicationTitle; - } - - // series - var series = getNodeByType(isPartOf, n.bib+"Series"); - if(series) { - newItem.series = getFirstResults(series, [n.dc+"title"], true); - newItem.seriesTitle = getFirstResults(series, [n.dcterms+"alternative"], true); - newItem.seriesText = getFirstResults(series, [n.dc+"description"], true); - newItem.seriesNumber = getFirstResults(series, [n.dc+"identifier"], true); - } - - // volume - newItem.volume = getFirstResults((container ? container : node), [n.prism+"volume"], true); - - // issue - newItem.issue = getFirstResults((container ? container : node), [n.prism+"number"], true); - // these mean the same thing - newItem.patentNumber = newItem.number = newItem.issue; - - // edition - newItem.edition = getFirstResults(node, [n.prism+"edition"], true); - // these fields mean the same thing - newItem.version = newItem.edition; - - // pages - newItem.pages = getFirstResults(node, [n.bib+"pages"], true); - - // mediums - newItem.artworkMedium = newItem.interviewMedium = getFirstResults(node, [n.dcterms+"medium"], true); - - // publisher - var publisher = getFirstResults(node, [n.dc+"publisher", n.vcard2+"org"]); - if(publisher) { - if(typeof(publisher[0]) == "string") { - newItem.publisher = publisher[0]; - } else { - var type = Zotero.RDF.getTargets(publisher[0], rdf+"type"); - if(type) { - type = Zotero.RDF.getResourceURI(type[0]); - if(type == n.foaf+"Organization") { // handle foaf organizational publishers - newItem.publisher = getFirstResults(publisher[0], [n.foaf+"name"], true); - var place = getFirstResults(publisher[0], [n.vcard+"adr"]); - if(place) { - newItem.place = getFirstResults(place[0], [n.vcard+"locality"]); - } - } else if(type == n.vcard2+"Organization") { - newItem.publisher = getFirstResults(publisher[0], [n.vcard2+"organization-name"], true); - } - } - } - } - - // these fields mean the same thing - newItem.distributor = newItem.label = newItem.company = newItem.institution = newItem.publisher; - - // date - newItem.date = getFirstResults(node, [n.dc+"date", n.dcterms+"dateSubmitted"], true); - if (!newItem.date) { - newItem.date = getFirstResults(node, [n.dc+"date.issued"], true); - if (!newItem.date) { - newItem.date = getFirstResults(node, [n.dcterms+"issued"], true); - } - } - // accessDate - newItem.accessDate = getFirstResults(node, [n.dcterms+"dateSubmitted"], true); - // lastModified - newItem.lastModified = getFirstResults(node, [n.dcterms+"modified"], true); - - // identifier - var identifiers = getFirstResults(node, [n.dc+"identifier"]); - if(container) { - var containerIdentifiers = getFirstResults(container, [n.dc+"identifier"]); - // concatenate sets of identifiers - if(containerIdentifiers) { - if(identifiers) { - identifiers = identifiers.concat(containerIdentifiers); - } else { - identifiers = containerIdentifiers; - } - } - } - - if(identifiers) { - for(var i in identifiers) { - if(typeof(identifiers[i]) == "string") { - // grab other things - var beforeSpace = identifiers[i].substr(0, identifiers[i].indexOf(" ")).toUpperCase(); - - if(beforeSpace == "ISBN") { - newItem.ISBN = identifiers[i].substr(5).toUpperCase(); - } else if(beforeSpace == "ISSN") { - newItem.ISSN = identifiers[i].substr(5).toUpperCase(); - } else if(beforeSpace == "DOI") { - newItem.DOI = identifiers[i].substr(4); - } else if(!newItem.accessionNumber) { - newItem.accessionNumber = identifiers[i]; - } - } else { - // grab URLs - var type = Zotero.RDF.getTargets(identifiers[i], rdf+"type"); - if(type && (type = Zotero.RDF.getResourceURI(type[0])) && type == n.dcterms+"URI") { - newItem.url = getFirstResults(identifiers[i], [rdf+"value"], true); - } - } - } - } - - if(!newItem.url) { - var url = getFirstResults(node, [n.vcard2+"url"]); - if(url) { - newItem.url = Zotero.RDF.getResourceURI(url[0]); - } - } - - // archiveLocation - newItem.archiveLocation = getFirstResults(node, [n.dc+"coverage"], true); - - // abstract - newItem.abstractNote = getFirstResults(node, [n.dcterms+"abstract"], true); - if (!newItem.abstractNote) { - newItem.abstractNote = getFirstResults(node, [n.dc+"description.abstract"], true); - } - - // type - var type = getFirstResults(node, [n.dc+"type"], true); - // these all mean the same thing - var typeProperties = ["reportType", "videoRecordingType", "letterType", - "manuscriptType", "mapType", "thesisType", "websiteType", - "audioRecordingType", "presentationType", "postType", - "audioFileType"]; - for each(var property in typeProperties) { - newItem[property] = type; - } - - // conferenceName - var conference = getFirstResults(node, [n.bib+"presentedAt"]); - if(conference) { - conference = conference[0]; - if(typeof(conference) == "string") { - newItem.conferenceName = conference; - } else { - newItem.conferenceName = getFirstResults(conference, [n.dc+"title"], true); - } - } - - // journalAbbreviation - newItem.journalAbbreviation = getFirstResults((container ? container : node), [n.dcterms+"alternative"], true); - - // address - var adr = getFirstResults(node, [n.vcard2+"adr"]); - if(adr) { - newItem.address = getFirstResults(adr[0], [n.vcard2+"label"], true); - } - - // telephone - newItem.telephone = getFirstResults(node, [n.vcard2+"tel"], true); - - // email - newItem.email = getFirstResults(node, [n.vcard2+"email"], true); - - // accepted - newItem.accepted = getFirstResults(node, [n.dcterms+"dateAccepted"], true); - - // see also - processSeeAlso(node, newItem); - - // description/attachment note - if(newItem.itemType == "attachment") { - newItem.note = getFirstResults(node, [n.dc+"description"], true); - } else { - newItem.extra = getFirstResults(node, [n.dc+"description"], true); - } - - /** NOTES **/ - - var referencedBy = Zotero.RDF.getTargets(node, n.dcterms+"isReferencedBy"); - for each(var referentNode in referencedBy) { - var type = Zotero.RDF.getTargets(referentNode, rdf+"type"); - if(type && Zotero.RDF.getResourceURI(type[0]) == n.bib+"Memo") { - // if this is a memo - var note = new Array(); - note.note = getFirstResults(referentNode, [rdf+"value", n.dc+"description"], true); - if(note.note != undefined) { - // handle see also - processSeeAlso(referentNode, note); - processTags(referentNode, note); - - // add note - newItem.notes.push(note); - } - } - } - - if(newItem.itemType == "note") { - // add note for standalone - var note = getFirstResults(node, [rdf+"value", n.dc+"description"], true); - newItem.note = note ? note : ""; - } - - /** TAGS **/ - - var subjects = getFirstResults(node, [n.dc+"subject"]); - for each(var subject in subjects) { - if(typeof(subject) == "string") { // a regular tag - newItem.tags.push(subject); - } else { // a call number or automatic tag - var type = Zotero.RDF.getTargets(subject, rdf+"type"); - if(type) { - type = Zotero.RDF.getResourceURI(type[0]); - if(callNumberTypes.indexOf(type) !== -1) { - newItem.callNumber = getFirstResults(subject, [rdf+"value"], true); - } else if(type == n.z+"AutomaticTag") { - newItem.tags.push({tag:getFirstResults(subject, [rdf+"value"], true), type:1}); - } - } - } - } - - /** ATTACHMENTS **/ - var relations = getFirstResults(node, [n.link+"link"]); - for each(var relation in relations) { - var type = Zotero.RDF.getTargets(relation, rdf+"type"); - if(Zotero.RDF.getResourceURI(type[0]) == n.z+"Attachment") { - var attachment = new Zotero.Item(); - newItem.attachments.push(attachment); - importItem(attachment, relation, n.z+"Attachment"); - } - } - - /** OTHER FIELDS **/ - var arcs = Zotero.RDF.getArcsOut(node); - for each(var arc in arcs) { - var uri = Zotero.RDF.getResourceURI(arc); - if(uri.substr(0, n.z.length) == n.z) { - var property = uri.substr(n.z.length); - newItem[property] = Zotero.RDF.getTargets(node, n.z+property)[0]; - } - } - - return true; -} - -function doImport() { - Zotero.setProgress(null); - var nodes = Zotero.RDF.getAllResources(); - if(!nodes) { - return false; - } - - // keep track of collections while we're looping through - var collections = new Array(); - - var i = 0; - for each(var node in nodes) { - var newItem = new Zotero.Item(); - newItem.itemID = Zotero.RDF.getResourceURI(node); - - // figure out if this is a part of another resource, or a linked - // attachment - if(Zotero.RDF.getSources(node, n.dcterms+"isPartOf") || - Zotero.RDF.getSources(node, n.bib+"presentedAt") || - Zotero.RDF.getSources(node, n.link+"link")) { - continue; - } - - // type - var type = Zotero.RDF.getTargets(node, rdf+"type"); - if(type) { - type = Zotero.RDF.getResourceURI(type[0]); - - // skip if this is not an independent attachment, - if((type == n.z+"Attachment" || type == n.bib+"Memo") && isPart(node)) { - continue; - } else if(type == n.bib+"Collection" || type == n.z+"Collection") { - // skip collections until all the items are done - collections.push(node); - continue; - } - } else { - type = false; - } - - if(importItem(newItem, node, type)) { - newItem.complete(); - } - - Zotero.setProgress(i++/nodes.length*100); - } - - /* COLLECTIONS */ - - for each(var collection in collections) { - if(!Zotero.RDF.getArcsIn(collection)) { - var newCollection = new Zotero.Collection(); - processCollection(collection, newCollection); - newCollection.complete(); - } - } -} - -/** - * Export doImport and defaultUnknownType to other translators - */ -var exports = { - "doImport":doImport, - "defaultUnknownType":"book" -}; -\ No newline at end of file diff --git a/translators/RIS.js b/translators/RIS.js @@ -1,632 +0,0 @@ -{ - "translatorID":"32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7", - "translatorType":3, - "label":"RIS", - "creator":"Simon Kornblith", - "target":"ris", - "minVersion":"2.1.3", - "maxVersion":"", - "priority":100, - "browserSupport":"gcsn", - "inRepository":true, - "displayOptions":{"exportCharset":"UTF-8", "exportNotes":true}, - "lastUpdated":"2011-07-08 04:51:41" -} - -function detectImport() { - var line; - var i = 0; - while((line = Zotero.read()) !== false) { - line = line.replace(/^\s+/, ""); - if(line != "") { - if(line.substr(0, 6).match(/^TY {1,2}- /)) { - return true; - } else { - if(i++ > 3) { - return false; - } - } - } - } -} - -var fieldMap = { - ID:"itemID", - T1:"title", - T3:"series", - JF:"publicationTitle", - CY:"place", - JA:"journalAbbreviation", - M3:"DOI" -}; - -var bookSectionFieldMap = { - ID:"itemID", - T1:"title", - T3:"series", - T2:"bookTitle", - CY:"place", - JA:"journalAbbreviation", - M3:"DOI" -}; - -// Accounting for input fields that we don't export the same way; -// mainly for common abuses of the spec -var inputFieldMap = { - TI:"title", - CT:"title", - CY:"place", - ST:"shortTitle", - DO:"DOI" -}; - -// TODO: figure out if these are the best types for letter, interview, webpage -var typeMap = { - book:"BOOK", - bookSection:"CHAP", - journalArticle:"JOUR", - magazineArticle:"MGZN", - newspaperArticle:"NEWS", - thesis:"THES", - letter:"PCOMM", - manuscript:"PAMP", - interview:"PCOMM", - film:"MPCT", - artwork:"ART", - report:"RPRT", - bill:"BILL", - "case":"CASE", - hearing:"HEAR", - patent:"PAT", - statute:"STAT", - map:"MAP", - blogPost:"ELEC", - webpage:"ELEC", - instantMessage:"ICOMM", - forumPost:"ICOMM", - email:"ICOMM", - audioRecording:"SOUND", - presentation:"GEN", - videoRecording:"VIDEO", - tvBroadcast:"GEN", - radioBroadcast:"GEN", - podcast:"GEN", - computerProgram:"COMP", - conferencePaper:"CONF", - document:"GEN" -}; - -// supplements outputTypeMap for importing -// TODO: DATA, MUSIC -var inputTypeMap = { - ABST:"journalArticle", - ADVS:"film", - CTLG:"magazineArticle", - INPR:"manuscript", - JFULL:"journalArticle", - PAMP:"manuscript", - SER:"book", - SLIDE:"artwork", - UNBILL:"manuscript", - CPAPER:"conferencePaper", - WEB:"webpage", - EDBOOK:"book", - MANSCPT:"manuscript", - GOVDOC:"document" -}; - -function processTag(item, tag, value) { - if (tag != "N1" && tag != "AB" && Zotero.Utilities.unescapeHTML) { - value = Zotero.Utilities.unescapeHTML(value); - } - - if(fieldMap[tag]) { - item[fieldMap[tag]] = value; - } else if(inputFieldMap[tag]) { - item[inputFieldMap[tag]] = value; - } else if(tag == "TY") { - // look for type - - // trim the whitespace that some providers (e.g. ProQuest) include - value = Zotero.Utilities.trim(value); - - // first check typeMap - for(var i in typeMap) { - if(value.toUpperCase() == typeMap[i]) { - item.itemType = i; - } - } - // then check inputTypeMap - if(!item.itemType) { - if(inputTypeMap[value]) { - item.itemType = inputTypeMap[value]; - } else { - // default to document - item.itemType = "document"; - } - } - } else if(tag == "JO") { - if (item.itemType == "conferencePaper"){ - item.conferenceName = value; - } else { - item.publicationTitle = value; - } - } else if(tag == "BT") { - // ignore, unless this is a book or unpublished work, as per spec - if(item.itemType == "book" || item.itemType == "manuscript") { - item.title = value; - } else { - item.backupPublicationTitle = value; - } - } else if(tag == "T2") { - item.backupPublicationTitle = value; - } else if(tag == "A1" || tag == "AU") { - // primary author (patent: inventor) - // store Zotero "creator type" in temporary variable - var tempType; - if (item.itemType == "patent") { - tempType = "inventor"; - } else { - tempType = "author"; - } - var names = value.split(/, ?/); - item.creators.push({lastName:names[0], firstName:names[1], creatorType:tempType}); - } else if(tag == "ED") { - var names = value.split(/, ?/); - item.creators.push({lastName:names[0], firstName:names[1], creatorType:"editor"}); - } else if(tag == "A2") { - // contributing author (patent: assignee) - if (item.itemType == "patent") { - if (item.assignee) { - // Patents can have multiple assignees (applicants) but Zotero only allows a single - // assignee field, so we have to concatenate them together - item.assignee += ", "+value; - } else { - item.assignee = value; - } - } else { - var names = value.split(/, ?/); - item.creators.push({lastName:names[0], firstName:names[1], creatorType:"contributor"}); - } - } else if(tag == "Y1" || tag == "PY") { - // year or date - var dateParts = value.split("/"); - - if(dateParts.length == 1) { - // technically, if there's only one date part, the file isn't valid - // RIS, but EndNote writes this, so we have to too - // Nick: RIS spec example records also only contain a single part - // even though it says the slashes are not optional (?) - item.date = value; - } else { - // in the case that we have a year and other data, format that way - - var month = parseInt(dateParts[1]); - if(month) { - month--; - } else { - month = undefined; - } - - item.date = Zotero.Utilities.formatDate({year:dateParts[0], - month:month, - day:dateParts[2], - part:dateParts[3]}); - } - } else if(tag == "Y2") { - // the secondary date field can mean two things, a secondary date, or an - // invalid EndNote-style date. let's see which one this is. - // patent: application (filing) date -- do not append to date field - var dateParts = value.split("/"); - if(dateParts.length != 4 && item.itemType != "patent") { - // an invalid date and not a patent. - // It's from EndNote or Delphion (YYYY-MM-DD) - if(item.date && value.indexOf(item.date) == -1) { - // append existing year - value += " " + item.date; - } - item.date = value; - } else if (item.itemType == "patent") { - // Date-handling code copied from above - if(dateParts.length == 1) { - // technically, if there's only one date part, the file isn't valid - // RIS, but EndNote writes this, so we have to too - // Nick: RIS spec example records also only contain a single part - // even though it says the slashes are not optional (?) - item.filingDate = value; - } else { - // in the case that we have a year and other data, format that way - - var month = parseInt(dateParts[1]); - if(month) { - month--; - } else { - month = undefined; - } - - item.filingDate = Zotero.Utilities.formatDate({year:dateParts[0], - month:month, - day:dateParts[2], - part:dateParts[3]}); - } - } - // ToDo: Handle correctly formatted Y2 fields (secondary date) - } else if(tag == "N1") { - // notes - if(value != item.title) { // why does EndNote do this!? - var clean = Zotero.Utilities.cleanTags(value); - if (clean == value) { - // \n\n => <p>, \n => <br/> - //str = Zotero.Utilities.htmlSpecialChars(str); - value = '<p>' - + value.replace(/\n\n/g, '</p><p>') - .replace(/\n/g, '<br/>') - .replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;') - .replace(/ /g, '&nbsp;&nbsp;') - + '</p>'; - item.notes.push({note:value}); - } else item.notes.push({note:value}); - } - // The RIS spec insanely claims that AB == N1, but other software seems - // to overlook or ignore this, so we will too on import - } else if(tag == "N2" || tag == "AB") { - // abstract - if (item.abstractNote) item.abstractNote += "\n" + value; - else item.abstractNote = value; - } else if(tag == "KW") { - // keywords/tags - - // technically, treating newlines as new tags breaks the RIS spec, but - // it's required to work with EndNote - item.tags = item.tags.concat(value.split("\n")); - } else if(tag == "SP") { - // start page - if(!item.pages) { - item.pages = value; - // EndNote uses SP without EP for number of pages - // Save as numPages only if there were no previous pages tags - if (item.itemType == "book") item.numPages = value; - } else if(item.pages[0] == "-") { // already have ending page - item.pages = value + item.pages; - } else { // multiple ranges? hey, it's a possibility - item.pages += ", "+value; - } - } else if(tag == "EP") { - // end page - if(value) { - if(!item.pages) { - item.pages = value; - } else if(value != item.pages) { - item.pages += "-"+value; - // EndNote uses SP without EP for number of pages - // Here, clear numPages if we have an EP != SP - if (item.itemType == "book") item.numPages = undefined; - } - } - } else if(tag == "SN") { - // ISSN/ISBN - just add both - // TODO We should be able to tell these apart - if(!item.ISBN) { - item.ISBN = value; - } - if(!item.ISSN) { - item.ISSN = value; - } - } else if(tag == "UR" || tag == "L1" || tag == "L2" || tag == "L4") { - // URL - if(!item.url) { - item.url = value; - } - if(tag == "UR") { - item.attachments.push({url:value}); - } else if(tag == "L1") { - item.attachments.push({url:value, mimeType:"application/pdf", - title:"Full Text (PDF)", downloadable:true}); - } else if(tag == "L2") { - item.attachments.push({url:value, mimeType:"text/html", - title:"Full Text (HTML)", downloadable:true}); - } else if(tag == "L4") { - item.attachments.push({url:value, - title:"Image", downloadable:true}); - } - } else if (tag == "IS") { - // Issue Number (patent: patentNumber) - if (item.itemType == "patent") { - item.patentNumber = value; - } else { - item.issue = value; - } - } else if (tag == "VL") { - // Volume Number (patent: applicationNumber) - if (item.itemType == "patent") { - item.applicationNumber = value; - // Report Number (report: reportNumber) - } else if(item.itemType == "report") { - item.reportNumber = value; - } else { - item.volume = value; - } - } else if (tag == "PB") { - // publisher (patent: references) - if (item.itemType == "patent") { - item.references = value; - } else { - item.publisher = value; - } - } else if (tag == "M1" || tag == "M2") { - // Miscellaneous fields - if (!item.extra) { - item.extra = value; - } else { - item.extra += "; "+value; - } - } -} - -function completeItem(item) { - // if backup publication title exists but not proper, use backup - // (hack to get newspaper titles from EndNote) - if(item.backupPublicationTitle) { - if(!item.publicationTitle) { - item.publicationTitle = item.backupPublicationTitle; - } - item.backupPublicationTitle = undefined; - } - // hack for sites like Nature, which only use JA, journal abbreviation - if(item.journalAbbreviation && !item.publicationTitle){ - item.publicationTitle = item.journalAbbreviation; - } - // Hack for Endnote exports missing full title - if(item.shortTitle && !item.title){ - item.title = item.shortTitle; - } - item.complete(); -} - -function doImport(attachments) { - var line = true; - var tag = data = false; - do { // first valid line is type - line = Zotero.read(); - line = line.replace(/^\s+/, ""); - } while(line !== false && !line.substr(0, 6).match(/^TY {1,2}- /)); - - var item = new Zotero.Item(); - var i = 0; - if(attachments && attachments[i]) { - item.attachments = attachments[i]; - } - - var tag = "TY"; - - // Handle out-of-spec old EndNote exports - if (line.substr(0, 5) == "TY - ") { - var data = line.substr(5); - } - else { - var data = line.substr(6); - } - - var rawLine; - while((rawLine = Zotero.read()) !== false) { // until EOF - // trim leading space if this line is not part of a note - line = rawLine.replace(/^\s+/, ""); - // Handle out-of-spec old EndNote exports with one space - var split = line.match(/^([A-Z0-9]{2}) {1,2}-(?: ([^\n]*))?/); - if(split) { - // if this line is a tag, take a look at the previous line to map - // its tag - if(tag) { - //Zotero.debug("tag: '"+tag+"'; data: '"+data+"'"); - processTag(item, tag, data); - } - - // then fetch the tag and data from this line - tag = split[1]; - data = split[2]; - - if(tag == "ER") { // ER signals end of reference - // unset info - tag = data = false; - completeItem(item); - } - if(tag == "TY") { - // new item - item = new Zotero.Item(); - i++; - if(attachments && attachments[i]) { - item.attachments = attachments[i]; - } - } - } else { - // otherwise, assume this is data from the previous line continued - if(tag == "N1" || tag == "N2" || tag == "AB" || tag == "KW") { - // preserve line endings for N1/N2/AB fields, for EndNote - // compatibility - data += "\n"+rawLine; - } else if(tag) { - // otherwise, follow the RIS spec - if(data[data.length-1] == " ") { - data += rawLine; - } else { - data += " "+rawLine; - } - } - } - } - - if(tag && tag != "ER") { // save any unprocessed tags - //Zotero.debug(tag); - processTag(item, tag, data); - completeItem(item); - } -} - -function addTag(tag, value) { - if(value) { - Zotero.write(tag+" - "+value+"\r\n"); - } -} - -function doExport() { - var item; - - while(item = Zotero.nextItem()) { - // can't store independent notes in RIS - if(item.itemType == "note" || item.itemType == "attachment") { - continue; - } - - // type - addTag("TY", typeMap[item.itemType] ? typeMap[item.itemType] : "GEN"); - - // use field map - if (item.itemType == "bookSection" || item.itemType == "conferencePaper") { - for(var j in bookSectionFieldMap) { - if(item[bookSectionFieldMap[j]]) addTag(j, item[bookSectionFieldMap[j]]); - } - } else { - for(var j in fieldMap) { - if(item[fieldMap[j]]) addTag(j, item[fieldMap[j]]); - } - } - - // creators - for(var j in item.creators) { - // only two types, primary and secondary - var risTag; - // authors and inventors are primary creators - if (item.creators[j].creatorType == "author" || item.creators[j].creatorType == "inventor") { - risTag = "A1"; - } else if (item.creators[j].creatorType == "editor") { - risTag = "ED"; - } else { - risTag = "A2"; - } - - var names = []; - if (item.creators[j].lastName) names.push(item.creators[j].lastName); - if (item.creators[j].firstName) names.push(item.creators[j].firstName); - - addTag(risTag, names.join(",")); - } - - // assignee (patent) - if(item.assignee) { - addTag("A2", item.assignee); - } - - // volume (patent: applicationNumber, report: reportNumber) - if(item.volume || item.applicationNumber || item.reportNumber) { - if (item.volume) { - var value = item.volume; - } else if(item.applicationNumber) { - var value = item.applicationNumber; - } else if(item.reportNumber) { - var value = item.reportNumber; - } - addTag("VL", value); - } - - // issue (patent: patentNumber) - if(item.issue || item.patentNumber) { - var value = (item.issue) ? item.issue : item.patentNumber; - addTag("IS", value); - } - - // publisher (patent: references) - if(item.publisher || item.references) { - var value = (item.publisher) ? item.publisher : item.references; - addTag("PB", value); - } - - - // date - if(item.date) { - var date = Zotero.Utilities.strToDate(item.date); - var string = date.year+"/"; - if(date.month != undefined) { - // deal with javascript months - date.month++; - if(date.month < 10) string += "0"; - string += date.month; - } - string += "/"; - if(date.day != undefined) { - if(date.day < 10) string += "0"; - string += date.day; - } - string += "/"; - if(date.part != undefined) { - string += date.part; - } - addTag("PY", string); - } - - // filingDate (patents) - if(item.filingDate) { - var date = Zotero.Utilities.strToDate(item.filingDate); - var string = date.year+"/"; - if(date.month != undefined) { - // deal with javascript months - date.month++; - if(date.month < 10) string += "0"; - string += date.month; - } - string += "/"; - if(date.day != undefined) { - if(date.day < 10) string += "0"; - string += date.day; - } - string += "/"; - if(date.part != undefined) { - string += date.part; - } - addTag("Y2", string); - } - - // notes - if(Zotero.getOption("exportNotes")) { - for(var j in item.notes) { - addTag("N1", item.notes[j].note.replace(/(?:\r\n?|\n)/g, "\r\n")); - } - } - - if(item.abstractNote) { - addTag("N2", item.abstractNote.replace(/(?:\r\n?|\n)/g, "\r\n")); - } - else if(item["abstract"]) { - // patent type has abstract - addTag("N2", item["abstract"].replace(/(?:\r\n?|\n)/g, "\r\n")); - } - - // tags - for each(var tag in item.tags) { - addTag("KW", tag.tag); - } - - // pages - if(item.pages) { - if(item.itemType == "book") { - addTag("EP", item.pages); - } else { - var range = Zotero.Utilities.getPageRange(item.pages); - addTag("SP", range[0]); - addTag("EP", range[1]); - } - } - - // ISBN/ISSN - addTag("SN", item.ISBN); - addTag("SN", item.ISSN); - - // URL - if(item.url) { - addTag("UR", item.url); - } else if(item.source && item.source.substr(0, 7) == "http://") { - addTag("UR", item.source); - } - - Zotero.write("ER - \r\n\r\n"); - } -} diff --git a/translators/RSC Publishing.js b/translators/RSC Publishing.js @@ -1,438 +0,0 @@ -{ - "translatorID":"1c34744d-690f-4cac-b31b-b7f0c90ac14d", - "translatorType":4, - "label":"RSC Publishing", - "creator":"Ramesh Srigiriraju", - "target":"http://(:?www\\.|google\\.)?rsc\\.org/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - var journalreg=new RegExp("http://(:?www\.)?rsc\.org/(:?P|p)ublishing/(:?J|j)ournals"); - if(journalreg.test(url)) { - var browspath='//div/p/a[text()="Use advanced search"]'; - if(doc.evaluate(browspath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "multiple"; - var searchpath='//a[text()="Back to Search Form"]'; - if(doc.evaluate(searchpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "multiple"; - var singpath='//ul/li/a[text()="HTML Article" or text()="PDF"]'; - if(doc.evaluate(singpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "journalArticle"; - } - var magpath='//div/h3[text()="Link to journal article"]'; - if(doc.evaluate(magpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "magazineArticle"; - var magbrows='//div/h4[@class="newstitle"]/a'; - if(doc.evaluate(magbrows, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "multiple"; - var magsearch='//p[@class="more"]/strong/a[text()="Search RSC journals"]'; - if(doc.evaluate(magsearch, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "multiple"; - var bookreg=new RegExp("http://(:?www\.)?rsc\.org/(:?P|p)ublishing/e(:?B|b)ooks"); - if(bookreg.test(url)) { - var pagepath='//title/text()'; - var page=doc.evaluate(pagepath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - if((page=="Books in a publication year")||(page=="Subject Area Books")||(page=="A - Z Index") - ||(page=="Book Series")) - return "multiple"; - var chappath='//dt/img[@alt="Chapter"]'; - var singpath='//h3[text()="Table of Contents"]'; - if(doc.evaluate(chappath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "bookSection"; - else if(doc.evaluate(singpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "book"; - } - var searchpath='//div/p[@class="title"][text()="Search Results"]'; - if(doc.evaluate(searchpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - return "multiple"; -} - -function doChap(newItem, chaptext) { - var chapdata=chaptext.split("<br>"); - for(var pos=chapdata.length-2; pos>=0; pos--) { - chapdata[pos]=Zotero.Utilities.cleanTags(chapdata[pos]); - if(chapdata[pos].indexOf("Editors")!=-1) { - var editors=chapdata[pos].split(","); - for(var i=0; i<=editors.length-1; i++) { - editors[i]=Zotero.Utilities.trimInternal(editors[i]); - var names=editors[i].split(" "); - var creators=new Array(); - if(i==0) - creators.firstName=names[1]; - else - creators.firstName=names[0]; - creators.lastName=names[names.length-1]; - creators.creatorType="editor"; - newItem.creators.push(creators); - } - } - if(chapdata[pos].indexOf("Authors")!=-1) { - var authors=chapdata[pos].split(","); - for(var i=0; i<=authors.length-1; i++) { - authors[i]=Zotero.Utilities.trimInternal(authors[i]); - var names=authors[i].split(" "); - var creators=new Array(); - if(i==0) - creators.firstName=names[1]; - else - creators.firstName=names[0]; - creators.lastName=names[names.length-1]; - creators.creatorType="editor"; - newItem.creators.push(creators); - } - } - if(chapdata[pos].indexOf("DOI")!=-1) - newItem.itemID=chapdata[pos].substring(chapdata[pos].indexOf("1")); - if(chapdata[pos].indexOf("Book")!=-1) - newItem.bookTitle=chapdata[pos].substring(chapdata[pos].indexOf(" ")+1); - } -} -function doBook(newItem, bookdata) { - var fields=bookdata.split("<br>"); - for(var pos=fields.length-2; pos>=0; pos--) { - fields[pos]=Zotero.Utilities.cleanTags(fields[pos]); - if(fields[pos].indexOf("Volume")!=-1) { - var i=fields[pos].lastIndexOf(";"); - var vol; - if(i!=-1) - vol=fields[pos].substring(i+1); - else - vol=fields[pos].substring(fields[pos].lastIndexOf(" ")); - newItem.volume=Zotero.Utilities.trimInternal(vol); - } - if(fields[pos].indexOf("Edition")!=-1) { - var i=fields[pos].lastIndexOf(";"); - if(i!=-1) - ed=fields[pos].substring(i+1); - else - ed=fields[pos].substring(fields[pos].lastIndexOf(" ")); - newItem.edition=Zotero.Utilities.trimInternal(ed); - } - if(fields[pos].indexOf("Copyright")!=-1) { - var i=fields[pos].lastIndexOf(";"); - var date; - if(i!=-1) - date=fields[pos].substring(i+1); - else - date=fields[pos].substring(fields[pos].indexOf(":")+2); - newItem.date=Zotero.Utilities.trimInternal(date); - } - if(fields[pos].indexOf("ISBN")!=-1&&fields[pos].indexOf("print")!=-1) { - var i=fields[pos].lastIndexOf(";"); - var isbn; - if(i!=-1) - isbn=fields[pos].substring(i+1); - else - isbn=fields[pos].substring(fields[pos].indexOf(":")+2); - newItem.ISBN=Zotero.Utilities.trimInternal(isbn); - } - if(fields[pos].indexOf("Author")!=-1||fields[pos].indexOf("Editor")!=-1) { - var authors=fields[pos].split(","); - for(var i=0; i<=authors.length-1; i++) { - authors[i]=Zotero.Utilities.trimInternal(authors[i]); - var names=authors[i].split(" "); - var creators=new Array(); - creators.firstName=names[0]; - creators.lastName=names[names.length-2]; - if(names[names.length-1]=="(Editor)") - creators.creatorType="editor"; - if(names[names.length-1]=="(Author)") - creators.creatorType="author"; - newItem.creators.push(creators); - } - } - if(fields[pos].indexOf("DOI:")!=-1) - newItem.itemID=fields[pos].substring(fields[pos].indexOf("1")); - } -} -function doWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - var journalreg=new RegExp("http://(:?www\.)?rsc\.org/(:?P|p)ublishing/(:?J|j)ournals"); - if(journalreg.test(url)) { - var browspath='//div/p/a[text()="Use advanced search"]'; - if(doc.evaluate(browspath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var doipath='//p[strong/text()="DOI:"]/a/text()'; - var dois=doc.evaluate(doipath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titlpath='//p/strong/a'; - var titles=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var items=new Array(); - var doi; - while(doi=dois.iterateNext()) - items[doi.nodeValue]=Zotero.Utilities.trimInternal(titles.iterateNext().textContent); - items=Zotero.selectItems(items); - var string="http://www.rsc.org/delivery/_ArticleLinking/refdownload.asp?"; - for(var codes in items) { - var string="http://www.rsc.org/delivery/_ArticleLinking/refdownload.asp?ManuscriptID="; - string+=codes.substring(codes.indexOf("/")+1)+"&type=refman"; - Zotero.Utilities.HTTP.doGet(string, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - // fix bad Y1 tags, which have wrong spacing and typically terminate with "///" - text = text.replace("Y1 - ", "Y1 - "); - trans.setString(text); - trans.translate(); - Zotero.done(); - }); - } - } - var searchpath='//a[text()="Back to Search Form"]'; - if(doc.evaluate(searchpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var doipath='//p[strong/text()="DOI:"]/a/text()'; - var dois=doc.evaluate(doipath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titlpath='//form/div/h5'; - var titles=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - var items=new Array(); - while(title=titles.iterateNext()) - items[dois.iterateNext().nodeValue]=title.textContent; - items=Zotero.selectItems(items); - var string="http://www.rsc.org/delivery/_ArticleLinking/refdownload.asp?"; - for(var codes in items) { - var string="http://www.rsc.org/delivery/_ArticleLinking/refdownload.asp?ManuscriptID="; - string+=codes.substring(codes.indexOf("/")+1)+"&type=refman"; - Zotero.Utilities.HTTP.doGet(string, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - // fix bad Y1 tags, which have wrong spacing and typically terminate with "///" - text = text.replace("Y1 - ", "Y1 - "); - trans.setString(text); - trans.translate(); - Zotero.done(); - }); - } - } - var singpath='//ul/li/a[text()="HTML Article" or text()="PDF"]'; - if(doc.evaluate(singpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var doipath='//div/p[strong/text()="DOI:"]'; - var text=doc.evaluate(doipath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var doi=text.substring(text.indexOf("/")+1); - var string="http://www.rsc.org/delivery/_ArticleLinking/refdownload.asp?ManuscriptID="+doi; - string+="&type=refman"; - Zotero.Utilities.HTTP.doGet(string, function(text) { - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - // fix bad Y1 tags, which have wrong spacing and typically terminate with "///" - text = text.replace("Y1 - ", "Y1 - "); - trans.setString(text); - trans.setHandler("itemDone", function(obj, newItem) { - var url2=newItem.url; - var stringy; - var archpath='//div[h3/text()="Journals archive purchaser access"]'; - if(doc.evaluate(archpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var stringy="http://www.rsc.org/ejarchive/"; - stringy+=url2.substring(url2.lastIndexOf("/")+1)+".pdf"; - newItem.attachments.push({url:stringy, title:"RSC PDF", mimeType:"application/pdf"}); - } - else { - var stringy="http://www.rsc.org/delivery/_ArticleLinking/DisplayArticleForFree.cfm?doi="; - stringy+=url2.substring(url2.lastIndexOf("/")+1); - newItem.attachments.push({url:stringy, title:"RSC PDF", mimeType:"application/pdf"}); - } - newItem.complete(); - }); - trans.translate(); - Zotero.done(); - }); - } - } - var magpath='//div/h3[text()="Link to journal article"]'; - if(doc.evaluate(magpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var newItem=new Zotero.Item("magazineArticle"); - var titlpath='//div/h2/div[@class="header"]/text()'; - newItem.title=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var authpath='//em/text()'; - var auth=doc.evaluate(authpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var authors=auth.split(","); - if(newItem.title.indexOf("Interview")==-1) - for(var i=0; i<=authors.length-1; i++) { - authors[i]=Zotero.Utilities.trimInternal(authors[i]); - var names=authors[i].split(" "); - var creator=new Array(); - creator.firstName=names[0]; - creator.lastName=names[names.length-1]; - newItem.creators.push(creator); - } - var textpath='//div[@id="content"]//text()'; - var text=doc.evaluate(textpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var temp; - while(temp=text.iterateNext()) - if(temp.nodeValue==newItem.title) { - newItem.date=text.iterateNext().nodeValue; - break; - } - var datapath= '//div[@id="breadcrumbs"]/ul/li/a/text()'; - var data=doc.evaluate(datapath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var prev; - while(temp=data.iterateNext()) { - if(temp.nodeValue.indexOf("Chemi")!=-1) - newItem.publication=temp.nodeValue; - prev=temp; - } - newItem.issue=prev.nodeValue; - newItem.complete(); - } - var magbrows='//div/h4[@class="newstitle"]/a'; - if(doc.evaluate(magbrows, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var titlpath='//h4[@class="newstitle"]/a'; - var titles=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - var items=new Array(); - while(title=titles.iterateNext()) - items[title.href]=title.textContent; - items=Zotero.selectItems(items); - for(var linx in items) { - var newItem=new Zotero.Item("magazineArticle"); - newItem.url=linx; - newItem.title=items[linx]; - var datepath='//div[h4/a/text()="'+items[linx]+'"]/h4[@class="datetext"]/text()'; - newItem.date=doc.evaluate(datepath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var datapath= '//div[@id="breadcrumbs"]/ul/li/a/text()'; - var data=doc.evaluate(datapath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var prev; - var temp; - while(temp=data.iterateNext()) { - if(temp.nodeValue.indexOf("Chemi")!=-1) - newItem.publication=temp.nodeValue; - prev=temp; - } - if(prev.nodeValue!=newItem.publication) - newItem.issue=prev.nodeValue; - newItem.complete(); - } - } - var magsearch='//p[@class="more"]/strong/a[text()="Search RSC journals"]'; - if(doc.evaluate(magsearch, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var titlpath='//div/p/a'; - var titles=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - titlpath='//blockquote/p/a[span/@class="l"]'; - var titles2=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null) - var title; - var items=new Array(); - while(title=titles.iterateNext()) - items[title.href]=title.textContent; - while(title=titles2.iterateNext()) - items[title.href]=title.textContent; - items=Zotero.selectItems(items); - for(var linx in items) { - var newItem=new Zotero.Item("magazineArticle"); - newItem.url=linx; - newItem.title=items[linx]; - newItem.complete(); - } - } - var bookreg=new RegExp("http://(:?www\.)?rsc\.org/(:?P|p)ublishing/e(:?B|b)ooks"); - if(bookreg.test(url)) { - var browspath='//title/text()'; - var page=doc.evaluate(browspath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - if((page=="Books in a publication year")||(page=="Subject Area Books")||(page=="A - Z Index") - ||(page=="Book Series")) { - var doipath='//dd/p/a/text()'; - var dois=doc.evaluate(doipath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var items=new Array(); - var title; - while(title=dois.iterateNext()) { - var doi=dois.iterateNext().nodeValue; - items[doi.substring(doi.indexOf("1"))]=title.nodeValue; - } - items=Zotero.selectItems(items); - for(var codes in items) { - var newItem=new Zotero.Item("book"); - newItem.itemID=codes; - newItem.title=items[codes]; - var itempath='//dd/p[contains(a[2]/text(), "'+codes+'")]'; - var itempath2='//dd/p[contains(a/text(), "'+codes+'")]'; - var data; - if(data=doc.evaluate(itempath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - data=data.innerHTML; - else if(data=doc.evaluate(itempath2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - data=data.innerHTML; - doBook(newItem, data); - newItem.complete(); - } - } - var chappath='//dt/img[@alt="Chapter"]'; - var singpath='//h3[text()="Table of Contents"]'; - if(doc.evaluate(chappath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var newItem=new Zotero.Item("bookSection"); - var titlpath='//span/h3/text()'; - var titles=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - newItem.title=titles.iterateNext().nodeValue; - newItem.bookTitle=titles.iterateNext().nodeValue; - var datapath='//dd/p'; - var entries=doc.evaluate(datapath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var chaptext=entries.iterateNext().innerHTML; - doChap(newItem, chaptext); - var bookdata=entries.iterateNext().innerHTML; - doBook(newItem, bookdata); - var linkpath='//td[1][@class="td1"]/a[1]'; - var linx=doc.evaluate(linkpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var pdflink; - while(pdflink=linx.iterateNext()) - newItem.attachments.push({url:pdflink.href, title:"RCS PDF", mimeType:"application/pdf"}); - newItem.complete(); - } - else if(doc.evaluate(singpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var newItem=new Zotero.Item("book"); - var itempath='//dd/p'; - var data=doc.evaluate(itempath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().innerHTML; - doBook(newItem, data); - var titlpath='//div/h2/text()'; - newItem.title=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var linkpath='//td[1][@class="td1"]/a[1]'; - var linx=doc.evaluate(linkpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var pdflink; - while(pdflink=linx.iterateNext()) - newItem.attachments.push({url:pdflink.href, title:"RCS PDF", mimeType:"application/pdf"}); - newItem.complete(); - } - } - var searchpath='//div/p[@class="title"][text()="Search Results"]'; - if(doc.evaluate(searchpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var doipath='//dd/p/a/text()'; - var dois=doc.evaluate(doipath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var title; - var items=new Array(); - while(title=dois.iterateNext()) { - var doi=dois.iterateNext().nodeValue; - items[doi.substring(doi.indexOf("1"))]=title.nodeValue; - } - items=Zotero.selectItems(items); - for(var codes in items) { - var itempath='//dd/p[contains(a/text(), "'+codes+'")]'; - var newpath='//dd[contains(p[2]/a/text(), "'+codes+'")]/p[1]/strong/text()'; - var data=doc.evaluate(itempath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().innerHTML; - if(data.indexOf("Book:")!=-1) { - var newItem=new Zotero.Item("bookSection"); - newItem.itemID=codes; - newItem.title=items[codes]; - doChap(newItem, data); - newItem.complete(); - } - else { - var newItem=new Zotero.Item("book"); - var newdata=doc.evaluate(newpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - if(newdata.indexOf("Volume")!=-1) - newItem.volume=newdata.substring(newdata.lastIndexOf(" ")+1); - else - newItem.series=newdata; - newItem.itemID=codes; - newItem.title=items[codes]; - doBook(newItem, data); - newItem.complete(); - } - } - } - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Radio Liberty.js b/translators/Radio Liberty.js @@ -1,268 +0,0 @@ -{ - "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" -} - -/* - Radio Liberty 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 works on articles posted on the websites of Radio Free Europe / Radio Liberty. - It imports the basic metadata the site provides, from normal article pages and from search - result pages. - - The translator tries to work on all of the languages of RFE/RL; they should all work. - - Editions: - English: http://www.rferl.org/ - Tatar/Bashkir: http://www.azatliq.org/ - Kazakh: http://www.azattyq.org/ (Kazakh) - http://rus.azattyq.org/ (Russian) - Afghan: http://da.azadiradio.org/ (Dari) - http://pa.azadiradio.org/ (Pashto) - Kirghiz: http://www.azattyk.org/ - Tajik: http://www.ozodi.org/ - Uzbek: http://www.ozodlik.org/ - Albanian: http://www.evropaelire.org/ - Bosnian/Montenegrin/Serbian: - http://www.slobodnaevropa.org/ - Macedonian: http://www.makdenes.org/ - Iraqi Arabic: http://www.iraqhurr.org/ - Farsi: http://www.radiofarda.com/ - Armenian: http://www.azatutyun.am/ - Azerbaijani: http://www.azadliq.org/ - Belarus: http://www.svaboda.org/ - Georgian: http://www.tavisupleba.org/ - Turkmen: http://www.azathabar.com/ - Russian: http://www.svobodanews.ru/ - Moldovan: http://www.europalibera.org/ (Romanian) - Ukrainian: http://www.radiosvoboda.org/ - - This translator does not yet attempt to work with the video files that Radio Liberty - hosts and produces; work with them must be left for a future revision. - - It does try to save linked audio files for stories-- still nothing - for video content. - - Another future improvement would be the facility to import from the front page and subject - pages. This is not yet possible. - - Some of the services use non-standard ways of marking authorship, for example, the Pashto edition - places the author at the bottom of the article, but there is no clear way to scrape that - information and the translator does not load it. -*/ - -function detectWeb(doc, url){ - if (url.match(/\/content\/|\/archive\/news/)) { - // The translator uses this type because RFE/RL generally has a place of publication - // and a Section; both are specific to newspaperArticle. - return "newspaperArticle"; - } else if (url.match(/\/search\/\?k=.+/)){ - return "multiple"; - } -} - -function doWeb(doc, url){ - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var results = doc.evaluate('//div[@class="searchResultItem"]', doc, ns, XPathResult.ANY_TYPE, null); - var items = new Array(); - var result; - while(result = results.iterateNext()) { - var link = doc.evaluate('./a[@class="resultLink"]', result, ns, XPathResult.ANY_TYPE, null).iterateNext(); - var title = link.textContent; - var url = link.href; - items[url] = title; - } - items = Zotero.selectItems(items); - if(!items) return true; - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - - Zotero.Utilities.processDocuments(articles, function(doc) { - item = new Zotero.Item("newspaperArticle"); - item.title = Zotero.Utilities.trimInternal( - doc.evaluate('//h1', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent - ); - - var author = doc.evaluate('//div[@id="article"]/div[@class="author"]', doc, ns, XPathResult.ANY_TYPE, null); - if ((author = author.iterateNext()) !== null) { - author = author.textContent; - // Sometimes we have "By Author" - 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 == "") { - cleaned["fieldMode"] = true; - } else { - // We can check for all lower-case and capitalize if necessary - // All-uppercase is handled by cleanAuthor - cleaned.firstName = (cleaned.firstName == cleaned.firstName.toLowerCase()) ? - Zotero.Utilities.capitalizeTitle(cleaned.firstName, true) : cleaned.firstName; - cleaned.lastName = (cleaned.lastName == cleaned.lastName.toLowerCase()) ? - Zotero.Utilities.capitalizeTitle(cleaned.lastName, true) : cleaned.lastName; - } - item.creators.push(cleaned); - } - // The section should _always_ be present - item.section = doc.evaluate('//div[@id="article" or @class="middle_content"]/h2', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.trim(); - - // This exposes a limitation of Zotero's date handling; the Afghan services - // use the Hijri calendar, and mixed sorting looks funny-- I'd like to be able - // to mark such dates to be handled appropriately - var date = doc.evaluate('//div[@id="article"]/div[@class="date"]', doc, ns, XPathResult.ANY_TYPE, null); - if ((date = date.iterateNext()) !== null) { - // sometimes not present - item.date = Zotero.Utilities.trimInternal(date.textContent); - } - - // We can also try to derive the location-- if the byline can be parsed - // Here, we assume that the byline uses all-caps for the location - // TODO Use more general all-caps character class, since this excludes special - // characters that may occur in city names. - // This all-caps class is borrowed from utilities.js and augmented by - // the basic Cyrillic capital letters. - var textnode = doc.evaluate('//div[@id="article"]/div[@class="zoomMe"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if (textnode) { - var text = textnode.textContent; - hits = text.match(/([A-ZА-Я \u0400-\u042f]+) \((.*)\) --/); - if (!hits) { - hits = text.match(/([A-ZА-Я \u0400-\u042f]+) --/); - } - if (hits) { - var place = Zotero.Utilities.capitalizeTitle(hits[1], true); - item.place = place; - // We add the wire service as an author; it would be nice to have a field for it - item.creators.push({lastName : hits[2], creatorType:"author", fieldMode:true}); - } - } - - item.url = url; - item.publicationTitle = doc.evaluate('//h2[@id="header_logo_anchor"]//span', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - // Language map: - var map = { - "www.rferl.org" : "English", - "www.azatliq.org" : "Tatar/Bashkir", - "www.azattyq.org" : "Kazakh", - "rus.azattyq.org" : "Russian", - "da.azadiradio.org" : "Dari", - "pa.azadiradio.org" : "Pashto", - "www.azattyk.org" : "Kirghiz", - "www.ozodi.org" : "Tajik", - "www.ozodlik.org" : "Uzbek", - "www.evropaelire.org" : "Albanian", - "www.slobodnaevropa.org" : "Bosnian/Montenegrin/Serbian", - "www.makdenes.org" : "Macedonian", - "www.iraqhurr.org" : "Iraqi Arabic", - "www.radiofarda.com" : "Farsi", - "www.azatutyun.am" : "Armenian", - "www.azadliq.org" : "Azerbaijani", - "www.svaboda.org" : "Belarussian", - "www.tavisupleba.org" : "Georgian", - "www.azathabar.com" : "Turkmen", - "www.svobodanews.ru" : "Russian", - "www.europalibera.org" : "Romanian", - "www.radiosvoboda.org" : "Ukrainian" - } - domain = doc.location.href.match(/https?:\/\/([^/]+)/); - item.language = map[domain[1]]; - - /* The printable version doesn't save nicely, unfortunately. - // Make printable URL for better saving - var printurl = url.replace(/(.*)\/.*\/(.*\.html)/,"$1/articleprintview/$2"); - item.attachments.push({url:printurl, title:"RFE/RL Snapshot", mimeType:"text/html"}); - */ - item.attachments.push({url:url, title: (item.publicationTitle + " Snapshot"), mimeType:"text/html"}); - - var listenLink = doc.evaluate('//li[@class="listenlink"]/a', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if (listenLink) { - Zotero.Utilities.doGet(listenLink.href, addAudio, null); - } else item.complete(); - - }, function() {Zotero.done();}); - Zotero.wait(); -} - -function addAudio(text) { - // http://realaudio.rferl.org/TB/2011/03/29/20110329-183936-TB-clip.mp3 - 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(); -} - -/** 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/RePEc.js b/translators/RePEc.js @@ -1,181 +0,0 @@ -{ - "translatorID":"411f9a8b-64f3-4465-b7df-a3c988b602f3", - "translatorType":4, - "label":"RePEc", - "creator":"Asa Kusuma", - "target":"^https?://ideas\\.repec\\.org/", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var singXpath = '//html/body/a/table/tbody/tr/td/font/b'; - var multXpath = '//html/body/h2'; - - - - if (doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - if(doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.indexOf("Search")!=-1) - return "multiple"; - } else if(doc.evaluate(singXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } -} - -function strrev(str) { - if (!str) return ''; - var revstr=''; - for (i = str.length-1; i>=0; i--) - revstr+=str.charAt(i) - return revstr; -} - - -function parseRIS(uris) { - - - Zotero.Utilities.HTTP.doGet(uris, function(text){ - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - Zotero.done(); - }, function() {}); - Zotero.wait(); -} - -function doWeb(doc, url) { - - - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var singXpath = '//html/body/a/table/tbody/tr/td/font/b'; - var multXpath = '//html/body/h2'; - - - - if (doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - if(doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.indexOf("Search")!=-1) - - - shortXpath = '//html/body/strong/a'; - longXpath = '//html/body/dl/dt/strong/a'; - var multXpath=''; - if(doc.evaluate(shortXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - multXpath=shortXpath; - - } else { - multXpath=longXpath; - - } - - - var bibElmts = doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titleElmts = doc.evaluate(multXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var titleElmt; - var bibElmt; - bibElmt = bibElmts.iterateNext(); - titleElmt = titleElmts.iterateNext(); - - var items = new Array(); - - do { - - var bibcode = bibElmt.href; - - bibcode=bibcode.substr(24); - - bibcode=strrev(bibcode); - bibcode=bibcode.substr(5,bibcode.length); - bibcode=strrev(bibcode); - - //Replace slashes with colons - bibcode=bibcode.replace("/",":","g"); - - //Insert colons between numbers and letters and letters and numbers - bibcode=bibcode.replace(/([A-Za-z])([0-9])/g, - function (str, p1, p2, offset, s) { - return p1 + ":" + p2; - } - ) - - bibcode=bibcode.replace(/([0-9])([A-Za-z])/g, - function (str, p1, p2, offset, s) { - return p1 + ":" + p2; - } - ) - - items[bibcode] = Zotero.Utilities.trimInternal(titleElmt.textContent); - - } while((bibElmt = bibElmts.iterateNext()) && (titleElmt = titleElmts.iterateNext())); - - items = Zotero.selectItems(items); - if(!items) return true; - - var bibcodes=""; - var uris = new Array(); - for(var bibcode in items) { - - var getURL = "http://ideas.repec.org/cgi-bin/ref.cgi?handle=RePEc"; - getURL = getURL + bibcode + "&output=3"; - - uris.push(getURL); - } - - parseRIS(uris); - - - - - } else if(doc.evaluate(singXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - var bibcode = url; - - bibcode=bibcode.substr(24); - - bibcode=strrev(bibcode); - bibcode=bibcode.substr(5,bibcode.length); - bibcode=strrev(bibcode); - - - //Replace slashes with colons - bibcode=bibcode.replace("/",":","g"); - - //Insert colons between numbers and letters and letters and numbers - bibcode=bibcode.replace(/([A-Za-z])([0-9])/g, - function (str, p1, p2, offset, s) { - return p1 + ":" + p2; - } - ) - - bibcode=bibcode.replace(/([0-9])([A-Za-z])/g, - function (str, p1, p2, offset, s) { - return p1 + ":" + p2; - } - ) - - - var getURL = "http://ideas.repec.org/cgi-bin/ref.cgi?handle=RePEc"; - getURL = getURL + bibcode + "&output=3"; - - var idarray = new Array(); - idarray.push(getURL); - parseRIS(idarray); - - } - - -} -\ No newline at end of file diff --git a/translators/Readability.js b/translators/Readability.js @@ -1,82 +0,0 @@ -{ - "translatorID": "cd77f1e5-507f-4c41-a6d2-bda5fa6f8694", - "label": "Readability", - "creator": "Avram Lyon", - "target": "^https?://www\\.readability\\.com/articles", - "minVersion": "2.1.3", - "maxVersion": "", - "priority": 100, - "inRepository": "0", - "translatorType": 4, - "lastUpdated": "2011-04-03 17:16:55" -} - -/* - Readability 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){ - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - var title = doc.evaluate('//h1[@id="article-entry-title"]', doc, ns, XPathResult.ANY_TYPE, null); - if (title) return "webpage"; - else return false; -} - -function doWeb(doc, url){ - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - // Since we don't know much about the site, we have to assume that - // it is a webpage - var item = new Zotero.Item("webpage"); - var title = doc.evaluate('//h1[@id="article-entry-title"]', doc, ns, XPathResult.ANY_TYPE, null); - item.title = title.iterateNext().textContent; - var rurl = doc.evaluate('//a[@id="article-url"]', doc, ns, XPathResult.ANY_TYPE, null); - rurl = rurl.iterateNext(); - item.url = rurl.href; - - // This is just the domain name, but it'll serve as the site title, - // since we don't know anything else. - item.websiteTitle = rurl.textContent; - - // It is possible that Readability sometimes has multiple authors, - // in which case this will have to be slightly amended - var author = doc.evaluate('//span[@id="article-author"]/span[@class="fn"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if (author) { - var auts = author.textContent.split(" and "); - for (var i in auts) { - if(auts[i].toUpperCase() == auts[i]) { - auts[i] = Zotero.Utilities.capitalizeTitle(auts[i].toLowerCase(), true) - } - item.creators.push(Zotero.Utilities.cleanAuthor(auts[i],"author")); - } - } - - // There is also a standardized timestamp, but we're ignoring that - // in favor of the nice-looking time. - var time = doc.evaluate('//time[@id="article-timestamp"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if(time) item.date = time.textContent; - - // We snapshot the page, using the existing document - item.attachments = [{document:doc, title:"Readability Snapshot"}] - item.complete(); -} diff --git a/translators/ReferBibIX.js b/translators/ReferBibIX.js @@ -1,285 +0,0 @@ -{ - "translatorID":"881f60f2-0802-411a-9228-ce5f47b64c7d", - "translatorType":3, - "label":"Refer/BibIX", - "creator":"Simon Kornblith", - "target":"txt", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "browserSupport":"gcsn", - "configOptions":{"dataMode":"line"}, - "displayOptions":{"exportCharset":"UTF-8"}, - "inRepository":true, - "lastUpdated":"2011-07-08 04:51:41" -} - -function detectImport() { - var lineRe = /%[A-Z0-9\*\$] .+/; - var line; - var matched = 0; - while((line = Zotero.read()) !== false) { - line = line.replace(/^\s+/, ""); - if(line != "") { - if(lineRe.test(line)) { - matched++; - if(matched == 2) { - // threshold is two lines - return true; - } - } else { - return false; - } - } - } -} - -var fieldMap = { - T:"title", - S:"series", - V:"volume", - N:"issue", - C:"place", - I:"publisher", - R:"type", - P:"pages", - W:"archiveLocation", - "*":"rights", - "@":"ISBN", - L:"callNumber", - M:"accessionNumber", - U:"url", - 7:"edition", - X:"abstractNote" -}; - -var inputFieldMap = { - J:"publicationTitle", - B:"publicationTitle", - 9:"type" -}; - -// TODO: figure out if these are the best types for personal communication -var typeMap = { - book:"Book", - bookSection:"Book Section", - journalArticle:"Journal Article", - magazineArticle:"Magazine Article", - newspaperArticle:"Newspaper Article", - thesis:"Thesis", - letter:"Personal Communication", - manuscript:"Unpublished Work", - interview:"Personal Communication", - film:"Film or Broadcast", - artwork:"Artwork", - webpage:"Web Page", - report:"Report", - bill:"Bill", - "case":"Case", - hearing:"Hearing", - patent:"Patent", - statute:"Statute", - email:"Personal Communication", - map:"Map", - blogPost:"Web Page", - instantMessage:"Personal Communication", - forumPost:"Web Page", - audioRecording:"Audiovisual Material", - presentation:"Report", - videoRecording:"Audiovisual Material", - tvBroadcast:"Film or Broadcast", - radioBroadcast:"Film or Broadcast", - podcast:"Audiovisual Material", - computerProgram:"Computer Program", - conferencePaper:"Conference Paper", - document:"Generic", - encyclopediaArticle:"Encyclopedia", - dictionaryEntry:"Dictionary" -}; - -// supplements outputTypeMap for importing -// TODO: BILL, CASE, COMP, CONF, DATA, HEAR, MUSIC, PAT, SOUND, STAT -var inputTypeMap = { - "Ancient Text":"book", - "Audiovisual Material":"videoRecording", - "Generic":"book", - "Chart or Table":"artwork", - "Classical Work":"book", - "Conference Proceedings":"conferencePaper", - "Conference Paper":"conferencePaper", - "Edited Book":"book", - "Electronic Article":"journalArticle", - "Electronic Book":"book", - "Equation":"artwork", - "Figure":"artwork", - "Government Document":"document", - "Grant":"document", - "Legal Rule or Regulation":"statute", - "Online Database":"webpage", - "Online Multimedia":"webpage", - "Electronic Source":"webpage" -}; - -var isEndNote = false; - -function processTag(item, tag, value) { - value = Zotero.Utilities.trim(value); - if(fieldMap[tag]) { - item[fieldMap[tag]] = value; - } else if(inputFieldMap[tag]) { - item[inputFieldMap[tag]] = value; - } else if(tag == "0") { - if(inputTypeMap[value]) { // first check inputTypeMap - item.itemType = inputTypeMap[value] - } else { // then check typeMap - for(var i in typeMap) { - if(value == typeMap[i]) { - item.itemType = i; - break; - } - } - // fall back to generic - if(!item.itemType) item.itemType = inputTypeMap["Generic"]; - } - } else if(tag == "A" || tag == "E" || tag == "?") { - if(tag == "A") { - var type = "author"; - } else if(tag == "E") { - var type = "editor"; - } else if(tag == "?") { - var type = "translator"; - } - - item.creators.push(Zotero.Utilities.cleanAuthor(value, type, value.indexOf(",") != -1)); - } else if(tag == "Q") { - item.creators.push({creatorType:"author", lastName:value, fieldMode:true}); - } else if(tag == "H" || tag == "O") { - item.extra += "\n"+value; - } else if(tag == "Z") { - item.notes.push({note:value}); - } else if(tag == "D") { - if(item.date) { - if(item.date.indexOf(value) == -1) { - item.date += " "+value; - } - } else { - item.date = value; - } - } else if(tag == "8") { - if(item.date) { - if(value.indexOf(item.date) == -1) { - item.date += " "+value; - } - } else { - item.date = value; - } - } else if(tag == "K") { - item.tags = value.split("\n"); - } -} - -function doImport() { - var line = true; - var tag = data = false; - do { // first valid line is type - Zotero.debug("ignoring "+line); - line = Zotero.read(); - line = line.replace(/^\s+/, ""); - } while(line !== false && line[0] != "%"); - - var item = new Zotero.Item(); - - var tag = line[1]; - var data = line.substr(3); - while((line = Zotero.read()) !== false) { // until EOF - line = line.replace(/^\s+/, ""); - if(!line) { - if(tag) { - processTag(item, tag, data); - // unset info - tag = data = readRecordEntry = false; - // new item - item.complete(); - item = new Zotero.Item(); - } - } else if(line[0] == "%" && line[2] == " ") { - // if this line is a tag, take a look at the previous line to map - // its tag - if(tag) { - processTag(item, tag, data); - } - - // then fetch the tag and data from this line - tag = line[1]; - data = line.substr(3); - } else { - // otherwise, assume this is data from the previous line continued - if(tag) { - data += "\n"+line; - } - } - } - - if(tag) { // save any unprocessed tags - processTag(item, tag, data); - item.complete(); - } -} - -function addTag(tag, value) { - if(value) { - Zotero.write("%"+tag+" "+value+"\r\n"); - } -} - -function doExport() { - var item; - while(item = Zotero.nextItem()) { - // can't store independent notes in RIS - if(item.itemType == "note" || item.itemType == "attachment") { - continue; - } - - // type - addTag("0", typeMap[item.itemType] ? typeMap[item.itemType] : "Generic"); - - // use field map - for(var j in fieldMap) { - if(item[fieldMap[j]]) addTag(j, item[fieldMap[j]]); - } - - //handle J & B tags correctly - if (item["publicationTitle"]) { - if (item.itemType == "journalArticle") { - addTag("J", item["publicationTitle"]); - } else { - addTag("B", item["publicationTitle"]); - } - } - - // creators - for(var j in item.creators) { - var referTag = "A"; - if(item.creators[j].creatorType == "editor") { - referTag = "E"; - } else if(item.creators[j].creatorType == "translator") { - referTag = "?"; - } - - addTag(referTag, item.creators[j].lastName+(item.creators[j].firstName ? ", "+item.creators[j].firstName : "")); - } - - // date - addTag("D", item.date); - - // tags - if(item.tags) { - var keywordTag = ""; - for each(var tag in item.tags) { - keywordTag += "\r\n"+tag.tag; - } - addTag("K", keywordTag.substr(2)); - } - Zotero.write("\r\n"); - } -} -\ No newline at end of file diff --git a/translators/ReliefWeb.js b/translators/ReliefWeb.js @@ -1,58 +0,0 @@ -{ - "translatorID":"6f5f1b24-7519-4314-880f-d7004fbcfe7e", - "translatorType":4, - "label":"ReliefWeb", - "creator":"Michael Berkowitz", - "target":"http://(www.)?reliefweb.int/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/(S|s)earch(R|r)esults/)) { - return "multiple"; - } else if (url.match(/(O|o)pen(D|d)ocument/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//div[@id="View"]/table/tbody/tr/td[4][@class="docView"]/a', doc, null, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.debug(arts); - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="docTitle"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.date = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="link"]/p[2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(6)); - item.url = doc.location.href; - if (doc.evaluate('//div[@id="docBody"]/p/i',doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var auts = doc.evaluate('//div[@id="docBody"]/p/i', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="docBody"]/p[1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(auts, "")); - auts = auts.replace('By ', "").split(/\//); - for each (var aut in auts) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } else { - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="docBody"]/p[1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Reuters.js b/translators/Reuters.js @@ -1,81 +0,0 @@ -{ - "translatorID": "83979786-44af-494a-9ddb-46654e0486ef", - "label": "Reuters", - "creator": "Avram Lyon, Michael Berkowitz", - "target": "^https?://(www\\.)?reuters\\.com/", - "minVersion": "2.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-10 21:05:59" -} - -/* - Reuters 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/>. -*/ - -/* - Translator for Reuters. This is a minimal translator just to get Reuters back working after a redesign. - Future versions should implement multiple item saving and attend to the nits that this translator has - probably missed. -*/ - -function detectWeb(doc, url) { - if (url.match(/^https?:\/\/(www\.)?reuters\.com\/article/)) { - return "newspaperArticle"; - } -} - -function doWeb(doc, url) { - var item = new Zotero.Item("newspaperArticle"); - - item.title = doc.evaluate('//meta[@property="og:title"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().content; - item.date = doc.evaluate('//meta[@name="REVISION_DATE"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().content; - item.place = doc.evaluate('//div[@id="articleInfo"]//span[@class="location"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var byline = doc.evaluate('//div[@id="articleInfo"]//p[@class="byline"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var authors = byline.substr(3).split(','); - for each (var aut in authors) { - item.creators.push(authorFix(aut)); - } - item.abstractNote = doc.evaluate('//span[@class="focusParagraph"]/p', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^.*\(Reuters\)\s+-\s+/,""); - item.url = doc.evaluate('//link[@rel="canonical"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href; - item.publicationTitle = "Reuters"; - if (item.place == item.place.toUpperCase()) - item.place = Zotero.Utilities.capitalizeTitle(item.place.toLowerCase(),true); - item.complete(); -} - -function authorFix(author) { - // Sometimes we have "By Author" - 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 == "") { - cleaned["fieldMode"] = true; - } else { - // We can check for all lower-case and capitalize if necessary - // All-uppercase is handled by cleanAuthor - cleaned.firstName = (cleaned.firstName == cleaned.firstName.toLowerCase()) ? - Zotero.Utilities.capitalizeTitle(cleaned.firstName, true) : cleaned.firstName; - cleaned.lastName = (cleaned.lastName == cleaned.lastName.toLowerCase()) ? - Zotero.Utilities.capitalizeTitle(cleaned.lastName, true) : cleaned.lastName; - } - return cleaned; -} diff --git a/translators/Revues.org.js b/translators/Revues.org.js @@ -1,345 +0,0 @@ -{ - "translatorID":"87766765-919e-4d3b-9071-3dd7efe984c8", - "translatorType":4, - "label":"Revues.org", - "creator":"Michael Berkowitz", - "creator":"Pierre-Alain Mignot", - "target":"http://.*\\.revues\\.org", - "minVersion":"1.0.1b1.r1", - "maxVersion":"", - "priority":1, - "inRepository":true, - "lastUpdated":"2010-02-23 11:26:00" -} - -function detectWeb(doc, url) { - // don't do anything on main domain, because there's nothing to fetch there - if(url.match(/http:\/\/(www\.)?revues\.org/)) return false; - - var types = doc.evaluate('//meta[@name="DC.type"]', doc, null, XPathResult.ANY_TYPE, null); - var type; - while(type = types.iterateNext()) { - type = type.content.toLowerCase(); - if('journalarticle' === type) { - return 'journalArticle'; - } else if('collection' === type) { - return 'multiple'; - } else if('booksection' === type) { - return 'bookSection'; - } - } - - if (doc.evaluate('//div[@id="inside"]/div[@class="sommaire"]/dl[@class="documents"]/dd[@class="titre"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext() - || doc.evaluate('//ul[@class="summary"]//div[@class="title"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//h1[@id="docTitle"]/span[@class="text"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || url.match(/document\d+/)) { - return "journalArticle"; - } - - return false; -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if(doc.evaluate('//meta[@name="DC.description.tableOfContents"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var titles = doc.evaluate('//meta[@name="DC.description.tableOfContents"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().content.split(' -- '); - var articles = doc.evaluate('//meta[@name="DC.relation.hasPart"]', doc, null, XPathResult.ANY_TYPE, null); - var article; - var i = 0; - while(article = articles.iterateNext()) { - items[article.content] = titles[i++]; - } - } else { - if (doc.evaluate('//ul[@class="summary"]//div[@class="title"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//ul[@class="summary"]//div[@class="title"]/a'; - } else if (doc.evaluate('//div[@id="inside"]/div[@class="sommaire"]/dl[@class="documents"]/dd[@class="titre"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//div[@id="inside"]/div[@class="sommaire"]/dl[@class="documents"]/dd[@class="titre"]/a'; - } else { - return false; - } - - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var title; - while(title = titles.iterateNext()) { - items[title.href] = title.textContent; - } - } - - items = Zotero.selectItems(items); - for(var i in items) { - arts.push(i); - } - } else { - arts.push(url); - } - - if(url.match(/persee\-\d+/)) { - // the article is on Persée portal, getting it to be translated by COinS - var translator = Zotero.loadTranslator("web"); - translator.setTranslator("05d07af9-105a-4572-99f6-a8e231c0daef"); - Zotero.Utilities.processDocuments(arts, function(doc) { - translator.setDocument(doc); - translator.translate(); - }, function() {Zotero.done();}); - } else { - Zotero.Utilities.processDocuments(arts, function(doc) { - var metas = doc.evaluate('//meta', doc, null, XPathResult.ANY_TYPE, null); - var links = doc.evaluate('//link[@rel="alternate"]', doc, null, XPathResult.ANY_TYPE, null); - var meta, type, link; - var data = new Array(); - // those four to have unique authors, not used by Zotero - data['authors'] = new Array(); - data['contrib'] = new Array(); - data['editors'] = new Array(); - data['translators'] = new Array(); - // authors - data['creators'] = new Array(); - // keywords - data['tags'] = new Array(); - data['attachments'] = new Array(); - data['notes'] = new Array(); - - while(link = links.iterateNext()) { - switch(link.type) { - case 'application/pdf': - data['attachments'].push({'url':link.href,'title':link.title,'mimeType':'application/pdf','downloadable':true}); - break; - // maybe later, epub ... - default: break; - } - } - - while(meta = metas.iterateNext()) { // iterate over each metas - switch(meta.name.toLowerCase()) { - case 'dc.type': - switch(meta.content.toLowerCase()) { - case 'journalarticle': - type = 'journalArticle'; - break; - - case 'collection': - case 'book': - type = 'multiple'; - break; - - case 'booksection': - type = 'bookSection'; - break; - - default: break; - } - break; - - case 'author': - case 'dc.creator': - var authors = meta.content.split(';'); - for(var i in authors) { - if(!data['authors'][authors[i]]) { - data['authors'][authors[i]] = true; - data['creators'].push(Zotero.Utilities.cleanAuthor(authors[i], "author", true)); - } - } - break; - - case 'dc.contributor': - case 'dc.contributor.ill': - var contribs = meta.content.split(';'); - for(var i in contribs) { - if(!data['contrib'][contribs[i]]) { - data['contrib'][contribs[i]] = true; - data['creators'].push(Zotero.Utilities.cleanAuthor(contribs[i], "contributor", true)); - } - } - break; - - case 'dc.contributor.edt': - var editors = meta.content.split(';'); - for(var i in editors) { - if(!data['editors'][editors[i]]) { - data['editors'][editors[i]] = true; - data['creators'].push(Zotero.Utilities.cleanAuthor(editors[i], "editor", true)); - } - } - break; - - case 'dc.contributor.com': - var bookAuthors = meta.content.split(';'); - for(var i in bookAuthors) { - if(!data['authors'][bookAuthors[i]]) { - data['authors'][bookAuthors[i]] = true; - data['creators'].push(Zotero.Utilities.cleanAuthor(bookAuthors[i], "bookAuthor", true)); - } - } - break; - - case 'dc.contributor.trl': - var translators = meta.content.split(';'); - for(var i in translators) { - if(!data['translators'][translators[i]]) { - data['translators'][translators[i]] = true; - data['creators'].push(Zotero.Utilities.cleanAuthor(translators[i], "translator", true)); - } - } - break; - - case 'dc.subject': - case 'keywords': - for each(var tag in meta.content.split(/,\s*/)) - data['tags'].push(tag); - break; - - case 'dc.identifier': - if(!meta.scheme || meta.scheme === 'URI') { - if(!data['url']) data['url'] = meta.content; - } else if(meta.scheme === 'ISSN' && !data['ISSN']) { - data['ISSN'] = meta.content; - } - break; - - case 'dc.title': - data['title'] = meta.content; - break; - - case 'dc.publisher': - data['publisher'] = data['publisher'] ? data['publisher'] + ';' + meta.content : meta.content; - break; - - case 'dc.language': - data['language'] = data['language'] ? data['language'] + ';' + meta.content : meta.content; - break; - - case 'dc.date': - if(!data['date']) data['date'] = meta.content; - break; - - case 'dc.rights': - data['rights'] = data['rights'] ? data['rights'] + ';' + meta.content : meta.content; - break; - - case 'dc.relation.ispartof': - if(meta.scheme && 'ISBN' === meta.scheme) { - data['ISBN'] = meta.content; - } else if(!data['publicationTitle']) { - data['publicationTitle'] = meta.content.replace(/(\s*,\s*)+$/, ''); - } - break; - - case 'dc.description.tableofcontents': - data['notes'].push({'note':meta.content}); - break; - - case 'dc.description': - case 'description': - if(!data['abstractNote']) { - data['abstractNote'] = meta.content; - } else if(-1 === data['abstractNote'].indexOf(meta.content)) { - data['abstractNote'] += ';' + meta.content; - } - break; - - case 'prism.publicationname': - data['publicationTitle'] = meta.content; - break; - - case 'prism.number': - data['issue'] = meta.content; - break; - - case 'prism.volume': - data['volume'] = meta.content; - break; - - case 'prism.issuename': - data['prism.series'] = meta.content; - break; - - case 'prism.startingpage': - data['pagination_first'] = meta.content; - break; - - case 'prism.endingpage': - data['pagination_last'] = meta.content; - break; - - case 'prism.publicationdate': - // we take only the date and not the time - data['date'] = meta.content.substr(0,10); - break; - - case 'prism.issn': - data['ISSN'] = meta.content; - break; - - case 'prism.isbn': - data['ISBN'] = meta.content; - break; - - case 'prism.elssn': - //if(!data['ISSN']) data['ISSN'] = meta.content; - break; - - case 'prism.url': - data['url'] = meta.content; - break; - - case 'prism.teaser': - data['extra'] = meta.content; - break; - - case 'prism.section': - data['prism.section'] = meta.content; - break; - - default: break; - } - } - - var item = new Zotero.Item(type ? type : 'journalArticle'); - - if('bookSection' === type) { - if(data['publicationTitle']) { - data['bookTitle'] = data['publicationTitle']; - delete data['publicationTitle']; - } - if(data['prism.series']) { - data['publicationTitle'] = data['prism.series']; - } - } else { - if(data['prism.series']) { - data['seriesTitle'] = data['prism.series']; - } else if(data['prism.section']) { - data['seriesTitle'] = data['prism.section']; - } - delete data['prism.section']; - } - delete data['prism.series']; - - if(data['pagination_first'] && data['pagination_last']) { - data['pages'] = data['pagination_first'] + '-' + data['pagination_last']; - } else if(data['pagination_first']) { - data['pages'] = data['pagination_first']; - } else if(data['pagination_last']) { - data['pages'] = data['pagination_last']; - } - delete data['pagination_first'], data['pagination_last'], data['authors'], data['contrib']; - - if(!data['title']) { - // if no dc.title found, Zotero will throw an error, so we get the page title - data['title'] = doc.evaluate('//title', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - data['attachments'].push({'title':data['title'],'url':data['url'],'mimeType':'text/html'}); - - for(var i in data) // populate - item[i] = data[i]; - - // will always be Revues.org - item.libraryCatalog = 'Revues.org'; - - item.complete(); - }, function() {Zotero.done();}); - } - Zotero.wait(); -} diff --git a/translators/Rice University Library Catalog.js b/translators/Rice University Library Catalog.js @@ -1,363 +0,0 @@ -{ - "translatorID":"23ba3be6-412d-4dde-9cc1-c4df0cc09378", - "label":"Rice University Library Catalog", - "creator":"Mang Sun", - "target":"^https?://[^/]*\\.rice\\.edu[^/]*/uhtbin/cgisirsi", - "minVersion":"2.1", - "maxVersion":"", - "priority":90, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-07-29 12:52:04" -} - -/* Based on the SIRSI translator by Simon Kornblith and Michael Berkowitz, - and the modifications for Rutgers (IRIS) by Chad Mills. - */ - -// Priority of 90 to override SIRSI - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="columns_container"]/div[contains(@class, "left_column")]/div[@class="content_container"]/div[@class="content"]/form[@id="hitlist"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//div[@class="columns_container"]/div[contains(@class, "left_column")]/form[@name="item_view"]/div[@class="content_container item_details"]/div[@class="content"]/h3[.="Item Details"] ', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var xpath = '/html/body/div[@class="columns_container"]/div[contains(@class, "left_column")]/form[@name="item_view"]/div[@class="content_container item_details"]/div[@class="content"]/ul[contains(@class, "detail_page")]/li[@id="detail_marc_record"]/dl/dt[@class="viewmarctags"]'; - - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - - var elmt = elmts.iterateNext(); - - if(!elmt) { - - return false; - } - - var newItem = new Zotero.Item("book"); - newItem.extra = ""; - newItem.series = ""; - var seriesItemCount = 0; - - - while(elmt) { - try { - - //By Rice. Select all non space text nodes. - var node = doc.evaluate('./text()[normalize-space()]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if(node) { - - if (doc.evaluate('following-sibling::dd[position()=1]/a/text()', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - { - - //By Rice. Some meta data must be retrieved from the text node of anchor tags. - var value = Zotero.Utilities.superCleanString(doc.evaluate('following-sibling::dd[position()=1]/a/text()[normalize-space()]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - } - else - { - //while other metadata can be retrieved directly from the text node of DD tags - var value = Zotero.Utilities.superCleanString(doc.evaluate('following-sibling::dd[position()=1]/text()[normalize-space()]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - } - - - //acquire label and create super clean text by removing colon, space and etc. - casedField = Zotero.Utilities.superCleanString(node.nodeValue); - field = casedField.toLowerCase(); - - - if(field == "publisher") { - newItem.publisher = value; - }else if(field == "pub date") { - var re = /[0-9]+/; - var m = re.exec(value); - newItem.date = m[0]; - }else if(field == "isbn") { - var re = /^[0-9](?:[0-9X]+)/; - var m = re.exec(value); - newItem.ISBN = m[0]; - }else if(field == "title") { - var titleParts = value.split(" / "); - re = /\[(.+)\]/i; - if (re.test(titleParts[0])) { - var ar = re.exec(titleParts[0]); - var itype = ar[1].toLowerCase(); - if(itype== "phonodisc" || itype == "sound recording"){ - newItem.itemType = "audioRecording"; - }else if(itype=="videorecording"){ - newItem.itemType = "videoRecording"; - }else if(itype=="electronic resource"){ - //newItem.itemType = "webPage"; - //Rice treats eletronic resource as book - newItem.itemType = "book"; - } - } - newItem.title = Zotero.Utilities.capitalizeTitle(titleParts[0]); - - }else if(field == "series") {//push onto item, delimit with semicolon when needed - if (seriesItemCount != 0){ - newItem.series += "; " + value; - }else if(seriesItemCount == 0) { - newItem.series = value; - } - seriesItemCount++;//bump counter - }else if(field == "dissertation note") { - newItem.itemType = "thesis"; - var thesisParts = value.split("--"); - var uniDate = thesisParts[1].split(", "); - newItem.university = uniDate[0]; - newItem.date = uniDate[1]; - }else if(field == "edition") { - newItem.edition = value; - }else if(field == "physical description") { - - var physParts = value.split(" : "); - var physParts = physParts[0].split(" ; "); - //determine pages, split on " p." - var physPages = value.split(" p."); - //break off anything in the beginning before the numbers - var pageParts = physPages[0].split(" "); - newItem.numPages = pageParts[pageParts.length-1]; - }else if(field == "publication info") { - var pubParts = value.split(" : "); - newItem.place = pubParts[0]; - //drop off first part of array and recombine - pubParts.shift(); - var i; - var publisherInfo; - for (i in pubParts) { - if (i == 0) { - publisherInfo = pubParts[i] + " : "; - } else { - publisherInfo = publisherInfo + pubParts[i] + " : "; - } - }//END for - //drop off last colon - publisherInfo = publisherInfo.substring(0,(publisherInfo.length - 3)); - //break apart publication parts into Publisher and Date - var publisherParts = publisherInfo.split(","); - newItem.publisher = publisherParts[0]; - //check that first character isn't a 'c', if so drop it - if (publisherParts[1].substring(1,2) == "c") { - newItem.date = publisherParts[1].substring(2); - } - else { - newItem.date = publisherParts[1]; - } - }else if(field == "personal author") { - - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); - }else if(field == "performer") { - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "performer", true)); - }else if(field == "author"){ - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); - }else if(field == "added author") { - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "contributor", true)); - }else if(field == "conference author" || field == "corporate author") { - - - - //The following line is included by Rice to handle corporate or conference author - newItem.creators.push(Zotero.Utilities.cleanAuthor(value, "author", true)); - }else if(field == "subject" || field == "corporate subject" || field == "geographic term") { - var subjects = value.split("--"); - newItem.tags = newItem.tags.concat(subjects); - }else if(field == "personal subject") { - var subjects = value.split(", "); - newItem.tags = newItem.tags.push(value[0]+", "+value[1]); - }else if(value && field != "http") { - newItem.extra += casedField+": "+value+"\n"; - } - } - } catch (e) {} - elmt = elmts.iterateNext(); - - }//END if node - - if(newItem.extra) { - newItem.extra = newItem.extra.substr(0, newItem.extra.length-1); - } - - var callNumber = doc.evaluate('//tr/td[1][@class="holdingslist"]/strong/text()', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if(callNumber && callNumber.nodeValue) { - newItem.callNumber = callNumber.nodeValue; - } - - newItem.libraryCatalog = "Rice University Library Catalog"; - newItem.complete(); - //Zotero.debug('hi'); - return true; - }//END try - - function doWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var sirsiNew = true; //toggle between SIRSI -2003 and SIRSI 2003+ - //Adapted to catch the hitlist page of Rice Catalog - var xpath = '/html/body/div[@class="columns_container"]/div[contains(@class, "left_column")]/div[@class="content_container"]/div[@class="content"]/form[@id="hitlist"]/ul[@class="hit_list"]/li/ul[starts-with(@class, "hit_list_row")]/li[@class="hit_list_item_info"]/dl'; - - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: searchsum"); - sirsiNew = true; - }else if (doc.evaluate('//form[@name="hitlist"]/table/tbody/tr', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: hitlist"); - sirsiNew = false; - }else if (doc.evaluate('//tr[th[@class="viewmarctags"]][td[@class="viewmarctags"]]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: viewmarctags"); - sirsiNew = true; - }else if (doc.evaluate('//input[@name="VOPTIONS"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - Zotero.debug("SIRSI doWeb: VOPTIONS"); - sirsiNew = false; - }else { - var elmts = doc.evaluate('/html/body/form//text()', doc, nsResolver, XPathResult.ANY_TYPE, null); - //var elmts = doc.evaluate(' ', doc, nsResolver, XPathResult.ANY_TYPE, null); - while(elmt = elmts.iterateNext()) { - if(Zotero.Utilities.superCleanString(elmt.nodeValue) == "Viewing record") { - Zotero.debug("SIRSI doWeb: Viewing record"); - sirsiNew = false; - } - }//END while elmts - }//END FUNCTION doWeb - // Zotero.debug(xpath); - if (sirsiNew) { //executes Simon's SIRSI 2003+ scraper code - - if(!scrape(doc)) { - - var checkboxes = new Array(); - var urls = new Array(); - var availableItems = new Array(); - //pull items - var tableRows = doc.evaluate('//ul[@class="hit_list"]/li/ul[contains(@class, "hit_list_row")][//input[@value="Details"]]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - var input = doc.evaluate('.//input[@value="Details"]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - //var text = doc.evaluate('.//strong', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var text = doc.evaluate('.//dd[@class="title"]/a', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if(text) { - availableItems[input.name] = text; - } - }//END while - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - - var hostRe = new RegExp("^http(?:s)?://[^/]+"); - var m = hostRe.exec(doc.location.href); - Zotero.debug("href: " + doc.location.href); - var hitlist = doc.forms.namedItem("hitlist"); - var baseUrl = m[0]+hitlist.getAttribute("action")+"?first_hit="+hitlist.elements.namedItem("first_hit").value+"&last_hit="+hitlist.elements.namedItem("last_hit").value; - var alexandria = new Array(); - for(var i in items) { - alexandria.push(baseUrl+"&"+i+"=Details"); - } - Zotero.Utilities.processDocuments(alexandria, function(doc) { scrape(doc) }, function() { Zotero.done() }, null); - Zotero.wait(); - }//END if not scrape(doc) - }else{ //executes Simon's SIRSI -2003 translator code - Zotero.debug("Running SIRSI -2003 code"); - - var uri = doc.location.href; - var recNumbers = new Array(); - var xpath = '//form[@name="hitlist"]/table/tbody/tr'; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - if(elmt) { // Search results page - var uriRegexp = /^http:\/\/[^\/]+/; - var m = uriRegexp.exec(uri); - var postAction = doc.forms.namedItem("hitlist").getAttribute("action"); - var newUri = m[0]+postAction.substr(0, postAction.length-1)+"40"; - var titleRe = /<br>\s*(.*[^\s])\s*<br>/i; - var items = new Array(); - do { - var checkbox = doc.evaluate('.//input[@type="checkbox"]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - // Collect title - var title = doc.evaluate("./td[2]", elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if(checkbox && title) { - items[checkbox.name] = Zotero.Utilities.trimInternal(title); - } - } while(elmt = elmts.iterateNext()); - items = Zotero.selectItems(items); - if(!items) { - return true; - } - for(var i in items) { - recNumbers.push(i); - } - } else {// Normal page - // this regex will fail about 1/100,000,000 tries - var uriRegexp = /^((.*?)\/([0-9]+?))\//; - var m = uriRegexp.exec(uri); - var newUri = m[1]+"/40" - var elmts = doc.evaluate('/html/body/form', doc, nsResolver, XPathResult.ANY_TYPE, null); - while(elmt = elmts.iterateNext()) { - var initialText = doc.evaluate('.//text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(initialText && initialText.nodeValue && Zotero.Utilities.superCleanString(initialText.nodeValue) == "Viewing record") { - recNumbers.push(doc.evaluate('./b[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - break; - } - } - } - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - var marc = translator.getTranslatorObject(); - Zotero.Utilities.loadDocument(newUri+'?marks='+recNumbers.join(",")+'&shadow=NO&format=FLAT+ASCII&sort=TITLE&vopt_elst=ALL&library=ALL&display_rule=ASCENDING&duedate_code=l&holdcount_code=t&DOWNLOAD_x=22&DOWNLOAD_y=12&address=&form_type=', function(doc) { - var pre = doc.getElementsByTagName("pre"); - var text = pre[0].textContent; - var documents = text.split("*** DOCUMENT BOUNDARY ***"); - for(var j=1; j<documents.length; j++) { - var uri = newUri+"?marks="+recNumbers[j]+"&shadow=NO&format=FLAT+ASCII&sort=TITLE&vopt_elst=ALL&library=ALL&display_rule=ASCENDING&duedate_code=l&holdcount_code=t&DOWNLOAD_x=22&DOWNLOAD_y=12&address=&form_type="; - var lines = documents[j].split("\n"); - var record = new marc.record(); - var tag, content; - var ind = ""; - for(var i=0; i<lines.length; i++) { - var line = lines[i]; - if(line[0] == "." && line.substr(4,2) == ". ") { - if(tag) { - content = content.replace(/\|([a-z])/g, marc.subfieldDelimiter+"$1"); - record.addField(tag, ind, content); - } - } else { - content += " "+line.substr(6); - continue; - } - tag = line.substr(1, 3); - if(tag[0] != "0" || tag[1] != "0") { - ind = line.substr(6, 2); - content = line.substr(8); - } else { - content = line.substr(7); - if(tag == "000") { - tag = undefined; - record.leader = "00000"+content; - Zotero.debug("the leader is: "+record.leader); - } - } - }//end FOR - var newItem = new Zotero.Item(); - record.translate(newItem); - - newItem.libraryCatalog = "Rice University Library "; - newItem.complete(); - }//end FOR - Zotero.done(); - }); - Zotero.wait(); - }//END while -}//END scrape function diff --git a/translators/Royal Historical Society.js b/translators/Royal Historical Society.js @@ -1,88 +0,0 @@ -{ - "translatorID":"a69deb08-47d9-46ad-afca-bc3a2499ad34", - "translatorType":4, - "label":"Royal Historical Society", - "creator":"Michael Berkowitz", - "target":"http://www.rhs.ac.uk/bibl/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-03-19 17:15:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//div[@class="bib_data"]/a[contains(@title, "view in more detail")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//a[text() = "View records in XML"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "document"; - } -} - -function doWeb(doc, url) { - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath = '//div[@class="bib_data"]/a[contains(@title, "view in more detail")]'; - var results = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - items[result.href] = Zotero.Utilities.trimInternal(result.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - books.push(i.replace(/DATABASE=[^&]+/, "DATABASE=xmlcatalo")); - } - } else { - books = [url.replace(/DATABASE=[^&]+/, "DATABASE=xmlcatalo")]; - } - for each (var link in books) { - Zotero.Utilities.HTTP.doGet(link, function(text) { - text = text.replace(/<\?[^?]+\?>/, ""); - var xml = new XML(text); - xml = xml..recordList; - var itemtype = "book"; - if (xml..journal.length() != 0) itemtype = "journalArticle"; - if (xml..in.length() != 0) itemtype = "bookSection"; - - var item = new Zotero.Item(itemtype); - item.title = Zotero.Utilities.cleanTags(xml..title.toString()); - item.date = xml..date.toString().match(/\d+/); - item.pages = xml..length.toString(); - for (var i = 0; i < xml..author.length(); i++) { - var name = xml..author[i].toString().match(/^[^,]+,[^,]+/)[0].split(/,\s+/); - item.creators.push({lastName:name[0], firstName:name[1], creatorType:"author"}); - } - if (item.itemType == "book") { - item.place = xml..place_of_publication.toString(); - item.publisher = xml..publisher.toString(); - item.ISBN = xml..ISBN.toString(); - } else if (item.itemType == "journalArticle") { - item.publicationTitle = xml..journal.toString(); - item.volume = xml..journal_volume.toString(); - item.issue = xml..journal_issue.toString(); - item.series = xml..series.toString(); - item.ISSN = xml..ISSN.toString(); - } else if (item.itemType == "bookSection") { - if (xml..title_interpolation.toString()) { - item.bookTitle = xml..title_interpolation.toString(); - } else { - item.bookTitle = xml..in.toString().match(/\),\s(.+)\s\(/)[1]; - } - - item.ISBN = xml..ISBN.toString(); - try { // this regex is iffy - bookInfo = xml..in.toString().match(/\(([A-Za-z;\s]+:[A-Za-z\s']+),\s\d+\)/)[1]; - } catch (e) { - Zotero.debug("regex didn't work"); - } - item.place = bookInfo.split(": ")[0] - item.publisher = bookInfo.split(": ")[1] - } - - item.complete(); - }, function(){Zotero.done();}); - - } - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/SAE International.js b/translators/SAE International.js @@ -1,74 +0,0 @@ -{ - "translatorID":"e9632edc-8032-4dc5-b2d4-284d481583e6", - "translatorType":4, - "label":"SAE International", - "creator":"Michael Berkowitz", - "target":"http://www.sae.org/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-12-30 22:30:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//td[2][@class="search-results"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.match(/\/books\//)) {return "book";} - else if (url.match(/\/papers\//)) {return "conferencePaper";} -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//td[2][@class="search-results"]/a', doc, null, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var type = detectWeb(doc, doc.location.href); - if (type == "conferencePaper") { - var data = new Object(); - var metas = doc.evaluate('//meta', doc, null, XPathResult.ANY_TYPE, null); - var meta; - while (meta = metas.iterateNext()) { - name = meta.name; - content = meta.content; - if (data[name]) { - data[name] = data[name] + ";" + content; - } else { - data[name] = content; - } - } - var item = new Zotero.Item("conferencePaper"); - item.title = doc.evaluate('//title', doc, null, XPathResult.ANY_TYPe, null).iterateNext().textContent; - item.data = data['publ_date']; - item.url = data['identifier_url']; - var authors = data['author'].split(/\s+;/); - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//td[1][@class="spg spg-left"]/p[strong[contains(text(), "Abstract")]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(9)); - } else if (type = "book") { - var item = new Zotero.Item("book"); - var data = doc.evaluate('//p[strong[contains(text(), "ISBN")]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.ISBN = data.match(/ISBN Number:\s+([\d\-]+)/)[1]; - item.date = data.match(/Date Published:\s+(.*)\n/)[1]; - item.url = doc.location.href; - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//title', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//td[1][@class="spg spg-left"]/p[contains(text(), ".")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - item.attachments = [{url:item.url, title:item.title, mimeType:"text/html"}]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/SFU IPinCH.js b/translators/SFU IPinCH.js @@ -1,190 +0,0 @@ -{ - "translatorID":"7448d1d7-57e4-4685-b6e4-d4d9f7046fc2", - "label":"SFU IPinCH", - "creator":"Gladys Tang", - "target":"^http://www\\.sfu\\.ca/kbipinch/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-01-13 10:29:52" -} - -/* - SFU IPinCH - translator for Zotero - Copyright (C) 2010 Gladys Tang - - 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) { - if (url.match(/records\//)) { - var metasT = doc.evaluate('//meta', doc, null , XPathResult.ANY_TYPE, null); - var meta; - while(meta = metasT.iterateNext()){ - //the catalog has more than 15 different item types records. - if(meta.name == 'itemType') - return meta.content; - } - } -} - -function scrape(doc, url) { - //namespace code - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var metasT = doc.evaluate('//meta', doc, null , XPathResult.ANY_TYPE, null); - var meta; - var item; - while(meta = metasT.iterateNext()){ - if(meta.name == 'itemType') - item = meta.content; - } - - var newItem = new Zotero.Item(item); - - var items = new Object(); - var isDateStart = 0; - var isDateEnd =0; - var isPlace = 0; - var dateStart =''; - var dateEnd = ''; - var newspaperTitle = ''; - newItem.url = doc.location.href; - var metas = doc.evaluate('//meta', doc, null , XPathResult.ANY_TYPE, null); - while (meta = metas.iterateNext()) { -// Zotero.debug(meta); - if(meta.name !='itemType') - { - items[meta.name] = meta.content; - //AUTHOR case - if(meta.name =='author' || meta.name =='translator' || meta.name =='editor' || meta.name =='contributor' || meta.name =='reviewedAuthor' || meta.name =='interviewee' - || meta.name == 'interviewer' || meta.name == 'director' || meta.name == 'recipient' || meta.name == 'artist' || meta.name == 'presenter') - { - var creatorStr = meta.content; - var firstname, lastname; - var i = creatorStr.indexOf(","); - if(i!=-1) - { - lastname = creatorStr.slice(0, i); - firstname = creatorStr.slice(i +1 ); - creatorStr = firstname +' ' + lastname; - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(creatorStr, meta.name, true)); - } - else - if(item='newspaperArticle' && meta.name == 'title') - { - if (newspaperTitle == '') - newspaperTitle = meta.content; - else - newspaperTitle += ', ' + meta.content - } - else - //Date start case - if(meta.name == 'dateY' || meta.name=='dateM' || meta.name=='dateD') - { - if(isDateStart ==0) - { - items['dateY'] = ''; - items['dateM'] = ''; - items['dateD'] = ''; - } - items[meta.name] = meta.content; - isDateStart = 1; - } - else - //Date end case - if(meta.name == 'dateYE' || meta.name=='dateME' || meta.name=='dateDE') - { - if(isDateEnd ==0) - { - items['dateYE'] = ''; - items['dateME'] = ''; - items['dateDE'] = ''; - } - items[meta.name] = meta.content; - isDateEnd = 1; - } - - else - if(meta.name == 'placeCountry' || meta.name == 'placeCity') - { - if(isPlace ==0) - { - items['placeCountry'] = ''; - items['placeCity'] = ''; - } - items[meta.name] = meta.content; - isPlace = 1; - } - else - newItem[meta.name] = meta.content; - } - } - - if(item='newspaperArticle') - { - newItem.title = newspaperTitle; - } - if(!newItem.title) - newItem.title = "No title"; - if (isDateStart==1) - { - if(items['dateM'] == '' && items['dateD']=='') - dateStart = items['dateY']; - else - dateStart = items['dateM'] + '-' + items['dateD'] + '-' + items['dateY']; - newItem['date'] = dateStart; - } - if (isDateEnd==1) - { - if(items['dateME'] == '' && items['dateDE']=='') - dateEnd = items['dateYE']; - else - dateEnd =' to ' + items['dateME'] + '-' + items['dateDE'] + '-' + items['dateYE']; - newItem['date'] = dateStart + '-' + dateEnd; - } - - if (isPlace==1) - newItem['place'] = items['placeCity'] + ' , ' + items['placeCountry']; - -// No such record yet. -// if(item=='document') //special case, publication location merge to publisher. -// { -// newItem['publisher'] = newItem['publisher'] + ',' + newItem['place'] -// } - - newItem.repository = "SFU IPinCH"; - - newItem.complete(); -} - -function doWeb(doc, url) { - //namespace code - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var uris = new Array(); - - uris =[url]; - - Zotero.Utilities.processDocuments(uris, scrape, function() {Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/SPIE Digital Library.js b/translators/SPIE Digital Library.js @@ -1,57 +0,0 @@ -{ - "translatorID":"48d3b115-7e09-4134-ad5d-0beda6296761", - "translatorType":4, - "label":"SPIE Digital Library", - "creator":"Michael Berkowitz", - "target":"http://(?:spiedl|spiedigitallibrary)\\.aip\\.org/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-06 17:00:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//table[@class="searchResultsTable"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//div[@id="articletoolsdisplay"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "journalArticle"; - } -} - -//http://spiedl.aip.org/getabs/servlet/GetCitation?fn=view_isi&source=scitation&PrefType=ARTICLE&PrefAction=Add+Selected&SelectCheck=JBOPFO000013000002024024000001&downloadcitation=+Go+ - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var results = doc.evaluate('//table[@class="searchResultsTable"]/tbody/tr', doc, null, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - var title = doc.evaluate('.//td[3]/a[1]', result, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var id = doc.evaluate('.//td[2]/input', result, null, XPathResult.ANY_TYPE, null).iterateNext().value; - items[id] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - var id = doc.evaluate('//input[@name="SelectCheck"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().value; - arts = [id]; - } - - var getstr1 = 'http://' + doc.location.host + '/getabs/servlet/GetCitation?fn=view_isi&source=scitation&PrefType=ARTICLE&PrefAction=Add+Selected&SelectCheck='; - var getstr2 = '&downloadcitation=+Go+'; - for each (var id in arts) { - var get = getstr1 + id + getstr2; - Zotero.Utilities.HTTP.doGet(get, function(text) { - Zotero.debug(text); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.translate(); - }); - } - -} -\ No newline at end of file diff --git a/translators/SPIRES.js b/translators/SPIRES.js @@ -1,85 +0,0 @@ -{ - "translatorID":"232903bc-7307-4058-bb1a-27cfe3e4e655", - "translatorType":4, - "label":"SPIRES", - "creator":"Sean Takats", - "target":"^http://www.slac.stanford.edu/spires/find/hep/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var citations = doc.evaluate('//dl/dd/a[text()="BibTeX"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var citation = citations.iterateNext(); - var titles = doc.evaluate('//p/b[1]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var title = titles.iterateNext(); - if(citation && title) { - // search page - return "multiple"; - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var citations = doc.evaluate('//dl/dd/a[text()="BibTeX"]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var citation = citations.iterateNext(); -// var titles = doc.evaluate('//p/b[1]', doc, nsResolver, -// XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('//p[b[1]]', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var title = titles.iterateNext(); - if(citation && title) { - // search page - var items = new Object(); - do { - items[citation.href] = Zotero.Utilities.trimInternal(title.textContent); - } while((citation=citations.iterateNext()) && (title=titles.iterateNext())) - - items = Zotero.selectItems(items); - if(!items) return true; - - var newUris = new Array(); - for(var id in items) { - newUris.push(id); - } - } else { - //single result page? - } - - Zotero.Utilities.HTTP.doGet(newUris, function(text) { - var m = text.match(/<pre>(?:.|[\r\n])*?<\/pre>/g); - var bibTeXString = ""; - for each(var citation in m) { - // kill pre tags - citation = citation.substring(5, citation.length-6); - bibTeXString += citation; - } - - // import using BibTeX - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - translator.setString(bibTeXString); - translator.setHandler("itemDone", function(obj, item) { - item.complete(); - }); - translator.translate(); - - Zotero.done(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/SSRN.js b/translators/SSRN.js @@ -1,112 +0,0 @@ -{ - "translatorID":"b61c224b-34b6-4bfd-8a76-a476e7092d43", - "translatorType":4, - "label":"SSRN", - "creator":"Michael Berkowitz", - "target":"http://papers\\.ssrn\\.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-07-01 18:10:00" -} - -function detectWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - if (doc.evaluate('//font/strong/a[substring(@class, 1, 4) = "text"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (url.indexOf("abstract_id") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var namespace=doc.documentElement.namespaceURI; - var nsResolver=namespace?function(prefix) { - return (prefix=="x")?namespace:null; - }:null; - - var uris = new Array(); - - if (doc.evaluate('//font/strong/a[substring(@class, 1, 4) = "text"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var items = new Object(); - var xpath = '//font/strong/a[substring(@class, 1, 4) = "text"]'; - var titles = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_title = titles.iterateNext(); - while (next_title) { - items[next_title.href] = next_title.textContent; - next_title = titles.iterateNext(); - } - items = Zotero.selectItems(items); - for (var i in items) { - uris.push(i); - } - } else { - uris.push(url); - } - - Zotero.Utilities.processDocuments(uris, function(doc) { - if (doc.evaluate('//span[@id="knownuser"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var id = doc.location.href.match(/abstract_id=(\d+)/)[1]; - if (doc.evaluate('//a[@title="Download from Social Science Research Network"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var pdfurl = doc.evaluate('//a[@title="Download from Social Science Research Network"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - } - var newURL = 'http://papers.ssrn.com/sol3/RefExport.cfm?abstract_id=' + id + '&format=3'; - Zotero.Utilities.HTTP.doGet(newURL, function(text) { - var ris=text.match(/<input type=\"Hidden\"\s+name=\"hdnContent\"\s+value=\"([^"]*)\">/)[1]; - var trans=Zotero.loadTranslator("import"); - trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - trans.setString(ris); - trans.setHandler("itemDone", function(obj, item) { - item.itemType = "journalArticle"; - var tags = new Array(); - for each (var tag in item.tags) { - var newtags = tag.split(","); - for each (var newtag in newtags) tags.push(newtag); - } - item.tags = tags; - item.attachments = [{url:item.url, title:"SSRN Snapshot", mimeType:"text/html"}]; - if (pdfurl) item.attachments.push({url:pdfurl, title:"SSRN Full Text PDF", mimeType:"application/pdf"}); - item.complete(); - }); - trans.translate(); - }); - } else { - var item = new Zotero.Item("journalArticle"); - item.title = Zotero.Utilities.capitalizeTitle(Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="abstractTitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent)); - var authors = doc.evaluate('//center/font/a[@class="textlink"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var author; - while (author = authors.iterateNext()) { - var aut = Zotero.Utilities.capitalizeTitle(Zotero.Utilities.trimInternal(author.textContent)); - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="innerWhite"]/font[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent).replace(/^abstract/i,''); - var tags = doc.evaluate('//font[contains(./b/text(), "Key")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (tags) { - item.tags = Zotero.Utilities.trimInternal(tags.textContent).substr(10).split(/,\s+/); - } - item.publicationTitle = "SSRN eLibrary"; - - var date = doc.evaluate('id("innerWhite")/center/font[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (date && date.textContent.match(/\d{4}/)) { - item.date = Zotero.Utilities.trimInternal(date.textContent); - } - item.url = doc.location.href; - /* Commenting out PDF downloading until we add referer capability - var pdfurl = doc.evaluate('//a[contains(@href,"pdf")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (pdfurl) { - pdfurl = pdfurl.href; - } - */ - item.attachments = [{url:item.url, title:"SSRN Snapshot", mimeType:"text/html"}]; - if (pdfurl) { - item.attachments.push({url:pdfurl, title:"SSRN Full Text PDF", mimeType:"application/pdf"}); - } - item.complete(); - } - }, function() {Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/Sage Journals Online.js b/translators/Sage Journals Online.js @@ -1,85 +0,0 @@ -{ - "translatorID":"636c8ea6-2af7-4488-8ccd-ea280e4a7a98", - "translatorType":4, - "label":"Sage Journals Online", - "creator":"Michael Berkowitz", - "target":"http://[^/]*\\.sagepub\\.com[^/]*/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-28 18:10:00" -} - -function detectWeb(doc, url) { - if (url.indexOf("searchresults") != -1 || (doc.title.indexOf("Table of Contents") != -1)) { - return "multiple"; - } else if (url.indexOf("cgi/content") != -1) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.title.indexOf("Table of Contents") != -1) { - var searchx = '//div[@id="maincontent"]/div[@class="contentarea"]/table[@class="toc"]/tbody/tr/td[2][@class="rightcol"]/form/dl/dd'; - var titlex = './/strong'; - } else { - var searchx = '//form[@id="search_results"]/div[@class="resultsitem"]/div[2]'; - var titlex = './/label'; - - } - var linkx = './/a[contains(@href, "abstract")]'; - var searchres = doc.evaluate(searchx, doc, null, XPathResult.ANY_TYPE, null); - var next_res; - while (next_res = searchres.iterateNext()) { - var title = doc.evaluate(titlex, next_res, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - // sometimes there is no abstract, the search results returns an entire journal, I am skipping it silently - var link = doc.evaluate(linkx, next_res, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (link) { - items[link.href] = title; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - var newurls = new Array(); - for each (var i in arts) { - newurls.push(i); - } - Zotero.Utilities.HTTP.doGet(arts, function(text) { - var id = text.match(/=([^=]+)\">\s*Add to Saved Citations/)[1]; - var newurl = newurls.shift(); - var pdfurl = newurl.replace(/content\/[^/]+/, "reprint") + ".pdf"; - if (pdfurl.indexOf("?") != -1) { - pdfurl = pdfurl.substring(0,pdfurl.indexOf("?")) + ".pdf"; - } - Zotero.debug("pdf= "+pdfurl); - var get = 'http://online.sagepub.com/cgi/citmgr?type=refman&gca=' + id; - Zotero.Utilities.HTTP.doGet(get, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - if (text.match(/N1(.*)\n/)) { - var doi = text.match(/N1\s+\-\s+(.*)\n/)[1]; - } - translator.setHandler("itemDone", function(obj, item) { - item.attachments = [ - {url:newurl, title:"Sage Journals Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:"Sage Journals Full Text PDF", mimeType:"application/pdf"} - ]; - if (doi) item.DOI = doi; - if (item.notes) item.notes = []; - item.complete(); - }); - translator.translate(); - }); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/SciELO.js b/translators/SciELO.js @@ -1,106 +0,0 @@ -{ - "translatorID":"3eabecf9-663a-4774-a3e6-0790d2732eed", - "translatorType":4, - "label":"SciELO", - "creator":"Michael Berkowitz", - "target":"http://(www.)?scielo.(org|br)/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-30 08:00:00" -} - -function detectWeb(doc, url) { - if (url.indexOf("wxis.exe") != -1) { - if (doc.evaluate('//*[@class="isoref"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } - } else if (url.indexOf("issuetoc") != -1) { - return "multiple" - } else if (url.indexOf("&pid=") != -1) { - return "journalArticle"; - } else { - Zotero.debug("ok"); - } -} - -function makeURL(host, str) { - return 'http://www.scielo.br/scieloOrg/php/articleXML.php?pid=' + str.match(/pid=([^&]+)/)[1]; -} - -function doWeb(doc, url) { - var host = doc.location.host; - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (url.indexOf(".exe") != -1) { - var titlepath = '//font[@class="isoref"]/font[@class="negrito"]'; - var linkpath = '//font[@class="isoref"]/a[@class="isoref"]'; - } else { - var titlepath = '//font[@class="normal"]/b/b[1]'; - var linkpath = '//tr/td/div/a[1]'; - } - var titles = doc.evaluate(titlepath, doc, null, XPathResult.ANY_TYPE, null); - var links = doc.evaluate(linkpath, doc, null, XPathResult.ANY_TYPE, null); - var next_title; - var next_link; - while ((next_title = titles.iterateNext()) && (next_link = links.iterateNext())) { - items[next_link.href] = next_title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(makeURL(host, i)); - } - } else { - arts = [makeURL(host, url)]; - } - Zotero.Utilities.HTTP.doGet(arts, function(text) { - var item = new Zotero.Item("journalArticle"); - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, "").replace(/<self-uri.*\/self\-uri>/g, ""); - var journal = text.split("<journal-meta>")[1].split("</journal-meta>")[0]; - journal = "<journal>" + journal + "</journal>"; - journal = journal.replace(/\-([a-z])/g, "$1"); - var xml2 = new XML(journal); - var art = text.split("<article-meta>")[1].split("</article-meta>")[0]; - art = "<article>" + art + "</article>"; - art = art.replace(/\-([a-z])/g, "$1"); - var xml3 = new XML(art); - - item.publicationTitle = xml2..journaltitle.text().toString(); - item.journalAbbreviation = xml2..abbrevjournaltitle.text().toString(); - item.ISSN = xml2..issn.text().toString(); - item.publisher = xml2..publisher..publishername.text().toString(); - item.title = xml3..titlegroup..articletitle.text().toString(); - for (var i = 0 ; i < xml3..contribgroup..contrib.length() ; i++) { - var name = xml3..contribgroup..contrib[i]..name; - item.creators.push({firstName:name..givennames.text().toString(), lastName:name..surname.text().toString(), creatorType:"author"}); - } - - var date = xml3..pubdate[0]; - var day = date..day.text().toString(); - var month = date..month.text().toString(); - var year = date..year.text().toString(); - - date = year; - if (month != "00") { - date = month + "/" + date; - } - if (day != "00") { - date = day + "/" + date; - } - item.date = date; - item.volume = xml3..volume.text().toString(); - item.pages = xml3..fpage.text().toString() + "-" + xml3..lpage.text().toString(); - - for (var i = 0 ; i < xml3..kwdgroup..kwd.length() ; i++) { - item.tags.push(xml3..kwdgroup..kwd[i].text().toString()); - } - - item.attachments = [ - {url:url, title:"SciELO Snapshot", mimeType:"text/html"} - ]; - - item.complete(); - }); -} -\ No newline at end of file diff --git a/translators/Science Links Japan.js b/translators/Science Links Japan.js @@ -1,73 +0,0 @@ -{ - "translatorID":"c0d7d260-d795-4782-9446-f6c403a7922c", - "translatorType":4, - "label":"Science Links Japan", - "creator":"Michael Berkowitz", - "target":"http://sciencelinks.jp/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/result/) || url.match(/journal/)) { - return "multiple"; - } else if (url.match(/article/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var ns = doc.documentElement.namespaceURI; - nsR = ns ? function(prefix) { - if (prefix == 'x') return ns; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, "(article|display\.php)"); - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var data = new Array(); - var bits = doc.evaluate('//div[@id="result_detail"]/table/tbody/tr/td', doc, nsR, XPathResult.ANY_TYPE, null); - var bit; - while (bit = bits.iterateNext()) { - data.push(Zotero.Utilities.trimInternal(bit.textContent)); - } - var item = new Zotero.Item("journalArticle"); - for each (var datum in data) { - if (datum.match(/^Title;/)) { - item.title = Zotero.Utilities.capitalizeTitle(datum.match(/Title;(.*)$/)[1]); - } else if (datum.match(/^Author;/)) { - var auts = datum.match(/\b[A-Z'\-]+\s+[A-Z'\-]+/g); - for each (var aut in auts) { - item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.capitalizeTitle(aut, true), "author")); - } - } else if (datum.match(/^Journal Title;/)) { - item.publicationTitle = datum.match(/;(.*)$/)[1]; - } else if (datum.match(/^ISSN/)) { - item.ISSN = datum.match(/[\d\-]+/)[0]; - } else if (datum.match(/^VOL/)) { - var voliss = datum.match(/^VOL\.([^;]*);NO\.([^;]*);PAGE\.([^(]*)\((\d+)\)/); - item.volume = voliss[1]; - item.issue = voliss[2]; - item.pages = voliss[3]; - item.date = voliss[4]; - } else if (datum.match(/^Abstract/)) { - item.abstractNote = datum.match(/;(.*)/)[1]; - } - } - item.url = doc.location.href; - item.attachments = [{url:item.url, title:"Science Links Japan Snapshot", mimeType:"text/html"}]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/ScienceDirect.js b/translators/ScienceDirect.js @@ -1,382 +0,0 @@ -{ - "translatorID": "b6d0a7a-d076-48ae-b2f0-b6de28b194e", - "label": "ScienceDirect", - "creator": "Michael Berkowitz", - "target": "^https?://[^/]*science-?direct\\.com[^/]*/science(\\/article)?(\\?(?:.+\\&|)ob=(?:ArticleURL|ArticleListURL|PublicationURL))?", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-09 01:55:35" -} - -function detectWeb(doc, url) { - if ((url.indexOf("_ob=DownloadURL") != -1) || doc.title == "ScienceDirect Login" || doc.title == "ScienceDirect - Dummy") { - return false; - } - if((!url.match("pdf") && url.indexOf("_ob=ArticleURL") == -1 && url.indexOf("/article/") == -1) || url.indexOf("/journal/") != -1) { - // TEMP: disabled - //return "multiple"; - return false; - } else if (!url.match("pdf")) { - 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; - - if (doc.evaluate('//*[contains(@class, "icon_exportarticlesci_dir")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() - || doc.evaluate('//*[contains(@src, "exportarticle_a.gif")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var articles = new Array(); - if(detectWeb(doc, url) == "multiple") { - //search page - var items = new Object(); - var xpath; - if (url.indexOf("_ob=PublicationURL") != -1) { - // not sure if this case still arises. may need to be fixed at some point - xpath = '//table[@class="resultRow"]/tbody/tr/td[2]/a'; - } else { - xpath = '//div[@class="font3"][@id="bodyMainResults"]/table/tbody/tr/td[2]/a'; - } - var rows = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_row; - while (next_row = rows.iterateNext()) { - var title = next_row.textContent; - var link = next_row.href; - if (!title.match(/PDF \(/) && !title.match(/Related Articles/)) items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - - var sets = []; - for each (article in articles) { - sets.push({article:article}); - } - - } else { - articles = [url]; - var sets =[{currentdoc:doc}]; - } - if(articles.length == 0) { - Zotero.debug('no items'); - return; - } - - - var scrape = function(newDoc, set) { - var PDF; - var tempPDF = newDoc.evaluate('//a[contains(@class, "icon_pdf")]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (!tempPDF) { // PDF xpath failed, lets try another - // TODO: others? - //tempPDF = newDoc.evaluate('//a[@class="noul" and contains(text(), "PDF")]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (!tempPDF) { // second PDF xpath failed set PDF to null to avoid item.attachments - PDF = null; - } else { - PDF = tempPDF.href; // second xpath succeeded, use that link - } - } else { - PDF = tempPDF.href; // first xpath succeeded, use that link - } - var url = newDoc.location.href; - var get = newDoc.evaluate('//a[contains(@class, "icon_exportarticlesci_dir")]', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - // if the PDF is available make it an attachment otherwise only use snapshot. - var attachments; - if (PDF) { - attachments = [ - {url:url, title:"ScienceDirect Snapshot", mimeType:"text/html"}, - {url:PDF, title:"ScienceDirect Full Text PDF", mimeType:"application/pdf"} // Sometimes PDF is null...I hope that is ok - ]; - } else { - attachments = [ - {url:url, title:"ScienceDirect Snapshot", mimeType:"text/html"} - ]; - } - // This does not work, not sure why. - //var doi = newDoc.evaluate('//a[contains(text(), "doi")]/text()', newDoc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - //Zotero.debug(doi); - //doi = doi.textContent.substr(4); - // pass these values to the next function - //set.doi = doi; - set.url = url; - set.get = get; - set.attachments = attachments; - return set; - - }; - - var first = function(set, next) { - var article = set.article; - Zotero.Utilities.processDocuments(article, function(doc){ - set = scrape(doc, set); - next(); - }); - }; - - var second = function(set, next) { - var url = set.url; - var get = set.get; - - Zotero.Utilities.HTTP.doGet(get, function(text) { - var md5 = text.match(/<input type=hidden name=md5 value=([^>]+)>/)[1]; - var acct = text.match(/<input type=hidden name=_acct value=([^>]+)>/)[1]; - var userid = text.match(/<input type=hidden name=_userid value=([^>]+)>/)[1]; - var uoikey = text.match(/<input type=hidden name=_uoikey value=([^>]+)>/)[1]; - if (text.match(/<input type=hidden name=_ArticleListID value=([^>]+)>/)) { - var alid = text.match(/<input type=hidden name=_ArticleListID value=([^>]+)>/)[1]; - } - if (alid) { - var docID = "_ArticleListID=" + alid + "&_uoikey=" + uoikey; - } else { - var docID = "_uoikey=" + uoikey; - } - var post = "_ob=DownloadURL&_method=finish&_acct=" + acct + "&_userid=" + userid + "&_docType=FLA&" + docID + "&md5=" + md5 + "&count=1&JAVASCRIPT_ON=Y&format=cite-abs&citation-type=RIS&Export=Export&x=26&y=17"; - var baseurl = url.match(/https?:\/\/[^/]+\//)[0]; - - set.post = post; - set.baseurl = baseurl; - - next(); - }); - - - }; - - var third = function(set, next) { - var baseurl = set.baseurl; - var post = set.post; - var attachments = set.attachments; - - - Zotero.Utilities.HTTP.doPost(baseurl + 'science', post, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.attachments = attachments; - - if(item.notes[0]) { - item.abstractNote = item.notes[0].note; - item.notes = new Array(); - } - item.DOI = item.DOI.replace(/^doi:\s+/i, ''); - item.complete(); - }); - translator.translate(); - - next(); - }, false, 'windows-1252'); - - - }; - - - if(detectWeb(doc, url) == "journalArticle") { - Zotero.debug("Single"); - var set = scrape(doc, {}); - second(set, function(){ - third(set, function(){ - Zotero.done(); - }); - }); - - } else { - var callbacks = [first, second, third]; - Zotero.Utilities.processAsync(sets, callbacks, function() {Zotero.done()}); - } - - } else { - throw ("Guest-mode saving from ScienceDirect temporarily disabled due to a site update -- an updated Zotero translator will be available soon"); - - var sets = []; - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (url.indexOf("_ob=PublicationURL") != -1) { - xpath = '//table[@class="resultRow"]/tbody/tr/td[2]/a'; - // not sure whether this case still exists - } else { - xpath = '//div[@class="font3"][@id="bodyMainResults"]/table/tbody/tr/td[2]/a'; - } - var rows = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_row; - while (next_row = rows.iterateNext()) { - var title = next_row.textContent; - var link = next_row.href; - if (!title.match(/PDF \(/) && !title.match(/Related Articles/)) items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - - } else { - articles = [url]; - } - if(articles.length == 0) { - Zotero.debug('no items'); - return; - } - - for each (article in articles) { - sets.push({article:article}); - } - - var unauthScrape = function(doc2) { - var item = new Zotero.Item("journalArticle"); - item.repository = "ScienceDirect"; - item.url = doc2.location.href; - var title = doc2.title.match(/^[^-]+\-([^:]+):(.*)$/); - item.title = Zotero.Utilities.trimInternal(title[2]); - item.publicationTitle = Zotero.Utilities.trimInternal(title[1]); - voliss = doc2.evaluate('//div[@class="pageText"][@id="sdBody"]/table/tbody/tr/td[1]', doc2, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (voliss.match(/Volume\s+\d+/)) item.volume = voliss.match(/Volume\s+(\d+)/)[1]; - if (voliss.match(/Issues?\s+[^,]+/)) item.issue = voliss.match(/Issues?\s+([^,]+)/)[1]; - if (voliss.match(/(J|F|M|A|S|O|N|D)\w+\s+\d{4}/)) item.date = voliss.match(/(J|F|M|A|S|O|N|D)\w+\s+\d{4}/)[0]; - if (voliss.match(/Pages?\s+[^,^\s]+/)) item.pages = voliss.match(/Pages?\s+([^,^\s]+)/)[1]; - /* - - FIXME: pulling full article content - - var abspath = '//div[@class="articleHeaderInner"][@id="articleHeader"]/div[@class="articleText"]/p'; - var absx = doc2.evaluate(abspath, doc2, nsResolver, XPathResult.ANY_TYPE, null); - var ab; - item.abstractNote = ""; - while (ab = absx.iterateNext()) { - item.abstractNote += Zotero.Utilities.trimInternal(ab.textContent) + " "; - } - if (item.abstractNote.substr(0, 7) == "Summary") { - item.abstractNote = item.abstractNote.substr(9); - } - */ - var tagpath = '//div[@class="articleText"]/p[strong[starts-with(text(), "Keywords:")]]'; - if (doc2.evaluate(tagpath, doc2, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - if (doc2.evaluate(tagpath, doc2, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(":")[1]) { - var tags = doc2.evaluate(tagpath, doc2, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(":")[1].split(";"); - for (var i in tags) { - item.tags.push(Zotero.Utilities.trimInternal(tags[i])); - } - } - } - /* - - FIXME: producing empty pages - - item.attachments.push({url:doc2.location.href, title:"ScienceDirect Snapshot", mimeType:"text/html"}); - - */ - - return item; - }; - - var first = function(set, next) { - - var article = set.article; - - Zotero.Utilities.processDocuments(article, function(doc2) { - - set.item = unauthScrape(doc2); - - next(); - }); - - }; - - var second = function(set, next) { - var item = set.item; - - Zotero.Utilities.HTTP.doGet(item.url, function(text) { - item.DOI = text.match(/>doi:([^<]*)/)[1]; - - try { - var aus = text.match(/<strong>\s+<p>.*<\/strong>/)[0].replace(/<sup>/g, "$").replace(/<\/sup>/g, "$"); - aus = aus.replace(/\$[^$]*\$/g, ""); - aus = aus.replace(/<a[^>]*>/g, "$").replace(/<\/a[^>]*>/g, "$"); - aus = aus.replace(/\$[^$]*\$/g, ""); - aus = Zotero.Utilities.cleanTags(aus); - aus = aus.split(/(,|and)/); - for (var a in aus) { - if (aus[a] != "," && aus[a] != "and" && aus[a].match(/\w+/)) { - item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.unescapeHTML(Zotero.Utilities.trimInternal(aus[a]), "author"))); - } - } - } catch(e) { - Zotero.debug("No Authors listed."); - } - item.complete(); - next(); - }); - }; - var callbacks = [first, second]; - if(detectWeb(doc, url) == "journalArticle") { - second({item:unauthScrape(doc)}, function() {Zotero.done()}); - } else { - Zotero.Utilities.processAsync(sets, callbacks, function() {Zotero.done()}); - } - - } - Zotero.wait(); -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.sciencedirect.com/science/article/pii/S0896627311004430#bib5", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "lastName": "Schaaf", - "firstName": "Christian P.", - "creatorType": "author" - }, - { - "lastName": "Zoghbi", - "firstName": "Huda Y.", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "ScienceDirect Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "title": "ScienceDirect Full Text PDF", - "mimeType": "application/pdf" - } - ], - "title": "Solving the Autism Puzzle a Few Pieces at a Time", - "publicationTitle": "Neuron", - "volume": "70", - "issue": "5", - "pages": "806-808", - "date": "June 9, 2011", - "ISBN": "0896-6273", - "ISSN": "0896-6273", - "DOI": "10.1016/j.neuron.2011.05.025", - "url": "http://www.sciencedirect.com/science/article/pii/S0896627311004430", - "abstractNote": "In this issue, a pair of studies (Levy et al. and Sanders et al.) identify several de novo copy-number variants that together account for 5%-8% of cases of simplex autism spectrum disorders. These studies suggest that several hundreds of loci are likely to contribute to the complex genetic heterogeneity of this group of disorders. An accompanying study in this issue (Gilman et al.), presents network analysis implicating these CNVs in neural processes related to synapse development, axon targeting, and neuron motility.", - "libraryCatalog": "ScienceDirect" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/ScientificCommons.js b/translators/ScientificCommons.js @@ -1,89 +0,0 @@ -{ - "translatorID":"19643c25-a4b2-480d-91b7-4e0b761fb6ad", - "translatorType":4, - "label":"ScientificCommons", - "creator":"Sean Takats", - "target":"^http://(?:en|de|www)\\.scientificcommons\\.org", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - var articleRe = /^http:\/\/(?:www|en|de)\.scientificcommons\.org\/([0-9]+)/; - var m = articleRe.exec(url); - - if(m) { - return "journalArticle"; - } else { - var frontRe = /^http:\/\/(?:www|en|de)\.scientificcommons\.org\/$/; - if(frontRe.test(url)) return "multiple"; - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var listElt = doc.evaluate('//div[@id="content_search_details"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (listElt) return "multiple"; - } - return false; -} - -function doWeb(doc, url) { - 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 articleRe = /^http:\/\/(?:www|en|de)\.scientificcommons\.org\/([0-9]+)/; - m = articleRe.exec(url); - var uris = new Array(); - - if(m) { - var idElt = doc.evaluate('//div[@id="publication_id"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (idElt) { - uris.push(host + "/export/ris/" + idElt.textContent); - } else { - return false; - } - } else { - var items = new Array(); - var listElts = doc.evaluate('//div[@class="content_element"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var id; - var link; - var title; - while (listElt = listElts.iterateNext()) { - id = doc.evaluate('./@id', listElt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - link = host + "/export/ris/" + id; - title = doc.evaluate('.//p[@class="title"]', listElt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - items[link] = Zotero.Utilities.trimInternal(title); - } - - items = Zotero.selectItems(items); - if(!items) return true; - - for(var uri in items) { - uris.push(uri); - } - } - - Zotero.Utilities.HTTP.doGet(uris, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - // add attachment support? - item.complete(); - }); - translator.translate(); - Zotero.done(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Scitation.js b/translators/Scitation.js @@ -1,79 +0,0 @@ -{ - "translatorID": "d75381ee-7d8d-4a3b-a595-b9190a06f43f", - "label": "Scitation", - "creator": "Eugeniy Mikhailov", - "target": "^https?://(?:www\\.)?scitation.aip.org", - "minVersion": "1.0.0b3.r1", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-12 12:50:18" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var multids = doc.evaluate('//input[@class="sr-checkbox" and @type="checkbox" and @name="SelectCheck"]',doc, nsResolver, XPathResult.ANY_TYPE, null); - var singid = doc.evaluate('//input[@type="hidden" and @name="SelectCheck"]',doc, nsResolver, XPathResult.ANY_TYPE, null); - - if (multids.iterateNext()){ - return "multiple"; - } else if (singid.iterateNext()){ - 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 multids = doc.evaluate('//input[@class="sr-checkbox" and @type="checkbox" and @name="SelectCheck"]',doc, nsResolver, XPathResult.ANY_TYPE, null); - var singids = doc.evaluate('//input[@type="hidden" and @name="SelectCheck"]',doc, nsResolver, XPathResult.ANY_TYPE, null); - var multid; - var singid; - var getstring = "/getabs/servlet/GetCitation?PrefType=ARTICLE&PrefAction=Add+Selected&fn=open_isi&source=scitation&downloadcitation=+Go+"; - if (multid = multids.iterateNext()){ - var titles = new Array(); - var ids = new Array(); - var items = new Array(); - var title; - do { - title = doc.evaluate('../../..//a[1]',multid, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - items[multid.value] = Zotero.Utilities.trimInternal(title.textContent); - } while (multid =multids.iterateNext()); - - items = Zotero.selectItems(items); - if(!items) return true; - - for(var i in items) { - getstring = getstring + "&SelectCheck=" + i; - } - } else if (singid = singids.iterateNext()){ - getstring = getstring + "&SelectCheck=" + singid.value; - } - - var hostRe = new RegExp("^(https?://[^/]+)/"); - var m = hostRe.exec(url); - var host = m[1]; - var newuri = host + getstring; - Zotero.Utilities.HTTP.doGet(newuri, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var doi = text.match(/[E|U]R\s{2}\-\s.*org\/(10\..*)\n/); - if (doi) item.DOI = doi[1]; - item.complete(); - }); - translator.translate(); - - Zotero.done(); - }); - Zotero.wait(); -} diff --git a/translators/Scopus.js b/translators/Scopus.js @@ -1,107 +0,0 @@ -{ - "translatorID": "a14ac3eb-64a0-4179-970c-92ecc2fec992", - "label": "Scopus", - "creator": "Michael Berkowitz, Rintze Zelle and Avram Lyon", - "target": "^http://www\\.scopus\\.com[^/]*", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-27 14:06:10" -} - -/* - Scopus Translator - Copyright (C) 2008-2011 Center for History and New Media - - 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 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 <http://www.gnu.org/licenses/>. - */ - -function detectWeb(doc, url) { - if (url.indexOf("/results/") !== -1) { - return "multiple"; - } else if (url.indexOf("/record/") !== -1) { - return "journalArticle"; - } -} - -function getEID(url) { - return url.match(/eid=([^&]+)/)[1]; -} - -function returnURL(eid) { - return 'http://www.scopus.com/citation/output.url?origin=recordpage&eid=' + eid + '&src=s&view=FullDocument&outputType=export'; -} - -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(); - if (detectWeb(doc, url) == "multiple") { - items = new Object(); - var boxes = doc.evaluate('//div[@id="resultsBody"]/table/tbody/tr[@class and (not(@id) or not(contains(@id,"previewabstractrow")))]/td[@class="fldtextPad"][1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var box; - while (box = boxes.iterateNext()) { - var link = doc.evaluate('.//a', box, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - Zotero.selectItems(items, function (items) { - for (var i in items) { - articles.push(returnURL(getEID(i))); - } - scrape(articles); - }); - } else { - articles = [returnURL(getEID(url))]; - scrape(articles); - } - Zotero.wait(); -} - -function scrape(articles) { - var article = articles.shift(); - Zotero.Utilities.doGet(article, function(text, obj) { - var stateKey = text.match(/<input[^>]*name="stateKey"[^>]*>/); - if (!stateKey) Zotero.debug("No stateKey"); - else stateKey = stateKey[0].match(/value="([^"]*)"/)[1]; - var eid = text.match(/<input[^>]*name="eid"[^>]*>/); - if (!eid) Zotero.debug("No eid"); - else eid = eid[0].match(/value="([^"]*)"/)[1]; - var get = 'http://www.scopus.com/citation/export.url'; - var post = 'origin=recordpage&sid=&src=s&stateKey=' + stateKey + '&eid=' + eid + '&sort=&exportFormat=RIS&view=CiteAbsKeyws&selectedCitationInformationItemsAll=on'; - var rislink = get + "?" + post; - Zotero.Utilities.HTTP.doGet(rislink, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - for (i in item.notes) { - if (item.notes[i]['note'].match(/Export Date:|Source:/)) - delete item.notes[i]; - } - delete item.url; - item.complete(); - }); - translator.translate(); - }, function() { - if (articles.length > 0) scrape(articles); - else Zotero.done(); - }); - }); -} diff --git a/translators/Slate.js b/translators/Slate.js @@ -1,139 +0,0 @@ -{ - "translatorID": "a667ae9e-186f-46d2-b824-d70064614668", - "label": "Slate", - "creator": "Sebastian Karcher", - "target": "^https?://(.*)slate\\.com", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-03 08:32:22" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'magazineArticle', -detect : FW.Xpath('//div[@id="article_main"]//h2[@class="title"]'), -title : FW.Xpath('//div[@id="article_top"]/h2[@class="title"]').text().trim(), -attachments : [{ url: FW.Url().remove(/\?(.*)/).remove(/pagenum\/all\//).append("pagenum\/all\/"), - title: "Slate Snapshot", - type: "text/html" }], -creators : FW.Xpath('//div[@id="article_top"]/span[@class="byline"]').text().remove(/By/).split(/\ and\ /).cleanAuthor("author"), -date : FW.Xpath('//div[@id="article_top"]/span[@class="dateline"]').text().remove(/\, at.*/).remove(/.*?day\,/).trim(), -abstractNote : FW.Xpath('//div[@id="article_top"]/h1[@class="subhead"]').text().trim(), -publicationTitle : "Slate" -}); - -/** Dialogues & Dispatches */ -FW.Scraper({ -itemType : 'website', -detect : FW.Xpath('//span[@class="multipart_byline"]'), -title : FW.Xpath('//head/title[1]').text().remove(/ -.*/).trim(), -attachments : [{ url: FW.Url(), - title: "Slate Snapshot", - type: "text/html" }], -creators : FW.Xpath('//div[@id="multipart1"]/span[@class="multipart_byline"]').text().remove(/To:.*/).remove(/.*?From:/).remove(/By/).cleanAuthor("author"), -date : FW.Xpath('//div[@id="multipart1"]/span[@class="multipart_date"]').text().remove(/\, at.*/).remove(/.*?day\,/).trim(), -publicationTitle : FW.Xpath('//div[@class="department_kicker"]/a/div').text().capitalizeTitle().prepend("Slate - "), -}); - - -/**Multiple */ -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Xpath('//table[@id="resultTable"]'), -choices : { - titles : FW.Xpath('//a[@class="srch_headline"]').text().trim(), - urls : FW.Xpath('//a[@class="srch_headline"]').key("href") -} -}); - - - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.slate.com/id/2297793/", - "items": [ - { - "itemType": "magazineArticle", - "creators": [ - { - "firstName": "Eric", - "lastName": "Posner", - "creatorType": "author" - }, - { - "firstName": "Adrian", - "lastName": "Vermeule", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.slate.com/id/2297793/pagenum/all/", - "title": "Slate Snapshot", - "type": "text/html" - } - ], - "url": "http://www.slate.com/id/2297793/", - "abstractNote": "Why there's nothing wrong with Obama ignoring some of his own legal advisers on Libya.", - "date": "June 27, 2011", - "publicationTitle": "Slate", - "title": "Libyan Legal Limbo", - "libraryCatalog": "Slate", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - }, - { - "type": "web", - "url": "http://www.slate.com/id/52653/entry/73301/", - "items": [ - { - "itemType": "website", - "creators": [ - { - "firstName": "Dahlia", - "lastName": "Lithwick", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.slate.com/id/52653/entry/73301/", - "title": "Slate Snapshot", - "type": "text/html" - } - ], - "url": "http://www.slate.com/id/52653/entry/73301/", - "date": "Jan. 19, 2000", - "publicationTitle": "Slate - Dispatches", - "title": "Supreme Court Dispatches (13)", - "libraryCatalog": "Slate", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - }, - { - "type": "web", - "url": "http://www.slate.com/default.aspx?id=3944&qt=supreme", - "items": "multiple" - } -] -/** END TEST CASES **/ diff --git a/translators/SlideShare.js b/translators/SlideShare.js @@ -1,75 +0,0 @@ -{ - "translatorID":"0cc8e259-106e-4793-8c26-6ec8114a9160", - "translatorType":4, - "label":"SlideShare", - "creator":"Michael Berkowitz", - "target":"http://www.slideshare.net/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":99, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.indexOf("search") != -1) { - return "multiple"; - } else if (doc.evaluate('//div[@class="slideProfile"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "presentation"; - } -} - -function doWeb(doc, url) { - var loggedin = false; - if (doc.evaluate('//a[@class="green_link"][text() = "logout"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - loggedin = true; - } - var shows = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//div[@class="search_list_box"]/div[@class="text_12"]/a', doc, null, XPathResult.ANY_TYPE, null); - var next_link; - while (next_link = links.iterateNext()) { - items[next_link.href] = Zotero.Utilities.trimInternal(next_link.textContent); - } - items = Zotero.selectItems(items); - if (!items) { - return true; - } - for (var i in items) { - shows.push(i); - } - } else { - shows = [url]; - } - Zotero.Utilities.processDocuments(shows, function(newDoc) { - var downloadable = true; - if (newDoc.evaluate('//p[@class="upload_p_left"][contains(text(), "Download not available")]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - downloadable = false; - } - var item = new Zotero.Item("presentation"); - item.title = newDoc.evaluate('//div[@class="slideProfile"]//h3', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var creator = newDoc.evaluate('//div[@class="slideProfile"]//p/a[@class="blue_link_normal"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.creators.push(Zotero.Utilities.cleanAuthor(creator, "author")); - var tags = newDoc.evaluate('//a[@class="grey_tags"]', newDoc, null, XPathResult.ANY_TYPE, null); - var next_tag; - while (next_tag = tags.iterateNext()) { - item.tags.push(Zotero.Utilities.trimInternal(next_tag.textContent)); - } - var newurl = newDoc.location.href; - item.url = newurl; - item.repository = "SlideShare"; - var pdfurl; - if (newurl.substr(-1) == "/") { - pdfurl = newurl + "download"; - } else { - pdfurl = newurl + "/download"; - } - if (loggedin) { - if (downloadable) { - item.attachments.push({url:pdfurl, title:"SlideShare Slide Show", mimeType:"application/pdf"}); - } - } - item.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/Spiegel Online.js b/translators/Spiegel Online.js @@ -1,221 +0,0 @@ -{ - "translatorID": "eef50507-c756-4081-86fd-700ae4ebf22e", - "label": "Spiegel Online", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.spiegel\\.de/", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-04-01 11:56:06" -} - -/* -Spiegel Online Translator -Copyright (C) 2011 Martin Meyerhoff - -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/>. -*/ - -/* -Test with the following URLs: -http://www.spiegel.de/suche/index.html?suchbegriff=AKW -http://www.spiegel.de/international/search/index.html?suchbegriff=Crisis -http://www.spiegel.de/international/topic/german_french_relations/ -http://www.spiegel.de/international/europe/0,1518,700530,00.html -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var spiegel_article_XPath = ".//div[@id='spArticleFunctions']"; - - if (doc.evaluate(spiegel_article_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/thema/)){ - Zotero.debug("multiple"); - return "multiple"; - } else if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/suche/)){ - Zotero.debug("multiple"); - return "multiple"; - } else if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/international\/search/)){ - Zotero.debug("multiple"); - return "multiple"; - } else if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/international\/topic/)){ - Zotero.debug("multiple"); - return "multiple"; - } -} - -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("newspaperArticle"); - newItem.url = doc.location.href; - - // This is for the title - - var title_xPath = ".//*[@id='spArticleColumn']/h2|.//*[@id='spArticleColumn ']/h2"; - if (doc.evaluate(title_xPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var title = doc.evaluate(title_xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = title; - } else { - var title = doc.evaluate('//title', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - title = title.split(" - ")[0]; - newItem.title = title; - } - - // Tags - var tags_xPath = '//meta[contains(@name, "keywords")]'; - var tags= doc.evaluate(tags_xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - tags = tags.split(/,/); - tags = tags.slice(5); // The first six 5 Tags are generic or section info. - if (tags[0] != "" ) { - for (var i in tags) { - tags[i] = tags[i].replace(/^\s*|\s*$/g, ''); - newItem.tags.push(tags[i]); - } - } - - // Author - var author_XPath1 = ".//p[contains(@class, 'spAuthor')]"; // Most of the time, the author has its own tag. Easy Case, really. - var author_XPath2 = ".//*[@id='spIntroTeaser']/strong/i"; // Sometimes, though, the author is in italics in the teaser. - if (doc.evaluate(author_XPath1, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate(author_XPath1, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - Zotero.debug(author); - } else if (doc.evaluate(author_XPath2, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate(author_XPath2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - Zotero.debug(author); - } else { - author = ""; - } - - author = author.replace(/^\s*By\s|^\s*Von\s|\s*$/g, ''); // remove whitespace around the author and the "Von "at the beginning - if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/spiegel/)){ // Spiegel Online and the Spiegel Archive have different formatting for the author line - author = author.split(/\sund\s|\su\.\s|\;\s|\sand\s/); - for (var i in author) { - author[i] = author[i].replace(/(.*),\s(.*)/, '$2 $1'); - } - } else { - - author = author.replace(/,\s|in\s\S*$/, ""); //remove ", location" or "in location" - author = author.split(/\sund\s|\su\.\s|\,\s|\sand\s/); - } - for (var i in author) { - if (author[i].match(/\s/)) { // only names that contain a space! - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - - // Section - var section_xPath = ".//ul[contains(@id, 'spChannel')]/li/ul/li/a[contains(@class, 'spActive')]"; - if (doc.evaluate(section_xPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var section = doc.evaluate(section_xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.section = section; - } - - if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/spiegel/)){ - var printurl_xPath = ".//div[@id='spArticleFunctions']/ul/li[1]/a"; - var printurl = doc.evaluate(printurl_xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - Zotero.debug(printurl); - newItem.attachments.push({url:printurl, title:doc.title, mimeType:"application/pdf"}); - } else { - // Attachment. Difficult. They want something inserted into the URL. - var printurl = doc.location.href; - printurl = printurl.replace(/(\d+\,\d+\.html.*$)/, 'druck-$1'); //done! - newItem.attachments.push({url:printurl, title:doc.title, mimeType:"text/html"}); - } - - - - // Summary - var summary_xPath = ".//p[@id='spIntroTeaser']"; - if (doc.evaluate(summary_xPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var summary= doc.evaluate(summary_xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = Zotero.Utilities.trim(summary); - } - - // Date - sometimes xpath1 doesn't yield anything. Fortunately, there's another possibility... - var date1_xPath = ".//h5[contains(@id, 'ShortDate')]"; - var date2_xPath = "//meta[@name='date']"; - if (doc.evaluate(date1_xPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var date= doc.evaluate(date1_xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (date.match('/')) { - date = date.replace(/(\d\d)\/(\d\d)\/(\d\d\d\d)/, "$2.$1.$3"); - } - } else if (doc.evaluate(date2_xPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var date= doc.evaluate(date2_xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - date=date.replace(/(\d\d\d\d)-(\d\d)-(\d\d)/, '$3.$2.$1'); - } - newItem.date = Zotero.Utilities.trim(date); - - if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/spiegel/)){ - newItem.publicationTitle = "Der Spiegel"; - }else { - newItem.publicationTitle = "Spiegel Online"; - } - - - newItem.complete() -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/thema/)){ - var titles = doc.evaluate(".//*[@id='spTeaserColumn']/div/h3/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - } else if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/suche/)){ - var titles = doc.evaluate(".//*[@id='spTeaserColumn']/div/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - } else if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/international\/search/)){ - var titles = doc.evaluate("//*[@id='spTeaserColumn']/div/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - } else if (doc.location.href.match(/^http\:\/\/www\.spiegel\.de\/international\/topic/)){ - var titles = doc.evaluate(".//*[@id='spTeaserColumn']/div/h3/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - var next_title; - while (next_title = titles.iterateNext()) { - //The search searches also manager-magazin.de, which won't work - if (next_title.textContent != "mehr..." && next_title.href.match(/^http:\/\/www\.spiegel\.de\//) ) { - items[next_title.href] = Zotero.Utilities.trim(next_title.textContent); - } - } - - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/SpringerLink.js b/translators/SpringerLink.js @@ -1,105 +0,0 @@ -{ - "translatorID":"f8765470-5ace-4a31-b4bd-4327b960ccd", - "translatorType":4, - "label":"SpringerLink", - "creator":"Simon Kornblith and Michael Berkowitz", - "target":"https?://(www\\.)*springerlink\\.com|springerlink.metapress.com[^/]*/content/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-04-12 18:40:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if((doc.title == "SpringerLink - All Search Results") || (doc.title == "SpringerLink - Journal Issue")) { - return "multiple"; - } else if(doc.title == "SpringerLink - Book Chapter") { - return "bookSection"; - } else if (doc.title == "SpringerLink - Book") { - return "book"; - } else if (doc.title == "SpringerLink - Journal Article") { - return "journalArticle"; - } else if(doc.evaluate('//a[text() = "RIS"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - 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 m = url.match(/https?:\/\/[^\/]+/); - var host = m[0]; - - if(detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.title == "SpringerLink - Journal Issue") { - var items = Zotero.Utilities.getItemArray(doc, doc.getElementsByTagName("table")[8], '/content/[^/]+/\\?p=[^&]+&pi='); - } else { - var results = doc.evaluate('//div[@class="listItemName"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - items[result.href] = Zotero.Utilities.trimInternal(result.textContent); - } - } - items = Zotero.selectItems(items); - if(!items) return true; - - var urls = new Array(); - for(var url in items) { - urls.push(url); - } - } else { - var urls = [url]; - } - - var RIS = new Array(); - - for each(var item in urls) { - var m = item.match(/\/content\/([^/]+)/); - RIS.push(host+"/export.mpx?code="+m[1]+"&mode=ris"); - } - Zotero.Utilities.HTTP.doGet(RIS, function(text) { - // load translator for RIS - text = text.replace("CHAPTER", "CHAP"); - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var url = urls.shift(); - var m = url.match(/https?:\/\/[^\/]+\/content\/[^\/]+\/?/); - item.attachments = [ - {url:url, title:"SpringerLink Snapshot", mimeType:"text/html"}, - {url:m[0]+"fulltext.pdf", title:"SpringerLink Full Text PDF", mimeType:"application/pdf"} - ]; - - var oldCreators = item.creators; - item.creators = new Array(); - for each (var creator in oldCreators) { - if (creator['lastName'] + creator['firstName'] != "") { - var fName = creator['firstName'] ? creator['firstName'] : ""; - item.creators.push({firstName:Zotero.Utilities.trimInternal(fName), lastName:creator['lastName'], creatorType:"author"}); - } - } - - // fix incorrect chapters - if(item.publicationTitle && item.itemType == "book") item.title = item.publicationTitle; - - // fix "V" in volume - if(item.volume) { - item.volume = item.volume.replace("V", ""); - } - item.complete(); - }); - translator.translate(); - }, function() { Zotero.done() }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Stuff.co.nz.js b/translators/Stuff.co.nz.js @@ -1,469 +0,0 @@ -{ - "translatorID":"631ff0c7-2e64-4279-a9c9-ad9518d40f2b", - "label":"Stuff.co.nz", - "creator":"Sopheak Hean (University of Waikato, Faculty of Education)", - "target":"^http://(www\\.)?stuff\\.co\\.nz/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-08-23 00:34:34" -} - -/* - Stuff.co.nz Translator- Parses Stuff.co.nz articles and creates Zotero-based metadata - Copyright (C) 2010 Sopheak Hean, University of Waikato, Faculty of Education - - 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/>. -*/ - -/* Stuff.co.nz does not have an ISSN because it is not a newspaper publisher. Stuff.co.nz is a collection of newspaper articles from around the country*/ - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - var definePath = '//div[@class="blog_content"]'; - var XpathObject = doc.evaluate(definePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); -if (XpathObject){ - return "blogPost"; - } - - else { - var definePath = '//div[@class="story_landing"]'; - var XpathObject = doc.evaluate(definePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (XpathObject){ - return "newspaperArticle"; - } - } - -} - -function myUpperCaseFunction(input){ - /*Will define one later*/ -} - - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var url = doc.location.href; - var splitIntoArray; - var fullName=""; - var emptyString =" "; - var firstName; var lastName; - /*==========================Blog Post===========================*/ - - if (detectWeb(doc, url) =="blogPost"){ - - var newItem = new Zotero.Item('blogPost'); - newItem.url = doc.location.href; - //newItem.title = "No Title Found"; - newItem.publicationTitle = "Stuff.co.nz"; - newItem.language = "English"; - - //Get Author - try { /*Try and Catch if encounter erro */ - - var blogAuthor = "//div[@id='left_col']/span"; - var blogAuthorObject = doc.evaluate(blogAuthor, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (blogAuthorObject) { - - if (blogAuthorObject.textContent.replace(/\s*/g,'') ==""){ - newItem.creators =blogAuthorObject.textContent.replace(/\s*/g,''); - } - - else{ - blogAuthorObject = blogAuthorObject.textContent; - if(blogAuthorObject.match(/[\s\n\r\t]+-[\s\n\r\t]+[a-zA-Z\s\n\r\t]*/g)){ - blogAuthorObject = blogAuthorObject.replace(/([\s\n\r\t]+-[\s\n\r\t]+[a-zA-Z\s\n\r\t]*)/g, '').replace(/\bBy \b/g,''); - splitIntoArray = blogAuthorObject.split (" "); - for (var i = 0; i < splitIntoArray.length; i++){ - firstName = splitIntoArray[i].substring(0,1).toUpperCase(); - lastName = splitIntoArray[i].substring(1).toLowerCase(); - fullName += firstName + lastName + emptyString; - - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(fullName , "author")); - } - - else { - splitIntoArray = blogAuthorObject.replace(/\bBy \b/g,'').split (" "); - for (var i = 0; i < splitIntoArray.length; i++){ - firstName = splitIntoArray[i].substring(0,1).toUpperCase(); - lastName = splitIntoArray[i].substring(1).toLowerCase(); - fullName += firstName + lastName + emptyString; - - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(fullName , "author")); } - } - } - } catch (err) { - newItem.creators ="error"; - - } - - //Title of the Article - var getBlogTitle = "//span[@class='hbox_top_title headlines_title']/a"; - var getBlogTitleObject = doc.evaluate(getBlogTitle, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (getBlogTitleObject){ - newItem.blogTitle =getBlogTitleObject.textContent.replace(/\s+\bHeadlines\b/g, ''); - } - newItem.shortTitle = doShortTitle(doc,url); - newItem.title= doTitle(doc, url); - newItem.date = doDate(doc, url); - newItem.abstractNote = doAbstract(doc, url); - newItem.websiteType = "Newspaper"; - newItem.attachments.push({url:url, title:"Stuff.co.nz Snapshot", mimeType:"text/html"}); - newItem.complete(); - } - - - - /* ======================Newspaper Article========================*/ - - else if (detectWeb(doc, url) =="newspaperArticle"){ - - var newItem = new Zotero.Item('newspaperArticle'); - newItem.url = doc.location.href; - //newItem.title = "No Title Found"; - - //Get extended publisher if there is any then replace with stuff.co.nz - var myPublisher = '//span[@class="storycredit"]'; - - var myPublisherObject = doc.evaluate(myPublisher , doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (myPublisherObject) { - var realPublisher = myPublisherObject.textContent; - if (realPublisher.match(/\bBy[\s\n\r\t]+[a-zA-Z\s\r\t\n]*-[\s\n\r\t]*/g)){ - realPublisher = realPublisher.replace (/\bBy[\s\n\r\t]+[a-zA-Z\s\r\t\n]*-[\s\n\r\t]*/g, '').replace(/^\s*|\s*$/g, ''); - newItem.publicationTitle = realPublisher; - } else { - newItem.publicationTitle = "Stuff.co.nz"; - } - - } else { - newItem.publicationTitle = "Stuff.co.nz"; - } - - newItem.language = "English"; - - //Short Title - newItem.shortTitle = doShortTitle(doc,url); - - - //get Abstract - newItem.abstractNote = doAbstract(doc, url); - var authorXPath = '//span[@class="storycredit"]'; - - var authorXPathObject = doc.evaluate(authorXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (authorXPathObject){ - var authorArray = new Array("NZPA", "The Press", "The Dominion Post"); - authorXPathObject = authorXPathObject.textContent; - - if(authorXPathObject.match(/[\s\n\r\t]+-[\s\n\r\t]+\b[a-zA-Z\s\n\r\t]*|^\s+\bBy\s*/g)){ - authorXPathObject = authorXPathObject.replace(/([\s\n\r\t]+-[\s\n\r\t]+\b[a-zA-Z\s\n\r\t]*)|\b.co.nz|\b.com|(-[a-zA-Z0-9]*)/g, ''); - var authorString = authorXPathObject.replace(/^\s+\bBy\s*|^\s+\bBY\s*/g, ''); - - if (authorString.match(/\W\band\W+/g)){ - authorTemp = authorString.replace(/\W\band\W+/g, ', '); - authorArray = authorTemp.split(", "); - - } else if (!authorString.match(/\W\band\W+/g)) - { - authorArray = authorString.toLowerCase(); - } - if( authorArray instanceof Array ) { - for (var i in authorArray){ - splitIntoArray = authorArray[i].split (" "); - for (var i = 0; i < splitIntoArray.length; i++){ - firstName = splitIntoArray[i].substring(0,1).toUpperCase(); - lastName = splitIntoArray[i].substring(1).toLowerCase(); - fullName += firstChar + lastChar + emptyString; - - - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(JoinString, "author")); - - } - - } else { - - - if (authorString.match(/\W\bof\W+/g)){ - authorTemp = authorString.replace (/\W\bof\W(.*)/g, ''); - splitIntoArray = authorTemp.split (" "); - for (var i = 0; i < splitIntoArray.length; i++){ - firstName = splitIntoArray[i].substring(0,1).toUpperCase(); - lastName = splitIntoArray[i].substring(1).toLowerCase(); - fullName += firstChar + lastChar + emptyString; - - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(JoinString, "author")); - - - } else { - - splitIntoArray = authorArray.split (" "); - for (var i = 0; i < splitIntoArray.length; i++){ - firstName = splitIntoArray[i].substring(0,1).toUpperCase(); - lastName = splitIntoArray[i].substring(1).toLowerCase(); - fullName += firstName+ lastName + emptyString; - - - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(fullName, "author")); - } - - } - } else { - - if(authorXPathObject.match(/[\s\n\r]+/g)){ - - authorXPathObject = authorXPathObject.replace(/^\s*|\s*$/g, '').replace(/\s+/g, '-'); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorXPathObject, "author")); - } - else { newItem.creators.push(Zotero.Utilities.cleanAuthor(authorXPathObject , "author"));} - - } - - } else{ - newItem.creators =""; - } - - //Title of the Article - newItem.title= doTitle(doc, url); - - - //Section of the Article - - var current = '//li/a[@class="current"]'; - var currentObject = doc.evaluate(current, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (currentObject){ - currentObject = currentObject.textContent; - - var articleSection = '//li[@class="mid_nav_item"]/a'; - var articleSectionObject = doc.evaluate(articleSection , doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (articleSectionObject){ - articleSectionObject = articleSectionObject .textContent; - switch (articleSectionObject){ - case "National": - case "Business": - case "Sport": - case "Politics": - newItem.place= "New Zealand"; - newItem.section = currentObject; - break; - - case "World": - newItem.place= "World"; - newItem.section = currentObject; break; - - default: - newItem.section = articleSectionObject;break; - } - } - var SectionType = '//li[@class="current_nav_item"]/a'; - var SectionTypeObject = doc.evaluate(SectionType, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (SectionType){ - - SectionTypeObject = SectionTypeObject.textContent; - switch (SectionTypeObject) { - case "National": - case "Crime": - case "Education": - case "Health": - case "Politics": - case "Environment": - case "Business": - - newItem.place= "New Zealand"; - newItem.section = currentObject; break; - - case "Opinion": - case "Rugby": - case "Soccer": - case "Cricket": - case "Basketball": - case "Fishing": - case "League": - case "Scoreboard": - case "Football": - case "Golf": - case "Motorsport": - case "Netball": - case "Tennis": - - newItem.section ="Sport"; break; - default: - newItem.section = SectionTypeObject; break; - } - } - } - else { - var SectionType = '//li[@class="current_nav_item"]/a'; - var SectionTypeObject = doc.evaluate(SectionType, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (SectionType){ - - SectionTypeObject = SectionTypeObject.textContent; - - switch (SectionTypeObject) { - case "National": - case "Crime": - case "Education": - case "Health": - case "Politics": - case "Environment": - case "Business": - newItem.place= "New Zealand"; - newItem.section = SectionTypeObject; break; - - default: - newItem.section =SectionTypeObject; break; - } - - } - } - //Snapshot of the web page. - newItem.attachments.push({url:url, title:"Stuff.co.nz Snapshot", - mimeType:"text/html"}); - - //Call Do date function to make it cleaner in scape. This way things are easier to follow. - newItem.date = doDate(doc,url); - newItem.complete(); - - } - -} - - -function doShortTitle(doc, url){ - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var shortTitle=""; - var subTitle = '//div[@id="left_col"]/h2'; - var subTitleObject = doc.evaluate(subTitle, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (subTitleObject){ - shortTitle= subTitleObject.textContent.replace(/^\s*|\s*$/g, ''); - return shortTitle; - } else { - return shortTitle; - } - -} - -function doAbstract(doc, url){ - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var abstractString=""; - var a= "//meta[@name='description']"; - var abs= doc.evaluate(a, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abs){ - abstractString = abs.content; - return abstractString; - - } - return abstractString; - -} - -function doTitle(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var temp=""; - var getTitle = '//div[@id="left_col"]/h1'; - var getTitleObject = doc.evaluate(getTitle, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (getTitleObject) { - var temp=getTitleObject.textContent.replace(/^\s*|\s*$/g, ''); - return temp; - } - return temp; -} - -function doDate(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dateXpath = "//div[@id='toolbox']/div[3]"; - var dateXpathObject = doc.evaluate(dateXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - try { - if (dateXpathObject){ - var storeDateValue = dateXpathObject.textContent.replace(/\b(Last updated )\d{0,9}:\d{0,9} /g,''); - - var ArrayDate = storeDateValue.split('/'); - var emptyString = " "; - var comma = ", "; - var DateString; - var ArrayMonth = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "July", "Aug", "Sep", "Oct", "Nov", "Dec"); - var ArrayNumber = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"); - for (var i=0; i <ArrayNumber.length; i++){ - if(ArrayDate[1] ==ArrayNumber[i]) { - - ArrayNumber[i] = ArrayMonth[i]; - var month = ArrayNumber[i] + emptyString; - } - DateString = month + ArrayDate[0] + comma + ArrayDate[2]; - - } - return DateString; - } else { - DateString = ""; - return DateString; - } - }catch (err) { - - DateString = ""; - } - return DateString; -} - - -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(); - - if (detectWeb(doc, url) == "newspaperArticle") { - var articles = [url]; - - }else if (detectWeb(doc, url) == "blogPost") { - var articles = [url]; - - } - - - //Zotero.debug(articles); - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - -} - diff --git a/translators/Sudoc.js b/translators/Sudoc.js @@ -1,288 +0,0 @@ -{ - "translatorID":"1b9ed730-69c7-40b0-8a06-517a89a3a278", - "translatorType":4, - "label":"Sudoc", - "creator":"Sean Takats, Michael Berkowitz, Sylvain Machefert", - "target":"^http://(www|corail)\\.sudoc\\.abes\\.fr", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2010-09-03 14:40:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var multxpath = "//span[@class='tab1']"; - if (elt = doc.evaluate(multxpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var content = elt.textContent; - if ( (content == "Liste des résultats") || (content == "shortlist") ) - { - return "multiple"; - } - else if ( (content == "Notice détaillée") || (content == "title data") ) - { - var xpathimage = "//span[@class='rec_mat_long']/img"; - if (elt = doc.evaluate(xpathimage, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - { - var type = elt.getAttribute('src'); - if (type.indexOf('article.') > 0) - { - return "journalArticle"; - } - else if (type.indexOf('audiovisual.') > 0) - { - return "film"; - } - else if (type.indexOf('book.') > 0) - { - return "book"; - } - else if (type.indexOf('handwriting.') > 0) - { - return "manuscript"; - } - else if (type.indexOf('sons.') > 0) - { - return "audioRecording"; - } - else if (type.indexOf('sound.') > 0) - { - return "audioRecording"; - } - else if (type.indexOf('thesis.') > 0) - { - return "thesis"; - } - else if (type.indexOf('map.') > 0) - { - return "map"; - } - } - return "book"; - } - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var zXpath = '//span[@class="Z3988"]'; - var eltCoins = doc.evaluate(zXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - if (eltCoins = doc.evaluate(zXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) - { - var coins = eltCoins.getAttribute('title'); - - var newItem = new Zotero.Item(); - newItem.repository = false; // do not save repository - if(Zotero.Utilities.parseContextObject(coins, newItem)) - { - // ppn is the national identifier, used to make a permalink on the record - var ppn = ""; - if (newItem.title) - { - newItem.itemType = detectWeb(doc, url); - // The number of pages uses COinS field : rft.pages, even if the information - // concerns the number of pages. - if (newItem.pages != undefined) - { - newItem.numPages = newItem.pages; - - var m = newItem.pages.match(/(\d*) vol\. \((.*) [pf]\./); - if (m) - { - newItem.numberOfVolumes = m[1]; - newItem.numPages = m[2]; - } - } - - // We need to correct some informations where COinS is wrong - var rowXpath = '//tr[td[@class="rec_lable"]]'; - var tableRows = doc.evaluate(rowXpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var tableRow; - - while (tableRow = tableRows.iterateNext()) - { - var field = doc.evaluate('./td[1]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var value = doc.evaluate('./td[2]', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - field = Zotero.Utilities.superCleanString(field); - field = field.replace(/(\(s\))?\s*:\s*$/, ""); - - // With COins, only one author is taken, changed. - if (field.substr(0,6) == "Auteur" || field.substr(0,6) == "Author") - { - var authors = doc.evaluate('./td[2]/div', tableRow, nsResolver, XPathResult.ANY_TYPE, null); - newItem.creators = new Array(); - while (author = authors.iterateNext()) - { - var authorText = author.textContent; - - authorFunction = authorText.split(". ")[1]; - authorText = authorText.split(". ")[0]; - if (authorFunction) - { - authorFunction = Zotero.Utilities.superCleanString(authorFunction); - } - var zoteroFunction = ''; - - // TODO : Add other authotiry types - if (authorFunction == 'Traduction') - { - zoteroFunction = 'translator'; - } - else if ( (newItem.itemType == "thesis") && (authorFunction != 'Auteur') ) - { - zoteroFunction = "contributor"; - } - else - { - zoteroFunction = 'author'; - } - - // We need to remove the author dates from reference - authorText = authorText.replace(/ \(.{4}\-.{4}\)$/, "") - if (authorFunction == "Université de soutenance") - { - // If the author function is "université de soutenance" it means that this author has to be in "university" field - newItem.university = authorText; - } - else - { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorText, zoteroFunction, true)); - } - } - } - // The serie isn't in COinS - else if (field.substr(0,5) == "Serie" || field.substr(0,10) == "Collection") - { - newItem.series = value; - } - // When there's a subtitle, only main title is used ! - else if (field == "Titre" || field == "Title") - { - var title = ''; - var titles = doc.evaluate('./td[2]/div/span', tableRow, nsResolver, XPathResult.ANY_TYPE, null); - while (partTitle = titles.iterateNext()) - { - partTitle = partTitle.textContent; - partTitle = partTitle.replace(/(\[[^\]]+\] ?)/g,""); - title = title + partTitle; - } - // Remove the author - title = title.split(" / ")[0]; - newItem.title = title; - } - // Language not defined in COinS - else if ( (field == "Langue") || (field == "Language") ) - { - newItem.language = value; - } - else if ( (field == "Résumé") || (field == "Abstract") ) - { - if (newItem.abstractNote) - { - newItem.abstractNote = newItem.abstractNote + " " + value; - } - else - { - newItem.abstractNote = value; - } - - } - else if (field == "Notes") - { - if (newItem.abstractNote) - { - newItem.abstractNote = newItem.abstractNote + " " + value; - } - else - { - newItem.abstractNote = value; - } - } - else if ( (field == "Sujets" ) || (field == "Subjects") ) - { - var subjects = doc.evaluate('./td[2]/div', tableRow, nsResolver, XPathResult.ANY_TYPE, null); - var subject_out = ""; - - while (subject = subjects.iterateNext()) - { - var subject_content = subject.textContent; - subject_content = subject_content.replace(/^\s*/, ""); - subject_content = subject_content.replace(/\s*$/, ""); - if (subject_content != "") - { - newItem.tags.push(Zotero.Utilities.trimInternal(subject_content)); - } - } - } - else if ( (field == "Thèse") || (field == "Dissertation") ) - { - var thesisType = value.split(/ ?:/)[0]; - newItem.type = thesisType; - } - else if ( (field == "Numéro\u00A0de\u00A0notice") || (field == "Record\u00A0number") ) - { - ppn = value; - } - } - - // We store the original place of the record, using its ppn - newItem.attachments = [{url:'http://www.sudoc.abes.fr/DB=2.1/SRCH?IKT=12&TRM=' + ppn, title:"Notice sudoc", mimeType:"text/html", snapshot:false}]; - newItem.complete(); - } - } - } -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var type = detectWeb(doc, url); - if (type == "multiple") - { - // On va lister les titres - var newUrl = doc.evaluate('//base/@href', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var xpath = "//table[@summary='short title presentation']/tbody/tr//td[@class='rec_title']"; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = elmts.iterateNext(); - var links = new Array(); - var availableItems = new Array(); - - var i = 0; - do - { - var link = doc.evaluate(".//a/@href", elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - var searchTitle = doc.evaluate(".//a", elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - availableItems[i] = searchTitle ; - links[i] = link; - i++; - } while (elmt = elmts.iterateNext()); - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - var uris = new Array(); - for(var i in items) { - uris.push(newUrl + links[i]); - } - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, - function() { Zotero.done(); }, null); - Zotero.wait(); - } - else if (type != "") - { - scrape(doc, url); - } -} diff --git a/translators/Sueddeutsche.de.js b/translators/Sueddeutsche.de.js @@ -1,185 +0,0 @@ -{ - "translatorID": "2e4ebd19-83ab-4a56-8fa6-bcd52b576470", - "label": "Sueddeutsche.de", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.sueddeutsche\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-26 15:02:54" -} - -/* -Sueddeutsche.de Translator -Copyright (C) 2011 Martin Meyerhoff - -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 one has the search function on a different host, so I cannot scan the search results. A multiple option, though, is given for the page itself. -Test here: -http://www.sueddeutsche.de/politik -http://www.sueddeutsche.de/thema/Krieg_in_Libyen -http://www.sueddeutsche.de/muenchen -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var SZ_ArticleTitle_XPath = ".//h1[@id='articleTitle']"; - var SZ_Multiple_XPath = ".//*[contains(@class, 'maincolumn')]/ol/li/a|.//*[contains(@class, 'maincolumn')]/ol/li/ul/li/a"; - - if (doc.evaluate(SZ_ArticleTitle_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.evaluate(SZ_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - return "multiple"; - } -} - - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var title_XPath =".//h1[@id='articleTitle']"; - // This is clumsy, but it excludes image galleries, which link fine but then are not articles. The closing bracket is right at the end of scrape(). - if (doc.evaluate(title_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - - - var newItem = new Zotero.Item("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the title! - - var title_XPath = '//meta[contains(@property, "og:title")]'; - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.title = Zotero.Utilities.trim(title.replace(/\s?–\s?/, ": ")); - - // Author. This is tricky, the SZ uses the author field for whatever they like. Sometimes, there is no author. - - var author_XPath = './/span[contains(@class, "hcard fn")]'; - - // If there is an author, use it. Otherwise: "" - if (doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - author = author.replace(/^Von\s/, ''); - } else { - var author = ""; - } - - // One case i've seen: A full sentence as the "author", with no author in it. "" - if (author.match(/\.$/)){ - author = ""; - } - - // For multiple Authors, the SZ uses comma, und and u. separate em, and put them into an array of strings. - author = author.split(/\sund\s|\su\.\s|\,\s/); - Zotero.debug(author); - for (var i in author) { - if (author[i].match(/\s/)) { // only names that contain a space! - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - - // Now the summary - var summary_XPath = '//meta[contains(@property, "og:description")]'; - var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.abstractNote = summary; - - // Date - var date_XPath = ".//*[@class='updated']/*[@class='value']"; - var date = doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - date = date.split(/\s/)[0]; - newItem.date = date; - - // Section - var section_XPath = "//meta[contains(@name, 'keywords')]"; - var section= doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - section = section.split(",")[0]; - newItem.section = section; - - // Tags - var tags_XPath = ".//ul[@class='themen']" - var tags= doc.evaluate(tags_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - tags = tags.replace(/^\s*|\s*$/g, ''); - tags = tags.split(/\n/); - for (var i in tags) { - tags[i] = tags[i].replace(/^\s*|\s*$/g, ''); - newItem.tags.push(tags[i]); - } - - // Publikation - newItem.publicationTitle = "sueddeutsche.de" - - // Attachment. Difficult. They want something inserted into the URL. - - var printurl = doc.location.href; - printurl = printurl.replace(/(.*\/)(.*$)/, '$12.220/$2'); //done! - Zotero.debug(printurl); - newItem.attachments.push({url:printurl, title:doc.title, mimeType:"text/html"}); - - newItem.complete() - } - -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate(".//*[contains(@class, 'maincolumn')]/ol/li/a|.//*[contains(@class, 'maincolumn')]/ol/li/ul/li/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.href.match(/^http\:\/\/www\.sueddeutsche\.de/)) { - items[next_title.href] = Zotero.Utilities.trim(next_title.textContent); - items[next_title.href] =items[next_title.href].replace(/\n/, ''); - items[next_title.href] =items[next_title.href].replace(/\s–|—/g, ': '); - items[next_title.href] =items[next_title.href].replace(/\s+/g, ' '); - } - } - items = Zotero.selectItems(items); - Zotero.debug(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} - diff --git a/translators/Sydney Morning Herald.js b/translators/Sydney Morning Herald.js @@ -1,84 +0,0 @@ -{ - "translatorID":"19120a71-17a8-4629-936a-ccdf899b9861", - "translatorType":4, - "label":"Sydney Morning Herald", - "creator":"Michael Berkowitz", - "target":"^http://(www|search).smh.com.au/(news|siteSearch|articles)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":99, - "inRepository":true, - "lastUpdated":"2007-08-14 22:15:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.indexOf("news") != -1 || doc.location.href.indexOf("articles") != -1) { - return "newspaperArticle"; - } else if (doc.location.href.indexOf("siteSearch") != -1) { - return "multiple"; - } -} - -function regexMeta(str, item) { - var re = /name=\"(.*)\"\s+content=\"(.*)\"\s+\/>/; - var stuff = str.match(re); - if (stuff[1] == "byline") { - authors = stuff[2].split(" and "); - for (var i = 0 ; i < authors.length ; i++) { - item.creators.push(Zotero.Utilities.cleanAuthor(authors[i].split(" in ")[0], "author")); - } - } else if (stuff[1] == "sitecategories") { - item.section = stuff[2]; - } else if (stuff[1] == "publishdate") { - item.date = stuff[2].split(/\s+/)[0]; - } -} - -function doWeb(doc, url) { - var articles = new Array(); - if (doc.location.href.indexOf("siteSearch") != -1) { - var items = new Array(); - var xpath = '//div[@class="searchresults"]/dl/dt/a'; - var stuff = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var thing = stuff.iterateNext(); - while (thing) { - items[thing.href] = thing.textContent; - thing = stuff.iterateNext(); - } - - items = Zotero.selectItems(items); - - for (var i in items) { - articles.push(i); - } - } else { - articles.push(url); - } - for (var i = 0 ; i < articles.length ; i++) { - var url = articles[i] - Zotero.Utilities.HTTP.doGet(url, function(text) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "Sydney Morning Herald"; - newItem.url = url; - newItem.ISSN = "0312-6315"; - //title - var t = /<HEADLINE>(.*)<\/HEADLINE>/; - newItem.title = Zotero.Utilities.unescapeHTML(Zotero.Utilities.capitalizeTitle(text.match(t)[1])); - //hooray for real meta tags! - var meta = /<meta\s+name=(.*)\/>/g; - var metaTags = text.match(meta); - for (var i = 0 ; i <metaTags.length ; i++) { - regexMeta(metaTags[i], newItem); - } - //abstract - var abs = /meta name=\"Description\" content=\"([^\"]*)\"/; - var abstract = text.match(abs)[1].split(/\s+/); - abstract[0] = abstract[0][0] + abstract[0].substr(1).toLowerCase(); - abstract = abstract.join(" "); - newItem.abstractNote = Zotero.Utilities.unescapeHTML(abstract.substr(0, abstract.length - 3)); - newItem.complete(); - Zotero.done(); - }, function() {}); - } - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/TV by the Numbers.js b/translators/TV by the Numbers.js @@ -1,138 +0,0 @@ -{ - "translatorID":"180a62bf-efdd-4d38-8d85-8971af04dd85", - "label":"TV by the Numbers", - "creator":"odie5533", - "target":"^http://tvbythenumbers\\.com", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"0", - "translatorType":4, - "lastUpdated":"2010-08-04 03:31:19" -} - -/* - TV by the Numbers - translator for Zotero - Copyright (C) 2010 odie5533 - - 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 supports saving a snapshot of a single post and saving - the citation of many posts at once without visiting each post. Thus, it does - not save a snapshot when multiple citations are to be saved. -*/ - - -PUB_TITLE = "TV by the Numbers"; -XPATH_TITLE = "//title"; -XPATH_PAGES = null; -XPATH_DATE = "substring-after(substring-before(string(//p[@class='posted_on']),' by '), 'on ')"; -RE_DATE = /(.*)/; -XPATH_AUTHORS = "substring-after(string(//p[@class='posted_on']),' by ')"; -RE_AUTHORS = /(.*)/; - -function detectWeb(doc, url) { - /* site has lots of garbage, check we're on the right doc */ - if (!xpath_string(doc, doc, XPATH_TITLE)) - return; - var posts = doc.evaluate("count(//div[@class='post-alt blog'])", doc, null, - XPathResult.NUMBER_TYPE, null).numberValue; - if (posts == 1) - return "webpage"; - else if (posts > 1) - return "multiple"; -} - -function xpath_string(doc, node, xpath) { - var res = doc.evaluate(xpath, node, null, XPathResult.STRING_TYPE, null); - if (!res || !res.stringValue) - return null; - return Zotero.Utilities.trim(res.stringValue); -} - -function xpre(doc, node, xpath, reg) { - var xpmatch = xpath_string(doc, node, xpath); - return reg.exec(xpmatch)[1]; -} - -function scrape(doc, url) { - var items = new Array(); - var posts = doc.evaluate("//div[@class='post-alt blog']", doc, null, - XPathResult.ANY_TYPE, null); - - var post_count = 0; - - while (post = posts.iterateNext()) { - var newItem = new Zotero.Item("webpage"); - newItem.publicationTitle = PUB_TITLE; - - var link = post.getElementsByTagName("a")[0]; - newItem.url = link.href; - - var title = Zotero.Utilities.unescapeHTML( - Zotero.Utilities.cleanTags(link.textContent)); - title = title.replace(/(\s+)(?:‘|’)|(?:‘|’)(\s+)/g, "$1''$2").replace(/‘|’/g, "'"); - newItem.title = title; - - if (XPATH_DATE) - newItem.date = xpre(doc, post, XPATH_DATE, RE_DATE); - if (XPATH_PAGES) - newItem.pages = xpath_string(doc, post, XPATH_PAGES); - - //authors - var author_text = xpre(doc, post, XPATH_AUTHORS, RE_AUTHORS); - var authors = []; - if (author_text) { - if (author_text.indexOf(" and ") != -1) - authors = author_text.split(" and "); - else if (author_text.indexOf(";") != -1) - authors = author_text.split(";"); - else - authors.push(author_text); - } - for each(var a in authors) - if (a != 'null') - newItem.creators.push( - Zotero.Utilities.cleanAuthor(a, "author")); - - // attach html - if (url == newItem.url) - newItem.attachments.push({title:PUB_TITLE+" Snapshot", - mimeType:"text/html", url:doc.location.href, snapshot:true}); - - newItem.toString = function() { return this.title; }; - items[newItem.url] = newItem; - post_count++; - } - - /* a stupidly complex way of calling selectItems, and then completing - the items which were selected */ - if (post_count > 1) { - var sel_items = new Object(); - for each(var i in items) - sel_items[i.url] = i.title; - sel_items = Zotero.selectItems(sel_items); - - for (var i in sel_items) - items[i].complete(); - } else if (post_count == 1) - for each(var i in items) - i.complete(); -} - -function doWeb(doc, url) { - scrape(doc, url); -} diff --git a/translators/TVNZ.js b/translators/TVNZ.js @@ -1,215 +0,0 @@ -{ - "translatorID" : "649c2836-a94d-4bbe-8e28-6771f283702f", - "label" : "TVNZ", - "creator" : "Sopheak Hean", - "target" : "^http://tvnz\\.co\\.nz", - "minVersion" : "1.0", - "maxVersion" : "", - "priority" : 100, - "inRepository" : true, - "translatorType" : 4, - "lastUpdated":"2010-09-20 10:30:20" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - if (doc.location.href.indexOf("/search/") !=-1){ - return "multiple"; - } - else if ((doc.location.href.indexOf("politics-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("politics-news/") !=-1) && (doc.location.href.indexOf("/video") !=-1) - || (doc.location.href.indexOf("business-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("national-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("breakfast-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("breakfast-news/") !=-1) && (doc.location.href.indexOf("/video") !=-1) - || (doc.location.href.indexOf("world-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("all-blacks/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("weather/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("-news/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("-news/") !=-1) && (doc.location.href.indexOf("/video") !=-1) - || (doc.location.href.indexOf("on/") !=-1) && (doc.location.href.indexOf("-video") !=-1) - || (doc.location.href.indexOf("up/") !=-1) && (doc.location.href.indexOf("/video") !=-1)){ - return "tvBroadcast"; - } - else if ((doc.location.href.indexOf("news/") !=-1) || (doc.location.href.indexOf("all-blacks/") !=-1) || (doc.location.href.indexOf("up/")!=-1)){ - return "newspaperArticle"; - } -} - -function scrape(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - if (detectWeb(doc, url) == "newspaperArticle") { - var newItem = new Zotero.Item('newspaperArticle'); - newItem.url = doc.location.href; - newItem.publicationTitle = "TVNZ"; - newItem.language = "English"; - - var titleXPath = '//h1'; - var titleXPathObject = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (titleXPathObject){ - var titleXPathString = titleXPathObject.textContent; - newItem.title = titleXPathString ; - } - - var dateXPath = '//p[@class="time"]'; - var dateXPathObject = doc.evaluate(dateXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(dateXPathObject){ - var dateXPathString = dateXPathObject.textContent.replace(/\W\bPublished:\W\d{1,2}:\d{1,2}(AM|PM) (\w)+ /g, ''); - newItem.date = dateXPathString.replace(/^\s*|\s*$/g, ''); - } - //get Author from the article - var authorXPath = '//p[@class="source"]'; - var authorXPathObject = doc.evaluate(authorXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (authorXPathObject){ - var authorXPathString = authorXPathObject.textContent.replace(/\W\bSource:\W+/g, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorXPathString.replace(/\W+/g, '-'), "author")); - } - - //get Section of the article - var sectionXPath = '//li[@class="selectedLi"]/a/span'; - var sectionXPathObject = doc.evaluate(sectionXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (sectionXPathObject){ - - var sectionXPathString = sectionXPathObject.textContent.replace(/^s/g, ''); - var sectionArray = new Array("Rugby", "All Blacks", "Cricket", "League", "Football", "Netball", "Basketball", "Tennis", "Motor", "Golf", "Other", "Tipping"); - - //loop through the Array and check for condition for section category - //var count =0; - for (var i=0; i <sectionArray.length; i++){ - //count = 1; - //if there is a match in the loop then replacing the section found with SPORT - if(sectionXPathString == sectionArray[i]){ - sectionXPathString = "Sport"; - newItem.section = sectionXPathString; - } - //if not found then take the value from XPath - newItem.section = sectionXPathString; - //count++; - - } - } - - //get Abstract - var a= "//meta[@name='description']"; - var abs= doc.evaluate(a, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abs){ - var abstractString = abs.content; - newItem.abstractNote = abstractString; - } - - //closed up NewItem - newItem.complete(); - - } else if (detectWeb(doc, url) == "tvBroadcast"){ - var newItem = new Zotero.Item("tvBroadcast"); - newItem.url = doc.location.href; - - newItem.network = "TVNZ"; - newItem.language = "English"; - - /* get Title and Running time for video clip */ - //if meta title exist - - - //if the array is true then do this - - var dateXPath = '//p[@class="added"]'; - var dateXPathObject = doc.evaluate(dateXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if (dateXPathObject){ - var dateString = dateXPathObject.textContent.replace(/\W\bAdded:\W\d{1,2}:\d{1,2}(AM|PM) (\w)+ /g, ''); - newItem.date = dateString.replace(/^\s*|\s*$/g, ''); - } else { - var dateXPath = '//p[@class="time"]'; - var dateXPathObject = doc.evaluate(dateXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/\W\bPublished:\W\d{1,2}:\d{1,2}(AM|PM) (\w)+ /g, ''); - newItem.date = dateXPathObject.replace(/^\s*|\s*$/g, ''); - - } - - var myTitlePath ='//meta[@name="title"]'; - var myTitlePathObject= doc.evaluate(myTitlePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (myTitlePathObject){ - var titleString= myTitlePathObject.content.replace(/\b[)]+/g, ''); - var TitleResult= titleString.split(" ("); - newItem.title = TitleResult[0]; - var runTime = TitleResult[1]; - if(TitleResult[1] == undefined) { - newItem.runningTime =""; - } else { - newItem.runningTime = runTime; - } - }else{ - var myPath = '//head/title'; - var myPathObject = doc.evaluate(myPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(" | "); - newItem.title= myPathObject[0]; - } - - //get Author from the article - var authorXPath = '//p[@class="source"]'; - var authorXPathObject = doc.evaluate(authorXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (authorXPathObject){ - var authorString = authorXPathObject.textContent.replace(/\W\bSource:\W+/g, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorString.replace(/\W+/g, '-'), "author")); - - } else { - var keywordsPath = '//meta[@name="keywords"]'; - var keywordsObject = doc.evaluate(keywordsPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content.replace(/\s+/g, '-').split(","); - newItem.creators.push(Zotero.Utilities.cleanAuthor(keywordsObject[0], "author")); - } - - //get Abstract - var a= "//meta[@name='description']"; - var abs= doc.evaluate(a, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.abstractNote = abs; - - //get Section of the video, not sure if this meant for Archive location, if incorrect then leave it commented. - //var sectionPath = "//meta[@name='keywords']"; - //var sectionPathObject = doc.evaluate(sectionPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - //var sectionResult = sectionMetaObject.split(","); - //newItem.archiveLocation = sectionPathObject; - - newItem.complete(); - } -} - -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"){ - var titleXPath = '//div[@class="readItem"]/h4/a'; - var titles = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (nextTitle = titles.iterateNext()){ - items[nextTitle.href] = nextTitle.textContent; - } - items= Zotero.selectItems(items); - for (var i in items){ - articles.push(i); - } - } else if (detectWeb(doc,url) =="newspaperArticle"){ - articles = [url]; - } - else if (detectWeb(doc,url) =="tvBroadcast"){ - articles = [url]; - } - - Zotero.debug(articles); - //Zotero.Util only works when scrape function is declared - Zotero.Utilities.processDocuments(articles, scrape, function(){Zotero.done();}); - - Zotero.wait(); -} diff --git a/translators/Tagesspiegel.js b/translators/Tagesspiegel.js @@ -1,146 +0,0 @@ -{ - "translatorID": "374ac2a5-dd45-461e-bf1f-bf90c2eb7085", - "label": "Der Tagesspiegel", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.tagesspiegel\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-30 22:04:46" -} - -/* -Tagesspiegel Translator -Copyright (C) 2011 Martin Meyerhoff - -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) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var tspiegel_ArticleTools_XPath = ".//div[@class='hcf-article']"; - var tspiegel_Multiple_XPath = "//*[@id='hcf-wrapper']/div[2]/div[contains(@class, 'hcf-main-col')]/div/ul/li/h2/a|//*[@id='hcf-wrapper']/div[@class='hcf-lower-hp']/div/ul/li/ul/li/a|//ul/li[contains(@class, 'hcf-teaser')]/h2/a"; - - if (doc.evaluate(tspiegel_ArticleTools_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.location.href.match(/http\:\/\/www\.tagesspiegel\.de\/suchergebnis\//)){ - Zotero.debug("multiple"); - return "multiple"; - } else if (doc.evaluate(tspiegel_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ) { - Zotero.debug("multiple"); - return "multiple"; - } -} - -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("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the title! - - var title_XPath = "//div[@class='hcf-article']/h1"; - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = title; - - // Date - var date_XPath = "//span[contains(@class, 'hcf-date')]"; - var date= doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.date= date.replace(/(.{10,10}).*/, '$1'); - - // Summary - - var summary_XPath = ".//p[@class='hcf-teaser']" - if (doc.evaluate(summary_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.abstractNote = Zotero.Utilities.trim(summary); - } - - // Publication Title - newItem.publicationTitle = "Der Tagesspiegel Online"; - - // Authors - var author_XPath = "//span[contains(@class, 'hcf-author')]"; - if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var author = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - Zotero.debug(author); - author = author.replace(/^Von\s|Kommentar\svon\s/g, ''); - author = author.split(/,\s/); - for (var i in author) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - - // Printurl (add "v_print," before the article ID and "?p=" at the end) - var printurl = doc.location.href.replace(/^(.*\/)(\d+.html$)/, '$1v_print,$2?p='); - newItem.attachments.push({url:printurl, title:doc.title, mimeType:"text/html"}); - - // Tags - var tags_XPath = "//meta[@name='keywords']"; - var tags = doc.evaluate(tags_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - var tags= tags.split(","); // this seems to work even if there's no | - for (var i in tags) { - tags[i] = tags[i].replace(/^\s*|\s*$/g, '') // remove whitespace around the tags - newItem.tags.push(tags[i]); - } - - newItem.complete(); - -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate("//*[@id='hcf-wrapper']/div[2]/div[contains(@class, 'hcf-main-col')]/div/ul/li/h2/a|//*[@id='hcf-wrapper']/div[@class='hcf-lower-hp']/div/ul/li/ul/li/a|//ul/li[contains(@class, 'hcf-teaser')]/h2/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - // The following conditions excludes the image galleries and videos. - if (next_title.href.match(/http\:\/\/www\.tagesspiegel\.de\/(?!mediacenter)/)) { - items[next_title.href] = next_title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/TalisPrism.js b/translators/TalisPrism.js @@ -1,434 +0,0 @@ -{ - "translatorID":"53f8d182-4edc-4eab-b5a1-141698a20202", - "label":"TalisPrism", - "creator":"William Smith and Emma Reisz", - "target":"/TalisPrism/(browseResults|doSearch)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-01-31 19:10:00" -} - -/* TalisPrism translator. - Version 1.1 - By William Smith (http://www.willsmith.org/contactme) - and Emma Reisz - -TalisPrism is a library management system used by a number of universities -and public bodies in the UK, Ireland and elsewhere. -For example: http://qu-prism.qub.ac.uk/TalisPrism/ -and http://http://star.shef.ac.uk/TalisPrism/ - -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/>. - -*/ - - -// TalisPrism doesn't use metadata so everything must be scraped. - -function detectWeb(doc, url){ - - /* Can't differentiate multiple from single results by URL - as single search results have a search URL but display as browse. - Can't scrape the titles to differentiate between single and multiple as the display format - is too different to be scraped consistently. - Instead we differentiate by URL but make an exception for a solo result. - */ - var search=searchTest(doc, url); - - if (search==1) { - var doctype = 'multiple'; - } else {doctype=docType(doc, url); - } - return doctype; -} - -function docType (doc,url){ - //Need xpaths to detect type. - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - // Best way to identify item type on an entry page is by its icon. - if (getXPath(doc, '//img[@alt="sound - disc"]/@alt').length) { - doctype = 'audioRecording'; - } else if (getXPath(doc, '//img[@alt="Book"]/@alt').length) { - doctype = 'book'; - } else if (getXPath(doc, '//img[@alt="video - disc"]/@alt').length) { - doctype = 'videoRecording'; - } else { - doctype = 'document'; - } - return doctype; -} - - -function searchTest (doc, url){ - - //Need xpaths to differentiate search and item pages. - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var searchPage; - var search; - if (url.match(/doSearch/)) { - var resultCount; - var resultCountElements = new Array(); - var resultCountText; - var resultCountPath = '//table/tbody/tr/td/table/tbody/tr/td[1]/font/span[@class="text"]/font'; - var resultCountObject = doc.evaluate(resultCountPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (resultCountText = resultCountObject.iterateNext()) { - resultCountElements.push(resultCountText.textContent); - } - resultCount=resultCountElements[0]; - if (resultCount == 1) { - search=0; - } else { - search=1; - } - } else { - var pageCount; - var pageCountElements = new Array(); - var pageCountText; - var pageCountPath= '//tbody/tr/td[2]/font/span[@class="text"]/table/tbody/tr[2]/td/font/span[@class="text"]/table/tbody/tr/td[4]'; - var pageCountObject = doc.evaluate(pageCountPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (pageCountText = pageCountObject.iterateNext()) { - pageCountElements.push(pageCountText.textContent); - } - pageCount=pageCountElements[0]; - if (pageCount==undefined){ - search=0; - } else if (pageCount.match(/Page/)){ - search=1 - } else { - search=0; - } - } - return search; -} - -function getXPath ( doc, field ) { - xpath = field; - - content = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - - if (content) - return content.textContent; - else - return ''; - -} - -//TalisPrism displays with labels. The getField function searches for the next different field after a label. - -function getField (doc, field) { - - xpath='//span[@class="text"]'; - - content = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - - while (c = content.iterateNext()) - { - if (c.textContent == field) - { - // OK, find the next field - while (val = content.iterateNext()) { - - if (val && val.textContent != c.textContent) - { - return val.textContent; - } - } - } - } - return ''; -} - -function multiscrape(doc, url) { - url=doc.documentURI; - var item; - var doctype = docType(doc, url); - item = new Zotero.Item(doctype); - scrape(doc,url, item); -} - - -function soloscrape(doc, url) { - url=doc.documentURI; - var item; - item = new Zotero.Item(doctype); - scrape(doc,url, item); - return ''; -} - - -function scrape(doc, url, item){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // The fields often contain multiple data types and need some cleanup. - var title = getField(doc, 'Title'); - - if (title.length == 0) { - title = 'Unknown Title'; - } - // If title includes a forward slash, omit the last bit. - if (title.match('/')) { - title = title.substring(0, title.lastIndexOf('/')); - } - title = title.replace(/^\s+|\s+$/g, ''); - item.title = title; - - var author = getField(doc, 'Author'); - if (author.length) { - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author", 1)); - } else { - author = getField(doc, 'Other Author(s) / Title(s)'); - if (author.length) { - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author", 1)); - } - } - - - // Place, publisher and publish date are in the same field. Format is usually "Place : Publisher, yyyy". - - var publishing = getField(doc, 'Publisher'); - if (publishing.length == 0) { - publishing = getField(doc, 'Published'); - } - if (publishing.length == 0) { - publishing = getField(doc, 'Publication details'); - } - - if (publishing.match(/(13|14|15|16|17|18|19|20)\d\d/)) { - var pos = publishing.search(/(13|14|15|16|17|18|19|20)\d\d/); - item.date = publishing.substring(pos, publishing.lastIndexOf('.')).match(/\d\d\d\d/); - var place = publishing.substring(0, publishing.indexOf(':')); - item.place = place.replace(/^\s+|\s+$/g, ''); - var publisher = publishing.substring(publishing.indexOf(':')+1, pos); - item.publisher = publisher.replace(/^\s+|\s+$|\,\s+$/g, ''); - } - - - var isbn = getField(doc, 'ISBN'); - if (isbn.length == 0) { - isbn = getField(doc, 'ISBN, etc.'); - } - - isbn=isbn.replace(/^\D+|\D+$/g, ""); - item.ISBN = isbn.substring(0).match(/\d+/); - - var series = getField(doc, 'Series'); - var pos2 =series.lastIndexOf(';'); - if (pos2==-1){ - item.series=series.replace(/^\s+|\s+$/g, ''); - }else{ - var seriesName = series.substring(0, pos2); - item.series = seriesName.replace(/^\s+|\s+$/g, ''); - var seriesNumber = series.substring(pos2+1); - item.seriesNumber = seriesNumber.replace(/^\s+|\s+$/g, ''); - } - - item.edition = getField(doc, 'Edition'); - - var physical = getField(doc, 'Physical details'); - var numPages = physical.substring(0, physical.indexOf(':')); - item.numPages = numPages.replace(/^\s+|\s+$/g, ''); - - var physicaldetails = physical.substring(physical.indexOf(':')+1, physical.lastIndexOf('.')); - physicaldetails = physicaldetails.replace(/^\s+|\s+$/g, ''); - - var databasedetails = getField(doc, 'Cited/indexed in'); - databasedetails = databasedetails.replace(/^\s+|\s+$/g, ''); - - item.extra = databasedetails + physicaldetails - - item.attachments.push({url:url, title:"Snapshot of Library Page", mimeType:"text/html"}); - - var doctitle - doctitle = doc.title - if (doctitle == "TalisPrism"){ - item.libraryCatalog =url.substring(url.indexOf('http'), url.indexOf('/TalisPrism')); - } else { - item.libraryCatalog = doctitle - } - - - /* We need to XPath to the call number as we cannot be sure about the previous cell, - so the label method won't work. Some items have multiple call numbers, - but a generalised XPath which retrieves multiple sets of location data (tr[2], tr[3] etc.) - also retrieves tr [1], which contains all the rest of the bibliographic entry. - The size of tr[1] varies and there is no consistent final item, - so instead of using a general XPath, we scrape tr[2], tr[3] and tr[4] successively into an array; - tr[5] is also scraped into the array, but if non-null, 'See record for additional call numbers.' - is returned as the final shelfmark. Note that each call number is itself scraped into an - array ('shelfmarkElements'), as we need both the Library and Shelfmark elements. - */ - - var shelfmark = new Array(); - var callNumber = ""; - - //Need to test whether the search page has a sidebar showing as this shifts the classmarks. - - var authorModePath='//td/table/tbody/tr/td[1]/font/span[@class="text"]/table/tbody/tr[2]/td/font/span[@class="text"]/font/b/span[@class="text"]/table/tbody/tr/td[2]'; - var authorModeObject=doc.evaluate(authorModePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var browseModePath='//td/table/tbody/tr/td[1]/font/span[@class="text"]/table/tbody/tr/td[2]/font/span[@class="text"]/table/tbody/tr/td[1]'; - var browseModeObject=doc.evaluate(browseModePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - var shelfmarkPath = new Array(); - shelfmarkPath[0] = '//td[2]/font/span[@class="text"]/table/tbody/tr/td/font/span[@class="text"]/table/tbody/tr[2]/td'; - shelfmarkPath[1] = '//td[2]/font/span[@class="text"]/table/tbody/tr/td/font/span[@class="text"]/table/tbody/tr[3]/td'; - shelfmarkPath[2] = '//td[2]/font/span[@class="text"]/table/tbody/tr/td/font/span[@class="text"]/table/tbody/tr[4]/td'; - shelfmarkPath[3] = '//td[2]/font/span[@class="text"]/table/tbody/tr/td/font/span[@class="text"]/table/tbody/tr[5]/td'; - var shelfmarkText; - if (authorModeObject==null||authorModeObject.innerHTML==null){ - if (browseModeObject==null||browseModeObject.innerHTML==null){ - for (var i=0; i < 4; i ++){ - var shelfmarkObject = new Array(); - var shelfmarkElements = new Array(); - shelfmarkObject[i] = doc.evaluate(shelfmarkPath[i], doc, nsResolver, XPathResult.ANY_TYPE, null); - while (shelfmarkText = shelfmarkObject[i].iterateNext()) { - shelfmarkElements.push(shelfmarkText.textContent); - } - shelfmark[i]=shelfmarkElements[0]+" "+shelfmarkElements[1]; - //Need to remove junk text scraped when there is a request button in the call number field. - shelfmark[i] = shelfmark[i].replace(/\s*\/*(?:xc_d.write.*\;)/, ''); - } - } else if (browseModeObject.innerHTML.match(/arrow/)) { - for (var i=0; i < 4; i ++){ - var shelfmarkObject = new Array(); - var shelfmarkElements = new Array(); - shelfmarkObject[i] = doc.evaluate(shelfmarkPath[i], doc, nsResolver, XPathResult.ANY_TYPE, null); - while (shelfmarkText = shelfmarkObject[i].iterateNext()) { - shelfmarkElements.push(shelfmarkText.textContent); - } - shelfmark[i]=shelfmarkElements[1]+" "+shelfmarkElements[2]; - shelfmark[i] = shelfmark[i].replace(/\s*\/*(?:xc_d.write.*\;)/, ''); - } - } - }else if (authorModeObject.innerHTML.match(/arrow/)){ - for (var i=0; i < 4; i ++){ - var shelfmarkObject = new Array(); - var shelfmarkElements = new Array(); - shelfmarkObject[i] = doc.evaluate(shelfmarkPath[i], doc, nsResolver, XPathResult.ANY_TYPE, null); - while (shelfmarkText = shelfmarkObject[i].iterateNext()) { - shelfmarkElements.push(shelfmarkText.textContent); - } - shelfmark[i]=shelfmarkElements[1]+" "+shelfmarkElements[2]; - shelfmark[i] = shelfmark[i].replace(/\s*\/*(?:xc_d.write.*\;)/, ''); - } - } - if (shelfmark[0] != "undefined undefined"){ - callNumber = shelfmark[0]; - } - for (var i=1; i<3; i++){ - if (shelfmark[i] != "undefined undefined"){ - callNumber = callNumber + "; " + shelfmark[i]; - } - } - if (shelfmark[3] != "undefined undefined"){ - callNumber = callNumber + ". See record for additional call numbers."; - } - - item.callNumber = callNumber; - - var link = getField (doc, 'Link to'); - if (link.length == 0) { - var linkPath='//span[@class="text"]/table/tbody/tr/td/table/tbody/tr/td[2]/font/span[@class="text"]/table/tbody/tr/td/font/span[@class="text"]/table/tbody/tr/td[2]/font/span[@class="text"]/a'; - var linkObject=doc.evaluate(linkPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (linkObject==null){ - } else { - var linkTitle=linkObject.textContent; - var linkLink=linkObject.href; - if (linkTitle=="Link to electronic text"){ - link=linkLink; - } - } - } - item.url = link; - - item.complete(); - return ''; -} - -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 names = new Array (); - var items = new Object (); - var nextTitle; - doctype=detectWeb(doc, url); - - /* Typically scrapers process both search pages and item pages in the same way; - the processDocuments function is used, calling the scraped result link URLs for a search page, - and for an item page calling the item page's own URL. - But Talis displays solo search results with an unstable URL and with no link to an item page. - So we cannot call the URL for a solo search result as it will yield a null page. - Instead we must process solo search results directly without using processDocuments. - We want to process item pages in the same way as solo search pages because - waiting for the URL on an item page to be called noticeably slows down the scrape. - */ - - var indexPath ='//span[@class="text"]/x:table/x:tbody/x:tr/x:td/x:table/x:tbody/x:tr/x:td[1]' - var index; - var indexElements = new Array(); - var indexText; - var indexObject = doc.evaluate(indexPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (indexText = indexObject.iterateNext()) { - indexElements.push(indexText.textContent); - } - index=indexElements[0]; - index1=indexElements[1]; - if (doctype == "multiple" && index.match(/Index/) && index1 == ""){ - var titlePath = '//td[3]/font/span[@class="text"]/table/tbody/tr/td/font/span[@class="text"]/table/tbody/tr/td[1]/font/span[@class="text"]/a'; - var titles = doc.evaluate(titlePath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (nextTitle = titles.iterateNext()) { - items[nextTitle.href] = nextTitle.textContent; - names.push(nextTitle.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, multiscrape, function(){Zotero.done();}); - - } else if (doctype == "multiple") { - var titlePath = '//td[4]/font/span[@class="text"]/table/tbody/tr/td/font/span[@class="text"]/table/tbody/tr/td[1]/font/span[@class="text"]/a'; - var titles = doc.evaluate(titlePath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (nextTitle = titles.iterateNext()) { - items[nextTitle.href] = nextTitle.textContent; - names.push(nextTitle.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, multiscrape, function(){Zotero.done();}); - } - else { - soloscrape(doc, url); - } - Zotero.wait(); - -} -\ No newline at end of file diff --git a/translators/Tatknigafund.js b/translators/Tatknigafund.js @@ -1,129 +0,0 @@ -{ - "translatorID":"f909cbda-2fac-4700-965f-6c0783b77eeb", - "translatorType":4, - "label":"Tatknigafund", - "creator":"Avram Lyon", - "target":"^https?://www.tatknigafund.ru/books/", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "inRepository":false, - "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, - independent of interface language (Russian or Tatar). - - It should be able to fetch bibliographic data even for non-logged-in users, although - to read the full-text of works in the repository, users will need to create a free account. - - It works on URLs of the form http://www.tatknigafund.ru/books/XXXX/ , where XXXX is the - book ID assigned by the repository. One such URL is: - http://www.tatknigafund.ru/books/1037 - Which should give the result: - Ф. Гыйбадуллина, Роман hәм милләт: Гаяз Исхакый иҗатында роман жанры (Татарстан китап нəшрияты, 2007), - http://www.tatknigafund.ru/books/1037?locale=tt. - It should also populate the abstract field. - - It can also work on search results, of the form http://www.tatknigafund.ru/books/search?locale=ru&type=meta&query=XXXX - where XXXX is the query string. One such URL is: - http://www.tatknigafund.ru/books/search?locale=ru&type=meta&query=%D0%B8%D1%81%D1%85%D0%B0%D0%BA%D0%B8 - Which at present gives six results. - - When Zotero is able to assign languages to bibliographic data, the data obtained here would - be a good candidate, since all the author names, titles and abstracts are served in Russian - or Tatar, depending on the user's locale choice. - - This translator draws heavily on the National Library of Australia translator for inspiration, - in lieu of up-to-date translator documentation. - */ - -function detectWeb(doc, url) { - if (url.match("books/search?")) { - return "multiple"; - } else - if (url.match("books") && !url.match("read")) { - return "book"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var tablerow = doc.evaluate('//table[@class="books_list"]/tbody/tr', doc, ns, XPathResult.ANY_TYPE, null); - var items = new Array(); - var row; - while(row = tablerow.iterateNext()) { - var link = doc.evaluate('./td/a[@class="book_title"]', row, ns, XPathResult.ANY_TYPE, null).iterateNext(); - var title = link.textContent; - var url = link.href; - items[url] = title; - } - items = Zotero.selectItems(items); - if(!items) return true; - for (var i in items) { - books.push(i); - } - } else { - books = [url]; - } - - Zotero.Utilities.processDocuments(books, function(doc) { - item = new Zotero.Item("book"); - item.title = Zotero.Utilities.trimInternal( - doc.evaluate('//div[@class="description"]/h1', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent - ); - - var author = doc.evaluate('//a[@class="author_link"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - // Authors here are Last Name, First initial(s) (ФИО) - var spaceIndex = author.lastIndexOf(" "); - var firstName = author.substring(spaceIndex+1); - var lastName = author.substring(0, spaceIndex); - item.creators.push({firstName:firstName, lastName:lastName, creatorType:"author"}); - - var info = doc.evaluate('//p[@class="summary"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var pub = info.match(/(Нәшрият|Издательство): (.+)/); - var publisher = pub[2]; - yr = info.match(/(Нәшрият|Издательство): (.+),\s+(\d+)\s(ел|г)\./); - var year = yr[3]; - - var pagematch = info.match(/(\d+) (бит|страница|страниц|страницы)/); - var pages = pagematch[1]; - item.publisher = Zotero.Utilities.trimInternal(publisher); - item.date = Zotero.Utilities.trimInternal(year); - item.numPages = pages; - - var description = doc.evaluate('//div[@class="description"]/p[2]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - item.abstractNote = description; - - item.url = url; - - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/The Age.js b/translators/The Age.js @@ -1,109 +0,0 @@ -{ - "translatorID":"efb3c424-daa9-40c9-8ee2-983d2802b27a", - "translatorType":4, - "label":"The Age", - "creator":"Michael Berkowitz", - "target":"^http://(www|search).theage.com.au/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-08-14 22:15:00" -} - -function detectWeb(doc, url) { - if (url.indexOf("siteSearch.ac") != -1) { - return "multiple"; - } else if (url.indexOf("html") != -1) { - return "newspaperArticle"; - } -} - -function scrape(url) { - Zotero.Utilities.HTTP.doGet(url, function(text) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.ISSN = "0312-6307"; - newItem.url =url; - newItem.publicationTitle = "The Age"; - Zotero.debug(url); - - //title - var t = /<HEADLINE>(.*)<\/HEADLINE>/; - newItem.title = Zotero.Utilities.unescapeHTML(Zotero.Utilities.capitalizeTitle(text.match(t)[1]).split(" - ")[0]); - - //meta tags? (except abstract, for some reason) - var m = /name=\"(.*)\"\s+content=\"(.*)\"\s+\/>/g; - var metaTags = text.match(m); - var metaInfo = new Object(); - var metaNames = new Array(); - var m2 = /name=\"(.*)\"\s+content=\"(.*)\"\s+\/>/; - for (var i = 0 ; i < metaTags.length ; i++) { - var stuff = metaTags[i].match(m2); - metaInfo[stuff[1]] = stuff[2]; - metaNames.push(stuff[1]); - } - - for (var i = 0 ; i <metaNames.length ; i++) { - if (metaNames[i] == "sitecategories") { - newItem.section = metaInfo[metaNames[i]].split(",")[0]; - } else if (metaNames[i] == "publishdate") { - newItem.date = metaInfo[metaNames[i]].split(/\s+/)[0]; - } else if (metaNames[i] == "byline") { - var byline = metaInfo[metaNames[i]].split(",")[0]; - if (byline.indexOf(" and ") != -1) { - byline = byline.split(" and "); - for (var j = 0 ; j < byline.length ; j++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(byline[j], "author")); - } - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(byline, "author")); - } - } else if (metaNames[i] == "keywords") { - var keywords = metaInfo[metaNames[i]].split(","); - for (var k = 0 ; k < keywords.length ; k++) { - if (keywords[k].length > 1) { - newItem.tags.push(Zotero.Utilities.unescapeHTML(keywords[k][0].toUpperCase() + keywords[k].substr(1).toLowerCase())); - } - } - } - } - - //abstract - var a = /\"Description\"\s+content=\"([^\"]*)\"/; - newItem.abstractNote = Zotero.Utilities.unescapeHTML(text.match(a)[1].substring(0, text.match(a)[1].length - 3)); - - newItem.complete(); - Zotero.done(); - }, function() {}); -} - -function doWeb(doc, url) { - var URLS = new Array(); - if (url.indexOf("siteSearch.ac") != -1) { - var xpath = '//div[@class="searchresults"]/dl/dt/a'; - var titles = new Object(); - var stuff = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var newest = stuff.iterateNext(); - while (newest) { - titles[newest.href] = newest.textContent; - newest = stuff.iterateNext(); - } - - var items = Zotero.selectItems(titles); - - for (var i in items) { - URLS.push(i.split("u=")[1].replace(/%3A/g,":").replace(/%2F/g,"/").split("&")[0]); - } - } else { - URLS.push(url); - } - - Zotero.debug(URLS); - - Zotero.Utilities.HTTP.doPost(URLS, "", function(text) { - for (var i = 0 ; i < URLS.length ; i++) { - scrape(URLS[i]); - } - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/The Atlantic.js b/translators/The Atlantic.js @@ -1,147 +0,0 @@ -{ - "translatorID": "575ba37f-c871-4ee8-8bdb-3e7f954e4e6a", - "label": "The Atlantic", - "creator": "Sebastian Karcher", - "target": "^https?://www\\.theatlantic\\.com", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "browserSupport":"gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-23 10:28:50" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Blog/Webpage */ -FW.Scraper({ -itemType : 'webpage', -detect : FW.Xpath('//p[@class="bio"]/span[@class="authors"]/a'), -title : FW.Xpath('//h1[@class="headline"]').text().trim(), -attachments : [{ url: FW.Url().replace(/archive/,"print"), - title: "The Atlantic Print View", - type: "text/html" }], -creators : FW.Xpath('//p/span[@class="authors"]/a').text().cleanAuthor("author"), -date : FW.Xpath('//p[@class="metadata"]/span[1]').text(), -publicationTitle : "The Atlantic" -}); - -/** Magazine */ -FW.Scraper({ -itemType : 'magazineArticle', -detect : FW.Xpath('//div[@class="magazineContent"]'), -title : FW.Xpath('//h1[@class="headline"]').text().trim(), -attachments : [{ url: FW.Url().replace(/archive/,"print"), - title: "The Atlantic Print View", - type: "text/html" }], -creators : FW.Xpath('//h5/span/a[@class="author"]').text().cleanAuthor("author"), -date : FW.Xpath('//div[@class="metadata"]/a[@class="issueTitle"]').text().remove(/ATLANTIC MAGAZINE/), -abstractNote : FW.Xpath('//div[@class="post"]/p[@class="blurb"]').text(), -publicationTitle : "The Atlantic", -ISSN : "1072-7825" -}); - - /** Search Results */ -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Xpath('//div[@class="post"][2]'), -choices : { - titles : FW.Xpath('//div[@class="post"]/h3/a').text().trim(), - urls : FW.Xpath('//div[@class="post"]/h3/a').key("href").text() -} -}); - - /** Search Results */ -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Xpath('//div[@id="searchResults"]'), -choices : { - titles : FW.Xpath('//div[@id="searchResults"]/div[@class="post"]/h3/a').text().trim(), - urls : FW.Xpath('//div[@id="searchResults"]/div[@class="post"]/h3/a').key("href").text() -} -}); - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.theatlantic.com/ta-nehisi-coates/", - "items": [] - }, - { - "type": "web", - "url": "http://www.theatlantic.com/politics/archive/2011/06/jon-stewart-challenges-fox-news-to-correct-its-errors/240900/", - "items": [ - { - "itemType": "webpage", - "creators": [ - { - "firstName": "Conor", - "lastName": "Friedersdorf", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.theatlantic.com/politics/print/2011/06/jon-stewart-challenges-fox-news-to-correct-its-errors/240900/", - "title": "The Atlantic Print View", - "type": "text/html" - } - ], - "url": "http://www.theatlantic.com/politics/archive/2011/06/jon-stewart-challenges-fox-news-to-correct-its-errors/240900/", - "date": "Jun 23 2011, 11:00 AM ET", - "publicationTitle": "The Atlantic", - "title": "Jon Stewart Challenges Fox News to Correct Its Errors", - "libraryCatalog": "The Atlantic", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - }, - { - "type": "web", - "url": "http://www.theatlantic.com/magazine/archive/2011/07/the-world-8217-s-schoolmaster/8532/", - "items": [ - { - "itemType": "magazineArticle", - "creators": [ - { - "firstName": "Amanda", - "lastName": "Ripley", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.theatlantic.com/magazine/print/2011/07/the-world-8217-s-schoolmaster/8532/", - "title": "The Atlantic Print View", - "type": "text/html" - } - ], - "url": "http://www.theatlantic.com/magazine/archive/2011/07/the-world-8217-s-schoolmaster/8532/", - "abstractNote": "How a German scientist is using test data to revolutionize global learning", - "date": "July/August 2011 ", - "ISSN": "1072-7825", - "publicationTitle": "The Atlantic", - "title": "The World’s Schoolmaster", - "libraryCatalog": "The Atlantic", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - }, - { - "type": "web", - "url": "http://www.theatlantic.com/search/?sort=time&source=magazine&q=arab", - "items": [] - } -] -/** END TEST CASES **/ diff --git a/translators/The Australian.js b/translators/The Australian.js @@ -1,104 +0,0 @@ -{ - "translatorID":"393afc28-212d-47dd-be87-ec51bc7a58a4", - "translatorType":4, - "label":"The Australian", - "creator":"Michael Berkowitz", - "target":"^http://(searchresults|www.theaustralian).news.com.au/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-08-14 22:20:00" -} - -function detectWeb(doc, url) { - if (url == "http://searchresults.news.com.au/servlet/Search" || url.indexOf("siteSearch") != -1) { - return "multiple"; - } else if (url.indexOf("story") != -1) { - return "newspaperArticle"; - } -} - -function scrape(url) { - Zotero.Utilities.HTTP.doGet(url, function(text) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.url = url; - newItem.publicationTitle = "The Australian"; - - //title - var t = /<title>(.*)<\/title>/; - newItem.title = Zotero.Utilities.capitalizeTitle(text.match(t)[1].split(" | ")[0]); - - //abstract - var abs = /meta name=\"description\"\s+content=\"(.*)\"/; - var abstract = Zotero.Utilities.unescapeHTML(text.match(abs)[1]).split(" "); - abstract[0] = abstract[0][0] + abstract[0].substr(1).toLowerCase(); - newItem.abstractNote = abstract.join(" "); - - //tags - var t = /meta name=\"keywords\"\s+content=\"(.*)\"/; - var tags = text.match(t)[1].split(/,\s+/); - for (var i = 0 ; i < tags.length ; i++) { - newItem.tags.push(Zotero.Utilities.unescapeHTML(tags[i])); - } - - //section - var sec = /active\"><a[^>]*>(.*)<\/a>/; - if (text.match(sec)) { - newItem.section = text.match(sec)[1]; - } - - //timestamp - var t = /<em class=\"timestamp\">(.*)<\/em>/; - newItem.date = text.match(t)[1]; - - //byline - var by = /<div\s+class=\"module-subheader\"><p>(.*)/; - if (text.match(by)[1]) { - var byline = text.match(by)[1]; - var authors = new Array(); - if (byline.indexOf(",") != -1) { - byline = byline.split(",")[0]; - } - if (byline.indexOf(" and ") != -1) { - var authors = byline.split(" and "); - } else { - authors.push(byline); - } - for (var i = 0 ; i < authors.length ; i++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } - - newItem.complete(); - Zotero.debug(newItem); - - Zotero.done(); - }, function() {}); -} - -function doWeb(doc, url) { - var URLS = new Array(); - var newItems = new Object(); - if (url == "http://searchresults.news.com.au/servlet/Search") { - var articles = new Array(); - var xpath = '//ol/li/h4[@class="heading"]/a'; - //var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - - newItems = Zotero.Utilities.getItemArray(doc, doc.getElementsByTagName("h4"), /^http:\/\//); - newItems = Zotero.selectItems(newItems); - } else { - newItems[url] = doc.title.split(" | ")[0]; - } - - for (var i in newItems) { - URLS.push(i); - } - - Zotero.debug(URLS); - Zotero.Utilities.HTTP.doPost(URLS, "", function(text) { - for (var i = 0 ; i < URLS.length ; i++) { - scrape(URLS[i]); - } - }); -} -\ No newline at end of file diff --git a/translators/The Boston Globe.js b/translators/The Boston Globe.js @@ -1,221 +0,0 @@ -{ - "translatorID": "1f245496-4c1b-406a-8641-d286b3888231", - "label": "The Boston Globe", - "creator": "Adam Crymble and Frank Bennett", - "target": "^http://(www|search|articles)\\.boston\\.com/", - "minVersion": "1.0.0b4.r5", - "maxVersion": "", - "priority": 100, - "inRepository": false, - "translatorType": 4, - "lastUpdated": "2011-05-06 20:57:16" -} - -/* - * Sample URLs - * - * [Original request -- uncommon page format, no embedded metadata of any kind] - * http://articles.boston.com/2011-05-03/news/29500032_1_bouncer-assault-local-restaurant - * - * [More common page formats, marginally reliable metadata in a comment block] - * http://www.boston.com/yourtown/news/charlestown/2011/04/meet_charlestowns_youth_of_the.html - * http://www.boston.com/business/articles/2011/05/05/oil_drops_below_100_per_barrel/ - * http://www.boston.com/lifestyle/articles/2011/04/28/anticipation_grows_for_mfas_art_in_bloom_festival/ - - * Support for search results will require rewriting scrape(..) to use only regular expressions - */ - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - }: null; - - if (url.match("search.boston.com")) { - // Search disabled until cross-domain can be dealt with - return false; - var results = doc.evaluate('//div[@class="resultsMain"]//div[@class="regTZ"]/a[@class="titleLink"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - if (results.iterateNext()) { - return "multiple"; - } else { - return false; - } - } else if (url.match(/(\/[0-9]{4}\/[0-9]{2}\/|[0-9]{4}-[0-9]{2}-[0-9]{2})/)) { - return "newspaperArticle"; - } -} - -//Boston Globe and Boston.com Translator. Original code by Adam Crymble -// Rewritten by Frank Bennett, 2011 - -function sniffComment (elem) { - if (!elem) { - return elem; - } - for (var i = 0, ilen = elem.childNodes.length; i < ilen; i += 1) { - if (elem.childNodes[i].nodeName === "#comment") { - return elem.childNodes[i].nodeValue; - } - } - return false; -} - -function findMagicComment (doc) { - var hideMeElems = doc.getElementsByClassName("hideMe"); - for (var i = 0, ilen = hideMeElems.length; i < ilen; i += 1) { - var elem = hideMeElems.item(i); - var sniff = sniffComment(elem); - if (sniff) { - return sniff; - } - } - var contentElem = doc.getElementById("content"); - return sniffComment(contentElem); -} - -function findAuthorString (doc, newItem) { - var authors = ""; - var bylineElem = false; - var bylineElems = doc.getElementsByClassName("byline"); - if (bylineElems.length) { - bylineElem = bylineElems.item(0); - } - if (!bylineElem) { - var bylineElem = doc.getElementById('byline'); - } - if (bylineElem) { - authors = bylineElem.textContent; - authors = authors.replace("\n", " ", "g"); - if (authors.match(/[Pp]osted\s+by\s+/)) { - newItem.itemType = "blogPost"; - } - authors = authors.replace(/^\s*(?:[Bb]y|[Pp]osted\s+by)\s+(.*)/, "$1"); - } - return authors; -} - -function scrape (doc, url) { - // The site content is pretty chaotic, we do our best. - - // There are two independent blocks set-and-save blocks - // below. - - // Many pages seem to have metadata embedded in a comment - // The date and headline info look reliable, but - // the byline is a disaster, to be used only - // if absolutely necessary. - var magicComment = findMagicComment(doc); - if (magicComment) { - // Blind acceptance - var newItem =new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "Boston.com"; - // URL - newItem.url = doc.location.href; - // Attachment - newItem.attachments.push({url:doc.location.href,mimetype:"text/html",snapshot:true,title:"Boston.com page"}); - // Now try to get some citation details (go ahead, try) - var info = magicComment.replace('\n','','g'); - newItem.title = Zotero.Utilities.unescapeHTML(info.replace(/.*<headline>(.*)<\/headline>.*/,"$1")); - newItem.date = info.replace(/.*<date>(.*)<\/date>.*/,"$1"); - var authors = findAuthorString(doc, newItem); - if (!authors) { - var authors = info.replace(/.*<byline>(.*)<\/byline>.*/,"$1"); - if (authors.toLowerCase() === authors) { - authors = info.replace(/.*<teasetext>(.*)<\/teasetext>.*/, "$1"); - var m = authors.match(/^(?:[Bb]y\s+)*([^ ,]+).*/); - if (m) { - authors = m[1]; - } else { - authors = ""; - } - } - } - authors = authors.split(/,*\s+and\s+/); - authors[authors.length - 1] = authors[authors.length - 1].split(/,\s+/)[0]; - authors = authors.join(", "); - authors = authors.split(/,\s+/); - for (var j = 0, jlen = authors.length; j < jlen; j += 1) { - var author = Zotero.Utilities.cleanAuthor(authors[j], 'author'); - if (author.lastName) { - newItem.creators.push(author); - } - } - newItem.complete(); - } - - - // Information block - var infoElem = doc.getElementById("mod-article-byline"); - if (infoElem) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "Boston.com"; - // URL - newItem.url = doc.location.href; - newItem.attachments.push({url:doc.location.href,mimetype:"text/html",snapshot:true,title:"Boston.com page"}); - - // Date - var dateElem = infoElem.getElementsByClassName('pubdate'); - if (dateElem.length) { - newItem.date = dateElem.textContent; - } - - // Authors - for (var i = 0, ilen = infoElem.childNodes.length; i < ilen; i += 1) { - var node = infoElem.childNodes.item(i); - if (node.nodeName === 'SPAN') { - if ('By' === node.textContent.slice(0,2)) { - - var authors = node.textContent.slice(3); - authors = authors.split(/(?:, |,*\s+and\s+)/); - for (var j = 0, jlen = authors.length; j < jlen; j += 1) { - var author = Zotero.Utilities.cleanAuthor(authors[j], 'author'); - newItem.creators.push(author); - } - } - } - } - - // Title - var headerElem = doc.getElementById('mod-article-header'); - if (headerElem) { - var h = headerElem.getElementsByTagName('h1'); - if (h.length) { - newItem.title = h[0].textContent; - } - } - newItem.complete(); - } -} - - -function doWeb (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - }: null; - - var uris= new Array(); - - if (detectWeb(doc, url) == "multiple") { - var items = {}; - var result = doc.evaluate('//div[@class="regTZ"]/a[@class="titleLink"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var elmt = result.iterateNext(); - while (elmt) { - //items.push(elmt.href); - items[elmt.href] = elmt.textContent; - elmt = result.iterateNext(); - } - - items = Zotero.selectItems(items); - - if (!items) { - return true; - } - - for (var i in items) { - uris.push(i); - } - Zotero.Utilities.processDocuments(uris, scrape, Zotero.done); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/The Chronicle of Higher Education.js b/translators/The Chronicle of Higher Education.js @@ -1,298 +0,0 @@ -{ - "translatorID": "1e6d1529-246f-4429-84e2-1f1b180b250d", - "label": "The Chronicle of Higher Education", - "creator": "Simon Kornblith, Avram Lyon", - "target": "^http://chronicle\\.com/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-01 20:03:35" -} - -/* - This translator works on articles posted in The Chronicle of Higher Education. - - It is based on the earlier translator by Simon Kornblith, but the Chronicle has - significantly restructured the site since 2006, breaking the old translator. -*/ - -function detectWeb(doc, url) { - /* The /daily/ and /weekly/ sections are leftover from the previous version - of the translator; they don't appear to still be on the Chronicle site, but - they might persist in older URLs. */ - var articleRegexp = /^http:\/\/chronicle\.com\/(daily|weekly|article|blogPost|blogs\/\w+)\/[^/]+\// ; - if(articleRegexp.test(url)) { - var section = url.match(articleRegexp); - switch (section[1]) { - case "weekly": - case "daily": - case "article": - return "newspaperArticle"; - case "blogPost": - return "blogPost"; - default: - if (section[1].indexOf("blogs") !== -1) - return "blogPost"; - return false; - } - } else { - // This approach, used again below, is pretty crude. - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - if(articleRegexp.test(aTags[i].href)) { - return "multiple"; - } - } - } -} - -function doWeb (doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = {}; - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - var articleRegexp = /^http:\/\/chronicle\.com\/(daily|weekly|article|blogPost|blogs\/\w+)\/[^/]+\//; - if(articleRegexp.test(aTags[i].href)) { - items[aTags[i].href] = aTags[i].textContent; - } - } - items = Zotero.selectItems(items); - if(!items) return true; - for (var i in items) { - articles.push(i); - } - } else { - articles = [url]; - } - - Zotero.Utilities.processDocuments(articles, function(doc) { - var type = detectWeb(doc, doc.location.href); - item = new Zotero.Item(type); - - item.url = doc.location.href; - item.publicationTitle = "The Chronicle of Higher Education"; - // Does the ISSN apply to online-only blog posts? - item.ISSN = "0009-5982"; - - var byline = doc.evaluate('//p[@class="byline"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if (byline !== null) { - var authors = parseAuthors(byline.textContent); - for (var i = 0; i < authors.length; i++) { - item.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } - - // Behavior for some items is different: - if(type === "blogPost") { - var dateline = doc.evaluate('//p[@class="time"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if (dateline !== null) { - item.date = Zotero.Utilities.trimInternal(dateline.textContent); - } - item.title = doc.evaluate('//div[@class="blog-mod"]//h1[@class="entry-title" or @class="title"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - // We keep the Chronicle as the Website Type, for lack of a better place - item.websiteType = item.publicationTitle; - item.publicationTitle = doc.evaluate('//div[@class="header-breadcrumb-wrap"]/ul/li[last()]/a', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else { - var dateline = doc.evaluate('//p[@class="dateline"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if (dateline !== null) { - item.date = dateline.textContent; - } - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="article"]/h1', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.section = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="header-breadcrumb-wrap"]/h1', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - - // Some items have publication details at the end of the article; one - // example is: http://chronicle.com/article/Grinnells-Green-Secrets/2653/ - var articleParagraphs = doc.evaluate('//div[@class="article-body"]/p', doc, ns, XPathResult.ANY_TYPE, null); - var par; - while ((par = articleParagraphs.iterateNext()) !== null) { - var data = par.textContent.match(/Section: ([a-zA-Z -&]+)[\n\t ]+Volume ([0-9]+), Issue ([0-9]+), Page ([0-9A-Za-z]+)/); - if (data !== null && data.length > 0) { - item.pages = data[4]; - // If the section here and in the page proper are different, concatenate - if (item.section !== data[1]) - item.section = item.section + " : " + Zotero.Utilities.trimInternal(data[1]); - // Since newspaperArticle doesn't have Volume / Issue, put as Edition - item.edition = "Volume " + data[2] + ", Issue " + data[3]; - } - } - } - - item.attachments.push({url:doc.location.href, title: ("Chronicle of Higher Education Snapshot"), mimeType:"text/html"}); - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} - -function parseAuthors(author) { - // Sometimes we have "By Author and Author" - if(author.substr(0, 3).toLowerCase() == "by ") { - author = author.substr(3); - } - - // Sometimes the author is in all caps - var pieces = author.split(" "); - for (var i = 0; i < pieces.length; i++) { - // TODO Make the all-caps character class more inclusive - if (pieces[i].match(/[A-Z-]+/) !== null) - pieces[i] = Zotero.Utilities.capitalizeTitle(pieces[i].toLowerCase(), true); - } - author = pieces.join(" "); - - // Somtimes we have multiple authors - var authors = author.split(" and "); - return authors; -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://chronicle.com/blogs/profhacker/the-second-day-of-thatcamp/23068", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "Amy", - "lastName": "Cavender", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Chronicle of Higher Education Snapshot", - "mimeType": "text/html" - } - ], - "url": "http://chronicle.com/blogs/profhacker/the-second-day-of-thatcamp/23068", - "publicationTitle": "ProfHacker", - "ISSN": "0009-5982", - "date": "March 26, 2010, 2:07 pm", - "title": "The Second Day of THATCamp", - "websiteType": "The Chronicle of Higher Education", - "libraryCatalog": "The Chronicle of Higher Education" - } - ] - }, - { - "type": "web", - "url": "http://chronicle.com/article/A-Little-Advice-From-32000/46210/", - "items": [ - { - "itemType": "newspaperArticle", - "creators": [ - { - "firstName": "Adam", - "lastName": "Fagen", - "creatorType": "author" - }, - { - "firstName": "Kimberly Suedkamp", - "lastName": "Wells", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Chronicle of Higher Education Snapshot", - "mimeType": "text/html" - } - ], - "url": "http://chronicle.com/article/A-Little-Advice-From-32000/46210/", - "publicationTitle": "The Chronicle of Higher Education", - "ISSN": "0009-5982", - "date": "January 14, 2002", - "title": "A Little Advice From 32,000 Graduate Students", - "section": "Advice", - "libraryCatalog": "The Chronicle of Higher Education" - } - ] - }, - { - "type": "web", - "url": "http://chronicle.com/article/Grinnells-Green-Secrets/2653/", - "items": [ - { - "itemType": "newspaperArticle", - "creators": [ - { - "firstName": "Xiao-Bo", - "lastName": "Yuan", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Chronicle of Higher Education Snapshot", - "mimeType": "text/html" - } - ], - "url": "http://chronicle.com/article/Grinnells-Green-Secrets/2653/", - "publicationTitle": "The Chronicle of Higher Education", - "ISSN": "0009-5982", - "date": "June 16, 2006", - "title": "Grinnell's Green Secrets", - "section": "News", - "libraryCatalog": "The Chronicle of Higher Education" - } - ] - }, - { - "type": "web", - "url": "http://chronicle.com/blogPost/humanities-cyberinfrastructure-project-bamboo/6138", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "Stan", - "lastName": "Katz", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Chronicle of Higher Education Snapshot", - "mimeType": "text/html" - } - ], - "url": "http://chronicle.com/blogPost/humanities-cyberinfrastructure-project-bamboo/6138", - "publicationTitle": "Brainstorm", - "ISSN": "0009-5982", - "date": "July 17, 2008, 01:29 PM ET", - "title": "Humanities Cyberinfrastructure: Project Bamboo", - "websiteType": "The Chronicle of Higher Education", - "libraryCatalog": "The Chronicle of Higher Education", - "shortTitle": "Humanities Cyberinfrastructure" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/The Daily Beast.js b/translators/The Daily Beast.js @@ -1,142 +0,0 @@ -{ - "translatorID": "3bdaeab1-2200-4e18-a68a-430d1cd50d21", - "label": "The Daily Beast", - "creator": "Sebastian Karcher", - "target": "^https?://(.*)thedailybeast\\.com", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-15 10:16:53" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - - - -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'webpage', -detect : FW.Xpath('//div[@id="floatingmod"]/h1'), -title : FW.Xpath('//div[@id="floatingmod"]/h1').text().trim(), -attachments : [{ url: FW.Url().remove(/\?(.*)/).remove(/full\//).append("full\/"), - title: "Daily Beast Snapshot", - type: "text/html" }], -creators : FW.Xpath('//div[@class="author1"]//a[@class="author-link-black"]') - .text().replace(/\s/," ").cleanAuthor("author"), -date : FW.Xpath('//div[@class="timestamp"]').text().replace(/\|/,"").trim(), -tags : FW.Xpath('//div[@class="relatedsearches"]/a').text(), -abstractNote : FW.Xpath('//span[@class="articlebyline"]').text(), -publicationTitle : "The Daily Beast" -}); - -/** Daily Dish */ -FW.Scraper({ -itemType : 'blogpost', -detect : FW.Xpath('//div[@class="pagination"]/a[@href="http://andrewsullivan.thedailybeast.com/"]'), -title : FW.Xpath('//div[@class="entry"]/h1/a').text().trim(), -attachments : [{ url: FW.Url(), - title: "The Dish Snapshot", - type: "text/html" }], -creators : FW.Xpath('//ul[@class="mastheadList"]/li[2]/h2/em').text().cleanAuthor("author"), -date : FW.Xpath('//time').text().replace(/\|/,"").trim(), -publicationTitle : "Andrew Sullivan - The Dish" -}); - -/** Daily Dish Multiple */ -FW.MultiScraper({ -itemType : 'multiple', -detect : FW.Xpath('//li/article'), -choices : { - titles : FW.Xpath('//div[@class="entry"]/h1/a').text().trim(), - urls : FW.Xpath('//div[@class="entry"]/h1/a').key("href") -} -}); - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://www.thedailybeast.com/blogs-and-stories/2011-06-13/michele-bachmann-for-president-2012-she-grabs-nh-gop-debate-spotlight/", - "items": [ - { - "itemType": "webpage", - "creators": [ - { - "firstName": "Howard", - "lastName": "Kurtz", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Barack Obama", - "Sarah Palin", - "Tea Party", - "Us News", - "Newt Gingrich", - "Mitt Romney", - "Michele Bachmann", - "Tim Pawlenty", - "Obamacare", - "2012 Presidential Campaign", - "Herman Cain", - "Gop Presidential Candidates" - ], - "seeAlso": [], - "attachments": [ - { - "url": "http://www.thedailybeast.com/blogs-and-stories/2011-06-13/michele-bachmann-for-president-2012-she-grabs-nh-gop-debate-spotlight/full/", - "title": "Daily Beast Snapshot", - "type": "text/html" - } - ], - "url": "http://www.thedailybeast.com/blogs-and-stories/2011-06-13/michele-bachmann-for-president-2012-she-grabs-nh-gop-debate-spotlight/", - "abstractNote": "The congresswoman used her bluntness and charm to overshadow the men at the GOP debate—announcing her presidential bid and passionately defending the Tea Party. Howard Kurtz on why she shouldn’t be underestimated.", - "date": "June 13, 2011 11:35pm", - "publicationTitle": "The Daily Beast", - "title": "Michele Bachmann Grabs GOP Presidential Debate Spotlight", - "libraryCatalog": "The Daily Beast", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - }, - { - "type": "web", - "url": "http://andrewsullivan.thedailybeast.com/2011/06/hathos-alert-4.html", - "items": [ - { - "itemType": "blogpost", - "creators": [ - { - "firstName": "Andrew", - "lastName": "Sullivan", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": "http://andrewsullivan.thedailybeast.com/2011/06/hathos-alert-4.html", - "title": "The Dish Snapshot", - "type": "text/html" - } - ], - "url": "http://andrewsullivan.thedailybeast.com/2011/06/hathos-alert-4.html", - "date": "15 Jun 2011 08:02 AM", - "publicationTitle": "Andrew Sullivan - The Dish", - "title": "Tea Party Summer Camp", - "libraryCatalog": "The Daily Beast", - "accessDate": "CURRENT_TIMESTAMP" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/The Economist.js b/translators/The Economist.js @@ -1,122 +0,0 @@ -{ - "translatorID":"6ec8008d-b206-4a4c-8d0a-8ef33807703b", - "label":"The Economist", - "creator":"Michael Berkowitz", - "target":"^http://(www\\.)?economist\\.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "translatorType":4, - "lastUpdated":"2010-10-03 13:27:34" -} - -function detectWeb(doc, url) { - if (doc.location.href.indexOf("search") != -1) { - /* Multiple article download disabled-- broken. - TODO Fix multiple article download. */ - //return "multiple"; - } else if (doc.location.href.toLowerCase().indexOf("node") != -1) { - return "magazineArticle"; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - newItem = new Zotero.Item("magazineArticle"); - newItem.ISSN = "0013-0613"; - newItem.url = doc.location.href; - newItem.publicationTitle = "The Economist"; - - - //get headline - var title = new Array(); - if (doc.title && doc.title != "" && doc.title != "Economist.com") { - title = doc.title.split(" | "); - } else { - title.push(doc.evaluate('//div[@class="clear"][@id="pay-barrier"]/div[@class="col-left"]/div[@class="article"]/font/b', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - - if (title.length == 1) { - title.push = title; - } else { - title = title.slice(0, title.length - 1); - title = title.join(": "); - } - newItem.title = title; - - if (doc.evaluate('//div[@class="clear"][@id="pay-barrier"]/div[@class="col-right"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - newItem.extra = "(Subscription only)"; - } - - if (newItem.extra == "(Subscription only)"){ newItem.complete(); return;} - //get abstract - if (doc.evaluate('//div[@id="content"]/div[@class="clear top-border"]/div[@class="col-left"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - newItem.abstractNote = doc.evaluate('//div[@id="content"]/div[@class="clear top-border"]/div[@class="col-left"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//div[@class="clear"][@id="pay-barrier"]/div[@class="col-left"]/div[@class="article"]/p/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - newItem.abstractNote = doc.evaluate('//div[@class="clear"][@id="pay-barrier"]/div[@class="col-left"]/div[@class="article"]/p/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (doc.evaluate('//div[@id="content"]/div[@class="clear top-border"]/div[@class="col-left"]/p[3]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate('//div[@id="content"]/div[@class="clear top-border"]/div[@class="col-left"]/p[3]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - if (newItem.abstractNote) newItem.abstractNote = Zotero.Utilities.trimInternal(newItem.abstractNote); - //get date and extra stuff - if (doc.evaluate('//p[@class="ec-article-info"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - newItem.date = Zotero.Utilities.trim(doc.evaluate('//p[@class="ec-article-info"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split("|")[0]); - } - - var url = doc.location.href; - newItem.attachments = [ - {url:url.replace("displaystory", "PrinterFriendly"), title:"The Economist Snapshot", mimeType:"text/html"} - ]; - - newItem.complete(); -} - - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - - var urls = new Array(); - - if (doc.title == "Search | Economist.com") { - var items = new Array(); - var uris = new Array(); - var results = doc.evaluate('//ol[@class="search-results"]/li/h2/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var headline = results.iterateNext(); - while (headline) { - items.push(headline.textContent); - uris.push(headline.href); - Zotero.debug(headline.href); - headline = results.iterateNext(); - } - - var newItems = new Object(); - for (var i = 0 ; i <items.length ; i++) { - newItems[uris[i]] = items[i]; - } - - newItems = Zotero.selectItems(newItems); - if (!newItems) { - return true; - } - - for (var i in newItems) { - urls.push(i); - } - } else if (doc.location.href.toLowerCase().indexOf("node") != -1) { - scrape(doc, url); - return; - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - - Zotero.wait(); -} diff --git a/translators/The Free Dictionary.js b/translators/The Free Dictionary.js @@ -1,29 +0,0 @@ -{ - "translatorID":"0c661209-5ec8-402b-8f18-7dec6ae37d95", - "translatorType":4, - "label":"The Free Dictionary", - "creator":"Michael Berkowitz", - "target":"http://(.*\\.)?thefreedictionary.com/(\\w+)", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-15 00:30:00" -} - -function detectWeb(doc, url) { - return "dictionaryEntry"; -} - -function doWeb(doc, url) { - var item = new Zotero.Item('dictionaryEntry'); - item.title = Zotero.Utilities.capitalizeTitle(url.replace("+", " ").match(/[^/]+$/)[0]); - item.dictionaryTitle = "The Free Dictionary"; - var defs = doc.evaluate('//div[@class="pseg"]', doc, null, XPathResult.ANY_TYPE, null); - var def; - while (def = defs.iterateNext()) { - item.notes.push({note:Zotero.Utilities.trimInternal(def.textContent)}); - } - item.url = - item.complete(); -} -\ No newline at end of file diff --git a/translators/The Globe and Mail.js b/translators/The Globe and Mail.js @@ -1,221 +0,0 @@ -{ - "translatorID":"e0234bcf-bc56-4577-aa94-fe86a27f6fd6", - "translatorType":4, - "label":"The Globe and Mail", - "creator":"Adam Crymble", - "target":"http://www.theglobeandmail.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-04 07:10:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var metaTags = new Object(); - var metaTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < metaTagHTML.length ; i++) { - metaTags[metaTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content")); - - } - - if (doc.evaluate('//div[@id="header"]/h2/a/img', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var printEdition1 = doc.evaluate('//div[@id="header"]/h2/a/img', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().src; - if (printEdition1.match("printedition")) { - return "newspaperArticle"; - } - } - - if (doc.evaluate('//p[@id="continueReading"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var payPerView = doc.evaluate('//p[@id="continueReading"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (payPerView == "purchase this article") { - return "newspaperArticle"; - } - } - - if (metaTags["article_id"]) { - return "newspaperArticle"; - - } else if (doc.title.match('globeandmail.com: Search')) { - return "multiple"; - } - - if (doc.evaluate('//ul[@id="utility"]/li[@class="email"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var blogCheck = doc.evaluate('//ul[@id="utility"]/li[@class="email"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var blogCheck1 = blogCheck.iterateNext().textContent; - if (blogCheck1.match("blog")) { - if (doc.location.href.match("story")) { - return "blogPost"; - } - } - } -} - -//Translator for the Globe and Mail newspaper: code by Adam Crymble - -function associateMeta (newItem, metaTags, field, zoteroField) { - if (metaTags[field]) { - newItem[zoteroField] = metaTags[field]; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if (detectWeb(doc, url) == "blogPost") { - var newItem = new Zotero.Item("blogPost"); - - var title = doc.evaluate('//div[@id="headline"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null); - newItem.title = title.iterateNext().textContent; - - var blogger = doc.evaluate('//div[@id="author"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null); - var bloggerName = blogger.iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - var bloggerName1 = bloggerName.split(","); - newItem.creators.push(Zotero.Utilities.cleanAuthor(bloggerName1[0], "author")); - } - var noMetaType = 0; - - if (detectWeb(doc, url) == "newspaperArticle") { - var newItem = new Zotero.Item("newspaperArticle"); - - //checks if the article is from the "Print Edition" which doesn't contain meta data. - if (doc.evaluate('//div[@id="header"]/h2/a/img', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var printEdition1 = doc.evaluate('//div[@id="header"]/h2/a/img', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().src; - if (printEdition1.match("printedition")) { - noMetaType = 1; - if (doc.evaluate('//div[@id="author"]/p[@class="article-date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.date= doc.evaluate('//div[@id="author"]/p[@class="article-date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - } - } - - //checks if the article is a Pay per view article. - if (doc.evaluate('//p[@id="continueReading"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var payPerView = doc.evaluate('//p[@id="continueReading"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (payPerView == "purchase this article") { - noMetaType = 1; - } - } - - //format for the "Print Edition" and "Pay per view" articles - if (noMetaType = 1) { - noMetaType = 1; - if (doc.evaluate('//div[@id="headline"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.title = doc.evaluate('//div[@id="headline"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - if (doc.evaluate('//div[@id="author"]/p[@class="byline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate('//div[@id="author"]/p[@class="byline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - noMetaType = 0; - } - - var metaTags = new Object(); - var tagsContent = new Array(); - - //get data - var metaTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < metaTagHTML.length ; i++) { - metaTags[metaTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content")); - } - - //author - if (metaTags["byline"]) { - var author = metaTags["byline"]; - } - - //date - if (metaTags["pubdate"]) { - var month = metaTags["pubdate"].substr(4, 2); - var day = metaTags["pubdate"].substr(6, 2); - var year = metaTags["pubdate"].substr(0, 4); - - newItem.date = (year + "-" + month + "-"+ day); - } - - //tags - if (metaTags["article_keywords"]) { - tagsContent = metaTags["article_keywords"].split("; "); - } - - for (var i = 0; i < tagsContent.length; i++) { - if (tagsContent[i] != (" ") && tagsContent[i] != ("")) { - newItem.tags[i] = tagsContent[i]; - } - } - - associateMeta (newItem, metaTags, "headline", "title"); - associateMeta (newItem, metaTags, "summary", "abstractNote"); - associateMeta (newItem, metaTags, "desk", "section"); - associateMeta (newItem, metaTags, "article_id", "callNumber"); - associateMeta (newItem, metaTags, "credit", "rights"); - - //rest of author (shared between both newspaperArticle types) - if (author) { - - - if (author.substr(0,3).toLowerCase() == "by ") { - author= author.substr(3); - } - - var authors = author.toLowerCase().split(" and "); - for each(var author in authors) { - var words = author.split(" "); - - for (var i in words) { - if (words[i] != "") { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - } - } - author = words.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - } - - newItem.url = doc.location.href; - newItem.complete(); - -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var next_title = new Array(); - - var titlesCount = doc.evaluate('count (//h3[@class="storyLink"]/a)', doc, nsResolver, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate('//h3[@class="storyLink"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i < titlesCount.numberValue; i++) { - next_title = titles.iterateNext(); - - if (next_title.href.match("story")) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/The Hamilton Spectator.js b/translators/The Hamilton Spectator.js @@ -1,114 +0,0 @@ -{ - "translatorID":"c9338ed5-b512-4967-8ffe-ab9c973559ef", - "translatorType":4, - "label":"The Hamilton Spectator", - "creator":"Adam Crymble", - "target":"http://www.thespec.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-04 07:10:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("search")) { - return "multiple"; - } else if (doc.location.href.match("article")) { - return "newspaperArticle"; - } -} - -//Hamilton Spectator translator. code by Adam Crymble - -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("newspaperArticle"); - - if (doc.title.match("TheSpec.com - ")) { - var lineBreak = doc.title.lastIndexOf(" - "); - newItem.section = doc.title.substr(14, lineBreak-14); - } - - var xPathAbstract = '//span[@class="subhead1"][@id="ctl00_ContentPlaceHolder_article_NavWebPart_Article_ctl00___SubTitle1__"]'; - if (doc.evaluate(xPathAbstract, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate(xPathAbstract, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - var xPathAuthor1 = '//span[@class="articleAuthor"][@id="ctl00_ContentPlaceHolder_article_NavWebPart_Article_ctl00___Author1__"]'; - if (doc.evaluate(xPathAuthor1, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author1 = doc.evaluate(xPathAuthor1, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (author1.match(", ")) { - author1 = author1.split(", "); - author1 = author1[0]; - } - var words = author1.toLowerCase().split(/\s/); - - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - } - - author1 = words.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author1, "author")); - } - - var xPathAuthor2 = '//span[@class="articleAuthor"][@id="ctl00_ContentPlaceHolder_article_NavWebPart_Article_ctl00___Author2__"]'; - if (doc.evaluate(xPathAuthor2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author2 = doc.evaluate(xPathAuthor2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - if (author2.match(", ")) { - author2 = author2.split(", "); - author2 = author2[0]; - } - var words = author2.toLowerCase().split(/\s/); - - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - } - - author2 = words.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author2, "author")); - } - - var xPathTitle = '//span[@class="headlineArticle"][@id="ctl00_ContentPlaceHolder_article_NavWebPart_Article_ctl00___Title__"]'; - newItem.title = doc.evaluate(xPathTitle, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - newItem.url = doc.location.href; - newItem.publicationTitle = "The Hamilton Spectator"; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.href.match("article") && !next_title.href.match("229246") && !next_title.textContent.match(/\s\s\s/)) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/The Hindu.js b/translators/The Hindu.js @@ -1,124 +0,0 @@ -{ - "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, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:32:21" -} - -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"; - } -} - -function regexMeta(str, item) { - var re = /NAME\=\"([\w\W]*?)\"\s+CONTENT\=\"([\w\W]*?)\"/; - var stuff = str.match(re); - 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") { - var xpath = '//h2[@class="r"]/a[@class="l"]'; - var links = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var link; - var items = new Object(); - while (link = links.iterateNext()) { - items[link.href] = link.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - - } else { arts = [url]; } - for each (var art in arts) { - Zotero.debug(art); - Zotero.Utilities.HTTP.doGet(art, function(text) { - var newItem = new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "The Hindu"; - newItem.url = art; - //title - var t = /\<TITLE\>[\w\W]*\:([\w\W]*?)<\/TITLE/; - newItem.title = Zotero.Utilities.unescapeHTML(Zotero.Utilities.capitalizeTitle(text.match(t)[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.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; - var metaTags = text.match(meta); - for (var i = 0 ; i <metaTags.length ; i++) { - regexMeta(metaTags[i], newItem); - } - newItem.complete(); - Zotero.done(); - }); - 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 **/ diff --git a/translators/The Microfinance Gateway.js b/translators/The Microfinance Gateway.js @@ -1,59 +0,0 @@ -{ - "translatorID":"2cd7d362-5fba-423a-887f-579ed343e751", - "translatorType":4, - "label":"The Microfinance Gateway", - "creator":"Michael Berkowitz", - "target":"http://(www.)?microfinancegateway.org/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/results\.php/) || url.match(/search/)) { - return "multiple"; - } else if (url.match(/content\/article/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var ns = doc.documentElement.namespaceURI; - var nsResolver = ns ? function (prefix) { - if (prefix == 'x') return ns; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = Zotero.Utilities.getItemArray(doc, doc, "content/article/detail"); - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//td[2][@class="main_content_box"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var authors = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="source"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent).split(/(\.,|&)/); - for each (var aut in authors) { - if (aut.match(/\w+/)) { - item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(aut), "author", true)); - } - } - item.url = doc.location.href; - item.date = Zotero.Utilities.trimInternal(doc.evaluate('//span[@class="date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//span[@class="summary"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var pdfurl = doc.evaluate('//div[@class="articleTopics"]/div/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href; - item.publicationTitle = doc.evaluate('//div[@class="articleTopics"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/Published\s+by:\s+(.*)\n/)[1]; - item.attachments = [ - {url:item.url, title:item.title + " Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:item.title + " PDF", mimeType:"application/pdf"} - ]; - - item.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/The Nation.js b/translators/The Nation.js @@ -1,134 +0,0 @@ -{ - "translatorID":"0d6f8450-72e8-4d8f-bdc2-b7fa03e6f2c5", - "label":"The Nation", - "creator":"odie5533", - "target":"^http://www\\.thenation\\.com", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"0", - "translatorType":4, - "creator":"odie5533", - "lastUpdated":"2010-08-08 01:01:01" -} - -/* - The Nation - translator for Zotero - Copyright (C) 2010 odie5533 - - 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/>. -*/ - - -PUB_TITLE = "The Nation"; -PUB_ISSN = "0027-8378"; -XPATH_TITLE = "substring-before(string(//title[contains(.,'Nation')]), ' | The \ -Nation')"; -XPATH_PAGES = null; -XPATH_DATE = "//span[@class='article-date']"; -RE_DATE = /(.*)/; -XPATH_AUTHORS = "//span[@property='dc:creator']"; -RE_AUTHORS = /(.*)/; -RE_ARTICLE_URL = '^http://www\\.thenation\\.com/(?:article|blog|video)/(?!.*com\ -ment$)'; -RE_PRETTY_URL = /com\//; -RE_PRETTY_URL_REPLACE = "com/print/"; -RE_SKIP_AUTHOR_PARSING = /(?:Nation in the News)/; - -function detectWeb(doc, url) { - if (!xpath_string(doc, doc, XPATH_TITLE)) - return; - if (url.match(RE_ARTICLE_URL)) - return "magazineArticle"; - else - return "multiple"; -} - -function xpath_string(doc, node, xpath) { - var res = doc.evaluate(xpath, node, null, XPathResult.STRING_TYPE, null); - if (!res || !res.stringValue) - return null; - return Zotero.Utilities.trim(res.stringValue); -} - -function xpre(doc, node, xpath, reg) { - var xpmatch = xpath_string(doc, node, xpath); - return reg ? reg.exec(xpmatch)[1] : xpmatch; -} - -function scrapeSingle(doc, url) { - var newItem = new Zotero.Item("magazineArticle"); - if (PUB_TITLE) newItem.publicationTitle = PUB_TITLE; - if (PUB_ISSN) newItem.ISSN = PUB_ISSN; - newItem.url = url; - - newItem.title = xpath_string(doc, doc, XPATH_TITLE); - - if (XPATH_DATE) { - var date = xpre(doc, doc, XPATH_DATE, RE_DATE); - if (date != 'null') - newItem.date = date; - } - if (XPATH_PAGES) - newItem.pages = xpath_string(doc, doc, XPATH_PAGES); - - //authors - var author_text = xpre(doc, doc, XPATH_AUTHORS, RE_AUTHORS); - var authors = []; - if (author_text) { - if (author_text.indexOf(" and ") != -1) - authors = author_text.split(" and "); - else if (author_text.indexOf(";") != -1) - authors = author_text.split(";"); - else - authors.push(author_text); - } - for each(var a in authors) { - if (a == 'null') - continue; - if (a.match(RE_SKIP_AUTHOR_PARSING)) - newItem.creators.push({firstName:a, creatorType:"author"}); - else - newItem.creators.push(Zotero.Utilities.cleanAuthor(a, "author")); - } - - var snapUrl = url; - if (RE_PRETTY_URL) snapUrl = snapUrl.replace(RE_PRETTY_URL, - RE_PRETTY_URL_REPLACE); - // attach html - newItem.attachments.push({title:PUB_TITLE+" Snapshot", mimeType:"text/html", - url:snapUrl, snapshot:true}); - - return newItem; -} - -function doWeb(doc, url) { - if (detectWeb(doc, url) != 'multiple') - scrapeSingle(doc, url).complete(); - else { - var items = Zotero.Utilities.getItemArray(doc, doc, RE_ARTICLE_URL); - items = Zotero.selectItems(items); - if(!items) - return true; - - var urls = new Array(); - for(var i in items) - urls.push(i); - - Zotero.Utilities.processDocuments(urls, function(d,u) { - scrapeSingle(d,d.location.href).complete(); - }, function() {Zotero.done();}); - Zotero.wait(); - } -} diff --git a/translators/The New York Review of Books.js b/translators/The New York Review of Books.js @@ -1,65 +0,0 @@ -{ - "translatorID": "4c164cc8-be7b-4d02-bfbf-37a5622dfd56", - "label": "The New York Review of Books", - "creator": "Simon Kornblith, Avram Lyon", - "target": "^https?://www\\.nybooks\\.com/", - "minVersion": "1.0.0b3.r1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-24 01:17:10" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'newspaperArticle', -detect : FW.Url().match(/\/articles\/archives\//), -title : FW.Xpath('//div[@id="page-title"]/h2').text().trim(), -creators : FW.Xpath('//div[@id="page-title"]/h3').text().cleanAuthor("author"), -url : FW.Url().remove(/\?.*/), -attachments : [ - { url : FW.Url().remove(/\?.*/).append("?pagination=false"), - type : "text/html", - title : "NYRB Snapshot" - }], -date : FW.Xpath('//div[@id="page-title"]/h5').text(), -abstractNote : FW.Xpath('//div[contains(@class, "article-reviewed-items")]').text().trimInternal().prepend("Review of: "), -publicationTitle : "The New York Review of Books", -ISSN : "0028-7504" -}); - -/** Blog Posts */ -FW.Scraper({ -itemType : 'blogPost', -detect : FW.Url().match(/\/blogs\//), -title : FW.Xpath('//div[@id="article-body"]/h2').text().trim(), -creators : FW.Xpath('//div[@id="article-body"]/h3').text().cleanAuthor("author"), -url : FW.Url().remove(/\?.*/), -attachments : [ - { url : FW.Url().remove(/\?.*/).append("?pagination=false"), - type : "text/html", - title : "NYRB Snapshot" - }], -date : FW.Xpath('//div[@id="article-body"]//em[last()]').text(), -blogTitle : "NYRblog" -}); - -/** Search results */ -FW.MultiScraper({ -itemType : "multiple", -detect : FW.Url().match(/\/search\/\?(.*)q=./), -choices : { titles : FW.Xpath('//table[@class="result-table"]/tbody/tr/td[2]/h3/a').text(), -urls : FW.Xpath('//table[@class="result-table"]/tbody/tr/td[2]/h3/a').key('href').text() } -}); - -/** Issue ToC */ -FW.MultiScraper({ -itemType : "multiple", -detect : FW.Url().match(/\/issues\//), -choices : { titles : FW.Xpath('//ul[@class="issue-article-list"]/li/h3/a').text(), -urls : FW.Xpath('//ul[@class="issue-article-list"]/li/h3/a').key('href').text() } -}); diff --git a/translators/The New Yorker.js b/translators/The New Yorker.js @@ -1,54 +0,0 @@ -{ - "translatorID": "0fba73bf-f113-4d36-810f-2c654fa985fb", - "label": "The New Yorker", - "creator": "Sebastian Karcher", - "target": "^https?://www\\.newyorker\\.com", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "browserSupport":"gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-17 18:54:40" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'magazineArticle', -detect : FW.Xpath('//div[@id="articleheads"]'), -title : FW.Xpath('//div[@id="articleheads"]/h1').text().trim(), -attachments: [{ url: FW.Xpath('//li[@class="utility-print"]/a').key('href').text(), - type : "text/html", - title : "The New Yorker"}], - abstractNote: FW.Xpath('//div[@id="articleheads"]/h2').text().trim(), -creators : FW.Xpath('//div[@id="articleheads"]/h4/span[@class="c cs"]/a').text().cleanAuthor("author"), -date : FW.Xpath('//div[@id="articleheads"]/h4/span[@class="dd dds"]').text().trimInternal(), -publicationTitle : "The New Yorker", -ISSN: "0028-792X", -tags: FW.Xpath('//div[@id="keywords"]').text().trimInternal().remove(/Keywords?/).split(';') -}); - - /** Blog Posts */ - FW.Scraper({ -itemType : 'blogPost', -detect : FW.Xpath('//div[@id="blogs"]'), -title : FW.Xpath('//div[@id="pagebody"]/*/h3').text().trim(), -attachments: [{ url: FW.Xpath('//li[@class="utility-print"]/a').key('href').text(), - type : "text/html", - title : "The New Yorker"}], -creators : FW.Xpath('//cite[@class="vcard author"]').text().cleanAuthor("author"), -date : FW.Xpath('//div[@id="pagebody"]/*/div[@class="published"]').text(), -publicationTitle : "The New Yorker Blogs", -tags: FW.Xpath('//div[@class="entry-keywords"]/ul').text().trimInternal().remove(/Keywords?/).split(';') -}); - -/** Search results */ -FW.MultiScraper({ -itemType : "multiple", -detect : FW.Xpath('//div[@class="results"]'), -choices : {titles : FW.Xpath('//div[@class="info"]/h3[@class="header"]/a').text(), -urls : FW.Xpath('//div[@class="info"]/h3[@class="header"]/a').key('href').text() } -}); diff --git a/translators/The Open Library.js b/translators/The Open Library.js @@ -1,173 +0,0 @@ -{ - "translatorID":"96b54986-16c7-45ea-b296-fde962d658b2", - "translatorType":4, - "label":"The Open Library", - "creator":"Adam Crymble", - "target":"http://openlibrary.org", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-24 05:30:00" -} - -function detectWeb(doc, url) { - - if (doc.location.href.match("search")) { - return "multiple"; - } else if (doc.evaluate('//div[@class="title-pad"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } - -} - -//Open Library Translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - - newItem.title = doc.evaluate('//div[@class="title-pad"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - if (doc.evaluate('//div[@id="header"]/div[@class="subtitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate('//div[@id="header"]/div[@class="subtitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - var m = 0; - if (doc.evaluate('//div[@id="statement"]/span[@class="book-details-italic"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var publisher = doc.evaluate('//div[@id="statement"]/span[@class="book-details-italic"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var publisher1 = publisher.split(/\n/); - for (var i= 0; i < publisher1.length; i++) { - publisher1[i] = publisher1[i].replace(/^\s*|\s+$/g, ''); - if (publisher1[i].match("Published in ")) { - newItem.date = publisher1[i].substr(13, publisher1[i].length-3); - m = i+1; - } else if (publisher1[i].match(/\(/)) { - newItem.place = publisher1[i]; - } - } - - if (m > 0) { - newItem.publisher = publisher1[m]; - } - } - - var headers = doc.evaluate('//td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//td[1])', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, ''); - dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - - //author - if (doc.evaluate('//div[@id="statement"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var author = doc.evaluate('//div[@id="statement"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var author = author.split(/\n/); - for (var i in author) { - author[i] = author[i].replace(/^\s*|\s*$/g, ''); - if (author[i].match(/^by/)) { - author = author[i].substr(3); - - if (author.match(", ")) { - if (author.match(/\s/)) { - var wordcount = author.split(/\s/); - - if (wordcount.length > 3) { - - var words = author.split(", "); - for (var k in words) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(words[k], "author")); - } - - } else { - - var words = author.split(", "); - author = words[1] + " " + words[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - break; - } - } - } else { - - newItem.creators.push({lastName: author, creatorType: "creator"}); - break; - } - } - } - } - - var m = 0; - if (dataTags["Subject:"]) { - if (dataTags["Subject:"].match(/\n/)) { - tagsContent = dataTags["Subject:"].split(/\n/); - for (var i = 0; i < tagsContent.length; i++) { - if (tagsContent[i].match(/\w/)) { - newItem.tags[m] = tagsContent[i]; - m++; - } - } - } else { - newItem.tags = dataTags["Subject:"]; - } - } - - if (dataTags["ISBN13:"]) { - newItem.extra = "ISBN 13: " + dataTags["ISBN13:"]; - } - - associateData (newItem, dataTags, "Language:", "language"); - associateData (newItem, dataTags, "ISBN10:", "ISBN"); - associateData (newItem, dataTags, "Series:", "series"); - associateData (newItem, dataTags, "Edition:", "edition"); - associateData (newItem, dataTags, "Pagination:", "pages"); - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//td[2][@class="result-text"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/The Telegraph.js b/translators/The Telegraph.js @@ -1,73 +0,0 @@ -{ - "translatorID": "40b9ca22-8df4-4f3b-9cb6-8f9b55486d30", - "label": "The Telegraph", - "creator": "Reino Ruusu", - "target": "^http://www\\.telegraph\\.co\\.uk/", - "minVersion": "1.0.0b4.r5", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-05 19:58:29" -} - -function detectWeb(doc, url) { - Zotero.debug("detectWeb URL= "+ url); - var result = doc.evaluate('html/head/meta[@name = "article-id"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (result) { - return "newspaperArticle"; - } - return null; -} - -function getAuthors(byline) { - if (byline.search(/.+(?:,\s.+)+\sand\s.+/) == -1) { - byline = byline.replace(/,\s.+$/, ""); - } - byline = byline.replace(/\s+(?:in|at)\s+.+$/, ""); - return byline.split(/(?:,\s+|\s+and\s+)/); -} - -function putAuthors(item, byline) { - for each (var a in getAuthors(byline)) { - item.creators.push(Zotero.Utilities.cleanAuthor(a, "author")); - } -} - -function doWeb(doc, url) { - Zotero.debug("doWeb URL= "+ url); - var newArticle = new Zotero.Item('newspaperArticle'); - newArticle.url = url; - newArticle.publicationTitle = 'The Telegraph'; - newArticle.publisher = 'Telegraph Media Group Limited'; - var metaElements = doc.evaluate('html/head/meta', doc, null, XPathResult.ANY_TYPE, null); - var tmp; - while (tmp = metaElements.iterateNext()) { - var name = tmp.getAttribute('name'); - var content = tmp.getAttribute('content'); - if (name == 'title') - newArticle.title = content; - else if (name == 'author' || name == "DCSext.author") { - content = Zotero.Utilities.trim(content); - //Zotero.debug(content); - content = content.replace(/^By\s+/, ""); - putAuthors(newArticle, content); - } - else if (name == 'description') { - newArticle.abstractNote = content.replace(/\s+/gm, " "); - } - } - - var datePath = '//div[@class="story"]/div[@class="byline"]/p[1]/br/following-sibling::text()'; - var dateElement = doc.evaluate(datePath, doc, null,XPathResult.ANY_TYPE, null).iterateNext(); - if (!dateElement) { - datePath = '//div[@class="story"]/div[@class="byline"]/span[@class="publishedDate"]'; - dateElement = doc.evaluate(datePath, doc, null,XPathResult.ANY_TYPE, null).iterateNext(); - } - if (dateElement) { - var dateRE = /\d\d?\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+\d\d\d\d/; - var date = dateElement.textContent.match(dateRE); - if (date) newArticle.date = date[0]; - } - newArticle.complete(); -} diff --git a/translators/The Times UK.js b/translators/The Times UK.js @@ -1,105 +0,0 @@ -{ - "translatorID":"53f8d182-4edc-4eab-b5a1-141698a10101", - "label":"The Times and Sunday Times", - "creator":"Will Smith", - "creator":"Andrew Brown", - "target":"^http://www\\.thetimes\\.co\\.uk/.+ece$", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "translatorType":4, - "lastUpdated":"2010-08-11 17:23:03" -} - -/**/ - -// TimesOnline.co.uk translator. -// Version 1.5 -// Original by William Smith, see http://www.willsmith.org/contactme/ -// extensively tweaked by Andrew Brown to cope with the paywalled structure - - -function detectWeb(doc, url) { - return "newspaperArticle" ; -} - - -function getMeta (doc, field) { - field='//meta[@name="' + field + '"]/@content'; - content = getXPath(doc, field).iterateNext(); - - if (content) { - return content.value; - } - -} - -function getXPath (doc, field) { - xpath=field; - return doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); -} -/* -function getXPathInstance (doc,field) { - xpath=field; - return doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext(); -} -*/ -function doWeb(doc, url){ - - var item = new Zotero.Item("newspaperArticle"); - - //Could be daily or Sunday Times - //The ISSN seems to be the same for both: - item.issn="0140-0460"; - - if (url.search(/\/tto\//)!=-1){ - item.publicationTitle = 'The Times (London)'; - item.title = doc.title.replace("| The Times", ""); - } - - if(url.search(/\/sto\//)!=-1){ - item.publicationTitle = 'The Sunday Times (London)'; - item.title = doc.title.replace("| The Sunday Times", ""); - } - - //Now we have the paper, what section is it in? - var section=url.match(/\/[ts]to\/([^\/]+)/); - // Zotero.debug(section[1]); - // Then print it pretty - item.section=section[1].substr(0,1).toUpperCase() + section[1].substr(1); - - // These next fields are easy... - item.url = url; - item.date=getMeta(doc,"dashboard_published_date"); - item.place="London"; - item.abstractNote = getMeta(doc, "description"); - // alternative, better, way follows - var standfirstXpath=doc.evaluate('//div[@class="cf "]//p[@class="f-standfirst"]',doc,null,XPathResult.ANY_TYPE,null); - // note space after cf in class name, haha, Murdoch really got value from those Times designers - if(standfirstXpath.iterateNext()!=null){ - item.abstractNote=standfirstXpath.iterateNext().textContent; - } - - - // extract authors who may be in an array - var authorXpath=doc.evaluate('//div[@class="cf "]//strong[@class="f-author"]',doc, null, XPathResult.ANY_TYPE, null); - var hack; - while (hack=authorXpath.iterateNext()){ - var hacks= new Array(); - hacks=hack.textContent.split(/and|,/); -// Zotero.debug("hacks: " +hack.textContent.split(/and/)); - if (hacks.length > 1){ - for (var h in hacks){ - item.creators.push(Zotero.Utilities.cleanAuthor(hacks[h],"author")); - } - } - else { - item.creators.push(Zotero.Utilities.cleanAuthor(hack.textContent,"author")); - } - } - - //ATTACH A SNAPSHOT - item.attachments.push({url:url, title:item.title, mimeType:"text/html"}); - item.complete(); -} diff --git a/translators/Time-Blog.com.js b/translators/Time-Blog.com.js @@ -1,139 +0,0 @@ -{ - "translatorID":"b33bbb49-03d2-4175-91c4-3840501bc953", - "translatorType":4, - "label":"Time-Blog.com", - "creator":"Michael Berkowitz", - "target":"^http://time-blog.com/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if (url.substr(-4,4) == "html") { - return "blogPost"; - } else { - return "multiple"; - } -} - -function scrape(doc, url) { - var newItem = new Zotero.Item("blogPost"); - - newItem.url = doc.location.href; - newItem.title = doc.title.substr(0, doc.title.indexOf(" - ")); - - var titleRE = new RegExp('^http://time-blog.com/([^/]*)/'); - var title = titleRE.exec(doc.location.href)[1].split("_"); - for (var i = 0 ; i < title.length ; i++) { - title[i] = title[i][0].toUpperCase() + title[i].substr(1).toLowerCase(); - } - newItem.blogTitle = title.join(" "); - var metaTags = new Object(); - - var metaTagHTML = doc.getElementsByTagName("meta"); - for (var i = 0 ; i < metaTagHTML.length ; i++) { - metaTags[metaTagHTML[i].getAttribute("name")] = metaTagHTML[i].getAttribute("content"); - } - - if (metaTags["description"]) { - newItem.abstractNote = Zotero.Utilities.trimInternal(Zotero.Utilities.cleanTags(metaTags["description"])); - } - - if (metaTags["date"]) { - var date = metaTags["date"]; - var months = new Object(); - months["jan"] = "January"; - months["feb"] = "February"; - months["mar"] = "March"; - months["apr"] = "April"; - months["may"] = "May"; - months["jun"] = "June"; - months["jul"] = "July"; - months["aug"] = "August"; - months["sep"] = "September"; - months["oct"] = "October"; - months["nov"] = "November"; - months["dec"] = "December"; - date = date.split(".").join("").split(", "); - date[0] = months[date[0].split(" ")[0].toLowerCase()] + " " + date[0].split(" ")[1]; - newItem.date = date.join(", "); - } - - if (metaTags["keywords"]) { - newItem.tags = metaTags["keywords"].split(", "); - for (var i in newItem.tags) { - if (newItem.tags[i] == "" || newItem.tags[i] == " ") { - break; - } else { - var words = newItem.tags[i].split(" "); - for (var j = 0 ; j < words.length ; j++) { - if (words[j][0] == words[j][0].toLowerCase() && words[j][0]) { - words[j] = words[j][0].toUpperCase() + words[j].substr(1).toLowerCase(); - } - } - } - newItem.tags[i] = words.join(" "); - } - } - - if (doc.evaluate('//span[@class="postedby"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var byline = Zotero.Utilities.trimInternal(doc.evaluate('//span[@class="postedby"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - if (byline.substr(0,9).toLowerCase() == "posted by") { - byline = byline.substr(10).split(" "); - } else { - byline.split(" "); - } - for (var i = 0; i < byline.length ; i++) { - byline[i] = byline[i][0].toUpperCase() + byline[i].substr(1).toLowerCase(); - } - newItem.creators.push(Zotero.Utilities.cleanAuthor(byline.join(" "), "author")); - } else if (newItem.blogTitle == "Theag") { - newItem.creators.push(Zotero.Utilities.cleanAuthor("Matthew Yeomans", "author")); - newItem.blogTitle = "the Aggregator"; - } - - Zotero.debug(newItem); - - newItem.complete(); - -} - -function doWeb(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - var URIS = new Array(); - - var xpath = '//h1[@class="entryTitle"]/a'; - var articles = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var art = articles.iterateNext(); - var arts = new Array(); - var urls = new Array(); - while (art) { - arts.push(art.textContent); - urls.push(art.href); - art = articles.iterateNext(); - } - if (arts.length > 1) { - var items = new Object; - for (var i = 0; i < arts.length ; i++ ) { - items[urls[i]] = arts[i]; - } - items = Zotero.selectItems(items); - - for (i in items) { - URIS.push(i); - } - } else { - URIS.push(url); - } - Zotero.Utilities.processDocuments(URIS, scrape, function() { Zotero.done(); } ); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Time.com.js b/translators/Time.com.js @@ -1,160 +0,0 @@ -{ - "translatorID":"d9be934c-edb9-490c-a88d-34e2ee106cd7", - "translatorType":4, - "label":"Time.com", - "creator":"Michael Berkowitz", - "target":"http://www.time.com/time/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.title == "TIME Magazine - Search Results") { - return "multiple"; - } else { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - var xpath = '//meta[@name="byline"]'; - var xpath2 = '//div[@class="byline"]'; - var xpath3 = '//div[@class="copy"]/div[@class="byline"]'; - if ((doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate(xpath2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate(xpath3, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) ) { - if (url.substr(-4,4) == "html") { - return "magazineArticle"; - } - } - } -} - - -function associateMeta(newItem, metaTags, field, zoteroField) { - if (metaTags[field]) { - newItem[zoteroField] = Zotero.Utilities.trimInternal(metaTags[field]); - } -} - -function scrape(doc, url) { - var newItem = new Zotero.Item("magazineArticle"); - newItem.publicationTitle = "Time"; - newItem.ISSN = "0040-718X"; - newItem.url = doc.location.href; - var metaTags = new Object(); - - var metaTagHTML = doc.getElementsByTagName("meta") - for (var i = 0 ; i < metaTagHTML.length ; i++) { - metaTags[metaTagHTML[i].getAttribute("name")] = metaTagHTML[i].getAttribute("content"); - } - - if (metaTags["head"]) { - associateMeta(newItem, metaTags, "head", "title"); - } else if (doc.title.length > 7) { - newItem.title = doc.title.substr(0, doc.title.length - 7); - } else { - newItem.title = "No Title"; - } - - if (metaTags["description"]) { - associateMeta(newItem, metaTags, "description", "abstractNote"); - } - - if (metaTags["date"]) { - var date = metaTags["date"]; - var months = new Object(); - months["jan"] = "January"; - months["feb"] = "February"; - months["mar"] = "March"; - months["apr"] = "April"; - months["may"] = "May"; - months["jun"] = "June"; - months["jul"] = "July"; - months["aug"] = "August"; - months["sep"] = "September"; - months["oct"] = "October"; - months["nov"] = "November"; - months["dec"] = "December"; - date = date.split(".").join("").split(", ").slice(1); - date[0] = months[date[0].split(" ")[0].toLowerCase()] + " " + date[0].split(" ")[1]; - newItem.date = date.join(", "); - } - if (metaTags["keywords"]) { - newItem.tags = Zotero.Utilities.trimInternal(metaTags["keywords"]).split(", "); - for (var i in newItem.tags) { - if (newItem.tags[i] == "" || newItem.tags[i] == " ") { - break; - } else { - var words = newItem.tags[i].split(" "); - for (var j = 0 ; j < words.length ; j++) { - Zotero.debug(words[j]); - if (words[j][0] == words[j][0].toLowerCase() && words[j][0]) { - words[j] = words[j][0].toUpperCase() + words[j].substr(1).toLowerCase(); - } - } - } - newItem.tags[i] = words.join(" "); - } - } - - if (metaTags["byline"]) { - var byline = Zotero.Utilities.trimInternal(metaTags["byline"]); - var byline1 = byline.split(" and "); - for (var i = 0 ; i < byline1.length ; i++) { - var byline2 = byline1[i].split("/"); - for (var j = 0 ; j < byline2.length ; j++) { - byline2[j] = Zotero.Utilities.trimInternal(byline2[j]); - if (byline2[j].indexOf(" ") == -1) { - if (byline2[j].length == 2) { - newItem.extra = byline2[j]; - } else { - newItem.extra = byline2[j][0].toUpperCase() + byline2[j].substr(1).toLowerCase(); - } - } else { - byline3 = byline2[j].split(" "); - for (var x = 0 ; x < byline3.length ; x++) { - byline3[x] = byline3[x][0].toUpperCase() + byline3[x].substr(1).toLowerCase(); - } - byline3 = byline3.join(" "); - newItem.creators.push(Zotero.Utilities.cleanAuthor(byline3, "author")); - } - } - } - } - newItem.attachments.push({document:doc, title:doc.title}); - newItem.complete(); -} - - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x") return namespace; else return null; - } : null; - - var urls = new Array(); - if (doc.title == "TIME Magazine - Search Results") { - var items = new Array(); - var items = Zotero.Utilities.getItemArray(doc, doc.getElementById("search_results").getElementsByTagName("h3"), '^http://www.time.com/time/.*\.html$'); - - items = Zotero.selectItems(items); - - if (!items) { - return true; - } - - for (var i in items) { - if (i.match("covers") == null) { - urls.push(i); - } - } - } else if (doc.evaluate('//meta[@name="byline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//div[@class="byline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//div[@class="copy"]/div[@class="byline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext() ) { - urls.push(doc.location.href); - } - Zotero.Utilities.processDocuments(urls, function(newDoc) { - scrape(newDoc); - }, function() { Zotero.done(); } ); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Toronto Star.js b/translators/Toronto Star.js @@ -1,160 +0,0 @@ -{ - "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) { - if (doc.location.href.match("search") && !doc.location.href.match("classifieds")) { - return "multiple"; - } else if (doc.location.href.match("article")) { - return "newspaperArticle"; - } -} - -//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) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("newspaperArticle"); - - 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 abstractNote = doc.evaluate('//meta[@property="og:description"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(abstractNote) newItem.abstractNote = abstractNote.content; - - 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 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"; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - if (next_title.href.match("http://www.thestar.com") && next_title.href.match("article") && !next_title.href.match("generic") && !next_title.href.match("static")) { - items[next_title.href] = next_title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} - -/** 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": "There’s no reason why Ontario can’t 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 **/ -\ No newline at end of file diff --git a/translators/Twitter.js b/translators/Twitter.js @@ -1,94 +0,0 @@ -{ - "translatorID": "31659710-d04e-45d0-84ba-8e3f5afc4a54", - "label": "Twitter", - "creator": "Avram Lyon", - "target": "^https?://twitter\\.com\\/.*\\/status\\/\\d+", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-07-30 13:05:30" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - -/* - Twitter 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 FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -FW.Scraper({ -itemType : "blogPost", -detect : FW.Url(), -attachments : { url : FW.Url() , - title : "Tweet Snapshot" , - type : "text/html" }, -blogTitle : FW.Url().match(/([^\/]+)\/status\/\d+/,1).prepend("@"), -creators : FW.Xpath('//div[contains(@class,"permalink-tweet")]//span[@class="tweet-user-block-full-name"]') - .text().cleanAuthor("author"), -// This part is fragile, since we have to iterate over the attributes -date : FW.Xpath('//div[contains(@class,"permalink-tweet")]//a[@class="tweet-timestamp"]/span[@class="_timestamp"]/attribute::*[2]') - .text(), -websiteType : "microblog", -title : FW.Xpath('//div[contains(@class,"permalink-tweet")]//div[contains(@class,"tweet-text-large")]').text(), -hooks : { - "scraperDone" : function (item, doc, url) { - var temp = new Date(item.date*1); - item.date = temp.toGMTString(); - } -} -}); - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://twitter.com/#!/mukhamadi/status/92477274246479872", - "items": [ - { - "itemType": "blogPost", - "creators": [ - { - "firstName": "Lenar", - "lastName": "Mukhamadi", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Tweet Snapshot", - "type": "text/html" - } - ], - "url": "http://twitter.com/#!/mukhamadi/status/92477274246479872", - "blogTitle": "@mukhamadi", - "date": "Sun, 17 Jul 2011 06:14:34 GMT", - "title": "Гали Акыш вафат...Идел-Урал ялкынының соңгы учагы сүнде...", - "websiteType": "microblog", - "libraryCatalog": "Twitter" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/UBC Library Catalog.js b/translators/UBC Library Catalog.js @@ -1,182 +0,0 @@ -{ - "translatorID":"35d6c82d-4749-4cc5-9e12-2924307df28f", - "translatorType":4, - "label":"UBC Library Catalog", - "creator":"Adam Crymble", - "target":"http://webcat(1||2).library.ubc", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-06 17:00:00" -} - -function detectWeb(doc, url) { - - if (doc.evaluate('//tbody/tr/td[1]/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.evaluate('//center/h4/i/strong/bdo', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "book"; - } -} - -//UBC Library Catalog translator. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var tagsContent = new Array(); - var headersArray = new Array(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - - var headers = doc.evaluate('//form/table/tbody/tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount= doc.evaluate('count (//form/table/tbody/tr/th)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var contents = doc.evaluate('//form/table', doc, nsResolver, XPathResult.ANY_TYPE, null); - var dump = contents.iterateNext(); - - - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent; - if (fieldTitle.match(/\w/)) { - headersArray.push(fieldTitle); - } - } - - var contentsArray = new Array(); - var j = 0; - contents = contents.iterateNext().textContent.replace(/\s\s/g, ''); - - for (var i = headersArray.length-1; i> -1; i--) { - - var fieldIndex = contents.lastIndexOf(headersArray[i]); - - var headerLength = headersArray[i].length; - - contentsArray.push(contents.substr(fieldIndex+headerLength)); - contents = contents.substr(0, fieldIndex); - - fieldTitle = headersArray[i].replace(/\s+/g, ''); - if (fieldTitle == "Subject(s):") { - if (contentsArray[j].match(". ")) { - var tagsContent = contentsArray[j].split(". ") - } else if (contentsArray[j].match(/\n/)) { - var tagsContent = contentsArray[j].split(/\n/); - } else { - newItem.tags = contentsArray[j]; - var noMoreTags = 1; - } - - } - dataTags[fieldTitle] = contentsArray[j].replace(/^\s*|\s+$/g, ''); - - j++; - } - - j = 0; - - if (noMoreTags != 1) { - for (var i = 0; i < tagsContent.length; i++) { - if (tagsContent[i].match(/\w/)) { - newItem.tags[j] = tagsContent[i].replace(/^\s*|\s+$/g, ''); - j++; - } - } - } - - if (dataTags["MainAuthor:"]) { - var author = dataTags["MainAuthor:"]; - if (author.match(", ")) { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - - if (dataTags["OtherAuthor(s):"]) { - var author = dataTags["OtherAuthor(s):"]; - - if (author.match(", ")) { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - - if (dataTags["Published:"]) { - if (dataTags["Published:"].match(": ")) { - var imprint = dataTags["Published:"]; - - var place1 = imprint.indexOf(": "); - - newItem.place = imprint.substr(0, place1); - - var imprint2 = imprint.substr(place1+2); - - if (imprint2.match(/\d\d\d/)) { - var date1 = imprint2.lastIndexOf(/\d\d\d/); - var date2 = imprint2.substr(date1-4); - newItem.date = date2; - newItem.publisher = imprint2.substr(0, imprint2.length-(newItem.date.length+2)); - } else { - newItem.publisher = imprint2; - } - } else { - newItem.publisher = dataTags["Published:"] - } - } - - associateData (newItem, dataTags, "Title:", "title"); - associateData (newItem, dataTags, "CallNumber:", "callNumber"); - associateData (newItem, dataTags, "Description:", "pages"); - associateData (newItem, dataTags, "Location:", "repository"); - - newItem.url = doc.location.href; - - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate('//form/table/tbody/tr/td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/US National Archives Research Catalog.js b/translators/US National Archives Research Catalog.js @@ -1,168 +0,0 @@ -{ - "translatorID":"f8b5501a-1acc-4ffa-a0a5-594add5e6bd3", - "translatorType":4, - "label":"US National Archives Research Catalog", - "creator":"Adam Crymble", - "target":"http://arcweb.archives.gov", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-06 17:00:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("ShowArchivalDescriptions") || doc.location.href.match("ShowDODescriptions")) { - return "multiple"; - } else if (doc.location.href.match("ShowFullRecord") && doc.location.href.match("showFullDescriptionTabs/details")) { - return "book"; - } -} - -//US National Archives. Code by Adam Crymble - -function associateData (newItem, dataTags, field, zoteroField) { - if (dataTags[field]) { - newItem[zoteroField] = dataTags[field]; - } -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - var fieldTitle; - - var newItem = new Zotero.Item("book"); - - var contents2 = doc.evaluate('//td[1]/div[@class="sT"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (var i = 0; i < 3; i++) { - if (i == 0) { - newItem.title = contents2.iterateNext().textContent.replace(/^\s*|\s+$/g, ''); - } else if (i == 1) { - newItem.extra = contents2.iterateNext().textContent.replace(/^\s*|\s+$/g, ''); - } else if (i == 2) { - newItem.locInArchive= contents2.iterateNext().textContent.replace(/^\s*|\s+$/g, ''); - } - } - - var headers = doc.evaluate('//tbody/tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null); - var contents = doc.evaluate('//body/div[@class="genPad"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var xPathCount = doc.evaluate('count (//tbody/tr/th)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var headersArray = new Array(); - var oneHeader = ''; - - if (xPathCount.numberValue > 1) { - for (var i = 0; i < xPathCount.numberValue; i++) { - fieldTitle = headers.iterateNext().textContent; - headersArray.push(fieldTitle); - } - } else { - oneHeader = (headers.iterateNext().textContent); - } - - var contentsArray = new Array(); - var j = 0; - - if (oneHeader.length<1) { - - for (var i = headersArray.length-1; i> -1; i--) { - - var fieldIndex = contents.lastIndexOf(headersArray[i]); - var fieldIndexLength = headersArray[i].length; - - contentsArray.push(contents.substr(fieldIndex)); - contents = contents.substr(0, fieldIndex); - fieldTitle = headersArray[i].replace(/\s+/g, ''); - - dataTags[fieldTitle] = contentsArray[j].substr(fieldIndexLength).replace(/^\s*|\s+$/g, ''); - - j++; - } - } - j = 0; - var k = 0; - var tagsContent = new Array(); - - if (dataTags["IndexTerms:"]) { - if (dataTags["IndexTerms:"].match(/\n/)){ - var tagsContent = dataTags["IndexTerms:"].split(/\n/); - } else { - if (!dataTags["IndexTerms:"].match("Subjects Represented in the Archival Material")) { - newItem.tags = dataTags["IndexTerms:"]; - } - } - if (tagsContent.length > 1) { - for (var i = 0; i < tagsContent.length; i++) { - if (tagsContent[i].match(/\w/)) { - if (k == 1) { - newItem.tags[j] = tagsContent[i]; - j++; - } - k = 1; - } - } - } - } - - associateData (newItem, dataTags, "ProductionDate(s):", "date"); - associateData (newItem, dataTags, "PartOf:", "series"); - associateData (newItem, dataTags, "VariantControlNumber(s):", "callNumber"); - - if (dataTags["Creator(s):"]) { - var author = dataTags["Creator(s):"]; - if (author.match(", ")) { - var authors = author.split(", "); - author = authors[1] + " " + authors[0]; - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } else { - newItem.creators.push({lastName: author, creatorType: "creator"}); - } - } - - newItem.url = doc.location.href; - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - if (doc.evaluate('//div[@class="sT"]/p/strong[@class="sFC"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var titles = doc.evaluate('//div[@class="sT"]/p/strong[@class="sFC"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - } else if (doc.evaluate('//td[3]/div[@class="sT"]/p/strong[@class="sFC"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var titles = doc.evaluate('//td[3]/div[@class="sT"]/p/strong[@class="sFC"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - - } - - - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/Unidade de Biologia da Conservaçao.js b/translators/Unidade de Biologia da Conservaçao.js @@ -1,134 +0,0 @@ -{ - "translatorID":"587aa172-af1a-4cab-b188-2b6d392cae5c", - "translatorType":4, - "label":"Unidade de Biologia da Conservaçao", - "creator":"Giovanni Manghi and Michael Berkowitz", - "target":"http://www.ubc.uevora.pt/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if(doc.title == "UBC: referencia bibliografica") { - return "book"; - } else if (doc.evaluate('//tr[@class]/td/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } -} - -function doWeb(doc, url) { - if (detectWeb(doc, url) == "multiple") { - var xpath = '//tr[@class]/td/a'; - var items = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_item; - var arts = new Object(); - while (next_item = items.iterateNext()) { - arts[next_item.href] = Zotero.Utilities.trimInternal(next_item.textContent); - } - arts = Zotero.selectItems(arts); - var newDocs = new Array(); - for (var i in arts) { - newDocs.push(i); - } - Zotero.debug(newDocs); - Zotero.Utilities.processDocuments(newDocs, function(newDoc) { scrape(newDoc, newDoc.location.href); }, function() {Zotero.done();}); - } else { - scrape(doc,url); - } -} - - -function scrape(doc,url) { - var xpath = "/html/body/div/div/div[3]/div[3]/table/tbody/tr/td" - var xpathurl ="/html/body/div/div/div[3]/div[3]/table/tbody/tr/td/a[1]" - var allRefText = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var allRefTexturl = Zotero.Utilities.trimInternal(doc.evaluate(xpathurl, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent); - - - - -// bib data scraper code here - -function getItem(reftext,re) { - var item = reftext.match(re); - // Zotero.debug(item[1]); - return item[1]; -} - -var TipoRe = "Type:(.*?)Title"; -var tipoo = getItem(allRefText,TipoRe); - -var titleRe = "Title:(.*?)Author"; -var title = getItem(allRefText,titleRe); - -var authorsRe = "Author.*?: (.*?)Journal"; -var authors = getItem(allRefText,authorsRe); - -var journalRe = "Journal:(.*?)Year"; -var journal = getItem(allRefText,journalRe); - -var yearRe = "Year:(.*?)Volume"; -var year = getItem(allRefText,yearRe); - -var volRe = "Volume:(.*?)Number"; -var vol = getItem(allRefText,volRe); - -var numRe = "Number:(.*?)Pages"; -var num = getItem(allRefText,numRe); - -var pageRe = "Pages:(.*?)Abstract"; -var page = getItem(allRefText,pageRe); - -var abstractRe = "Abstract:(.*?)Keywords"; -var abstract = getItem(allRefText,abstractRe); - -var keyRe = "Keywords:(.*?)Link"; -var key = getItem(allRefText,keyRe); - - - - -// zotero entry creation code here - -itemTypeMap = { - article:"journalArticle", - book:"book", - conference:"conferencePaper", - inproceedings:"conferencePaper", - inbook:"bookSection", - incollection:"bookSection", - mastersthesis:"thesis", - other:"journalArticle", - phdthesis:"thesis", - proceedings:"conferencePaper" -}; - -if (itemTypeMap[tipoo]) { - tipooo = itemTypeMap[tipoo]; -} else { - tipooo = 'document'; -} - -var newArticle = new Zotero.Item(tipooo); - - var aus = authors.split(","); - for (var i=0; i< aus.length ; i++) { - newArticle.creators.push(Zotero.Utilities.cleanAuthor(aus[i],"author")); - } - - newArticle.title = title; - newArticle.publicationTitle = journal; - newArticle.date = year; - newArticle.volume = vol; - newArticle.issue = num; - newArticle.pages = page; - newArticle.abstractNote = abstract; - newArticle.keywords = key; - newArticle.url = url; - - -newArticle.complete(); -} -\ No newline at end of file diff --git a/translators/Universiteit van Amsterdam.js b/translators/Universiteit van Amsterdam.js @@ -1,106 +0,0 @@ -{ - "translatorID":"675306d2-fca9-466f-b33d-1e3cc1bfd091", - "translatorType":4, - "label":"Universiteit van Amsterdam", - "creator":"Michael Berkowitz", - "target":"http://opc.uva.nl:8080/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//td[3][@class="hit"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.title.match("results/titledata")) { - return "book"; - } -} - -function scrape(item, langTags, data) { - for (var tag in data) { - tag = tag.toLowerCase(); - if (langTags[tag] == "creators") { - var authors = data[tag].split(","); - for each (var aut in authors) { - item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(aut), "author")); - } - } else if (langTags[tag] == "tags") { - var kws = data[tag].split(/(,|;)/); - for each (var key in kws) { - if (key.match(/\w+/)) item.tags.push(Zotero.Utilities.trimInternal(key)); - } - } else if (langTags[tag] == "publisher") { - var pub = data[tag].split(/\s*:\s*/); - item.place = pub[0]; - item.publisher = pub[1]; - } else { - item[langTags[tag]] = data[tag]; - } - } -} - -var tagsEN = { - "title":"title", - "author(s)":"creators", - "publisher":"publisher", - "year":"date", - "isbn":"ISBN", - "subject headings":"tags", - "subject heading person":"tags", - "call number":"callNumber" -} - -var tagsNE = { - "titel":"title", - "auteur(s)":"creators", - "uitgever":"publisher", - "jaar":"date", - "isbn":"ISBN", - "trefwoorden":"tags", - "trefwoord persoon":"tags", - "plaatsnummer":"callNumber" -} - -function doWeb(doc, url) { - var books = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var links = doc.evaluate('//td[3][@class="hit"]/a', doc, null, XPathResult.ANY_TYPE, null); - var link; - while (link = links.iterateNext()) { - items[link.href] = Zotero.Utilities.trimInternal(link.textContent); - } - items = Zotero.selectItems(items); - for (var i in items) { - books.push(i); - } - } else { - books = [url]; - } - Zotero.Utilities.processDocuments(books, function(newDoc) { - var data = new Object(); - var box = newDoc.evaluate('//table/tbody/tr[1]/td[2]/table/tbody/tr', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext(); - var tags = newDoc.evaluate('//table/tbody/tr[1]/td[2]/table/tbody/tr/td[1]', newDoc, null, XPathResult.ANY_TYPE, null); - var values = newDoc.evaluate('//table/tbody/tr[1]/td[2]/table/tbody/tr/td[2]', newDoc, null, XPathResult.ANY_TYPE, null); - var tag; - var value; - while ((tag = tags.iterateNext()) && (value = values.iterateNext())) { - tag = Zotero.Utilities.trimInternal(tag.textContent).replace(/:/, "").toLowerCase(); - if (tagsEN[tag] || tagsNE[tag]) { - data[tag] = Zotero.Utilities.trimInternal(value.textContent); - } - } - item = new Zotero.Item("book"); - var lingTags = new Array(); - if (data['titel']) { - lingTags = tagsNE; - } if (data['title']) { - lingTags = tagsEN; - } - scrape(item, lingTags, data); - item.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/University of Chicago.js b/translators/University of Chicago.js @@ -1,159 +0,0 @@ -{ - "translatorID":"df966c80-c199-4329-ab02-fa410c8eb6dc", - "translatorType":4, - "label":"University of Chicago", - "creator":"Sean Takats", - "target":"https?://[^/]*journals\\.uchicago\\.edu[^/]*/(?:doi/abs|doi/full|toc|action/doSearch)", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-05-05 07:15:00" -} - -function detectWeb(doc, url) { - if(url.indexOf("toc") != -1) { - return "multiple"; - } else if(url.match("doSearch")) { - 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 proxyURL =""; - var proxyRe = /http:\/\/([^\/]*)/; - var m = proxyRe.exec(doc.location.href); - if(m) { - proxyURL = "/"+m[1]+"/"; - } - - var post = ""; - - var fulltext = new Object(); - - if(url.indexOf("toc") != -1) { - var items = new Array(); - var links = new Array(); - - var tableRows = doc.evaluate('//li[div[@class="articleListing_col3"]/label][//input[@name="doi"]]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - var tableRow; - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - var id = doc.evaluate('.//input[@name="doi"]', tableRow, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().value; - items[id] = Zotero.Utilities.trimInternal(doc.evaluate('.//label', tableRow, - nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - var items = Zotero.selectItems(items); - if(!items) return true; - - // find all fulltext links so we can determine where we can scrape the fulltext article - var fulltextLinks = doc.evaluate('//a[starts-with(text(), "Full Text")]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - var fulltextLink; - while(fulltextLink = fulltextLinks.iterateNext()) { - links.push(fulltextLink.href.toString()); - } - - for(var i in items) { - post += "doi="+encodeURIComponent(i)+"&"; - - // check for fulltext links - for each(var link in links) { - if(link.indexOf(i) != -1) { - fulltext[i] = true; - break; - } - } - } - } else if(url.match("doSearch")) { // do search result, yes lots of duped code, please forgive - var items = new Array(); - var links = new Array(); - - var tableRows = doc.evaluate('//li[div[@class="articleResult_col2"]/h3/label][//input[@name="doi"]]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - var tableRow; - // Go through table rows - while(tableRow = tableRows.iterateNext()) { - var id = doc.evaluate('.//input[@name="doi"]', tableRow, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext().value; - items[id] = Zotero.Utilities.trimInternal(doc.evaluate('.//label', tableRow, - nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - var items = Zotero.selectItems(items); - if(!items) return true; - - // find all fulltext links so we can determine where we can scrape the fulltext article - var fulltextLinks = doc.evaluate('//a[starts-with(text(), "Full Text")]', doc, - nsResolver, XPathResult.ANY_TYPE, null); - var fulltextLink; - while(fulltextLink = fulltextLinks.iterateNext()) { - links.push(fulltextLink.href.toString()); - } - - for(var i in items) { - post += "doi="+encodeURIComponent(i)+"&"; - - // check for fulltext links - for each(var link in links) { - if(link.indexOf(i) != -1) { - fulltext[i] = true; - break; - } - } - } - - } else { - var m = url.match(/https?:\/\/[^\/]+\/doi\/[^\/]+\/([^\?]+)(\?|$)/); - if (m) { - var doi = m[1]; - } else { - m = url.match(/https?:\/\/[^\/]+\/links\/doi\/([^\?]+)(\?|$)/); - var doi = m[1]; - } - post += "doi="+encodeURIComponent(doi)+"&"; - - if(url.indexOf("doi/full") != -1 || - doc.evaluate('//img[@alt="Full Text Article"]', doc, nsResolver, XPathResult.ANY_TYPE, - null).iterateNext()) { - fulltext[doi] = true; - } - } - - post += "include=cit&downloadFileName=deadbeef&format=refman&direct=on&submit=Download+article+citation+data"; - Zotero.Utilities.HTTP.doPost("http://www.journals.uchicago.edu/action/downloadCitation", post, function(text) { - // load translator for RIS - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.attachments = [ - {url:item.url.replace("/dx.doi.org/", proxyURL+"doi/abs/"), title:"University of Chicago Journals Snapshot", mimeType:"text/html"}, - {url:item.url.replace("/dx.doi.org/", proxyURL+"doi/pdf/"), title:"University of Chicago Full Text PDF", mimeType:"application/pdf"} - ]; - if (item.notes[0]['note']) item.DOI = Zotero.Utilities.trimInternal(item.notes[0]['note'].substr(4)); - item.notes = new Array(); - // use fulltext if possible - if(fulltext[item.DOI]) { - item.attachments[0].url = item.attachments[0].url.replace("/doi/abs", "/doi/full"); - } - - item.complete(); - }); - translator.translate(); - - Zotero.done(); - }); - - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/University of Michigan.js b/translators/University of Michigan.js @@ -1,97 +0,0 @@ -{ - "translatorID":"04153a16-5f34-491c-9475-7f4093db8e3e", - "translatorType":4, - "label":"University of Michigan", - "creator":"Matt Burton", - "target":"http://mirlyn\\-classic\\.lib\\.umich\\.edu", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-11-19 05:05:00" -} - -var mirlyn2zoteroTypeMap = { - "Book":"book", - "Video (DVD)":"videoRecording", - "Video (VHS)":"videoRecording", - "Audio CD":"audioRecording" -}; - -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.indexOf("/Record/") != '-1') { - var type = doc.evaluate('//span[contains(@class,"iconlabel")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var zType = mirlyn2zoteroTypeMap[type]; - if (zType) { - return zType; - } else { // default to book - return "book"; - } - } else if (url.indexOf("/Search/") != "-1") { - return "multiple"; - } -} - -function doWeb (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var marcURLs = []; - - if (detectWeb(doc, url) == "multiple") { - var links = doc.evaluate("//a[@class='title']", doc, nsResolver, XPathResult.ANY_TYPE, null) - var items = {}, td; - while (td = links.iterateNext()) { - items[td.href] = td.textContent; - } - - items = Zotero.selectItems(items); - if (!items) { - return true; - } - for (item in items){ - marcURLs.push(item + "/Export?style=MARC"); - } - - } else { // we have a single - marcURLs.push(url + "/Export?style=MARC"); - } - Zotero.Utilities.doGet(marcURLs, function(text){ - // Merlyn is serving up the controL charcters in decimal, wassup wit dat? - text = text.replace(/#([^;]*);/g, function(match, group){ - // I wish I could get this more generic method to work, - // but something funky about programatically building these hex strings - // "\\x + parseInt(group).toString(16); - // do it manually instead - switch(group) { - case "29": - return "\x1d"; - case "30": - return "\x1e"; - case "31": - return "\x1f"; - default: - return; - } - }); - - var marc = Zotero.loadTranslator("import"); - marc.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973"); - marc.setString(text); - marc.setHandler("itemDone", function(obj, item) { - item.repository = "Mirlyn Library Catalog"; - item.complete(); - }); - marc.translate(); - - }, function(){Zotero.done();}); - Zotero.wait(); - -} -\ No newline at end of file diff --git a/translators/Unqualified Dublin Core RDF.js b/translators/Unqualified Dublin Core RDF.js @@ -1,122 +0,0 @@ -{ - "translatorID":"6e372642-ed9d-4934-b5d1-c11ac758ebb7", - "translatorType":2, - "label":"Unqualified Dublin Core RDF", - "creator":"Simon Kornblith", - "target":"rdf", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "browserSupport":"gcsn", - "configOptions":{"dataMode":"rdf/xml"}, - "inRepository":true, - "lastUpdated":"2011-07-08 04:51:41" -} - -function doExport() { - var dc = "http://purl.org/dc/elements/1.1/"; - Zotero.RDF.addNamespace("dc", dc); - - var item; - while(item = Zotero.nextItem()) { - if(item.itemType == "note" || item.itemType == "attachment") { - continue; - } - - var resource; - if(item.ISBN) { - resource = "urn:isbn:"+item.ISBN; - } else if(item.url) { - resource = item.url; - } else { - // just specify a node ID - resource = Zotero.RDF.newResource(); - } - - /** CORE FIELDS **/ - - // title - if(item.title) { - Zotero.RDF.addStatement(resource, dc+"title", item.title, true); - } - - // type - Zotero.RDF.addStatement(resource, dc+"type", item.itemType, true); - - // creators - for(var j in item.creators) { - // put creators in lastName, firstName format (although DC doesn't specify) - var creator = item.creators[j].lastName; - if(item.creators[j].firstName) { - creator += ", "+item.creators[j].firstName; - } - - if(item.creators[j].creatorType == "author") { - Zotero.RDF.addStatement(resource, dc+"creator", creator, true); - } else { - Zotero.RDF.addStatement(resource, dc+"contributor", creator, true); - } - } - - /** FIELDS ON NEARLY EVERYTHING BUT NOT A PART OF THE CORE **/ - - // source - if(item.source) { - Zotero.RDF.addStatement(resource, dc+"source", item.source, true); - } - - // accessionNumber as generic ID - if(item.accessionNumber) { - Zotero.RDF.addStatement(resource, dc+"identifier", item.accessionNumber, true); - } - - // rights - if(item.rights) { - Zotero.RDF.addStatement(resource, dc+"rights", item.rights, true); - } - - /** SUPPLEMENTAL FIELDS **/ - - // TODO - create text citation and OpenURL citation to handle volume, number, pages, issue, place - - // publisher/distributor - if(item.publisher) { - Zotero.RDF.addStatement(resource, dc+"publisher", item.publisher, true); - } else if(item.distributor) { - Zotero.RDF.addStatement(resource, dc+"publisher", item.distributor, true); - } else if(item.institution) { - Zotero.RDF.addStatement(resource, dc+"publisher", item.distributor, true); - } - - // date/year - if(item.date) { - Zotero.RDF.addStatement(resource, dc+"date", item.date, true); - } - - // ISBN/ISSN/DOI - if(item.ISBN) { - Zotero.RDF.addStatement(resource, dc+"identifier", "ISBN "+item.ISBN, true); - } - if(item.ISSN) { - Zotero.RDF.addStatement(resource, dc+"identifier", "ISSN "+item.ISSN, true); - } - if(item.DOI) { - Zotero.RDF.addStatement(resource, dc+"identifier", "DOI "+item.DOI, true); - } - - // callNumber - if(item.callNumber) { - Zotero.RDF.addStatement(resource, dc+"identifier", item.callNumber, true); - } - - // archiveLocation - if(item.archiveLocation) { - Zotero.RDF.addStatement(resource, dc+"coverage", item.archiveLocation, true); - } - - // medium - if(item.medium) { - Zotero.RDF.addStatement(resource, dcterms+"medium", item.medium, true); - } - } -} -\ No newline at end of file diff --git a/translators/Vanderbilt eJournals.js b/translators/Vanderbilt eJournals.js @@ -1,83 +0,0 @@ -{ - "translatorID":"882f70a8-b8ad-403e-bd76-cb160224999d", - "translatorType":4, - "label":"Vanderbilt eJournals", - "creator":"Michael Berkowitz", - "target":"http://ejournals.library.vanderbilt.edu/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/viewarticle.php/)) { - return "journalArticle"; - } else if (url.match(/viewissue.php/) || url.match(/search.php/)) { - return "multiple"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function (prefix) { - if (prefix == 'x') return n; else return null; - } : null; - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - if (doc.evaluate('/html/body/table/tbody/tr/td[2]/ul/li', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) { - var results = doc.evaluate('/html/body/table/tbody/tr/td[2]/ul/li', doc, ns, XPathResult.ANY_TYPE, null); - var titleX = './span[@class="toctitle"]'; - var linkX = './/a[contains(text(), "Abstract")]'; - /*var res; - while (res = results.iterateNext()) { - var title = doc.evaluate('./span[@class="toctitle"]', res, ns, XPathResult.ANY_TYPE, null).iterateNext.textContent; - var link = doc.evaluate('.//a[contains(text(), "Abstract")]', res, ns, XPathResult.ANY_TYPE, null).iterateNext.href; - items[link] = title; - }*/ - } else { - var results = doc.evaluate('//tr[td[3]//a[contains(text(), "Abstract")]]', doc, ns, XPathResult.ANY_TYPE, null); - var titleX = './td[2]'; - var linkX = './td[3]//a'; - } - var res; - while (res = results.iterateNext()) { - var title = doc.evaluate(titleX, res, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var link = doc.evaluate(linkX, res, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = Zotero.Utilities.trimInternal(title); - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i); - } - } else { - arts = [url]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var pdfurl = doc.evaluate('//a[contains(text(), "PDF")]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - var gets = doc.location.href.match(/^(http:\/\/[^/]+\/[^/]+\/).*id=(\d+)/); - var risurl = gets[1] + 'rst/rst.php?op=capture_cite&id=' + gets[2] + '&cite=refman'; - Zotero.Utilities.HTTP.doGet(risurl, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var voliss = item.publicationTitle.split(/;/); - item.publicationTitle = voliss[0]; - voliss = voliss[1].match(/Vol\.\s+(\d+)(,\s+No\.\s+(\d+))?\s+\((\d+)\)/); - item.volume = voliss[1]; - if (voliss[3]) item.issue = voliss[3]; - item.date = voliss[4]; - item.attachments = [ - {url:item.url, title:item.publicationTitle + " Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:item.publicationTitle + " PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }); - translator.translate(); - }); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Verniana-Jules Verne Studies.js b/translators/Verniana-Jules Verne Studies.js @@ -1,83 +0,0 @@ -{ - "translatorID":"cdf8269c-86b9-4039-9bc4-9d998c67740e", - "translatorType":4, - "label":"Verniana-Jules Verne Studies", - "creator":"Michael Berkowitz", - "target":"http://jv.gilead.org.il/studies/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-21 19:15:00" -} - -function detectWeb(doc, url) { - if (url.match(/article\/view/)) { - return "journalArticle"; - } else if (url.match(/(issue|advancedResults)/)) { - return "multiple"; - } -} - -function prepNos(link) { - if (link.match(/\d+\/\d+$/)) { - var nos = link.match(/\d+\/\d+$/)[0]; - } else { - var nos = link.match(/\d+$/)[0] + '/0'; - } - return 'http://jv.gilead.org.il/studies/index.php/studies/rt/captureCite/' + nos + '/RefManCitationPlugin'; -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath = '//tr[td/a[2]]'; - if (url.match(/issue/)) { - var titlex = './td[1]'; - var linkx = './td[2]/a[contains(text(), "HTML")]'; - } else if (url.match(/advanced/)) { - var titlex = './td[2]'; - var linkx = './td[3]/a[contains(text(), "HTML")]'; - } - var results = doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - var title = Zotero.Utilities.trimInternal(doc.evaluate(titlex, result, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - var link = doc.evaluate(linkx, result, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = title; - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(prepNos(i)); - } - } else { - arts = [prepNos(url)]; - } - Zotero.Utilities.HTTP.doGet(arts, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - var auts = new Array(); - for each (var aut in item.creators) { - auts.push(Zotero.Utilities.cleanAuthor(aut.lastName, "author")); - } - item.creators = auts; - item.attachments = [{url:item.url, title:"Verniana Snapshot", mimeType:"text/html"}]; - var bits = item.publicationTitle.split(/;/); - item.publicationTitle = bits[0]; - var voliss = bits[1].match(/Vol\s+(\d+)\s+\((\d+)\)/); - item.volume = voliss[1]; - item.date = voliss[2]; - item.complete(); - }); - translator.translate(); - }); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/VoxEU.js b/translators/VoxEU.js @@ -1,48 +0,0 @@ -{ - "translatorID": "508e8fb9-8a33-4095-844f-133cba7e7b54", - "label": "VoxEU", - "creator": "Sebastian Karcher", - "target": "^https?://www\\.voxeu\\.org", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-14 10:07:02" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};/*Examples: -Individual item -http://www.voxeu.org/index.php?q=node/6258 -Search results -http://www.voxeu.org/index.php?q=search/node/eichengreen */ - -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ -itemType : 'blogPost', -detect : FW.Xpath('//div[@class="terms"]'), -title : FW.Xpath('//div[@id="main"]/div[@id="squeeze"]/h1').text().trim(), -attachments : { - url : FW.Url(), - title : "voxEU snapshot", - type : "text/html" -}, -creators : FW.Xpath('//table[@class="layouttable"]/tbody/*/td/p/a ').text().cleanAuthor("author"), -abstractNote : FW.Xpath('//table[@class="layouttable"]/tbody/tr/td/div/em').text(), -date : FW.Xpath('//table[@class="layouttable"]/tbody/*/td/p/text()[last()] ').text(), -publicationTitle : "VoxEU.org", -tags : FW.Xpath('//div[@class="terms"]//li').text() -}); - -/** Search results */ -FW.MultiScraper({ -itemType : "multiple", -detect : FW.Xpath('//div[@class="content"]/dl[contains(@class, "search-results")]'), -choices : { - titles : FW.Xpath('//div[@class="content"]/dl/dt[@class="title"]/a').text(), - urls : FW.Xpath('//div[@class="content"]/dl/dt[@class="title"]/a').key('href').text() -} -}); -\ No newline at end of file diff --git a/translators/Wanfang Data.js b/translators/Wanfang Data.js @@ -1,364 +0,0 @@ -{ - "translatorID":"eb876bd2-644c-458e-8d05-bf54b10176f3", - "label":"Wanfang Data", - "creator":"Ace Strong <acestrong@gmail.com>", - "target":"^https?://[ds]\\.(?:g\\.)?wanfangdata\\.com\\.cn", - "minVersion":"2.0rc1", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2010-10-12 15:45:49" -} - -/* - Wanfang Data Translator - Copyright (C) 2010 TAO Cheng, acestrong@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/>. -*/ - -// ####################### -// ##### Sample URLs ##### -// ####################### - -/* - * The starting point for an search is the URL below. - * In testing, I tried the following: - * - * - A search listing of journals - * - A search listing of thesis - * - A search listing of conference papers - * - A search listing of foreign literatures(for chinese) - * - A journal paper page - * - A thesis page - * - A conference paper page - * - A foreign literature page - */ -// http://g.wanfangdata.com.cn/Default.aspx - - -// ################################# -// #### Local utility functions #### -// ################################# - -function detectCode(url) { - var pattern = /[ds]\.(?:g\.)?wanfangdata\.com\.cn\/([A-Za-z]*?)_/; - if (pattern.test(url)) { - var code = pattern.exec(url)[1]; - return code; - } - return null; -} - -function detectType(code) { - if (code == "Periodical") { - return "journalArticle"; - } else if (code == "Thesis") { - return "thesis"; - } else if (code == "Conference") { - return "conferencePaper"; - } else if (code == "NSTLHY") { - return "conferencePaper"; - } else if (code == "NSTLQK") { - return "journalArticle"; - } else { - return false; - } -} - -function getResolver(doc) { - var namespace, resolver; - namespace = doc.documentElement.namespaceURI; - if (namespace) { - resolver = function(prefix) { - if (prefix == 'x') { - return namespace; - } else { - return null; - } - }; - } else { - resolver = null; - } - return resolver; -} - -// ############################# -// ##### Scraper functions ##### -// ############################# - -function scrape(url) { - - Zotero.Utilities.HTTP.doGet(url, function(page) { - var pattern = /href=["'](.*?)["'] class="export"/; - var newurl = pattern.exec(page)[1]; - - Zotero.Utilities.HTTP.doGet(newurl, function(page) { - // scrape from xml data of export page - var pattern; - - pattern = /var text='(.*?)';/; - if (pattern.test(page)) { - var xml = pattern.exec(page)[1].replace(/(\\r\\n)/g, "\n"); -// Zotero.debug(xml); - - var newItem = new Zotero.Item(); - - // 类型 - pattern = /<ResourceCategory>(.*?)<\/ResourceCategory>/; - var category = pattern.exec(xml)[1]; - var type = detectType(category); - -// Zotero.debug(type); - newItem.itemType = type; - newItem.url = url; - - // 标题 - pattern = /<Titles>[\s\S]*?<Text>(.*?)<\/Text>[\s\S]*?(?:<Text>(.*?)<\/Text>[\s\S]*?)?<\/Titles>/; - var titles = pattern.exec(xml); - - newItem.title = titles[1]; - if (titles[2]) { - newItem.shortTitle = titles[2]; - } - - // 作者 - pattern = /<Creator>\s*<Name>(.*?)<\/Name>/g; - var author = pattern.exec(xml)[1]; - while (author) { -// Zotero.debug(author); - - var patt = /[a-zA-Z]/; - var useComma = true; - if (patt.test(author)) { - patt = /,/; - if (!patt.test(author)) { - useComma = false; - } - } - newItem.creators.push( - Zotero.Utilities.cleanAuthor( - author, - "author", - useComma)); - - var res = pattern.exec(xml); - if (res) { - author = res[1]; - } else { - author = null; - } - } - - // 引用页/页数 - pattern = /<Page>([0-9,-]*?)[^0-9,-]*?<\/Page>/; - if (pattern.test(xml)) { - var pages = pattern.exec(xml)[1]; -// Zotero.debug(pages); - pattern = /-/; - if (pattern.test(pages)) { - newItem.pages = pages; - } else { - newItem.numPages = pages; - } - } - - // 页数 - pattern = /<PageCount>([0-9]*)<\/PageCount>/; - if (pattern.test(xml)) { - var pages = pattern.exec(xml)[1]; -// Zotero.debug(pages); - newItem.numPages = pages; - } - - // 发表时间 - pattern = /<PublishDate>(.*?)<\/PublishDate>/; - if (pattern.test(xml)) { - newItem.date = pattern.exec(xml)[1]; - } - - // 关键词 - pattern = /<Keyword>(.*?)<\/Keyword>/g; - var res = pattern.exec(xml); - while (res) { - newItem.tags.push(res[1]); - res = pattern.exec(xml); - } - - // 摘要 - pattern = /<Abstract>\s*?<Text>([\s\S]*?)<\/Text>/; - if (pattern.test(xml)) { - newItem.abstractNote = pattern.exec(xml)[1]; - } - - // 硕士/博士 - pattern = /<Degree>(.*?)<\/Degree>/; - if (pattern.test(xml)) { - newItem.thesisType = pattern.exec(xml)[1]; - } - - // 导师 - pattern = /<Tutor>(.*?)<\/Tutor>/g; - var res = pattern.exec(xml); - while (res) { - var tutor = res[1]; - newItem.creators.push( - Zotero.Utilities.cleanAuthor( - tutor, - "director", - true)); - res = pattern.exec(xml); - } - - // 毕业学校 - pattern = /<School>(.*?)<\/School>/; - if (pattern.test(xml)) { - newItem.publisher = pattern.exec(xml)[1]; - } - - // 期刊名 - pattern = /<Periodical>[\s\S]*?<Name>(.*?)<\/Name>\s*?<NameEn>(.*?)<\/NameEn>/; - if (pattern.test(xml)) { - var res = pattern.exec(xml); - newItem.publicationTitle = res[1]; - newItem.journalAbbreviation = res[2]; - } - - // 卷 - pattern = /<Volum>([0-9]*?)<\/Volum>/; - if (pattern.test(xml)) { - newItem.volume = pattern.exec(xml)[1]; - } - - // 期 - pattern = /<Issue>([0-9]*?)<\/Issue>/; - if (pattern.test(xml)) { - newItem.issue = pattern.exec(xml)[1]; - } - - // 系列 - pattern = /<Column>(.*?)<\/Column>/; - if (pattern.test(xml)) { - newItem.series = pattern.exec(xml)[1]; - } - - // 会议名称 - pattern = /<Conference>[\s\S]*?<Name>(.*?)<\/Name>/; - if (pattern.test(xml)) { - newItem.conferenceName = pattern.exec(xml)[1]; - } - - // 会议地点 - pattern = /<Conference>[\s\S]*?<Locus>(.*?)<\/Locus>/; - if (pattern.test(xml)) { - newItem.place = pattern.exec(xml)[1]; - } - - // 会议论文集 - pattern = /<Source>(.*?)<\/Source>/; - if (pattern.test(xml)) { - newItem.proceedingsTitle = pattern.exec(xml)[1]; - } - - // ISSN - pattern = /<ISSN>(.*?)<\/ISSN>/; - if (pattern.test(xml)) { - newItem.ISSN = pattern.exec(xml)[1]; - } - - // 语言 - pattern = /<Language>([a-zA-Z]*?)<\/Language>/; - if (pattern.test(xml)) { - newItem.language = Zotero.Utilities.trim( - pattern.exec(xml)[1]); - } - - newItem.complete(); - } - }); - }); -} - -// ######################### -// ##### API functions ##### -// ######################### - -function detectWeb(doc, url) { - var pattern = /paper\.aspx/i; - if (pattern.test(url)) { - return "multiple" - } - - pattern = /[ds]\.(?:g\.)?wanfangdata\.com\.cn/; - if (pattern.test(url)) { - var code = detectCode(url); -// Zotero.debug(code); - return detectType(code); - } - - return false; -} - -function doWeb(doc, url) { - var nsResolver = getResolver(doc); - var urls, lis; - - Zotero.debug(url); - - if (detectWeb(doc, url) == "multiple") { -// Zotero.debug("Enter multiple."); - // search page - var items = new Array(); - - var xpath = '//li[@class="title_li"]'; - lis = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - - var li = lis.iterateNext(); - var link; - var title; - while (li) { - var a = li.getElementsByTagName("a")[0]; - title = Zotero.Utilities.cleanTags(a.textContent); - link = a.getAttribute("href"); - if (link) { - items[link] = Zotero.Utilities.trimInternal(title); -// Zotero.debug("title:"+title); -// Zotero.debug("link:"+link); - } - li = lis.iterateNext(); - } -// Zotero.debug(items); - if (items.__count__) { - // 让用户选择要保存哪些文献 - items = Zotero.selectItems(items); - if (!items) return true; - - urls = new Array(); - for (var url in items) { - urls.push(url); - } - } - } else { - urls = [url]; - } - - if (urls) { -// Zotero.debug(urls); - - for (var i=0; i<urls.length; i++) { - scrape(urls[i]); - } - } -} diff --git a/translators/Washington Monthly.js b/translators/Washington Monthly.js @@ -1,101 +0,0 @@ -{ - "translatorID": "e623eec7-ad54-4201-b709-654bf3fd7f70", - "label": "Washington Monthly", - "creator": "Sebastian Karcher", - "target": "^https?://www\\.washingtonmonthly\\.com", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-05-24 01:26:23" -} - -/* FW LINE 46:127318f30c1d */ 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})}}}};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){Zotero.debug("Entering MultiScraper.makeItems");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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")};function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -/** Articles */ -FW.Scraper({ - itemType : 'magazineArticle', - detect : FW.Xpath('//body[@class="article"]//div[@class="article"]'), - title : FW.Xpath('//div[@class="article"]/a[@class="headline-article"]').text(). - trim(), - abstractNote : FW.Xpath('//div[@class="article"]/p[@class="subhead"]').text(). - trim(), - attachments : [ - { url : FW.Url(), - title : FW.Url().match(/[0-9]+$/).prepend("Washington Monthly Snapshot pg. "), - type : "text/html" }, - { url : FW.Xpath('//div[@class="pagination"]/a[not(@class)]').key('href').text(), - title : FW.Xpath('//div[@class="pagination"]/a'). - key('href').text(). - match(/[0-9]+$/). - prepend("Washington Monthly Snapshot pg. "), - type : "text/html" }], - creators : FW.Xpath('//div[@class="article"]/p[@class="author"]').text(). - remove(/By/). - cleanAuthor("author"), - date : FW.Xpath('//div[@class="article"]/span[@class="date"]').text(), - publicationTitle : "The Washington Monthly" -}); - - - /** Blog Posts */ -FW.Scraper({ -itemType : 'blogPost', -detect : FW.Xpath('//body[@class="blog"]'), -title : FW.Xpath('//div[@class="article"]/a[@class="headline"]').text(). - trim(), -abstractNote : FW.Xpath('//div[@class="article"]/p[@class="subhead"]').text(). - trim(), -attachments : [{ - url : FW.Url(), - title : "Washington Monthly Snapshot", - type : "text/html" }], -creators : FW.Xpath('//div[@class="article"]/p[@class="author"]').text(). - remove(/By/). - cleanAuthor("author"), -date : FW.Xpath('//div[@class="article"]/span[@class="date"]').text(), -publicationTitle : FW.Xpath('//div[@id="content"]/h5').text(). - prepend('The Washington Monthly - ') -}); - - /** Articles Old */ -FW.Scraper({ -itemType : 'magazineArticle', -detect : FW.Xpath('//span[@class="HED"]'), -title : FW.Xpath('//span[@class="HED"]').text().trim(), -abstractNote : FW.Xpath('//span[@class="SubHed"]').text().trim(), -attachments : [{ - url: FW.Url(), - title: "Washington Monthly Snapshot", - type: "text/html" -}], -creators : FW.Xpath('//span[@class="Author"]/a').text().cleanAuthor("author"), -date : FW.Xpath('//td[@align="right"]/p[@class="TXT9"]').text().remove(/Washington Monthly,/).trim(), -publicationTitle : "The Washington Monthly" -}); - - - /** Blog Posts - old*/ -FW.Scraper({ -itemType : 'blogPost', -detect : FW.Xpath('//div[@class="blog"]'), -title : FW.Xpath('//div[@class="blogbody"]/*/p/child::*').text().remove(/\.\.\.\./).capitalizeTitle().trim(), -attachments : [{ - url: FW.Url(), - title: "Washington Monthly Snapshot", - type: "text/html" -}], -creators : FW.Xpath('//div[@class="blogbody"]/*/div[@class="header"]/span').text().cleanAuthor("author"), -date : FW.Xpath('//div[@class="blog"]/div[@class="date"]').text(), -publicationTitle : FW.Xpath('//td/div[@align="left"]/img').key('alt').text().prepend('The Washington Monthly - ') -}); - -/** Search results */ -FW.MultiScraper({ -itemType : "multiple", -detect : FW.Xpath('//div[@id="content"]/h4[@class="search-results"]'), -choices : { titles : FW.Xpath('//div[@class="gs-title"]/a').text(), -urls : FW.Xpath('//div[@class="gs-title"]/a').key('href').text() } -}); -\ No newline at end of file diff --git a/translators/Welt Online.js b/translators/Welt Online.js @@ -1,156 +0,0 @@ -{ - "translatorID": "f61beec2-1431-4218-a9d3-68063ede6ecd", - "label": "Welt Online", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.welt\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-29 18:43:49" -} - -/* -Welt Online Translator -Copyright (C) 2011 Martin Meyerhoff - -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/>. -*/ - -/* -"Multiple" doesn't work on the search pages, because that's another host. However, every other page does it: -http://www.welt.de/themen/Fukushima/ -http://www.welt.de/wirtschaft/ -http://www.welt.de/wirtschaft/article12962920/Krankenkassen-werfen-Aerzten-Gewinnstreben-vor.html -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var welt_article_XPath = ".//meta[contains(@property, 'og:type')]"; - var welt_multiple_XPath = ".//div[contains(@class, 'h2')]/a"; - if (doc.evaluate(welt_article_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.evaluate(welt_multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - return "multiple"; - } -} - -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("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the title! Welt's titles are ok without their "supertitles". They seem to convey - nothing. - - var xPath = ".//meta[contains(@property, 'og:title')]"; - var title = doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.title = title; - - // Authors - - var xPath = ".//meta[contains(@name, 'author')]"; - var author= doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - if (author == "WELT ONLINE") { - author = ""; - } - author = author.split(/\sund\s|\su\.\s|\,\s|\&|Und/); - for (var i in author) { - if (author[i].match(/\s/)) { // only names that contain a space! - author[i] = author[i].replace(/^\s*|\s*$/g, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - - // Summary - - var xPath = '//meta[contains(@name, "description")]'; - var summary = doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.abstractNote = summary; - - // Tags - var xPath = '//meta[contains(@name, "keywords")]'; - var tags= doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - tags = tags.split(/,\s/); - if (tags[0] != "" ) { - for (var i in tags) { - tags[i] = tags[i].replace(/^\s*|\s*$/g, ''); - newItem.tags.push(tags[i]); - } - } - - // Date - var xPath = ".//span[contains(@class, 'date')][last()]"; - var date= doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.date = date; - - // Publikation (I can only distinguish some articles from Welt am Sonntag by their URL, otherwise its all mishmash) - if (doc.location.href.match(/.*wams_print.*/)) { - newItem.publicationTitle = "Welt am Sonntag"; - } else { - newItem.publicationTitle = "Welt Online"; - } - - // Section - var xPath = ".//*[@id='mainNavi']/ul/li[contains(@class, 'menAc')]/a"; - var section= doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.section = section; - - // Attachment - newItem.attachments.push({url:doc.location.href+"?print=true", title:doc.title, mimeType:"text/html"}); - - newItem.complete() -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate(".//div[contains(@class, 'h2')]/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/Wikileaks Cables.js b/translators/Wikileaks Cables.js @@ -1,30 +0,0 @@ -{ - "translatorID": "6bb5099b-ae1a-4a08-8f2a-3429138ec2e5", - "label": "Wikileaks Cables", - "creator": "Erik Hetzner", - "target": "^http://(www\\.)?wikileaks\\.org/cable/", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-06-26 17:48:13" -} - -/* FW LINE 45:752c5f0defd3 */ 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})}}}};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(e,d){var b=new Array();for(var c in Zotero.selectItems(this._mkSelectItems(e,d))){b.push(c)}return 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(m,b,k,c,h){Zotero.debug("Entering MultiScraper.makeItems");if(this.beforeFilter){var n=this.beforeFilter(m,b);if(n!=b){this.makeItems(m,n,k,c,h);return}}var g=[];var l=[];this._makeChoices(this["choices"],m,b,g,l);var f=this._selectItems(g,l);var d=this._mkAttachments(m,b,l);if(!f){h([])}else{var j=[];var e=this.itemTrans;Zotero.Utilities.processDocuments(f,function(q){var p=q.documentURI;var o=e;if(o===undefined){o=FW.getScraper(q,p)}if(o===undefined){}else{o.makeItems(q,p,d[p],function(r){j.push(r);c(r,o,q,p)},function(){})}},function(){h(j)})}}};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){Zotero.debug("Entering DelegateTranslator.makeItems");var e;Zotero.Utilities.HTTP.doGet(d,function(h){this._translator.setHandler("itemDone",function(k,j){e=j;if(b){j.attachments=b}});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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);if(!d.detect){return f}else{var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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){Zotero.debug("Entering FW.doWeb");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();Zotero.debug("Leaving FW.doWeb")}; - -function detectWeb(doc, url) { return FW.detectWeb(doc, url); } -function doWeb(doc, url) { return FW.doWeb(doc, url); } - -FW.Scraper({ - itemType : 'document', - detect : "always", - title : FW.Xpath('//div[@class="pane big"]/h3').text().remove(/^Viewing cable /).prepend("Wikileaks Cable ") - attachments : [{ - url: FW.Url(), - title: "Wikileaks cable snapshot", - type: "text/html" }], - date : FW.Xpath('//table[@class="cable"]/tbody/tr[2]/td[2]/a').text().match(/^([0-9\-]+)/, 1), - extra : FW.Xpath('//table[@class="cable"]/tbody/tr[2]/td[5]/a').text().prepend("Origin: "), - publisher : "Wikileaks" -}); diff --git a/translators/Wikipedia Citation Templates.js b/translators/Wikipedia Citation Templates.js @@ -1,337 +0,0 @@ -{ - "translatorID":"3f50aaac-7acc-4350-acd0-59cb77faf620", - "translatorType":2, - "label":"Wikipedia Citation Templates", - "creator":"Simon Kornblith", - "target":"txt", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":100, - "displayOptions":{"exportCharset":"UTF-8"}, - "browserSupport":"gcsn", - "inRepository":true, - "lastUpdated":"2011-07-08 04:51:41" -} - -var fieldMap = { - edition:"edition", - publisher:"publisher", - doi:"DOI", - isbn:"ISBN", - issn:"ISSN", - conference:"conferenceName", - volume:"volume", - issue:"issue", - pages:"pages", - number:"episodeNumber" -}; - -var typeMap = { - book:"Cite book", - bookSection:"Cite book", - journalArticle:"Cite journal", - magazineArticle:"Cite news", - newspaperArticle:"Cite news", - thesis:"Cite paper", - letter:"Cite", - manuscript:"Cite book", - interview:"Cite interview", - film:"Cite video", - artwork:"Cite", - webpage:"Cite web", - report:"Cite conference", - bill:"Cite", - hearing:"Cite", - patent:"Cite", - statute:"Cite", - email:"Cite email", - map:"Cite", - blogPost:"Cite web", - instantMessage:"Cite", - forumPost:"Cite web", - audioRecording:"Cite", - presentation:"Cite paper", - videoRecording:"Cite video", - tvBroadcast:"Cite episode", - radioBroadcast:"Cite episode", - podcast:"Cite podcast", - computerProgram:"Cite", - conferencePaper:"Cite conference", - document:"Cite", - encyclopediaArticle:"Cite encyclopedia", - dictionaryEntry:"Cite encyclopedia" -}; - -function formatAuthors(authors, useTypes) { - var text = ""; - for each(var author in authors) { - text += ", "+author.firstName; - if(author.firstName && author.lastName) text += " "; - text += author.lastName; - if(useTypes) text += " ("+Zotero.Utilities.getLocalizedCreatorType(author.creatorType)+")"; - } - return text.substr(2); -} - -function formatFirstAuthor(authors, useTypes) { - var firstCreator = authors.shift(); - var field = firstCreator.lastName; - if(firstCreator.lastName && firstCreator.firstName) field += ", "; - field += firstCreator.firstName; - if(useTypes) field += " ("+Zotero.Utilities.getLocalizedCreatorType(firstCreator.creatorType)+")"; - return field; -} - -function formatDate(date) { - var date = date.substr(0, date.indexOf(" ")); - if(date.substr(4, 3) == "-00") { - date = date.substr(0, 4); - } else if(date.substr(7, 3) == "-00") { - date = date.substr(0, 7); - } - return date; -} - -function doExport() { - var first = true; - while(item = Zotero.nextItem()) { - // determine type - var type = typeMap[item.itemType]; - if(!type) type = "Cite"; - - var properties = new Object(); - - for(var wikiField in fieldMap) { - var zoteroField = fieldMap[wikiField]; - if(item[zoteroField]) properties[wikiField] = item[zoteroField]; - } - - if(item.creators && item.creators.length) { - if(type == "Cite episode") { - // now add additional creators - properties.credits = formatAuthors(item.creators, true); - } else if(type == "Cite video") { - properties.people = ""; - - // make first creator first, last - properties.people = formatFirstAuthor(item.creators, true); - // now add additional creators - if(item.creators.length) properties.people += ", "+formatAuthors(item.creators, true); - - // use type - if(item.type) { - properties.medium = item.type; - } - } else if(type == "Cite email") { - // get rid of non-authors - for(var i in item.creators) { - if(item.creators[i].creatorType != "author") { - // drop contributors - item.creators.splice(i, 1); - } - } - - // make first authors first, last - properties.author = formatFirstAuthor(item.creators); - // add supplemental authors - if(item.creators.length) { - properties.author += ", "+formatAuthors(item.creators); - } - } else if(type == "Cite interview") { - // check for an interviewer or translator - var interviewers = []; - var translators = []; - for(var i in item.creators) { - if(item.creators[i].creatorType == "translator") { - translators = translators.concat(item.creators.splice(i, 1)); - } else if(item.creators[i].creatorType == "interviewer") { - interviewers = interviewers.concat(item.creators.splice(i, 1)); - } else if(item.creators[i].creatorType == "contributor") { - // drop contributors - item.creators.splice(i, 1); - } - } - - // interviewers - if(interviewers.length) { - properties.interviewer = formatAuthors([interviewers.shift()]); - if(interviewers.length) properties.cointerviewers = formatAuthors(interviewers); - } - // translators - if(translators.length) { - properties.cointerviewers = (properties.cointerviewers ? properties.cointerviewers+", " : ""); - properties.cointerviewers += formatAuthors(translators); - } - // interviewees - if(item.creators.length) { - // take up to 4 interviewees - var i = 1; - while((interviewee = item.creators.shift()) && i <= 4) { - var lastKey = "last"; - var firstKey = "first"; - if(i != 1) { - lastKey += i; - firstKey += i; - } - - properties[lastKey] = interviewee.lastName; - properties[firstKey] = interviewee.firstName; - } - } - // medium - if(item.medium) { - properties.type = item.medium - } - } else { - // check for an editor or translator - var editors = []; - var translators = []; - for(var i in item.creators) { - if(item.creators[i].creatorType == "translator") { - translators = translators.concat(item.creators.splice(i, 1)); - } else if(item.creators[i].creatorType == "editor") { - editors = editors.concat(item.creators.splice(i, 1)); - } else if(item.creators[i].creatorType == "contributor") { - // drop contributors - item.creators.splice(i, 1); - } - } - - // editors - var others = ""; - if(editors.length) { - var editorText = formatAuthors(editors)+(editors.length == 1 ? " (ed.)" : " (eds.)"); - if(item.itemType == "bookSection" || type == "Cite conference" || type == "Cite encyclopedia") { - // as per docs, use editor only for chapters - properties.editors = editorText; - } else { - others = editorText; - } - } - // translators - if(translators.length) { - if(others) others += ", "; - others += formatAuthors(translators)+" (trans.)"; - } - - // pop off first author, if there is one - if(item.creators.length) { - var firstAuthor = item.creators.shift(); - properties.last = firstAuthor.lastName; - properties.first = firstAuthor.firstName; - - // add supplemental authors - if(item.creators.length) { - properties.coauthors = formatAuthors(item.creators); - } - } - - // attach others - if(others) { - if(type == "Cite book") { - properties.others = others; - } else { - properties.coauthors = (properties.coauthors ? properties.coauthors+", " : ""); - properties.coauthors += others; - } - } - } - } - - if(item.itemType == "bookSection") { - properties.title = item.publicationTitle; - properties.chapter = item.title;; - } else { - properties.title = item.title; - - if(type == "Cite journal") { - properties.journal = item.publicationTitle; - } else if(type == "Cite conference") { - properties.booktitle = item.publicationTitle; - } else if(type == "Cite encyclopedia") { - properties.encyclopedia = item.publicationTitle; - } else { - properties.work = item.publicationTitle; - } - } - - if(type == "Cite web" && item.type) { - properties.format = item.type; - } - - if(item.place) { - if(type == "Cite episode") { - properties.city = item.place; - } else { - properties.location = item.place; - } - } - - if(item.series) { - properties.series = item.series; - } else if(item.seriesTitle) { - properties.series = item.seriesTitle; - } else if(item.seriesText) { - properties.series = item.seriesText; - } - - if(item.accessDate) { - properties.accessdate = formatDate(item.accessDate); - } - - if(item.date) { - if(type == "Cite email") { - properties.senddate = formatDate(item.date); - } else { - var date = Zotero.Utilities.strToDate(item.date); - var mm = "00"; - var dd = "00"; - if (date["month"] != undefined){ - mm = date["month"]; - mm = mm + 1; - if (mm < 10){ - mm = "0" + mm; - } - } - if (date["day"] != undefined){ - dd = date["day"]; - if (dd < 10){ - dd = "0" + dd; - } - } - if (date["year"] != undefined){ - var yyyy = date["year"].toString(); - while (yyyy.length < 4){ - yyyy = "0"+yyyy; - } - properties.date = formatDate(yyyy+"-"+mm+"-"+dd+" "); - } - } - } - - if(item.runningTime) { - if(type == "Cite episode") { - properties.minutes = item.runningTime; - } else { - properties.time = item.runningTime; - } - } - - if(item.url && item.accessDate) { - if(item.itemType == "bookSection") { - properties.chapterurl = item.url; - } else { - properties.url = item.url; - } - } - - // write out properties - Zotero.write((first ? "" : "\r\n\r\n") + "{{"+type); - for(var key in properties) { - if(properties[key]) Zotero.write("\r\n| "+key+" = "+properties[key]); - } - Zotero.write("\r\n}}"); - - first = false; - } -} diff --git a/translators/Wildlife Biology in Practice.js b/translators/Wildlife Biology in Practice.js @@ -1,83 +0,0 @@ -{ - "translatorID":"b33af0e1-d122-45b2-b144-4b4eedd12d5d", - "translatorType":4, - "label":"Wildlife Biology in Practice", - "creator":"Michael Berkowitz", - "target":"http://www.socpvs.org/journals/index.php/wbp", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-01-08 08:19:07" -} - -function detectWeb(doc, url) { - if (url.match(/showToc/) || url.match(/advancedResults/)) { - return "multiple"; - } else if (url.match(/article/)) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var xpath = '//tr[td/a[2]]'; - if (url.match(/issue/)) { - var linkx = './td[2]/a[1]'; - var titlex = './td[1]'; - } else if (url.match(/advanced/)) { - var linkx = './td[3]/a[1]'; - var titlex = './td[2]'; - } - var results = doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null); - var result; - while (result = results.iterateNext()) { - var title = doc.evaluate(titlex, result, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var link = doc.evaluate(linkx, result, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = Zotero.Utilities.trimInternal(title); - } - items = Zotero.selectItems(items); - for (var i in items) { - arts.push(i.replace(/view/, "viewArticle")); - } - } else { - arts = [url.replace(/viewRST/, "viewArticle")]; - } - Zotero.Utilities.processDocuments(arts, function(doc) { - var item = new Zotero.Item("journalArticle"); - var voliss = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="main"]/h2', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - voliss = voliss.match(/^([^,]+),\s+([^;]+);\s+(\d+)\((\d+)\);\s+([^;]+)/); - item.journalAbbreviation = voliss[1]; - item.date = voliss[2]; - item.issue = voliss[3]; - item.volume = voliss[4]; - item.pages = voliss[5]; - var authors = doc.evaluate('//div[@id="authorDetails"]/ul[@class="lista"]/li/strong/a', doc, ns, XPathResult.ANY_TYPE, null); - var author; - while (author = authors.iterateNext()) { - item.creators.push(Zotero.Utilities.cleanAuthor(author.title.match(/^\w+\b\s+(.*)\s+\b\w+$/)[1], "author")); - } - item.publicationTitle = "Wildlife Biology in Practice"; - item.ISSN = "1646-2742"; - item.DOI = doc.evaluate('//div[@id="copyArticle"]/a[1]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/doi:\s+([^\s]+)/)[1]; - item.url = doc.location.href; - item.title = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="content"]/h3', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="abstract"]/blockquote/p', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent); - item.tags = doc.evaluate('//div[@id="abstract"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/Keywords:\s+([^\.]+)/)[1].split(/,\s+/); - - var pdfurl = doc.evaluate('//div[@id="rt"]/a[@class="action noarrow"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().href; - item.attachments = [ - {url:item.url, title:item.publicationTitle + " Snapshot", mimeType:"text/html"}, - {url:pdfurl, title:item.publicationTitle + " PDF", mimeType:"application/pdf"} - ]; - item.complete(); - }, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/Wiley Online Library.js b/translators/Wiley Online Library.js @@ -1,522 +0,0 @@ -{ - "translatorID": "fe728bc9-595a-4f03-98fc-766f1d8d0936", - "label": "Wiley Online Library", - "creator": "Sean Takats, Michael Berkowitz and Avram Lyon", - "target": "^https?://onlinelibrary\\.wiley\\.com[^\\/]*/(?:doi|advanced/search)", - "minVersion": "1.0.0b4.r5", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "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 <http://www.gnu.org/licenses/>. - */ - -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(/\/issuetoc|\/results/)) { - return "multiple"; - } else return "journalArticle"; -} - -function doWeb(doc, url){ - // Define ZU, Z - if (!ZU) var ZU = Zotero.Utilities; - if (!Z) var Z = Zotero; - - 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('//li//div[@class="citation article" or @class="citation tocArticle"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var article = false; - while (article = articles.iterateNext()) { - availableItems[article.href] = article.textContent; - } - var items = Zotero.selectItems(availableItems); - if(!items) { - return true; - } - for (var i in items) { - urls.push(i); - } - Zotero.Utilities.processDocuments(urls, scrape, function () { Zotero.done(); }); - } else { //single article - 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(); -} - -function parseIdentifier(identifier) { - var idPieces = identifier.split(':'); - if (idPieces.length > 1) { - var prefix = idPieces.shift(); - switch (prefix.toLowerCase()) { - case "doi": return ["doi", idPieces.join(':')]; - case "isbn": return ["isbn", idPieces.join(':')]; - case "issn": return ["issn", idPieces.join(':')]; - case "pmid": return ["pmid", idPieces.join(':')]; - default: // do nothing - } - Zotero.debug("Unknown identifier prefix '"+prefix+"'"); - return [prefix, idPieces.join(':')]; - } - if (identifer.substr(0,3) == '10.') return ["doi", identifier]; - - // If we're here, we have a funny number, and we don't know what to do with it. - var ids = idCheck(identifier); - if (ids.isbn13) return ["isbn13", isbn13]; - if (ids.isbn10) return ["isbn10", isbn10]; - if (ids.issn) return ["issn", isbn10]; - - return ["unknown", identifier]; -} - -function addIdentifier(identifier, item) { - var parsed = parseIdentifier(identifier); - switch (parsed[0]) { - case "doi": item.DOI = parsed[1]; break; - case "isbn": item.ISBN = parsed[1]; break; - case "isbn13": item.ISBN = parsed[1]; break; - case "isbn10": item.ISBN = parsed[1]; break; - case "issn": item.ISSN = parsed[1]; break; - default: - } -} - -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) { - // PRISM - case "prism.publicationName": newItem.publicationTitle = value; break; - case "prism.issn": if (!newItem.ISSN && value != "NaN" && value != "") newItem.ISSN = value; break; - case "prism.eIssn": if (!newItem.ISSN && value != "NaN" && value != "") newItem.ISSN = value; break; - // This is often NaN for some reason - case "prism.publicationDate": if (!newItem.date && value != "NaN" && value !== "") newItem.date = value; break; - case "prism.volume": if (!newItem.volume && value != "NaN" && value != "") newItem.volume = value; break; - case "prism.number": if (!newItem.issue && value != "NaN" && value != "") newItem.issue = value; break; - // These also seem bad - case "prism.startingPage": if(!pages[0] && value != "null" && value != "") pages[0] = value; break; - case "prism.endingPage": if(!pages[1] && value != "null" && value != "") pages[1] = value; break; - case "prism.number": newItem.issue = value; break; - // Google. - case "citation_journal_title": if (!newItem.publicationTitle) newItem.publicationTitle = value; break; - case "citation_authors": - if (newItem.creators.length == 0) { - for each(var author in value.split(';')) { - if (author.toUpperCase() == author) - author = ZU.capitalizeTitle(author.toLowerCase(), true); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author", true)); - } - } - break; - 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; - // Prefer long language names - case "citation_language": if ((!newItem.language || newItem.language.length < 4) - && value != "null" && value != "") newItem.language = value; break; - case "citation_doi": if (!newItem.DOI) newItem.DOI = value; break; - case "citation_abstract": newItem.abstractNote = value; break; - case "citation_abstract_html_url": newItem.url = value; break; - case "citation_pdf_url": if(!pdf) pdf = value; break; - case "citation_keywords": newItem.tags.push(value); break; - case "citation_fulltext_html_url": if(!pdf) pdf = value; break; - case "fulltext_pdf": if(!pdf) pdf = value; break; - // Dublin Core - case "dc.publisher": if(!newItem.publisher) newItem.publisher = value; break; - case "dc.language": if(!newItem.language) newItem.language = value; break; - case "dc.rights": if(!newItem.rights) newItem.rights = value; break; - case "dc.title": if(!newItem.title) newItem.title = value; break; - case "dc.creator": if(!newItem.creators.length == 0) newItem.creators.push(Zotero.Utilities.cleanAuthor(value)); break; - // This is often NaN for some reason - case "dc.date": if (!newItem.date && value != "NaN" && value !== "") newItem.date = value; break; - case "dc.identifier": addIdentifier(value, newItem); break; - 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] : ""); - - // Abstracts don't seem to come with - if (!newItem.abstractNote) { - var abstractNode = doc.evaluate('//div[@id="abstract"]/div[@class="para"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abstractNode) newItem.abstractNote = abstractNode.textContent; - } - - // Fix things in uppercase - var toFix = [ "title", "shortTitle" ]; - for each (var i in toFix) { - if (newItem[i] && newItem[i].toUpperCase() == newItem[i]) - newItem[i] = Zotero.Utilities.capitalizeTitle(newItem[i].toLowerCase(), true); - } - - // Remove final asterisk in title if present - newItem.title = newItem.title.replace(/\*$/,''); - - if (html) newItem.attachments = [{url:html, title:"Wiley Full Text HTML"}]; - - if (pdf) { - Zotero.Utilities.doGet(pdf, function(text) { - pdf = text.match(/<iframe id="pdfDocument" src="([^"]*)"/); - if (pdf) newItem.attachments.push({url:pdf[1].replace(/&amp;/g,"&"), title:"Wiley Full Text PDF", mimeType:"application/pdf"}); - //<iframe id="pdfDocument" src="http://onlinelibrary.wiley.com/store/10.1111/j.1088-4963.2009.01154.x/asset/j.1088-4963.2009.01154.x.pdf?v=1&amp;t=gqcawqo5&amp;s=7ea8c89d203f02c212feeda25925ae663d37cc48" width="100%" height="100%"> - newItem.complete(); - }, function () {Zotero.done()}); - } else { - newItem.complete(); - } -} - -// Implementation of ISBN and ISSN check-digit verification -// Based on ISBN Users' Manual (http://www.isbn.org/standards/home/isbn/international/html/usm4.htm) -// and the Wikipedia treatment of ISBN (http://en.wikipedia.org/wiki/International_Standard_Book_Number) -// and the Wikipedia treatment of ISSN (http://en.wikipedia.org/wiki/International_Standard_Serial_Number) - -// This will also check ISMN validity, although it does not distinguish from their -// neighbors in namespace, ISBN-13. It does not handle pre-2008 M-prefixed ISMNs; see -// http://en.wikipedia.org/wiki/International_Standard_Music_Number - -// This does not validate multiple identifiers in one field, -// but it will gracefully ignore all non-number detritus, -// such as extraneous hyphens, spaces, and comments. - -// It currently maintains hyphens in non-initial and non-final position, -// discarding consecutive ones beyond the first as well. - -// It also adds the customary hyphen to valid ISSNs. - -// Takes the first 8 valid digits and tries to read an ISSN, -// takes the first 10 valid digits and tries to read an ISBN 10, -// and takes the first 13 valid digits to try to read an ISBN 13 -// Returns an object with four attributes: -// "issn" -// "isbn10" -// "isbn13" -// Each will be set to a valid identifier if found, and otherwise be a -// boolean false. - -// There could conceivably be a valid ISBN-13 with an ISBN-10 -// substring; this should probably be interpreted as the latter, but it is a -idCheck = function(isbn) { - // For ISBN 10, multiple by these coefficients, take the sum mod 11 - // and subtract from 11 - var isbn10 = [10, 9, 8, 7, 6, 5, 4, 3, 2]; - - // For ISBN 13, multiple by these coefficients, take the sum mod 10 - // and subtract from 10 - var isbn13 = [1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3]; - - // For ISSN, multiply by these coefficients, take the sum mod 11 - // and subtract from 11 - var issn = [8, 7, 6, 5, 4, 3, 2]; - - // We make a single pass through the provided string, interpreting the - // first 10 valid characters as an ISBN-10, and the first 13 as an - // ISBN-13. We then return an array of booleans and valid detected - // ISBNs. - - var j = 0; - var sum8 = 0; - var num8 = ""; - var sum10 = 0; - var num10 = ""; - var sum13 = 0; - var num13 = ""; - var chars = []; - - for (var i=0; i < isbn.length; i++) { - if (isbn.charAt(i) == " ") { - // Since the space character evaluates as a number, - // it is a special case. - } else if (j > 0 && isbn.charAt(i) == "-" && isbn.charAt(i-1) != "-") { - // Preserve hyphens, except in initial and final position - // Also discard consecutive hyphens - if(j < 7) num8 += "-"; - if(j < 10) num10 += "-"; - if(j < 13) num13 += "-"; - } else if (j < 7 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum8 += isbn.charAt(i) * issn[j]; - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num8 += isbn.charAt(i); - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } else if (j == 7 && - (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || - ((isbn.charAt(i) - 0) == isbn.charAt(i)))) { - // In ISSN, an X represents the check digit "10". - if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") { - var check8 = 10; - num8 += "X"; - } else { - var check8 = isbn.charAt(i); - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num8 += isbn.charAt(i); - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } - } else if (j < 9 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum10 += isbn.charAt(i) * isbn10[j]; - sum13 += isbn.charAt(i) * isbn13[j]; - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } else if (j == 9 && - (isbn.charAt(i) == "X" || isbn.charAt(i) == "x" || - ((isbn.charAt(i) - 0) == isbn.charAt(i)))) { - // In ISBN-10, an X represents the check digit "10". - if(isbn.charAt(i) == "X" || isbn.charAt(i) == "x") { - var check10 = 10; - num10 += "X"; - } else { - var check10 = isbn.charAt(i); - sum13 += isbn.charAt(i) * isbn13[j]; - num10 += isbn.charAt(i); - num13 += isbn.charAt(i); - j++; - } - } else if(j < 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - sum13 += isbn.charAt(i) * isbn13[j]; - num13 += isbn.charAt(i); - j++; - } else if (j == 12 && ((isbn.charAt(i) - 0) == isbn.charAt(i))) { - var check13 = isbn.charAt(i); - num13 += isbn.charAt(i); - } - } - var valid8 = ((11 - sum8 % 11) % 11) == check8; - var valid10 = ((11 - sum10 % 11) % 11) == check10; - var valid13 = (10 - sum13 % 10 == check13); - var matches = false; - - // Since ISSNs have a standard hyphen placement, we can add a hyphen - if (valid8 && (matches = num8.match(/([0-9]{4})([0-9]{3}[0-9Xx])/))) { - num8 = matches[1] + '-' + matches[2]; - } - - if(!valid8) {num8 = false}; - if(!valid10) {num10 = false}; - if(!valid13) {num13 = false}; - return {"isbn10" : num10, "isbn13" : num13, "issn" : num8}; -} - - -/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://onlinelibrary.wiley.com/doi/10.1111/j.1088-4963.2009.01154.x/abstract", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "Michael", - "lastName": "Otsuka", - "creatorType": "author" - }, - { - "firstName": "Alex", - "lastName": "Voorhoeve", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "Wiley Full Text PDF", - "mimeType": "application/pdf" - } - ], - "url": "http://onlinelibrary.wiley.com/doi/10.1111/j.1088-4963.2009.01154.x/abstract", - "DOI": "10.1111/j.1088-4963.2009.01154.x", - "volume": "37", - "issue": "2", - "publicationTitle": "Philosophy & Public Affairs", - "publisher": "Blackwell Publishing Inc", - "ISSN": "1088-4963", - "title": "Why It Matters That Some Are Worse Off Than Others: An Argument against the Priority View", - "language": "en", - "date": "2009/03/01", - "pages": "171-199", - "libraryCatalog": "Wiley Online Library", - "shortTitle": "Why It Matters That Some Are Worse Off Than Others" - } - ] - }, - { - "type": "web", - "url": "http://onlinelibrary.wiley.com/doi/10.1111/j.1533-6077.2008.00144.x/abstract", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "David", - "lastName": "Copp", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "url": "http://onlinelibrary.wiley.com/doi/10.1111/j.1533-6077.2008.00144.x/abstract", - "DOI": "10.1111/j.1533-6077.2008.00144.x", - "volume": "18", - "issue": "1", - "publicationTitle": "Philosophical Issues", - "publisher": "Blackwell Publishing Inc", - "ISSN": "1758-2237", - "title": "Darwinian Skepticism About Moral Realism", - "language": "en", - "date": "2008/09/01", - "pages": "186-206", - "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 staff‐related outcomes", - "language": "en", - "libraryCatalog": "Wiley Online Library" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/WilsonWeb.js b/translators/WilsonWeb.js @@ -1,715 +0,0 @@ -{ - "translatorID":"af1af8fa-19dc-486f-a8cc-107acb849101", - "label":"WilsonWeb", - "creator":"Brinda Shah", - "target":"^http://(vnweb|webbeta|verityqa|verityqa2|atg-dev05)\\.hwwilsonweb\\.com/hww/results/", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-01-05 17:05:00" -} - -var dispType='brief'; -var titleObj= new Object(); -var resultType = ''; -var articles = new Array(); -var pgSize; - - -function detectWeb(doc, url) { - - var tClassObj; - var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? - function(prefix) { - if (prefix == "x" ) - return namespace; - else - return null; - } : null; - - if(doc.title.match("Search Results")) { - var dispElePath = "//input[@name='displayType']"; - var dispEle = doc.evaluate(dispElePath , doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(dispEle) { - dispType=dispEle.value; - } - - var cxpath = getXPath(dispType, 'cxpath'); - tClassObj = doc.evaluate(cxpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if (!tClassObj) { - cxpath = getXPath(dispType, 'cxpath1'); - tClassObj = doc.evaluate(cxpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - } - var tClass = tClassObj.textContent; - if(tClass.match("BIBL")) - resultType = "journalArticle"; - else if(tClass.match("BOOK")) - resultType = "book"; - else if(tClass.match("ART")) - resultType = "artwork"; - - var xpath = '//input[@name="pageSize"]'; - var eleObj = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var ele; - if(ele = eleObj.iterateNext()) { - if(ele) { - pgSize= ele.value; - - if(pgSize > 1) { - //if(resultType == 'journalArticle') - return "multiple"; - } - else - return resultType; - - } - } - - } - -} - -function doWeb(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? - function(prefix) { - if (prefix == 'x') - return namespace; - else - return null; - } : null; - - if (detectWeb(doc, url) == "multiple") { - - var nextTitle; - var c = 0; - - var titles = doc.evaluate(getXPath(dispType,'ti'), doc, nsResolver, XPathResult.ANY_TYPE, null); - while (nextTitle= titles.iterateNext()) { - c++; - titleObj[c] = nextTitle.textContent; - } - titleObj = Zotero.selectItems(titleObj); - - for (var t in titleObj ) { - articles.push(t); - var newArticle = new Zotero.Item(resultType); - newArticle.url = doc.location.href; - newArticle.title = titleObj[t]; - switch(resultType) { - case 'journalArticle' : associateBIBLData(doc,newArticle,t); - break; - case 'book': associateBookData(doc, newArticle, t); - break; - case 'artwork' : associateArtData(doc, newArticle,t); - break; - } - - newArticle.complete(); - } - } - else { - //saves single page items - articles = [url]; - } - - Zotero.Utilities.processDocuments(articles, scrape, function(){Zotero.done();}); - - Zotero.wait(); - -} - -function associateBIBLData(doc,newArticle,t) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? - function(prefix) { - if (prefix == 'x') - return namespace; - else - return null; - } : null; - - var host = doc.location.host; - - //author - var authorPath = getXPath(dispType,'au',t); - var authorObj = doc.evaluate(authorPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(authorObj) { - associateAuthorData(newArticle, authorObj); - } - - //journal - var journalPath = getXPath(dispType, 'jn', t); - var journalObj = doc.evaluate(journalPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(journalObj ) { - associateFieldData(newArticle, journalObj, 'journalAbbreviation'); - } - - - //source - var sourcePath = getXPath(dispType,'so',t); - if(sourcePath != '') { - var sourceObj = doc.evaluate(sourcePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(sourceObj) - associateSourceData(newArticle, sourceObj); - } - - //subject - var tagsContent = new Array(); - var suPath = getXPath(dispType, 'su', t); - if(suPath != '') { - var suObj = doc.evaluate(suPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(suObj) { - var subjects = suObj.textContent.split(';'); - for (var i in subjects) { - //Zotero.debug(subjects[i]); - tagsContent.push(subjects[i]); - } - for (var i = 0; i < tagsContent.length; i++) { - newArticle.tags[i] = tagsContent[i]; - } - } - } - - //issn - var issnPath = getXPath(dispType, 'issn', t); - if(issnPath != '') { - var issnObj = doc.evaluate(issnPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(issnObj) { - associateFieldData(newArticle, issnObj, 'ISSN'); - } - } - - //la - var laPath = getXPath(dispType, 'la', t); - if(laPath != '') { - var laObj = doc.evaluate(laPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(laObj) { - associateFieldData(newArticle, laObj, 'language'); - } - } - - //abstract - var absPath = getXPath(dispType, 'abs', t); - if(absPath != '') { - var absObj = doc.evaluate(absPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(absObj) { - associateFieldData(newArticle, absObj, 'abstractNote'); - } - } - - //doi - var doiPath = getXPath(dispType, 'doi', t); - if(doiPath != '') { - var doiObj = doc.evaluate(doiPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(doiObj) { - associateFieldData(newArticle, doiObj, 'DOI'); - } - } - - //inst - var instPath = getXPath(dispType, 'inst', t); - if(instPath != '') { - var instObj = doc.evaluate(instPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(instObj ) { - associateFieldData(newArticle, instObj , 'institution'); - } - } - - //publisher - var pbPath = getXPath(dispType, 'pb', t); - if(pbPath != '') { - var pbObj = doc.evaluate(pbPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(pbObj) { - associateFieldData(newArticle, pbObj, 'publisher'); - } - } - - //note - var ntPath = getXPath(dispType, 'nt', t); - Zotero.debug("ntPath : " + ntPath); - if(ntPath != '') { - var ntObj = doc.evaluate(ntPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(ntObj) { - associateFieldData(newArticle, ntObj, 'notes'); - } - } - - //date entered - var dtPath = getXPath(dispType, 'der', t); - if(dtPath != '') { - var dtObj = doc.evaluate(dtPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(dtObj) { - associateFieldData(newArticle, dtObj, 'dateAdded'); - } - } - - //date updated - var udtPath = getXPath(dispType, 'ud', t); - if(dtPath != '') { - var udtObj = doc.evaluate(udtPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(udtObj) { - associateFieldData(newArticle, udtObj, 'dateModified'); - } - } - - var pdfURL=''; - var pdfLink = getXPath(dispType,'pdfLink',t); - if(pdfLink != '') { - var pdfObj = doc.evaluate(pdfLink, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(pdfObj ) { - var pdf = pdfObj.textContent; - pdfURL =pdf.match(/https?:[/]+([-\w\.]+)+(:\d+)?([/]([\w/_\.]*(\?\S+)?)?)?/); - //Zotero.debug("pdfURL :" + pdfURL[0]); - } - } - - var snapShotURL=''; - var recid = getXPath(dispType,'recid',t); - if(recid != '') { - var recObj= doc.evaluate(recid, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(recObj) { - var rec = recObj.value; - snapShotURL = 'http://' + host + '/hww/jumpstart.jhtml?recid=' + rec + '&fmt=S&DT=full'; - //Zotero.debug("snapShotURL :" + snapShotURL ); - - } - } - - if(pdfURL != null || snapShotURL != null) { - newArticle.attachments = [ - {url:snapShotURL, title:"WilsonWeb Snapshot", mimeType:"text/html"}, - {url:pdfURL[0], title:"WilsonWeb Full Text PDF", mimeType:"application/pdf"} - ]; - } -} - -function associateBookData( doc, newArticle, t) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? - function(prefix) { - if (prefix == 'x') - return namespace; - else - return null; - } : null; - - var host = doc.location.host; - - //author - var authorPath = getXPath(dispType,'au',t); - var authorObj = doc.evaluate(authorPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - - if(authorObj) { - associateAuthorData(newArticle, authorObj); - } - - //publisher - var pbPath = getXPath(dispType, 'pb', t); - if(pbPath != '') { - var pbObj = doc.evaluate(pbPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(pbObj) { - associateFieldData(newArticle, pbObj, 'publisher'); - } - } - - //pages - var pgPath = getXPath(dispType, 'pa', t); - if(pgPath != '') { - var pgObj = doc.evaluate(pgPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(pgObj) { - associateFieldData(newArticle, pgObj, 'numPages'); - } - } - - //la - var laPath = getXPath(dispType, 'la', t); - if(laPath != '') { - var laObj = doc.evaluate(laPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(laObj) { - associateFieldData(newArticle, laObj, 'language'); - } - } - - //isbn - var isbnPath = getXPath(dispType, 'isbn', t); - if(isbnPath != '') { - var isbnObj = doc.evaluate(isbnPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(isbnObj) { - associateFieldData(newArticle, isbnObj, 'ISBN'); - } - } - - //abstract - var absPath = getXPath(dispType, 'abs', t); - if(absPath != '') { - var absObj = doc.evaluate(absPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(absObj) { - associateFieldData(newArticle, absObj, 'abstractNote'); - } - } - - //subject - var tagsContent = new Array(); - var suPath = getXPath(dispType, 'su', t); - if(suPath != '') { - var suObj = doc.evaluate(suPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(suObj) { - var subjects = suObj.textContent.split(';'); - for (var i in subjects) { - Zotero.debug(subjects[i]); - tagsContent.push(subjects[i]); - } - for (var i = 0; i < tagsContent.length; i++) { - newArticle.tags[i] = tagsContent[i]; - } - } - } - - //note - /*var noteContent = new Array(); - var ntPath = getXPath(dispType, 'nt', t); - Zotero.debug("ntPath : " + ntPath); - if(ntPath != '') { - var ntObj = doc.evaluate(ntPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(ntObj) { - var notes = ntObj.textContent.split(';'); - for(var i in notes) { - noteContent.push(notes[i]); - } - for (var i=0; i<noteContent.length; i++) { - newArticle.notes[i] = noteContent[i]; - } - //associateFieldData(newArticle, ntObj, 'notes'); - //newArticle.notes = ntObj.textContent; - } - }*/ - - //date entered - var dtPath = getXPath(dispType, 'der', t); - if(dtPath != '') { - var dtObj = doc.evaluate(dtPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(dtObj) { - associateFieldData(newArticle, dtObj, 'dateAdded'); - } - } - - //date updated - var udtPath = getXPath(dispType, 'ud', t); - if(dtPath != '') { - var udtObj = doc.evaluate(udtPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(udtObj) { - associateFieldData(newArticle, udtObj, 'dateModified'); - } - } - - //series - var seriesPath = getXPath(dispType, 'TSN', t); - if(seriesPath != '') { - var seriesObj = doc.evaluate(seriesPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(seriesObj) { - associateFieldData(newArticle, seriesObj, 'series'); - } - } - - var fullTextURL; - var fullTextLink = getXPath(dispType,'fullTextLink',t); - if(fullTextLink != '') { - var fullTextObj = doc.evaluate(fullTextLink, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(fullTextObj ) { - var fullText = fullTextObj.textContent; - fullTextURL=fullText.match(/https?:[/]+([-\w\.]+)+(:\d+)?([/]([\w/_\.]*(\?\S+)?)?)?/); - //Zotero.debug("fullTextURL:" + fullTextURL[0]); - } - } - - if(fullTextURL != null ) { - newArticle.attachments = [ - {url:fullTextURL[0], title:"Book Full Text", mimeType:"text/html"} - ]; - } - - var pdfURL; - var pdfLink = getXPath(dispType,'pdfLink',t); - if(pdfLink != '') { - var pdfObj = doc.evaluate(pdfLink, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(pdfObj ) { - var pdf = pdfObj.textContent;// - pdfURL =pdf.match(/https?:[/]+([-\w\.]+)+(:\d+)?([/]([\w/_\.]*(\?\S+)?)?)?/); - //Zotero.debug("pdfURL :" + pdfURL[0]); - } - } - - if(pdfURL != null ) { - newArticle.attachments = [ - {url:pdfURL[0], title:"WilsonWeb Full Text PDF", mimeType:"application/pdf"} - ]; - } - - -} - -function associateArtData(doc, newArticle,t) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? - function(prefix) { - if (prefix == 'x') - return namespace; - else - return null; - } : null; - - var host = doc.location.host; - - //artist - var artist; - var authorPath = getXPath(dispType,'ar',t); - var authorObj = doc.evaluate(authorPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - - while(artist = authorObj.iterateNext()) { - newArticle.creators.push(Zotero.Utilities.cleanAuthor(artist.textContent, "artist")); - } - - //subject - - var tagsContent = new Array(); - var suPath = getXPath(dispType, 'su', t); - if(suPath != '') { - var suObj = doc.evaluate(suPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(suObj) { - var subjects = suObj.textContent.split(';'); - for (var i in subjects) { - tagsContent.push(subjects[i]); - } - for (var i = 0; i < tagsContent.length; i++) { - newArticle.tags[i] = tagsContent[i]; - } - } - } - - //artworksize - var sizePath = getXPath(dispType,'siz',t); - if(sizePath != '') { - var sizeObj = doc.evaluate(sizePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(sizeObj) { - associateFieldData(newArticle, sizeObj, 'artworkSize'); - } - } - - //artworkmedium - var mediumPath = getXPath(dispType,'mt',t); - if(mediumPath != '') { - var mediumObj = doc.evaluate(mediumPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(mediumObj ) { - associateFieldData(newArticle, mediumObj, 'artworkMedium'); - } - } - - //location - var locPath = getXPath(dispType,'own',t); - if(locPath != '') { - var locObj = doc.evaluate(locPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(locObj) { - associateFieldData(newArticle, locObj, 'place'); - } - } - - //abstract - var absPath = getXPath(dispType, 'abs', t); - if(absPath != '') { - var absObj = doc.evaluate(absPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(absObj) { - associateFieldData(newArticle, absObj, 'abstractNote'); - } - } -} - -function associateAuthorData(zoteroItem, zoteroObj) { - var fTitle; - var author = zoteroObj.textContent; - //Zotero.debug("Author : " + author); - if (author.match("; ")) { - var authors = author.split(";"); - for (var i in authors) { - //Zotero.debug("authors["+i+"] - " + authors[i]); - zoteroItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author",true)); - } - } else { - zoteroItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author",true)); - } -} - -function associateSourceData(zoteroItem, zoteroObj) { - //source - var source = zoteroObj.textContent; - - //volume - var vol = source.match(/[v].\s*\d+/); - if(vol) - zoteroItem["volume"] = vol[0].match(/\d+/); - - //issue - var issue = source.match(/[no]..\s*\d+[/]*[\d+]*/); - if(issue) - zoteroItem["issue"] = issue[0].match(/\d+[/]*[\d+]*/); - - //date - var date = source.match(/\b\w+\s*\d*\s*\d{4}\b/); - zoteroItem["date"] = date; - - //pages - var pages = source.match(/[p].\s*\d+[-]*\d+/); - if(pages) - zoteroItem["pages"] = pages[0].match(/\d+[-]*\d+/); - - zoteroItem["source"] = source; -} - -function associateFieldData(zoteroItem, zoteroObj, zoteroField) { - var fieldValue = zoteroObj.textContent.replace(/^\s*|\s*$/g, ''); - zoteroItem[zoteroField] = fieldValue; - //Zotero.debug(zoteroField + " - " + fieldValue); -} - - - -function getXPath(dispType,field,p) { - var xPath = ""; - var pos = ""; - if(p) - pos = "[" + p + "]"; - - if(dispType == 'brief') { - - switch(field){ - - case 'cxpath1' : xPath = '//div[@id="results"]//table[contains(@class,"rectable")]/tbody/tr/td[2]/table/@class'; - break; - case 'cxpath' : xPath = '//div[@id="results"]/table[contains(@class,"rectable")]/tbody/tr/td[2]/p/@class'; - break; - case 'chk' : xPath = '//input[@name="checkbox"][@type="checkbox"]'; - break; - case 'ti': xPath = "//span[contains(@class,'ti')][1]"; - break; - case 'au': xPath = '//table[@class="rectable"]'+ pos +'//span[contains(@class,"au")]'; - break; - case 'jn': xPath = '//table[@class="rectable"]'+ pos +'//span[contains(@class,"jn")]'; - break; - case 'so' : xPath = '//table[@class="rectable"]'+ pos +'/tbody/tr/td[2]/table/tbody/tr/td/p/table[1]/tbody/tr/td/span[contains(@class,"so")]'; - break; - case 'pdfLink' : xPath = '//table[@class="rectable"]' + pos + '//span[@id="pdf"]/a/@onclick'; - break; - case 'fullTextLink' : xPath = '//div[@id="results"]/table' + pos + '//span[@id="fullText"]/a/@onclick'; - break; - case 'recid' : xPath = '//table[@class="rectable"]' + pos + '//input[@name="recid"]'; - break; - case 'pb' : xPath = '//table[@class="rectable"]' + pos + '//span[contains(@class,"pb")]'; - break; - case 'pa' : xPath = '//table[@class="rectable"]' + pos + '//span[contains(@class,"pa")]'; - break; - case 'ar' : xPath = '//table[@class="rectable"]' + pos + '//span[contains(@class,"ar")]'; - break; - - } - - } - else if (dispType == "details") { - - switch(field){ - - case 'cxpath' : xPath = '//div[@id="results"]/table/tbody/tr[2]/td/table/@class'; - break; - case 'ti': xPath = "//span[contains(@id,'ti')]"; - break; - case 'ar': xPath = '//table[@id="recData"]//td[@class="bioartmid"]//span[contains(@id,"namdir")]'; - break; - case 'siz' : xPath = "//span[contains(@id,'siz')]"; - break; - case 'mt' : xPath = "//span[contains(@id,'mt')]"; - break; - case 'abs' : - case 'su' : - case 'own' : xPath='//div[@id="results"]//table[@id="recData"]/tbody/tr/td[2]//span[contains(@id,"' + field + '")]'; - break; - - } - } - else { - - switch(field) { - - case 'cxpath' : xPath = '//div[@id="results"]/table/tbody/tr[2]/td/table/@class'; - break; - case 'ti': xPath = '//div[@id="results"]//td[contains(@id, "ti")]'; - break; - case 'au' : - case 'jn': - case 'su' : - case 'so' : - case 'issn' : - case 'la' : - case 'abs' : - case 'doi' : - case 'inst' : - case 'pb' : - case 'pa' : - case 'isbn' : - case 'der' : - case 'ud' : - case 'TSN' : - case 'orb' : - case 'siz' : - case 'mt' : - case 'own' : - case 'nt' : xPath = '//div[@id="results"]/table[@class="rectable"]' + pos + '//table[@id="recData"]//td[contains(@id, "' + field + '")]'; - break; - case 'pdfLink' : xPath = '//div[@id="results"]/table' + pos + '//table[@id="recData"]//span[@id="pdf"]/a/@onclick'; - break; - case 'fullTextLink' : xPath = '//div[@id="results"]/table' + pos + '//span[@id="fullText"]/a/@onclick'; - break; - case 'recid' : xPath = '//div[@id="results"]/table' + pos + '//input[@name="recid"]'; - break; - case 'ar': xPath = '//div[@id="results"]/table[@class="rectable"]' + pos + '//table[@id="recData"]//td[contains(@id, "ar")]/span[contains(@id,"namdir")]'; - break; - } - - } - return xPath; -} - -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(resultType); - newItem.url = doc.location.href; - - var titleObj = doc.evaluate(getXPath(dispType,'ti'), doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - newItem.title = titleObj.textContent; - - switch(resultType) { - case 'journalArticle' : associateBIBLData(doc, newItem, 1); - break; - case 'book' : associateBookData(doc, newItem, 1); - break; - case 'artwork' : associateArtData(doc, newItem, 1); - break; - - } - - newItem.complete(); - - -} diff --git a/translators/Winnipeg Free Press.js b/translators/Winnipeg Free Press.js @@ -1,98 +0,0 @@ -{ - "translatorID":"1d82cbdf-703d-4f96-9ae2-246af21bb96e", - "translatorType":4, - "label":"Winnipeg Free Press", - "creator":"Adam Crymble", - "target":"http://www.winnipegfreepress", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-08-06 17:00:00" -} - -function detectWeb(doc, url) { - if (doc.location.href.match("articles") || doc.location.href.match("story")) { - return "newspaperArticle"; - } -} - -//Winnipeg Free Press Translator. Code by Adam Crymble -//works for single entries only. - -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("newspaperArticle"); - - newItem.title = doc.evaluate('//h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - - if (doc.evaluate('//div[@id="middlecol"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.abstractNote = doc.evaluate('//div[@id="middlecol"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, ''); - } - - if (doc.evaluate('//div[@id="bylines"]/p[@class="byline"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - var byline = doc.evaluate('//p[@class="byline"]', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var k = 0; - var byLineArray = new Array(); - var nextByLine; - - while (nextByLine = byline.iterateNext()) { - byLineArray.push(nextByLine.textContent.replace(/^\s*|\s*$/g, '')); - k++; - } - - if (k>1) { - for (var i = 0; i < byLineArray.length; i++) { - if (byLineArray[i].match("Updated:")) { - newItem.date = byLineArray[i].substr(9).replace(/^\s*|\s*$/g, ''); - } else if (byLineArray[i].match("bylineParse") && byLineArray[i].substr(13).match(/\w/)) { - - var author = (byLineArray[i].substr(13)); - var authorLength = author.length/2; - var author = author.substr(0 + authorLength); - var m = 0; - - if (author.match(" - ")) { - var author = author.split(' - '); - } else if (author.match(", ")) { - var author = author.split(', '); - } else if (author.match(/ By /)) { - var author = author.split(/By/); - author[0] = author[1]; - } else if (author.match(/By:/)) { - var author = author.split(/By:/); - author[0] = author[1]; - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - m = 1; - } - - if (m == 0) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[0], "author")); - } - } - } - } - } - - newItem.publicationTitle = "Winnipeg Free Press"; - newItem.url = doc.location.href; - newItem.complete(); -} - -function doWeb (doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - }: null; - - var uris= new Array(); - uris.push(url); - Zotero.Utilities.processDocuments(uris, scrape, function() {Zotero.done();}); - Zotero.wait(); -} -\ No newline at end of file diff --git a/translators/World History Connected.js b/translators/World History Connected.js @@ -1,125 +0,0 @@ -{ - "translatorID":"0507797c-9bc4-4374-92ca-9e3763b6922b", - "translatorType":4, - "label":"World History Connected", - "creator":"Frederick Gibbs", - "target":"worldhistoryconnected\\.press|historycooperative.*/whc/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-05-06 08:15:00" -} - -function associateMeta(newItem, metaTags, field, zoteroField) { - var field = metaTags.namedItem(field); - if(field) { - newItem[zoteroField] = field.getAttribute("content"); - } -} - -function scrape(doc) { - - 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"); - newItem.url = doc.location.href; - - var titlePath; - var bookTitle; - var month, year; - var metaTags = doc.getElementsByTagName("meta"); - - associateMeta(newItem, metaTags, "Journal", "publicationTitle"); - associateMeta(newItem, metaTags, "Volume", "volume"); - associateMeta(newItem, metaTags, "Issue", "issue"); - - // in the case of book reviews, the title field is blank - //but quotes are not escaped properly, so if an article title begins with quotes, then the title tag looks blank even though it is not. - //(though semantically it is) - //they use the meta tag 'FileType' to indicate Aritlce or Book Review. silly, but we can use it. - - if (metaTags.namedItem('FileType').getAttribute("content") == 'Book Review') { - //for a book review, title of reviewed book is - titlePath = '/html/body/table[4]/tbody/tr[3]/td[1]/i'; - newItem.title = "Review of " + doc.evaluate(titlePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - } else { - //it would be nice to grab the title from the meta tags, but quotations are properly escaped and the tags are therefore malformed. - titlePath = '/html/body/table[4]/tbody/tr[2]/td[1]/h2/font/b'; - newItem.title = Zotero.Utilities.superCleanString(doc.evaluate(titlePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent); - } - - var author = metaTags.namedItem("Author"); - if(author) { - var authors = author.getAttribute("content").split(" and "); - for(j in authors) { - authors[j] = authors[j].replace("Reviewed by ", ""); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j], "author")); - } - } - - var month = metaTags.namedItem("PublicationMonth"); - var year = metaTags.namedItem("PublicationYear"); - if(month && year) { - newItem.date = month.getAttribute("content")+" "+year.getAttribute("content"); - } - - newItem.attachments.push({document:doc, title:"World History Connected Snapshot"}); - - newItem.complete(); -} - -function doWeb(doc, url) { - - var searchLinks; - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - if(doc.title.indexOf("Contents") != -1 || doc.title.indexOf("Search results") != -1) { - - if(doc.title.indexOf("Contents") != -1) { - searchLinks = doc.evaluate('//tbody/tr[2]/td[1]/table/tbody/tr/td/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - else if ( doc.title.indexOf("Search results") != -1) { - searchLinks = doc.evaluate('/html/body/dl/dt/strong/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - var link; - var title; - var items = new Object(); - - while (elmt = searchLinks.iterateNext()) { - Zotero.debug(elmt.href); - title = Zotero.Utilities.superCleanString(elmt.textContent); - link = elmt.href; - if (title && link){ - items[link] = title; - } - } - - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var uris = new Array(); - for(var i in items) { - uris.push(i); - } - - Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) }, - function() { Zotero.done(); }, null); - - Zotero.wait(); - } else { - scrape(doc); - } -} -\ No newline at end of file diff --git a/translators/YouTube.js b/translators/YouTube.js @@ -1,168 +0,0 @@ -{ - "translatorID": "d3b1d34c-f8a1-43bb-9dd6-27aa6403b217", - "label": "YouTube", - "creator": "Sean Takats and Michael Berkowitz and Matt Burton", - "target": "https?://[^/]*youtube\\.com\\/", - "minVersion": "1.0.0rc4", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-20 03:10:43" -} - -function detectWeb(doc, url){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - /*var xpath = '//input[@type="hidden" and @name="video_id"]'; - if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - return "videoRecording"; - }*/ - if (url.match(/\/watch\?(?:.*)v=([0-9a-zA-Z]+)/)) { - return "videoRecording"; - } - //Search results - if (doc.evaluate('//div[@class="result-item-main-content"]//a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } - //playlists - if (doc.evaluate('//div[starts-with(@class, "title")]/a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } - // still used? - if (doc.evaluate('//div[@class="vltitle"]/div[@class="vlshortTitle"]/a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - return "multiple"; - } - -} - -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 = doc.location.host; - var video_ids = new Array(); - var elmt, video_id; - var videoRe = /\/watch\?(?:.*)v=([0-9a-zA-Z_-]+)/; - if(video_id = videoRe.exec(url)) { - //single video - video_ids.push(video_id[1]); - } else { - // multiple videos - var items = new Object(); -// search results and community/user pages - if (elmt = doc.evaluate('//div[@class="result-item-main-content"]//a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - elmts = doc.evaluate('//div[@class="result-item-main-content"]//a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - // playlists - else if (doc.evaluate('//div[starts-with(@class, "title")]/a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - elmts = doc.evaluate('//div[starts-with(@class, "title")]/a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - // still used? - else if (doc.evaluate('//div[@class="vltitle"]/div[@class="vlshortTitle"]/a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){ - elmts = doc.evaluate('//div[@class="vltitle"]/div[@class="vlshortTitle"]/a[contains(@href, "/watch?v=")]', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - while (elmt = elmts.iterateNext()){ - var title = elmt.textContent; - title = Zotero.Utilities.trimInternal(title); - var link = elmt.href; - Zotero.debug(link); - var m = videoRe(link); - var video_id = m[1]; - items[video_id] = title; - } - items = Zotero.selectItems(items); - if(!items) return true; - for(var i in items) { - video_ids.push(i); - } - } - getData(video_ids, host); -} - -function getData(ids, host){ - var uris = new Array(); - var url = "http://gdata.youtube.com/feeds/videos/"; - for each(var id in ids){ - uris.push(url+id); - } - Zotero.Utilities.HTTP.doGet(uris, function(text) { - // Strip XML header - text = text.replace(/<\?xml[^>]*\?>/, ""); - - default xml namespace = "http://www.w3.org/2005/Atom"; with({}); - var mediaNS = new Namespace("http://search.yahoo.com/mrss/"); - var ytNS = new Namespace("http://gdata.youtube.com/schemas/2007"); - - // pad xml - text = "<zotero>"+text+"</zotero>"; - var xml = new XML(text); - var newItem = new Zotero.Item("videoRecording"); - var title = ""; - var title = xml..mediaNS::title[0].text().toString(); - if (xml..mediaNS::title.length()){ - var title = Zotero.Utilities.trimInternal(xml..mediaNS::title[0].text().toString()); - if (title == ""){ - title = " "; - } - newItem.title = title; - } - if (xml..mediaNS::keywords.length()){ - var keywords = xml..mediaNS::keywords[0].text().toString(); - keywords = keywords.split(","); - for each(var tag in keywords){ - newItem.tags.push(Zotero.Utilities.trimInternal(tag)); - } - } - if (xml..published.length()){ - var date = xml..published[0].text().toString(); - newItem.date = date.substr(0, 10); - } - if (xml..author.name.length()){ - var author = xml..author.name[0].text().toString(); - var creator = Zotero.Utilities.cleanAuthor(author, "contributor", true); - if (!creator.firstName) { - creator.fieldMode = 1; - } - newItem.creators.push(creator); - } - if (xml..mediaNS::player.length()){ - var url = xml..mediaNS::player[0].@url.toString(); - newItem.url = url; - } - if (xml..ytNS::duration.length()){ - var runningTime = xml..ytNS::duration[0].@seconds.toString(); - newItem.runningTime = runningTime + " seconds"; - } - if (xml..mediaNS::description.length()){ - newItem.abstractNote = xml..mediaNS::description[0].text().toString(); - } - /* -//temporary fix for downloads using techcrunch - var techcrunchurl = "http://www.techcrunch.com/ytdownload3.php?url="+encodeURIComponent(newItem.url)+"&submit=Get+Video"; - Zotero.debug(techcrunchurl); - Zotero.Utilities.HTTP.doGet(techcrunchurl, function(text) { - var flv = text.match(/HREF='([^']+)'/); - if (flv[1]){ - flv = flv[1]; - // title parameter needs to be encoded - var title = flv.match(/&title=([^&]+)/); - if (title[1]){ - title = encodeURIComponent(title[1]); - flv = flv.replace(/&title=([^&]+)/, title); - } - newItem.attachments.push({url:flv, title:"YouTube Video Recording", mimeType:"video/x-flv"}); - } - newItem.complete(); - }, function() {Zotero.done();}); - */ - newItem.complete(); - Zotero.done(); - }); - Zotero.wait(); -} diff --git a/translators/Zhurnalnyi zal.js b/translators/Zhurnalnyi zal.js @@ -1,80 +0,0 @@ -{ - "translatorID" : "0db1c2d0-eaae-4f3d-94ef-d4b3aa61de16", - "label" : "Журнальный зал", - "creator" : "Avram Lyon", - "target" : "^http://magazines\\.russ\\.ru/[a-zA-Z -_]+/[0-9]+/[0-9]+/", - "minVersion" : "2.0", - "maxVersion" : "", - "priority" : 100, - "inRepository" : "true", - "translatorType" : 4, - "lastUpdated" : "2010-08-23 00:45:42" -} - -/* - Журнальный зал Translator - Copyright (C) 2010 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/>. - - Translator for Russian journal aggregator. Scrapes basic bibliographic information - for all of the journals, many of them literary or academic, hosted on the site. - - Due to small variations in journal formatting, some will not be translated correctly. - - Examples (Chicago style): - 1. Сергей Бирюков, “Избранное из неизбранного,” Дети Ра, no. 6 (2010), http://magazines.russ.ru/ra/2010/6/bi3.html. - 2. Вера Проскурина, “Ода Г.Р. Державина «На Счастие»: политика и поэтика,” НЛО, no. 97 (2009), http://magazines.russ.ru/nlo/2009/97/pr8.html. - */ - -function detectWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var results = doc.evaluate('//div[@class="opub"]', doc, ns, XPathResult.ANY_TYPE, null); - if (results.iterateNext()) { - return "journalArticle"; - } -} - -function doWeb(doc, url) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var publication = doc.evaluate('//div[@class="opub"]/a', doc, ns, XPathResult.ANY_TYPE, null); - publication = publication.iterateNext().textContent; - var pieces = publication.match(/«(.*)»[\n\t ]*([0-9]+), №([0-9]+)/); - - var title = doc.evaluate('//div[@class="title1"]', doc, ns, XPathResult.ANY_TYPE, null); - title = title.iterateNext().textContent; - - var author = doc.evaluate('//*[@class="avt1"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - author = author.textContent; - - item = new Zotero.Item("journalArticle"); - item.publicationTitle = pieces[1]; - item.title = title; - item.date = pieces[2]; - item.issue = pieces[3]; - item.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - item.url = url; - item.attachments.push({url:url, title: (item.publicationTitle + " Snapshot"), mimeType:"text/html"}); - - item.complete(); - -} diff --git a/translators/Zotero RDF.js b/translators/Zotero RDF.js @@ -1,550 +0,0 @@ -{ - "translatorID":"14763d24-8ba0-45df-8f52-b8d1108e7ac9", - "translatorType":2, - "label":"Zotero RDF", - "creator":"Simon Kornblith", - "target":"rdf", - "minVersion":"1.0.0b4.r1", - "maxVersion":"", - "priority":25, - "configOptions":{"getCollections":"true", "dataMode":"rdf/xml"}, - "displayOptions":{"exportNotes":true, "exportFileData":false}, - "inRepository":true, - "lastUpdated":"2011-08-16 15:07:21" -} - -var item; -var rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; - -var n = { - bib:"http://purl.org/net/biblio#", - dc:"http://purl.org/dc/elements/1.1/", - dcterms:"http://purl.org/dc/terms/", - prism:"http://prismstandard.org/namespaces/1.2/basic/", - foaf:"http://xmlns.com/foaf/0.1/", - vcard:"http://nwalsh.com/rdf/vCard#", - vcard2:"http://www.w3.org/2006/vcard/ns#", // currently used only for NSF, but is probably - // very similar to the nwalsh vcard ontology in a - // different namespace - link:"http://purl.org/rss/1.0/modules/link/", - z:"http://www.zotero.org/namespaces/export#" -}; - -function generateSeeAlso(resource, seeAlso) { - for(var i in seeAlso) { - if(itemResources[seeAlso[i]]) { - Zotero.RDF.addStatement(resource, n.dc+"relation", itemResources[seeAlso[i]], false); - } - } -} - -function generateTags(resource, tags) { - Zotero.debug("processing tags"); - for each(var tag in tags) { - if(tag.type == 1) { - var tagResource = Zotero.RDF.newResource(); - // set tag type and value - Zotero.RDF.addStatement(tagResource, rdf+"type", n.z+"AutomaticTag", false); - Zotero.RDF.addStatement(tagResource, rdf+"value", tag.tag, true); - // add relationship to resource - Zotero.RDF.addStatement(resource, n.dc+"subject", tagResource, false); - } else { - Zotero.RDF.addStatement(resource, n.dc+"subject", tag.tag, true); - } - } -} - -function generateCollection(collection) { - var collectionResource = "#collection_"+collection.id; - Zotero.RDF.addStatement(collectionResource, rdf+"type", n.z+"Collection", false); - Zotero.RDF.addStatement(collectionResource, n.dc+"title", collection.name, true); - - var children = collection.children ? collection.children : collection.descendents; - if(!children) return; - for each(var child in children) { - // add child list items - if(child.type == "collection") { - Zotero.RDF.addStatement(collectionResource, n.dcterms+"hasPart", "#collection_"+child.id, false); - // do recursive processing of collections - generateCollection(child); - } else if(itemResources[child.id]) { - Zotero.RDF.addStatement(collectionResource, n.dcterms+"hasPart", itemResources[child.id], false); - } - } -} - -/** - * Get display title - * Analogous to getDisplayTitle in item.js, but returns null if no display title distinct from - * title property - */ -function getDisplayTitle(item) { - if(!item.title && (item.itemType == "interview" || item.itemType == "letter")) { - var participants = [] - for each(var creator in item.creators) { - if (item.itemType == "letter" && creator.creatorType == "recipient" || - item.itemType == "interview" && creator.creatorType == "interviewer") { - participants.push(creator); - } - } - - var displayTitle = "["+(item.itemType == "letter" ? "Letter" : "Interview"); - if(participants.length) { - //var names = [creator.firstName ? creator.firstName+" "+creator.lastName : creator.lastName - var names = []; - for each(var creator in participants) { - names.push(creator.lastName); - } - - displayTitle += (item.itemType == "letter" ? " to " : " of ")+names[0]; - - if(participants.length == 2) { - displayTitle += " and "+names[1]; - } else if(participants.length == 3) { - displayTitle += ", "+names[1]+", and "+names[2]; - } else if(participants.length > 3) { - displayTitle += " et al."; - } - } - - return displayTitle+"]"; - } if (item.itemType == "case" && item.title && item.reporter) { // 'case' itemTypeID - return item.title+' (' + item.reporter + ')'; - } - return null; -} - -function generateItem(item, zoteroType, resource) { - var container = null; - var containerElement = null; - - /** CORE FIELDS **/ - - // type - var type = null; - if(zoteroType == "book") { - type = n.bib+"Book"; - } else if (zoteroType == "bookSection") { - type = n.bib+"BookSection"; - container = n.bib+"Book"; - } else if(zoteroType == "journalArticle") { - type = n.bib+"Article"; - container = n.bib+"Journal"; - } else if(zoteroType == "magazineArticle") { - type = n.bib+"Article"; - container = n.bib+"Periodical"; - } else if(zoteroType == "newspaperArticle") { - type = n.bib+"Article"; - container = n.bib+"Newspaper"; - } else if(zoteroType == "thesis") { - type = n.bib+"Thesis"; - } else if(zoteroType == "letter") { - type = n.bib+"Letter"; - } else if(zoteroType == "manuscript") { - type = n.bib+"Manuscript"; - } else if(zoteroType == "interview") { - type = n.bib+"Interview"; - } else if(zoteroType == "film") { - type = n.bib+"MotionPicture"; - } else if(zoteroType == "artwork") { - type = n.bib+"Illustration"; - } else if(zoteroType == "webpage") { - type = n.bib+"Document"; - container = n.z+"Website"; - } else if(zoteroType == "note") { - type = n.bib+"Memo"; - if(!Zotero.getOption("exportNotes")) { - return; - } - } else if(zoteroType == "attachment") { - type = n.z+"Attachment"; - } else if(zoteroType == "report") { - type = n.bib+"Report"; - } else if(zoteroType == "bill") { - type = n.bib+"Legislation"; - } else if(zoteroType == "case") { - type = n.bib+"Document"; // ?? - container = n.bib+"CourtReporter"; - } else if(zoteroType == "hearing") { - type = n.bib+"Report"; - } else if(zoteroType == "patent") { - type = n.bib+"Patent"; - } else if(zoteroType == "statute") { - type = n.bib+"Legislation"; - } else if(zoteroType == "email") { - type = n.bib+"Letter"; - } else if(zoteroType == "map") { - type = n.bib+"Image"; - } else if(zoteroType == "blogPost") { - type = n.bib+"Document"; - container = n.z+"Blog"; - } else if(zoteroType == "instantMessage") { - type = n.bib+"Letter"; - } else if(zoteroType == "forumPost") { - type = n.bib+"Document"; - container = n.z+"Forum"; - } else if(zoteroType == "audioRecording") { - type = n.bib+"Recording"; - } else if(zoteroType == "presentation") { - type = n.bib+"ConferenceProceedings"; - } else if(zoteroType == "videoRecording") { - type = n.bib+"Recording"; - } else if(zoteroType == "tvBroadcast") { - type = n.bib+"Recording"; - } else if(zoteroType == "radioBroadcast") { - type = n.bib+"Recording"; - } else if(zoteroType == "podcast") { - type = n.bib+"Recording"; - } else if(zoteroType == "computerProgram") { - type = n.bib+"Data"; - } - - if(type) { - Zotero.RDF.addStatement(resource, rdf+"type", type, false); - } - Zotero.RDF.addStatement(resource, n.z+"itemType", zoteroType, true); - - // generate section - if(item.section) { - var section = Zotero.RDF.newResource(); - // set section type - Zotero.RDF.addStatement(section, rdf+"type", n.bib+"Part", false); - // set section title - Zotero.RDF.addStatement(section, n.dc+"title", item.section, true); - // add relationship to resource - Zotero.RDF.addStatement(resource, n.dcterms+"isPartOf", section, false); - } - - // generate container - if(container) { - var testISSN = "urn:issn:"+encodeURI(item.ISSN); - if(item.ISSN && !Zotero.RDF.getArcsIn(testISSN)) { - // use ISSN as container URI if no other item is - containerElement = testISSN; - } else { - containerElement = Zotero.RDF.newResource(); - } - // attach container to section (if exists) or resource - Zotero.RDF.addStatement((section ? section : resource), n.dcterms+"isPartOf", containerElement, false); - // add container type - Zotero.RDF.addStatement(containerElement, rdf+"type", container, false); - } - - // generate series - if(item.series || item.seriesTitle || item.seriesText || item.seriesNumber) { - var series = Zotero.RDF.newResource(); - // set series type - Zotero.RDF.addStatement(series, rdf+"type", n.bib+"Series", false); - // add relationship to resource - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.dcterms+"isPartOf", series, false); - } - - // generate publisher - // BEGIN NSF - if(zoteroType == "nsfReviewer") { - var organization = Zotero.RDF.newResource(); - Zotero.RDF.addStatement(organization, rdf+"type", n.vcard2+"Organization", false); - Zotero.RDF.addStatement(resource, n.vcard2+"org", organization, false); - } else { - // END NSF - if(item.publisher || item.distributor || item.label || item.company || item.institution || item.place) { - var organization = Zotero.RDF.newResource(); - // set organization type - Zotero.RDF.addStatement(organization, rdf+"type", n.foaf+"Organization", false); - // add relationship to resource - Zotero.RDF.addStatement(resource, n.dc+"publisher", organization, false); - } - } - - var typeProperties = ["reportType", "videoRecordingType", "letterType", - "manuscriptType", "mapType", "thesisType", "websiteType", - "audioRecordingType", "presentationType", "postType", - "audioFileType"]; - var ignoreProperties = ["itemID", "itemType", "firstCreator", "dateAdded", - "dateModified", "section", "sourceItemID"]; - - // creators - if(item.creators) { // authors/editors/contributors - var creatorContainers = new Object(); - - // not yet in biblio - var biblioCreatorTypes = ["author", "editor", "contributor"]; - - for(var j in item.creators) { - var creator = Zotero.RDF.newResource(); - Zotero.RDF.addStatement(creator, rdf+"type", n.foaf+"Person", false); - // gee. an entire vocabulary for describing people, and these aren't even - // standardized in it. oh well. using them anyway. - Zotero.RDF.addStatement(creator, n.foaf+"surname", item.creators[j].lastName, true); - Zotero.RDF.addStatement(creator, n.foaf+"givenname", item.creators[j].firstName, true); - - if(biblioCreatorTypes.indexOf(item.creators[j].creatorType) != -1) { - var cTag = n.bib+item.creators[j].creatorType+"s"; - } else { - var cTag = n.z+item.creators[j].creatorType+"s"; - } - - if(!creatorContainers[cTag]) { - var creatorResource = Zotero.RDF.newResource(); - // create new seq for author type - creatorContainers[cTag] = Zotero.RDF.newContainer("seq", creatorResource); - // attach container to resource - Zotero.RDF.addStatement(resource, cTag, creatorResource, false); - } - Zotero.RDF.addContainerElement(creatorContainers[cTag], creator, false); - } - } - - // notes - if(item.notes && Zotero.getOption("exportNotes")) { - for(var j in item.notes) { - var noteResource = itemResources[item.notes[j].itemID]; - - // add note tag - Zotero.RDF.addStatement(noteResource, rdf+"type", n.bib+"Memo", false); - // add note item.notes - Zotero.RDF.addStatement(noteResource, rdf+"value", item.notes[j].note, true); - // add relationship between resource and note - Zotero.RDF.addStatement(resource, n.dcterms+"isReferencedBy", noteResource, false); - - // Add see also info to RDF - generateSeeAlso(noteResource, item.notes[j].seeAlso); - generateTags(noteResource, item.notes[j].tags); - } - } - - // child attachments - if(item.attachments) { - for each(var attachment in item.attachments) { - var attachmentResource = itemResources[attachment.itemID]; - Zotero.RDF.addStatement(resource, n.link+"link", attachmentResource, false); - generateItem(attachment, "attachment", attachmentResource); - } - } - - // relative file path for attachment items - if(item.defaultPath) { // For Zotero 3.0 - item.saveFile(item.defaultPath, true); - Zotero.RDF.addStatement(resource, rdf+"resource", item.defaultPath, false); - } else if(item.path) { // For Zotero 2.1 - Zotero.RDF.addStatement(resource, rdf+"resource", item.path, false); - } - - // seeAlso and tags - if(item.seeAlso) generateSeeAlso(resource, item.seeAlso); - if(item.tags) generateTags(resource, item.tags); - - for(var property in item.uniqueFields) { - var value = item[property]; - if(!value) continue; - - if(property == "title") { // title - // BEGIN NSF - if(zoteroType == "nsfReviewer") { - Zotero.RDF.addStatement(resource, n.vcard2+"fn", value, true); - } else { - // END NSF - Zotero.RDF.addStatement(resource, n.dc+"title", value, true); - } - } else if(property == "source") { // authors/editors/contributors - Zotero.RDF.addStatement(resource, n.dc+"source", value, true); - } else if(property == "url") { // url - // BEGIN NSF - if(item.homepage) { - Zotero.RDF.addStatement(resource, n.vcard2+"url", value, false); - } else { - // END NSF - // add url as identifier - var term = Zotero.RDF.newResource(); - // set term type - Zotero.RDF.addStatement(term, rdf+"type", n.dcterms+"URI", false); - // set url value - Zotero.RDF.addStatement(term, rdf+"value", value, true); - // add relationship to resource - Zotero.RDF.addStatement(resource, n.dc+"identifier", term, false); - } - } else if(property == "accessionNumber") { // accessionNumber as generic ID - Zotero.RDF.addStatement(resource, n.dc+"identifier", value, true); - } else if(property == "rights") { // rights - Zotero.RDF.addStatement(resource, n.dc+"rights", value, true); - } else if(property == "edition" || // edition - property == "version") { // version - Zotero.RDF.addStatement(resource, n.prism+"edition", value, true); - } else if(property == "date") { // date - if(item.dateSent) { - Zotero.RDF.addStatement(resource, n.dcterms+"dateSubmitted", value, true); - } else { - Zotero.RDF.addStatement(resource, n.dc+"date", value, true); - } - } else if(property == "accessDate") { // accessDate - Zotero.RDF.addStatement(resource, n.dcterms+"dateSubmitted", value, true); - } else if(property == "issueDate") { // issueDate - Zotero.RDF.addStatement(resource, n.dcterms+"issued", value, true); - } else if(property == "pages") { // pages - // not yet part of biblio, but should be soon - Zotero.RDF.addStatement(resource, n.bib+"pages", value, true); - } else if(property == "extra") { // extra - Zotero.RDF.addStatement(resource, n.dc+"description", value, true); - } else if(property == "mimeType") { // mimeType - Zotero.RDF.addStatement(resource, n.link+"type", value, true); - } else if(property == "charset") { // charset - Zotero.RDF.addStatement(resource, n.link+"charset", value, true); - // THE FOLLOWING ARE ALL PART OF THE CONTAINER - } else if(property == "ISSN") { // ISSN - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"identifier", "ISSN "+value, true); - } else if(property == "ISBN") { // ISBN - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"identifier", "ISBN "+value, true); - } else if(property == "DOI") { // DOI - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"identifier", "DOI "+value, true); - } else if(property == "publicationTitle" || // publicationTitle - property == "reporter") { // reporter - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.dc+"title", value, true); - } else if(property == "journalAbbreviation") { // journalAbbreviation - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.dcterms+"alternative", value, true); - } else if(property == "volume") { // volume - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.prism+"volume", value, true); - } else if(property == "issue" || // issue - property == "number" || // number - property == "patentNumber") { // patentNumber - Zotero.RDF.addStatement((containerElement ? containerElement : resource), n.prism+"number", value, true); - } else if(property == "callNumber") { - var term = Zotero.RDF.newResource(); - // set term type - Zotero.RDF.addStatement(term, rdf+"type", n.dcterms+"LCC", false); - // set callNumber value - Zotero.RDF.addStatement(term, rdf+"value", value, true); - // add relationship to resource - Zotero.RDF.addStatement(resource, n.dc+"subject", term, false); - } else if(property == "abstractNote") { - Zotero.RDF.addStatement(resource, n.dcterms+"abstract", value, true); - // THE FOLLOWING ARE ALL PART OF THE SERIES - } else if(property == "series") { // series - Zotero.RDF.addStatement(series, n.dc+"title", value, true); - } else if(property == "seriesTitle") { // seriesTitle - Zotero.RDF.addStatement(series, n.dcterms+"alternative", value, true); - } else if(property == "seriesText") { // seriesText - Zotero.RDF.addStatement(series, n.dc+"description", value, true); - } else if(property == "seriesNumber") { // seriesNumber - Zotero.RDF.addStatement(series, n.dc+"identifier", value, true); - // THE FOLLOWING ARE ALL PART OF THE PUBLISHER - } else if(property == "publisher" || // publisher - property == "distributor" || // distributor (film) - property == "label" || // label (audioRecording) - property == "company" || // company (computerProgram) - property == "institution") { // institution (report) - // BEGIN NSF - if(zoteroType == "nsfReviewer") { - Zotero.RDF.addStatement(organization, n.vcard2+"organization-name", value, true); - } else { - // END NSF - Zotero.RDF.addStatement(organization, n.foaf+"name", value, true); - } - } else if(property == "place") { // place - var address = Zotero.RDF.newResource(); - // set address type - Zotero.RDF.addStatement(address, rdf+"type", n.vcard+"Address", false); - // set address locality - Zotero.RDF.addStatement(address, n.vcard+"locality", value, true); - // add relationship to organization - Zotero.RDF.addStatement(organization, n.vcard+"adr", address, false); - } else if(property == "archiveLocation") { // archiveLocation - Zotero.RDF.addStatement(resource, n.dc+"coverage", value, true); - } else if(property == "interviewMedium" || - property == "artworkMedium") { // medium - Zotero.RDF.addStatement(resource, n.dcterms+"medium", value, true); - } else if(property == "conferenceName") { - var conference = Zotero.RDF.newResource(); - // set conference type - Zotero.RDF.addStatement(conference, rdf+"type", n.bib+"Conference", false); - // set conference title - Zotero.RDF.addStatement(conference, n.dc+"title", value, true); - // add relationship to conference - Zotero.RDF.addStatement(resource, n.bib+"presentedAt", conference, false); - } else if(typeProperties.indexOf(property) != -1) { - Zotero.RDF.addStatement(resource, n.dc+"type", value, true); - // THE FOLLOWING RELATE TO NOTES - } else if(property == "note") { - if(Zotero.getOption("exportNotes")) { - if(item.itemType == "attachment") { - Zotero.RDF.addStatement(resource, n.dc+"description", value, true); - } else if(item.itemType == "note") { - Zotero.RDF.addStatement(resource, rdf+"value", value, true); - } - } - // BEGIN NSF - } else if(property == "address") { - var address = Zotero.RDF.newResource(); - Zotero.RDF.addStatement(address, rdf+"type", n.vcard2+"Address", false); - Zotero.RDF.addStatement(address, n.vcard2+"label", value, true); - Zotero.RDF.addStatement(resource, n.vcard2+"adr", address, false); - } else if(property == "telephone") { - Zotero.RDF.addStatement(resource, n.vcard2+"tel", value, true); - } else if(property == "email") { - Zotero.RDF.addStatement(resource, n.vcard2+"email", value, true); - } else if(property == "accepted") { - Zotero.RDF.addStatement(resource, n.dcterms+"dateAccepted", value, true); - // END NSF - // THIS CATCHES ALL REMAINING PROPERTIES - } else if(ignoreProperties.indexOf(property) == -1) { - Zotero.debug("Zotero RDF: using Zotero namespace for property "+property); - Zotero.RDF.addStatement(resource, n.z+property, value, true); - } - } - - var displayTitle = getDisplayTitle(item); - if(displayTitle) Zotero.RDF.addStatement(resource, n.z+"displayTitle", displayTitle, true); -} - -function doExport() { - // add namespaces - for(var i in n) { - Zotero.RDF.addNamespace(i, n[i]); - } - - // leave as global - itemResources = new Array(); - - // keep track of resources already assigned (in case two book items have the - // same ISBN, or something like that) - var usedResources = new Array(); - - var items = new Array(); - - // first, map each ID to a resource - while(item = Zotero.nextItem()) { - items.push(item); - Zotero.debug(item); - - var testISBN = "urn:isbn:"+encodeURI(item.ISBN); - if(item.ISBN && !usedResources[testISBN]) { - itemResources[item.itemID] = testISBN; - usedResources[itemResources[item.itemID]] = true; - } else if(item.itemType != "attachment" && item.url && !usedResources[item.url]) { - itemResources[item.itemID] = item.url; - usedResources[itemResources[item.itemID]] = true; - } else { - // just specify a node ID - itemResources[item.itemID] = "#item_"+item.itemID; - } - - for(var j in item.notes) { - itemResources[item.notes[j].itemID] = "#item_"+item.notes[j].itemID; - } - - for each(var attachment in item.attachments) { - // just specify a node ID - itemResources[attachment.itemID] = "#item_"+attachment.itemID; - } - } - - for each(item in items) { - // these items are global - generateItem(item, item.itemType, itemResources[item.itemID]); - } - - /** RDF COLLECTION STRUCTURE **/ - var collection; - while(collection = Zotero.nextCollection()) { - generateCollection(collection); - } -} -\ No newline at end of file diff --git a/translators/arXiv.org.js b/translators/arXiv.org.js @@ -1,252 +0,0 @@ -{ - "translatorID": "ecddda2e-4fc6-4aea-9f17-ef3b56d7377a", - "label": "arXiv.org", - "creator": "Sean Takats and Michael Berkowitz", - "target": "http://(?:([^\\.]+\\.))?(?:(arxiv\\.org|xxx.lanl.gov)/(?:find/\\w|list/\\w|abs/)|eprintweb.org/S/(?:search|archive|article)(?!.*refs$)(?!.*cited$))", - "minVersion": "2.1.9", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "browserSupport": "gcs", - "lastUpdated": "2011-07-27 13:39:47" -} - -function detectWeb(doc, url) { - var searchRe = new RegExp('^http://(?:([^\.]+\.))?(?:(arxiv\.org|xxx\.lanl\.gov)/(?:find|list)|eprintweb.org/S/(?:archive|search$))'); - - if(searchRe.test(url)) { - return "multiple"; - } else { - return "journalArticle"; - } -} - -function getPDF(articleID) { - return {url:"http://www.arxiv.org/pdf/" + articleID + ".pdf", - mimeType:"application/pdf", title:articleID + " PDF"}; -} - -function doWeb(doc, url) { - // eprintweb appears to be defunct as of mid-2011. leaving relevant code here for now - var eprintMultRe = new RegExp('^http://(?:www\.)?eprintweb.org/S/(?:search|archive)'); - var eprintMultM = eprintMultRe.exec(url); - - var eprintSingRe = new RegExp('^http://(?:www\.)?eprintweb.org/S/(?:article|search/[0-9]+/A[0-9]+)'); - var eprintSingM = eprintSingRe.exec(url); - - if (eprintMultM) { - var elmtsXPath = '//table/tbody/tr/td[@class="txt"]/a[text()="Abstract"]/../b'; - var titlesXPath = '//table/tbody/tr/td[@class="lti"]'; - var titleNode = './text()'; - } else { - var elmtsXPath = '//div[@id="dlpage"]/dl/dt/span[@class="list-identifier"]/a[1]'; - var titlesXPath = '//div[@id="dlpage"]/dl/dd/div[@class="meta"]/div[@class="list-title"]'; - } - - var elmts = doc.evaluate(elmtsXPath, doc, null, XPathResult.ANY_TYPE, null); - var titles = doc.evaluate(titlesXPath, doc, null, XPathResult.ANY_TYPE, null); - - var newURIs = new Array(); - var elmt = elmts.iterateNext(); - var title = titles.iterateNext(); - if (elmt && titles) { - var availableItems = new Array(); - var arXivCats = new Array(); - var arXivIDs = new Array(); - var i=0; - if (eprintMultM){ - do { - var newID = doc.evaluate('./text()', elmt, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newID = newID.replace(/arXiv:/, ""); - newID = newID.replace(/\//g, "%2F"); - newID = newID.replace(/v\d*/, ""); //remove version number - availableItems[i] = doc.evaluate(titleNode, title, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - arXivIDs[i] = newID; - i++; - } while ((elmt = elmts.iterateNext()) && (title = titles.iterateNext())); - } - else{ - do { - var newID= elmt.textContent; - newID = newID.replace(/arXiv:/, ""); - newID = newID.replace(/\//g, "%2F"); - newID = newID.replace(/v\d*/, ""); //remove version number - availableItems[i] = ZU.trimInternal(title.textContent.replace(/^\s*Title:\s+/, "")); - arXivIDs[i] = newID; - i++; - } while ((elmt = elmts.iterateNext()) && (title = titles.iterateNext())); - } - var items = Zotero.selectItems(availableItems, function(items) { - if(!items) { - return true; - } - for(var i in items) { - newURIs.push("http://export.arxiv.org/oai2?verb=GetRecord&identifier=oai%3AarXiv.org%3A" + arXivIDs[i] + "&metadataPrefix=oai_dc"); - } - Zotero.Utilities.HTTP.doGet(newURIs, parseXML, function() {Zotero.done();}, null); - }); - } - else { - if (eprintSingM){ - var titleID = doc.evaluate('//td[@class="ti"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var arXivID = doc.evaluate('//table/tbody/tr[4]/td/table/tbody/tr/td[1]/table/tbody/tr[1]/td[@class="txt"]/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - arXivID = arXivID.substring(0, arXivID.indexOf(" ")); - arXivID = arXivID.replace(/arXiv:/, ""); - arXivID = arXivID.replace(/\//g, "%2F"); - } else { - var arXivID = doc.evaluate('//title', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var titleRe = /\[([^\]]*)]/; - var m = titleRe.exec(arXivID); - arXivID = m[1]; - arXivID = arXivID.replace(/\//g, "%2F"); - } - arXivID = arXivID.replace(/v\d*/, ""); //remove version number - newURIs.push("http://export.arxiv.org/oai2?verb=GetRecord&identifier=oai%3AarXiv.org%3A" + arXivID + "&metadataPrefix=oai_dc"); - Zotero.Utilities.HTTP.doGet(newURIs, parseXML, function() {Zotero.done();}, null); - } - Zotero.wait(); -} - -function parseXML(text) { - var newItem = new Zotero.Item("journalArticle"); - // remove header - text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""); - // fix non-compliant XML tags (colons) - text = text.replace(/<dc:/g, "<dc_").replace(/<\/dc:/g, "</dc_"); - text = text.replace(/<oai_dc:dc/g, "<oai_dc_dc").replace(/<\/oai_dc:dc/g, "</oai_dc_dc"); - text = text.replace(/<OAI-PMH[^>]*>/, "").replace(/<\/OAI-PMH[^>]*>/, ""); - text = "<zotero>" + text + "</zotero>"; - - var xml = (new DOMParser()).parseFromString(text, "text/xml"); - - newItem.title = getXPathNodeTrimmed(xml, "dc_title"); - getCreatorNodes(xml, "dc_creator", newItem, "author"); - newItem.date = getXPathNodeTrimmed(xml, "dc_date"); - - var descriptions = ZU.xpath(xml, "//GetRecord/record/metadata/oai_dc_dc/dc_description"); - for(var j=0; j<descriptions.length; j++) { - var noteStr = ZU.trimInternal(descriptions[j].textContent); - newItem.notes.push({note:noteStr}); - } - - var subjects = ZU.xpath(xml, "//GetRecord/record/metadata/oai_dc_dc/dc_subject"); - for(var j=0; j<subjects.length; j++) { - var subject = ZU.trimInternal(subjects[j].textContent); - newItem.tags.push(subject); - } - - var identifiers = ZU.xpath(xml, "//GetRecord/record/metadata/oai_dc_dc/dc_identifier"); - for(var j=0; j<identifiers.length; j++) { - var identifier = ZU.trimInternal(identifiers[j].textContent); - if (identifier.substr(0, 4) == "doi:") { - newItem.DOI = identifier; - } - else if (identifier.substr(0, 7) == "http://") { - newItem.url = identifier; - } - else { - newItem.extra = identifier; - } - } - - var articleID = ZU.xpath(xml, "//GetRecord/record/header/identifier"); - articleID = ZU.trimInternal(articleID[0].textContent); - articleID = articleID.substr(14); - var idPrefixRegex = new RegExp('^arXiv:', "i"); - if (idPrefixRegex.test (articleID)) { - newItem.publicationTitle = articleID; - } - else { - newItem.publicationTitle = "arXiv:" + articleID; - } - -// TODO add "arXiv.org" to bib data? - newItem.attachments.push({url:newItem.url, title:"arXiv.org Snapshot", mimeType:"text/html"}); - newItem.attachments.push(getPDF(articleID)); - if (newItem.notes[0]['note']) { - newItem.abstractNote = newItem.notes[0]['note']; - newItem.notes = new Array(); - } - newItem.complete(); -} - - -function getXPathNodeTrimmed(xml, name) { - var node = ZU.xpath(xml, "//GetRecord/record/metadata/oai_dc_dc/"+name); - var val = ""; - if(node.length){ - val = Zotero.Utilities.trimInternal(node[0].textContent); - } - return val; -} - -function getCreatorNodes(xml, name, newItem, creatorType) { - var nodes = ZU.xpath(xml, "//GetRecord/record/metadata/oai_dc_dc/"+name); - for(var i=0; i<nodes.length; i++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(nodes[i].textContent, creatorType, true)); - } -}/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://arxiv.org/list/astro-ph/new", - "items": "multiple" - }, - { - "type": "web", - "url": "http://arxiv.org/abs/1107.4612", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "O'Dea, D.", - "lastName": "T", - "creatorType": "author" - }, - { - "firstName": "Clark, C.", - "lastName": "N", - "creatorType": "author" - }, - { - "firstName": "Contaldi, C.", - "lastName": "R", - "creatorType": "author" - }, - { - "firstName": "MacTavish, C.", - "lastName": "J", - "creatorType": "author" - } - ], - "notes": [], - "tags": [ - "Astrophysics - Cosmology and Extragalactic Astrophysics", - "Astrophysics - Galaxy Astrophysics" - ], - "seeAlso": [], - "attachments": [ - { - "url": false, - "title": "arXiv.org Snapshot", - "mimeType": "text/html" - }, - { - "url": false, - "mimeType": "application/pdf", - "title": "1107.4612 PDF" - } - ], - "title": "A Model For Polarised Microwave Foreground Emission From Interstellar Dust", - "date": "2011-07-22", - "url": "http://arxiv.org/abs/1107.4612", - "publicationTitle": "arXiv:1107.4612", - "abstractNote": "The upcoming generation of cosmic microwave background (CMB) experiments face a major challenge in detecting the weak cosmic B-mode signature predicted as a product of primordial gravitational waves. To achieve the required sensitivity these experiments must have impressive control of systematic effects and detailed understanding of the foreground emission that will influence the signal. In this paper we describe a model of foreground dust intensity and polarisation. The model includes a 3D description of the Galactic magnetic field, examining both large and small scales. We also include in the model the details of the dust density, grain alignment and the intrinsic polarisation of the emission from an individual grain. We present here Stokes parameter maps at 150 GHz and provide an on-line repository for these and additional template maps at frequencies that will be targeted by upcoming experiments such as EBEX, Spider and SPTpol.", - "libraryCatalog": "arXiv.org" - } - ] - } -] -/** END TEST CASES **/ -\ No newline at end of file diff --git a/translators/build_zip b/translators/build_zip @@ -1,20 +0,0 @@ -#!/bin/bash -if [ -f translators.zip ]; then - rm translators.zip -fi -if [ ! -d output ]; then - mkdir output; -fi - -counter=0; -for file in *.js; do - newfile=$counter.js; - cp "$file" output/$newfile; - counter=$(($counter+1)); -done; - -cd output -zip ../translators.zip * -cd .. -rm -rf output -mv translators.zip .. diff --git a/translators/cablegatesearch.net.js b/translators/cablegatesearch.net.js @@ -1,89 +0,0 @@ -{ - "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;d<c.length;d++){try{if((c[d]===undefined)||(c[d]===null)){continue}else{c[d]=this._filters[i](c[d],e)}}catch(b){c[d]=undefined;Zotero.debug("Caught exception "+b+"on filter: "+this._filters[i])}}c=c.filter(function(a){return((a!==undefined)&&(a!==null))})}return c}};FW.PageText=function(){return new FW._PageText()};FW._PageText=function(){this._filters=new Array();this.evaluate=function(c){var b=[c.documentElement.innerHTML];b=this._applyFilters(b,c);if(b.length==0){return false}else{return b}}};FW._PageText.prototype=new FW._StringMagic();FW.Url=function(){return new FW._Url()};FW._Url=function(){this._filters=new Array();this.evaluate=function(d,c){var b=[c];b=this._applyFilters(b,d);if(b.length==0){return false}else{return b}}};FW._Url.prototype=new FW._StringMagic();FW.Xpath=function(a){return new FW._Xpath(a)};FW._Xpath=function(a){this._xpath=a;this._filters=new Array();this.text=function(){var b=function(c){if(typeof c==="object"&&c.textContent){return c.textContent}else{return c}};this.addFilter(b);return this};this.sub=function(b){var c=function(f,e){var d=e.evaluate(b,f,null,XPathResult.ANY_TYPE,null);if(d){return d.iterateNext()}else{return undefined}};this.addFilter(c);return this};this.evaluate=function(e){var d=e.evaluate(this._xpath,e,null,XPathResult.ANY_TYPE,null);var c=new Array();var b;while(b=d.iterateNext()){c.push(b)}c=this._applyFilters(c,e);if(c.length==0){return false}else{return c}}};FW._Xpath.prototype=new FW._StringMagic();FW.detectWeb=function(e,b){for(var c in FW._scrapers){var d=FW._scrapers[c];var f=d.evaluateThing(d.itemType,e,b);var a=d.evaluateThing(d.detect,e,b);if(a.length>0&&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/dLibra.js b/translators/dLibra.js @@ -1,167 +0,0 @@ -{ - "translatorID":"915e3ae2-afa9-4b1d-9780-28ed3defe0ab", - "label":"dLibra", - "creator":"Pawel Kolodziej <p.kolodziej@gmail.com>", - "target":"/.*dlibra\\/(doccontent|docmetadata|collectiondescription|results)|/dlibra/?", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":"1", - "translatorType":4, - "lastUpdated":"2011-04-18 23:20:17" -} -/* - dLibra Translator - Copyright (C) 2010 Pawel Kolodziej, p.kolodziej@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/>. -*/ - -dd = Zotero.debug; // shortcut - -function detectWeb(doc, url) { - var singleRe = /.*dlibra\/(doccontent|docmetadata|publication).*/; - var multipleRe = /.*dlibra\/(collectiondescription|results).*|.*\/dlibra\/?/; - if(singleRe.test(url)) - return "document"; - if(multipleRe.test(url)) - return "multiple"; - return ""; -} - -function list2txt(list) -{ - var a= new Array(); - for each(var i in list) - a.push(i.text()); - return a.join(", "); - -} - -function translateType(type) -{ - var types = { - "book": /.*książka.*/ , - "journalArticle": /.*artykuł.*/ - } - - for (var t in types) - if (types[t].test(type)) - return t; -} - - -function doWeb(doc, url) { - if(detectWeb(doc,url)=="multiple"){ - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? - function(prefix) { - if (prefix == 'x') return namespace; else return null; - }: null; - - - var itemsXPath = '//ol[@class="itemlist"]/li/a | //td[@class="searchhit"]/b/a'; - - var obj = doc.evaluate(itemsXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var itemHtml; - var items= new Object() ; - while(itemHtml = obj.iterateNext()) - items[itemHtml.href] = itemHtml.textContent; - - items = Zotero.selectItems(items); - for (var itemUrl in items) - doSingleItem(itemUrl) - }else - doSingleItem(url); - - - return true; -} - -function doSingleItem(url) -{ - - var reSingle= new RegExp("(.*/dlibra)/(?:doccontent|docmetadata|publication).*[?&]id=([0-9]*).*"); - var m = reSingle.exec(url); - if(!m) - return ""; - var baseUrl = m[1]; - var id = m[2]; - var isPIA = baseUrl.match("lib.pia.org.pl|cyfrowaetnografia.pl"); - var rdf = Zotero.Utilities.retrieveSource( baseUrl + "/rdf.xml?type=e&id="+id); - - rdf = rdf.replace(/<\?xml[^>]*\?>/, ""); - var rdfXml = new XML(rdf); - - rdf = new Namespace("http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - dc = new Namespace("http://purl.org/dc/elements/1.1/"); - var desc = rdfXml.rdf::Description - - var itemType = translateType(list2txt(desc.dc::type)); - if(!itemType) - { - if( isPIA ) - itemType = "journalArticle"; - else - var itemType = "document"; - } - - var item = new Zotero.Item(itemType); - item.title = list2txt(desc.dc::title); - - item.rights = list2txt(desc.dc::rights) - item.publisher = list2txt(desc.dc::publisher) - var reComa = new RegExp(".*,.*"); - - for each(var i in desc.dc::creator){ - var hasComa = new Boolean(reComa.exec(i.toString())); - item.creators.push( Zotero.Utilities.cleanAuthor(i.toString(), "author", hasComa)); - } - for each(var i in desc.dc::contributor){ - var hasComa = new Boolean(reComa.exec(i.toString())); - item.creators.push( Zotero.Utilities.cleanAuthor(i.toString(), "contributor", hasComa)); - } - - item.date = list2txt(desc.dc::date); - item.language = list2txt(desc.dc::language); - item.description = list2txt(desc.dc::description); - - if(isPIA) - { // hacks for lib.pia.org.pl - // trim title at "/" character - var stripedTitle = item.title.match("[^/]*"); - if(stripedTitle) - item.title = stripedTitle[0]; - d = desc.dc::description.match("([A-Za-z/ ]*)(.*)") - item.publicationTitle = d[1]; - if(d[2]) - { - vol = d[2].match("t\\. *([0-9-, ]*[0-9])"); - //dd(d[2]); - if(vol) - item.volume = vol[1]; - pages = d[2].match("s\\. *([0-9-, ]*[0-9])"); - if(pages) - item.pages = pages[1]; - issue = d[2].match("z\\. *([0-9-, ]*[0-9])"); - if(issue) - item.issue = issue[1]; - } - - } -// Zotero.debug(item); - - item.complete(); - return item; -} diff --git a/translators/deleted.txt b/translators/deleted.txt @@ -1,22 +0,0 @@ -6 # Increment number when modifying file - -96b9f483-c44d-5784-cdad-ce21b984 # Amazon -add7c71c-21f3-ee14-d188-caf9da12 # SIRSI 2003+ -fcf41bed-0cbc-3704-85c7-8062a006 # PubMed -0faa6714-927a-4b07-911e-7101895daae0 # GBV -360da304-5a4c-44ea-b655-28dcb5ebfa25 # YouTube -3af43735-36d3-46ae-9ca8-506ff032b0d3 # HeinOnline -da440efe-646c-4a18-9958-abe1f7d55cde # NCSU Library (Endeca 2) -37445f52-64fa-4a2a-9532-35753520a0f0 # HeinOnline -e07e9b8c-0e98-4915-bb5a-32a08cb2f365 # Open WorldCat (Search) -490909d7-7d79-4c7a-a136-77df618d4db2 # Worldcat.org -dd149efc-7f0e-43e4-b3df-b6d15e171717 # Persée -56ea09bc-57ee-4f50-976e-cf7cb1f6c6d8 # Royal Society Publishing (replaced by HighWire 2.0) -83538f48-906f-40ef-bdb3-e94f63676307 # NAA RecordSearch (replaced by National Archives of Australia) -dbb5d4bc-3b21-47a2-9751-5dcbb65b902a # AMS Online Journals - Allenpress (replaced with DOI for now) -d2416f31-4f24-4e18-8c66-06122af5bc2c # Women in Judaism (replaced with COinS) -bc39e05b-141a-4322-85f0-a5b86edf896b # Hindawi -e78d20f7-488-4023-831-dfe39679f3f # ACM (replaced by newer version) -3f44a651-8b6b-4591-8ca4-4bfb943a13f4 # Edutopia (replaced with nothing) -636c8ea6-2af7-4488-8ccd-ea280e4a7a98 # Sage Journals Online (replaced by Highwire 2.0) -a8df3cb0-f76c-4e2c-a11e-5fa283f8010c # Copernicus (replaced by newer version) diff --git a/translators/eLibrary.ru.js b/translators/eLibrary.ru.js @@ -1,317 +0,0 @@ -{ - "translatorID": "587709d3-80c5-467d-9fc8-ed41c31e20cf", - "label": "eLibrary.ru", - "creator": "Avram Lyon", - "target": "^http://elibrary\\.ru/", - "minVersion": "2.1", - "maxVersion": "", - "priority": 100, - "browserSupport": "gcs", - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-08-22 22:43:15" -} - -/* - eLibrary.ru Translator - Copyright (C) 2010-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){ - if (url.match(/\/item.asp/)) { - return "journalArticle"; - } else if (url.match(/\/(query_results|contents|org_items|itembox_items)\.asp/)){ - return "multiple"; - } -} - -function doWeb(doc, url){ - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - - var articles = new Array(); - if (detectWeb(doc, url) == "multiple") { - var results = doc.evaluate('//table[@id="restab"]//tr[@bgcolor = "#f5f5f5"]/td[2]', doc, ns, XPathResult.ANY_TYPE, null); - var items = new Array(); - var result; - while(result = results.iterateNext()) { - var link = doc.evaluate('./a', result, ns, XPathResult.ANY_TYPE, null).iterateNext(); - var title = link.textContent; - var url = link.href; - items[url] = title; - } - items = Zotero.selectItems(items); - if(!items) return true; - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - } else { - scrape(doc); - } - - Zotero.wait(); -} - -function scrape (doc) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) { - if (prefix == 'x') return n; else return null; - } : null; - var datablock = doc.evaluate('//td[@align="right" and @width="100%" and @valign="top"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - - var tableLabels = doc.evaluate('./table/tbody/tr[1]/td[@bgcolor="#dddddd"][1]|./table//table[1]//tr[1]/td[@bgcolor="#dddddd"][1]', datablock, ns, XPathResult.ANY_TYPE, null); - - var titleBlock, authorBlock, publicationBlock, metaBlock, codeBlock, keywordBlock, abstractBlock, referenceBlock; - var t = 0, label; // Table number and label - while ((label = tableLabels.iterateNext()) !== null) { - t++; - label = label.textContent; - - switch (label) { - case "Названиепубликации": - titleBlock = doc.evaluate('./table['+t+']', datablock, ns, XPathResult.ANY_TYPE, null).iterateNext(); - Zotero.debug("have titleBlock"); - break; - case "Авторы": - authorBlock = doc.evaluate('./table['+t+']', datablock, ns, XPathResult.ANY_TYPE, null).iterateNext(); - Zotero.debug("have authorBlock"); - break; - case "Журнал": - case "Издательство": - metaBlock = doc.evaluate('./table['+t+']', datablock, ns, XPathResult.ANY_TYPE, null).iterateNext(); - Zotero.debug("have metaBlock"); - break; - case "Коды": - codeBlock = doc.evaluate('./table['+t+']', datablock, ns, XPathResult.ANY_TYPE, null).iterateNext(); - Zotero.debug("have codeBlock"); - break; - case "Ключевыеслова": - keywordBlock = doc.evaluate('./table['+t+']', datablock, ns, XPathResult.ANY_TYPE, null).iterateNext(); - Zotero.debug("have keywordBlock"); - break; - case "Аннотация": - abstractBlock = doc.evaluate('./table['+t+']', datablock, ns, XPathResult.ANY_TYPE, null).iterateNext(); - Zotero.debug("have abstractBlock"); - break; - case "Списоклитературы": - referenceBlock = doc.evaluate('./table['+t+']', datablock, ns, XPathResult.ANY_TYPE, null).iterateNext(); - Zotero.debug("have referenceBlock"); - break; - case "Переводнаяверсия": - default: - Zotero.debug("Unknown/unsupported block: "+ label); - break; - } - } - - var item = new Zotero.Item(); - /*var pdf = false; - // Now see if we have a free PDF to download - var pdfImage = doc.evaluate('//a/img[@src="/images/pdf_green.gif"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext(); - if (pdfImage) { - // A green PDF is a free one. We need to construct the POST request - var postData = [], postField; - var postNode = doc.evaluate('//form[@name="results"]/input', doc, ns, XPathResult.ANY_TYPE, null); - while ((postField = postNode.iterateNext()) !== null) { - postData.push(postField.name + "=" +postField.value); - } - postData = postData.join("&"); - Zotero.debug(postData + postNode.iterateNext()); - Zotero.Utilities.HTTP.doPost('http://elibrary.ru/full_text.asp', postData, function(text) { - var href = text.match(/http:\/\/elibrary.ru\/download\/.*?\.pdf/)[0]; - pdf = {url:href, title:"eLibrary.ru полный текст", mimeType:"application/pdf"}; - }); - }*/ - - item.title = doc.title.match(/eLIBRARY.RU - (.*)/)[1]; - - if (authorBlock) { - // Sometimes we don't have links, just bold text - var authorNode = doc.evaluate('.//td[2]/font/a | .//td[2]/font/b', authorBlock, ns, XPathResult.ANY_TYPE, null); - while ((author = authorNode.iterateNext()) !== null) { - // Remove organizations; by URL or by node name - if ((author.href && !author.href.match(/org_about\.asp/) - && !author.href.match(/org_items\.asp/)) - || author.nodeName == "B") { - author = author.textContent; - var authors = author.split(","); - for (var i = 0; i < authors.length; i++) { - var cleaned = Zotero.Utilities.cleanAuthor(authors[i], "author"); - // If we have only one name, set the author to one-name mode - if (cleaned.firstName == "") { - cleaned["fieldMode"] = true; - } else { - // We can check for all lower-case and capitalize if necessary - // All-uppercase is handled by cleanAuthor - cleaned.firstName = (cleaned.firstName == cleaned.firstName.toLowerCase()) ? - Zotero.Utilities.capitalizeTitle(cleaned.firstName, true) : cleaned.firstName; - cleaned.lastName = (cleaned.lastName == cleaned.lastName.toLowerCase()) ? - Zotero.Utilities.capitalizeTitle(cleaned.lastName, true) : cleaned.lastName; - } - // Skip entries with an @ sign-- email addresses slip in otherwise - if (cleaned.lastName.indexOf("@") === -1) item.creators.push(cleaned); - } - } else { Zotero.debug("Skipping presumed affiliation: " + author.textContent) ; } - } - } - // This is the table of metadata. We could walk through it, but I found it easier - // to just make a 2-d array of XPaths of field names values. - var mapped = false; - var metaPieces = [['.//table[1]//tr[1]/td[1]','.//table[1]//tr[1]/td[2]'], - ['.//table[1]//tr[2]/td[1]','.//table[1]//tr[2]/td[2]'], - ['.//table[2]//tr[1]/td[1]','.//table[2]//tr[1]/td[2]'], - ['.//table[2]//tr[1]/td[3]','.//table[2]//tr[1]/td[4]'], - ['.//table[2]//tr[2]/td[1]','.//table[2]//tr[2]/td[2]'], - ['.//table[2]//tr[2]/td[3]','.//table[2]//tr[2]/td[4]'], - ['.//table[2]//tr[3]/td[1]','.//table[2]//tr[3]/td[2]'], - ['.//table[2]//tr[3]/td[3]','.//table[2]//tr[3]/td[4]'], - ['.//table[2]//tr[4]/td[1]','.//table[2]//tr[4]/td[2]'], - ['.//table[2]//tr[4]/td[3]','.//table[2]//tr[4]/td[4]']] - for (i in metaPieces) { - mapped = mapper(metaPieces[i][0], metaPieces[i][1], metaBlock, doc); - item[mapped[0]] = mapped[1]; - } - if (item.extra) item.extra = "Цитируемость в РИНЦ: " + item.extra; - if (abstractBlock) - item.abstractNote = doc.evaluate('./tbody/tr/td[2]/table/tbody/tr/td/font', abstractBlock, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - // Set type - switch (item.itemType) { - case "обзорная статья": // Would be "review article" - case "научная статья": - item.itemType = "journalArticle"; - break; - case "учебное пособие": - case "монография": - item.itemType = "book"; - break; - case "публикация в сборнике трудов конференции": - item.itemType = "conferencePaper"; - break; - default: - Zotero.debug("Unknown type: "+item.itemType+". Using 'journalArticle'"); - item.itemType = "journalArticle"; - break; - } - - /*if (referenceBlock) { - var note = Zotero.Utilities.trimInternal( - doc.evaluate('./tbody/tr/td[2]/table', referenceBlock, ns, XPathResult.ANY_TYPE, null) - .iterateNext().textContent); - Zotero.debug(note); - item.notes.push(note); - }*/ - - if (codeBlock) { - item.extra += ' '+ doc.evaluate('.//td[2]', codeBlock, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var doi = item.extra.match(/DOI: (10\.[^\s]+)/); - if (doi) { - item.DOI = doi[1]; - item.extra = item.extra.replace(/DOI: 10\.[^\s]+/,""); - } - } - - if (keywordBlock) { - var tag, tagNode = doc.evaluate('.//td[2]/a', keywordBlock, ns, XPathResult.ANY_TYPE, null); - while ((tag = tagNode.iterateNext()) !== null) - item.tags.push(tag.textContent); - } - - if (item.title.toUpperCase() == item.title) { - Zotero.debug("Trying to fix all-uppers"); - item.title = item.title.substr(0,1) + item.title.toLowerCase().substr(1); - } - - //if(pdf) item.attachments.push(pdf); - - item.complete(); -} - -function mapper (from, to, block, doc) { - var name = doc.evaluate(from, block, null, XPathResult.ANY_TYPE, null).iterateNext(); - var value = doc.evaluate(to, block, null, XPathResult.ANY_TYPE, null).iterateNext(); - if (!name || !value) return false; - var key = false; - switch (name.textContent.trim()) { - case "Журнал": - key = "publicationTitle"; break; - case "Издательство": - key = "publisher"; break; - case "Год издания": - case "Год выпуска": - key = "date"; break; - case "Том": - key = "volume"; break; - case "Номер": - key = "issue"; break; - case "ISSN": - key = "ISSN"; break; - case "Страницы": - key = "pages"; break; - case "Язык": - key = "language"; break; - case "Место издания": - key = "place"; break; - case "Цит. в РИНЦ": - key = "extra"; break; - case "Тип": - key = "itemType"; break; - default: - Zotero.debug("Unmapped field: "+name.textContent.trim()); - } - return [key, value.textContent.trim()]; -}/** BEGIN TEST CASES **/ -var testCases = [ - { - "type": "web", - "url": "http://elibrary.ru/org_items.asp?orgsid=3326", - "items": "multiple" - }, - { - "type": "web", - "url": "http://elibrary.ru/item.asp?id=9541154", - "items": [ - { - "itemType": "journalArticle", - "creators": [ - { - "firstName": "М.В", - "lastName": "Свет", - "creatorType": "author" - } - ], - "notes": [], - "tags": [], - "seeAlso": [], - "attachments": [], - "title": "Иноязычные заимствования в художественной прозе на иврите в XX в", - "publicationTitle": "Вестник Московского университета. Серия 13: Востоковедение", - "publisher": "Издательство Московского государственного университета", - "date": "2007", - "ISSN": "0320-8095", - "extra": "Цитируемость в РИНЦ: 0", - "issue": "1", - "pages": "40-58", - "language": "русский", - "libraryCatalog": "eLibrary.ru" - } - ] - } -] -/** END TEST CASES **/ diff --git a/translators/eMJA.js b/translators/eMJA.js @@ -1,125 +0,0 @@ -{ - "translatorID":"966a7612-900c-42d9-8780-2a3247548588", - "translatorType":4, - "label":"eMJA", - "creator":"Michael Berkowitz", - "target":"http://www.mja.com.au/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2011-01-11 04:31:00" -} - -function detectWeb(doc, url) { - if (doc.evaluate('//p[@class="Pfoot"]/b/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('/html/body/table/tbody/tr[1]/td[2]/a/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - return "multiple"; - } else if (doc.title.indexOf("eMJA:") != -1) { - return "journalArticle"; - } -} - -function senCase(string) { - var smallwords = Array("and", "a", "in", "the", "by", "of", "s", "on"); - var sen = string.split(/\b/); - for (var i = 0 ; i < sen.length; i++) { - if (sen[i].match(/\w+/)) { - if (smallwords.indexOf(sen[i]) != -1 && i != 0) { - sen[i] = sen[i].toLowerCase(); - } else { - sen[i] = sen[i][0].toUpperCase() + sen[i].substring(1).toLowerCase(); - } - } - } - return sen.join(""); -} - -function doWeb(doc, url) { - var URIs = new Array(); - - if (doc.evaluate('//p[@class="Pfoot"]/b/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//p[@class="Pfoot"]/b/a'; - } else if (doc.evaluate('//tr[1]/td[2]/a/b', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) { - var xpath = '//tr[1]/td[2]/a/b'; - var linkpath = '//tr[2]/td[2]/small[@class="gr"]'; - } - - if (xpath) { - if (linkpath) { - var items = new Object(); - var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var links = doc.evaluate(linkpath, doc, null, XPathResult.ANY_TYPE, null); - var title = titles.iterateNext(); - var link = links.iterateNext(); - while (title) { - //Zotero.debug(Zotero.Utilities.trimInternal(title.textContent)); - //Zotero.debug(Zotero.Utilities.trimInternal(link.textContent)); - items[Zotero.Utilities.trimInternal(link.textContent)] = Zotero.Utilities.trimInternal(title.textContent).substring(6); - title = titles.iterateNext(); - link = links.iterateNext(); - } - } else { - var items = new Object(); - var things = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_thing = things.iterateNext(); - while (next_thing) { - items[next_thing.href] = senCase(Zotero.Utilities.trimInternal(next_thing.textContent)); - next_thing = things.iterateNext(); - } - } - items = Zotero.selectItems(items); - Zotero.debug(items); - for (var i in items) { - URIs.push(i); - } - } else { - URIs.push(url); - } - Zotero.debug(URIs); - Zotero.Utilities.processDocuments(URIs, function(newDoc) { - var newItem = new Zotero.Item("journalArticle"); - newItem.title = senCase(newDoc.title.substring(6)); - - newItem.publicationTitle = "The Medical Journal of Australia"; - newItem.ISSN = "0025-729X"; - newItem.url = newDoc.location.href; - - //date - newItem.date = newDoc.evaluate('//meta[@name="date"]/@content', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.substring(0,10); - - //voliss - var voliss = newDoc.evaluate('//meta[@name="citation"]/@content', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent; - //voliss = voliss.match(/[^\d]+(\d+)\s+\((\d+)\)/); - voliss = voliss.match(/;\s+(\d+)\s+\((\d+)[^:]+:\s+(.*)\.$/); - newItem.volume = voliss[1]; - newItem.issue = voliss[2]; - newItem.pages = voliss[3]; - - //authors - var authors = new Array(); - var apath = '//div[@class="By"]/span[@class="Pn"]'; - var author = newDoc.evaluate(apath, newDoc, null, XPathResult.ANY_TYPE, null); - var next_a = author.iterateNext(); - while (next_a) { - var name = next_a.textContent; - if (name.substring(0,1) == ",") { - name = name.substring(2); - } else if (name.substring(0,4) == " and") { - name = name.substring(5); - } - authors.push(name); - next_a = author.iterateNext(); - } - - for (var i in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - - //attachments - newItem.attachments = [ - {url:newDoc.location.href, title:"eMJA Snapshot", mimeType:"text/html"}, - {url:newDoc.location.href.replace(".html", ".pdf") , title:"eMJA PDF", mimeType:"application/pdf"} - ]; - newItem.complete(); - }, function() {Zotero.done();}); -} -\ No newline at end of file diff --git a/translators/eMedicine.js b/translators/eMedicine.js @@ -1,96 +0,0 @@ -{ - "translatorID":"ab88d517-d88c-4a73-a0ad-c94c76cca849", - "translatorType":4, - "label":"eMedicine", - "creator":"William Smith", - "target":"http://emedicine.medscape.com/article/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-12-09 13:40:00" -} - -// Emedicine.Medscape.com translator. -// Version 1.00 -// By William Smith, see http://www.willsmith.org/contactme/ - -function detectWeb(doc, url) { - if (doc.location.href.match("(overview|treatment|diagnosis|followup|media)")) { - return "journalArticle"; - } -} - - -// Everything lives in Metas. Very convenient. - -function useMeta (doc, newItem, field, zoteroField) { - xpath='//meta[@name="' + field + '"]/@content'; - temp=doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - if(temp) - { - newItem[zoteroField] =temp.value; - } -} -function getMeta (doc, newItem, field) { - xpath='//meta[@name="' + field + '"]/@content'; - temp=doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - return temp; -} - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var fieldTitle; - - var newItem = new Zotero.Item("journalArticle"); - - newItem.publication = 'Medscape - eMedicine'; - - // Geta few useful fields. - useMeta(doc, newItem, "displayTitle", "title"); - useMeta(doc, newItem, "date" , "date" ); - useMeta(doc, newItem, "book" , "repository"); - useMeta(doc, newItem, "description" , "abstractNote"); - newItem.abstractNote = newItem.abstractNote.replace(/^(Overview|Treatment|Diagnosis|Followup|Media):\s+/, ""); - - // Authors - we only handle one. - authors = getMeta(doc, newItem, "authors"); - if (authors) { - authors = authors.iterateNext().textContent; - Zotero.debug('author: <'+authors+'>'); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "author")); - } - - // Keywords. - keywords = getMeta(doc, newItem, "keywords"); - if (keywords) { - keywords = keywords.iterateNext().textContent; - Zotero.debug('keywords: <'+keywords+'>'); - keywords = keywords.split(","); - for (var i=0;i<keywords.length; i++) { - Zotero.debug('keyword['+i+']: <'+keywords[i]+'>'); - newItem.tags[i] = Zotero.Utilities.cleanTags(keywords[i], ""); - } - } - - newItem.url = url; - - // Attachment doesn't seem to work - misses a stylesheet or something, and looks ugly. - // newItem.attachments.push({url:url, title:"eMedicine Snapshot",mimeType:"text/html"}); - newItem.complete(); -} - -function doWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - - scrape(doc,url); -} -\ No newline at end of file diff --git a/translators/ePrint IACR.js b/translators/ePrint IACR.js @@ -1,109 +0,0 @@ -{ - "translatorID":"04a23cbe-5f8b-d6cd-8eb1-2e23bcc8ae8f", - "translatorType":4, - "label":"ePrint IACR", - "creator":"Jonas Schrieb", - "minVersion":"1.0.0b3.r1", - "target":"^http://eprint\\.iacr\\.org/", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2010-03-03 14:00:00" -} - -function detectWeb(doc, url) { - var singleRe = /^http:\/\/eprint\.iacr\.org\/(\d{4}\/\d{3}|cgi-bin\/print\.pl)/; - var multipleRe = /^http:\/\/eprint\.iacr\.org\/(complete|curr|\d{4}|cgi-bin\/search\.pl)/; - if(singleRe.test(url)) { - return "report"; - } else if(multipleRe.test(url)) { - return "multiple"; - } -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var reportNoXPath = "//h2"; - var titleXPath = "//p[1]/b"; - var authorsXPath = "//p[2]/i"; - var abstractXPath = "//p[starts-with(b/text(),\"Abstract\")]/text() | //p[not(*)]"; - var keywordsXPath = "//p[starts-with(b/text(),\"Category\")]"; - - var reportNo = doc.evaluate(reportNoXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - reportNo = reportNo.match(/(\d{4})\/(\d{3})$/); - var year = reportNo[1]; - var no = reportNo[2]; - - var title = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var authors = doc.evaluate(authorsXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - authors = authors.split(" and "); - - var abstr = ""; - var abstractLines = doc.evaluate(abstractXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var nextLine; - while(nextLine = abstractLines.iterateNext()) { - abstr += nextLine.textContent; - } - - var keywords = doc.evaluate(keywordsXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var tmp = keywords.match(/Category \/ Keywords: (?:([^\/]*) \/ )?([^\/]*)/); - keywords = tmp[2].split(", ") - keywords.unshift(tmp[1]); - - - var newItem = new Zotero.Item("report"); - newItem.date = year; - newItem.reportNumber = no; - newItem.url = "http://eprint.iacr.org/"+year+"/"+no; - newItem.title = title; - newItem.abstractNote = abstr; - for (var i in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - for (var i = 0; i < keywords.length; i++) { - newItem.tags[i] = keywords[i]; - } - newItem.attachments = [ - {url:newItem.url, title:"ePrint IACR Snapshot", mimeType:"text/html"}, - {url:newItem.url+".pdf", title:"ePrint IACR Full Text PDF", mimeType:"application/pdf"} - ]; - - newItem.complete(); -} - -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") { - var titleXPath = "//dl/dd/b"; - var linkXPath = "//dl/dt/a[1]"; - - var titles = doc.evaluate(titleXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - var links = doc.evaluate(linkXPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - while (nextTitle = titles.iterateNext()) { - nextLink = links.iterateNext(); - items[nextLink.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(); -} diff --git a/translators/fishpond.co.nz.js b/translators/fishpond.co.nz.js @@ -1,146 +0,0 @@ -{ - "translatorID": "c436f3c7-4246-4ed3-a227-a538c8113a0e", - "label": "fishpond.co.nz", - "creator": "Sopheak Hean", - "target": "^https?://www\\.fishpond\\.co\\.nz/", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": true, - "translatorType": 4, - "lastUpdated": "2011-04-21 09:34:42" -} - -/* - Fishpond.co.nz Translator- Parses Fishpond.co.nz articles and creates Zotero-based metadata - Copyright (C) 2011 Sopheak Hean, University of Waikato, Faculty of Education - Contact: maxximuscool@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) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == "x" ) return namespace; else return null; - } : null; - var definePath = '//td[@class="main hproduct"]/h1'; - var XpathObject = doc.evaluate(definePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (XpathObject) { - return "book"; - } else { - var definePath = '//td[@id="page_title"]/h1'; - var XpathObject = doc.evaluate(definePath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (XpathObject) { - return "multiple"; - } - } - -} - -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("book"); - var title = '//span[@class="fn"]'; - var titleObject = doc.evaluate(title, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (titleObject){ - newItem.title = titleObject.textContent; - } - - var author = '//p[@id="product_author"]'; - var authorObject = doc.evaluate(author, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (authorObject){ - authorObject = authorObject.textContent; - if (( authorObject.match(/By\s/)) && (authorObject.match(/\([A-Za-z]+\W[a-zA-Z]+\)/) )){ - authorObject = authorObject.replace(/By\s/, '').replace(/\([A-Za-z]+\W[a-zA-Z]+\)/, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorObject, "author")); - } - else if (authorObject.match(/By\W/)) { - authorObject = authorObject.replace(/By\s/, ''); - newItem.creators.push(Zotero.Utilities.cleanAuthor(authorObject, "author")); - } - - } - var date = '//table[@class="product_info_text"]/tbody/tr[3]'; - var dateObject = doc.evaluate(date, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (dateObject){ - dateObject = dateObject.textContent; - if (dateObject.match(/Release Date:\s/)){ - newItem.date = dateObject.replace(/Release Date:\s/, ''); - } else { - - var d = new Date(); - date ='//span[@class="arrival_time"]'; - dateObject = doc.evaluate(date, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(dateObject){ - newItem.date = dateObject.textContent.replace(/Available\s/, '')+ " " +d.getFullYear() - ; - } - } - } - var abstract = '//table[@class="product_info_text"]/tbody/tr/td/p[@class="description"]'; - var abstractObject = doc.evaluate(abstract, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (abstractObject){ - abstractObject = abstractObject.textContent; - newItem.abstractNote = abstractObject; - } - - var isbn = "//table/tbody/tr/td[2]/table[4]/tbody/tr[2]/td[2]"; - var isbnObject = doc.evaluate(isbn, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (isbnObject){ - newItem.ISBN = isbnObject.textContent; - } - var publisher = "//table/tbody/tr/td[2]/table[4]/tbody/tr[1]/td[2]/a"; - var publisherObject = doc.evaluate(publisher, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if (publisherObject) { - newItem.publisher= publisherObject.textContent; - } - - newItem.attachments.push({title:"FishPond Record", mimeType:"text/html", url:doc.location.href}); - newItem.complete(); -} - - -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(); - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = '//td[@class="productSearch-data"]/table/tbody/tr/td/div/a'; - var titleObject = doc.evaluate(titles, doc, nsResolver, XPathResult.ANY_TYPE, null); - var next_title; - while ( next_title = titleObject.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - items = Zotero.selectItems(items); - - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/fr-online.de.js b/translators/fr-online.de.js @@ -1,176 +0,0 @@ -{ - "translatorID": "488fe1e0-b7d2-406f-8257-5060418ce9b2", - "label": "fr-online.de", - "creator": "Martin Meyerhoff", - "target": "^http://www\\.fr-online\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-03-26 15:45:54" -} - -/* -fr-online.de Translator -Copyright (C) 2011 Martin Meyerhoff - -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/>. -*/ - -/* -Works w/ search and overviews. I had to include the ugly hack stopping non-articles (photo-streams) to make the multiple item import return an error. Test on: -http://www.fr-online.de/politik/spezials/wikileaks---die-enthuellungsplattform/-/4882932/4882932/-/index.html -http://www.fr-online.de/page/search/fr-online/home/suche/-/1473784/1473784/-/view/asSearch/-/index.html?contextsIds=1472660&docTypes=%22MauArticle,MauGallery,DMBrightcoveVideo,CMDownload,DMMovie,DMEvent,DMVenue%22&offset=5&pageNumber=2&searchMode=SIMPLEALL&sortBy=maupublicationdate&userQuery=Wikileaks -http://www.fr-online.de/wirtschaft/krise/-/1471908/1471908/-/index.html -http://www.fr-online.de/wirtschaft/krise/portugal-koennte-rettungspaket-benoetigen/-/1471908/8251842/-/index.html -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var FR_article_XPath = ".//div[contains(@class, 'ArticleToolBoxIcons')]"; - var FR_multiple_XPath = ".//*[@id='ContainerContent']/div/div[contains(@class, 'Headline2')]/a" - - - if (doc.evaluate(FR_article_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.location.href.match(/^http\:\/\/www\.fr-online\.de\/.*?page\/search/) ) { - Zotero.debug("multiple"); - return "multiple"; - } else if (doc.evaluate(FR_multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - return "multiple"; - } -} - -function authorCase(author) { // Turns All-Uppercase-Authors to normally cased Authors - var words = author.split(/\s/); - var authorFixed = ''; - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - authorFixed = authorFixed + words[i] + ' '; - } - return(authorFixed); -} - -function scrape(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - var FR_article_XPath = ".//div[contains(@class, 'ArticleToolBoxIcons')]"; // this protects against galleries... - if (doc.evaluate(FR_article_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - - var newItem = new Zotero.Item("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the title! - - var title_XPath = '//title' - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = title.split("|")[0].replace(/^\s*|\s*$/g, ''); - - // This is for the author! - - var author_XPath = '//meta[@name="author"]'; - var author= doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - author = author.split(/\,\s|\sund\s/g); - if (author[0].match(/Rundschau/)) { // Frankfurter Rundschau is no author. - author[0] = ""; - } - for (var i in author) { - if (author[i].match(/\s/)) { // only names that contain a space! - author[i] = Zotero.Utilities.trim(author[i]); - author[i] = authorCase(author[i]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - - //Summary - var summary_XPath = '//meta[@name="description"]'; - if (doc.evaluate(summary_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var summary= doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - newItem.abstractNote = Zotero.Utilities.trim(summary); - } - - //Date - var date_XPath = ".//div[contains(@class, 'TB_Date')]"; - var date = doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - date = date.replace(/^\s*Datum\:\s|\s/g, ''); // remove "Datum: " and " " - date = date.split("|"); - var realdate = ""; - realdate = realdate.concat(date[2], "-", date[1], "-", date[0]); - newItem.date = realdate; - - // No Tags. FR does not provide consistently meaningful ones. - - // Publikation - newItem.publicationTitle = "fr-online.de" - - // Section - var section_XPath = '//title' - var section = doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - section = section.split(/\||-/); - newItem.section = section[1].replace(/^\s*|\s*$/g, ''); - - // Attachment - var printurl = doc.location.href; - if (printurl.match("asFirstTeaser")) { - printurl = printurl.replace("asFirstTeaser", "printVersion"); - } else { - printurl = printurl.replace(/\-\/index.html$/, "-/view/printVersion/-/index.html"); - } - newItem.attachments.push({url:printurl, title:doc.title, mimeType:"text/html"}); - newItem.complete() - } -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - - var titles = doc.evaluate(".//*[@id='ContainerContentLinie']/div/h2/a|.//*[@id='ContainerContent']/div/div[contains(@class, 'Headline2')]/a|.//*[@id='ContainerContent']/div/div/div[contains(@class, 'link_article')]/a|.//*[@id='Main']/div[contains(@class, '2ColHP')]/div/div/div[contains(@class, 'Headline2')]/a", doc, nsResolver, XPathResult.ANY_TYPE, null); - - var next_title; - while (next_title = titles.iterateNext()) { - // This excludes the videos, whos link terminates in a hash. - if (next_title.href.match(/.*html$/)) { - items[next_title.href] = next_title.textContent; - } - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/informIT database.js b/translators/informIT database.js @@ -1,185 +0,0 @@ -{ - "translatorID":"add79dfd-7951-4c72-af1d-ce1d50aa4fb4", - "translatorType":4, - "label":"informIT database", - "creator":"Adam Crymble", - "target":"http://www.informit.com", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2008-07-07 14:50:00" -} - -function detectWeb(doc, url) { - if (doc.title.match("Search Results")) { - return "multiple"; - } else if (doc.location.href.match("topics")) { - return "multiple"; - - } else if (doc.location.href.match("product")) { - return "book"; - } else if (doc.location.href.match("guides")) { - return "book"; - - } else if (doc.location.href.match("library")) { - return "bookSection"; - } else if (doc.location.href.match(/articles\/article/)) { - return "bookSection"; - } -} - -//informIT database translator. Code by Adam Crymble - -function scrape(doc, url) { - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var dataTags = new Object(); - - //FOR GUIDES - if (doc.location.href.match("guides")) { - var newItem = new Zotero.Item("book"); - newItem.title = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - var authors = doc.evaluate('//div[@class="titling"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - //FOR ARTICLES - if (doc.location.href.match(/articles\/article/)) { - var newItem = new Zotero.Item("bookSection"); - - var contents = doc.evaluate('//div[@id="articleHeader"]/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//div[@id="articleHeader"]/ul/li)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - var authors = contents.iterateNext().textContent.substr(3); - - if (doc.evaluate('//div[@class="relatedBook"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - newItem.bookTitle = doc.evaluate('//div[@class="relatedBook"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } - - newItem.date = contents.iterateNext().textContent; - - var rights1; - if (xPathCount.numberValue> 2) { - newItem.rights = contents.iterateNext().textContent; - } - - newItem.title = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - } else if (doc.evaluate('//ul[@class="bibliography"]/li', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { - - - //FOR STORE BOOKS - var newItem = new Zotero.Item("book"); - - var contents = doc.evaluate('//ul[@class="bibliography"]/li', doc, nsResolver, XPathResult.ANY_TYPE, null); - var xPathCount = doc.evaluate('count (//ul[@class="bibliography"]/li)', doc, nsResolver, XPathResult.ANY_TYPE, null); - - for (i=0; i<xPathCount.numberValue; i++) { - dataTags[i] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '')); - } - - var authors = dataTags[0].substr(3); - - if (dataTags[1].match("Published")) { - var publisherInfo = dataTags[1].substr(10); - var date = publisherInfo.substr(0, 12); - newItem.date = date; - - if (publisherInfo.match("by ")) { - var publishCo = publisherInfo.split("by "); - newItem.publisher = publishCo[1]; - } - } - var extraStuff = dataTags[2].split(/\n/); - - var pageCut = extraStuff[0].indexOf("Pages"); - var dimensions = extraStuff[0].substr(0, pageCut).split("Dimensions "); - - newItem.description = "Dimensions: " + dimensions[1]; - newItem.pages = extraStuff[0].substr(pageCut+6); - newItem.edition = extraStuff[1].replace(/Edition\:\s| \s\s*/g, ''); - newItem.ISBN = extraStuff[2].substr(31, 18); - newItem.title = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - - - //FOR LIBRARY BOOKS - } else if (doc.location.href.match("library")) { - - var newItem = new Zotero.Item("bookSection"); - - newItem.title = doc.evaluate('//h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - var meta = doc.evaluate('//div[@id="columnOne"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null); - newItem.bookTitle = meta.iterateNext().textContent; - - var authors = meta.iterateNext().textContent.substr(3); - } - - //SHARED - var noMoreAuthor = 0; - - if (authors.match(" and ")) { - authors = authors.split(" and "); - } else if (authors.match(", ")) { - authors = authors.split(", "); - } else { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "author")); - noMoreAuthor = 1; - } - - if (authors.length>0 && noMoreAuthor != 1) { - - for (var i = 0; i < authors.length; i++) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author")); - } - } - - newItem.url = doc.location.href; - if (newItem.publisher) newItem.publisher = Zotero.Utilities.trimInternal(newItem.publisher); - newItem.complete(); -} - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var next_title; - - //xPath for Topics pages, else xPaths for regular search pages. - if (doc.location.href.match("topics")) { - var titles = doc.evaluate('//div[@class="productList articles"]/dl/dt/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } else { - var titles = doc.evaluate('//td[3][@class="results"]/ul/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - var chapters = doc.evaluate('//dt/a', doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.textContent; - } - - if (doc.title.match("Search Results")) { - while (next_title = chapters.iterateNext()) { - items[next_title.href] = next_title.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(); -} -\ No newline at end of file diff --git a/translators/jmlr.js b/translators/jmlr.js @@ -1,116 +0,0 @@ -{ - "translatorID":"80bc4fd3-747c-4dc2-86e9-da7b251e1407", - "translatorType":4, - "label":"Journal of Machine Learning Research", - "creator":"Fei Qi", - "target":"^http://jmlr\\.csail\\.mit\\.edu/papers", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2009-05-05 07:15:00" -} - -function detectWeb(doc, url) { - var contRe = /(v\d+|topic|special)/; - var m = contRe.exec( url ); - if (m) { - if( doc.title.match( "JMLR" ) ) - return "multiple"; - else - return "journalArticle"; - } - return false; -} - -function scrape( doc, url ) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) {} : null; - - var item = new Zotero.Item( "journalArticle" ); - item.url = doc.location.href; - item.publicationTitle = "Journal of Machine Learning Research"; - - // Zotero.debug( 'retrieving title' ); - var title = doc.evaluate( '//div[@id="content"]/h2', doc, ns, - XPathResult.ANY_TYPE, null ).iterateNext(); - if( title ){ - var titlecontent = title.textContent.replace( /^\s+/, '' ); - item.title = titlecontent.replace( /\s+$/, '' ); - } - - var refline = doc.evaluate( '//div[@id="content"]/p', doc, ns, - XPathResult.ANY_TYPE, null ).iterateNext(); - if( refline ) { - var info = refline.textContent.split( ';' ); - var authors = info[0].split( ',' ); - for ( var j = 0; j < authors.length; j++ ){ - item.creators.push( Zotero.Utilities.cleanAuthor( authors[j], "author" ) ); - } - // Zotero.debug( 'retrieving publication info' ); - var volissRe = /\s*(\d+)\(\s*(\w+)\s*\):\s*(\d+\s*--\s*\d+),\s*(\d+)./; - var voliss = info[1].match( volissRe ); - item.volume = voliss[1]; - item.date = voliss[2] + ', ' + voliss[4]; - item.pages = voliss[3]; - } - - var text = doc.evaluate( '//div[@id="content"]', doc, ns, - XPathResult.ANY_TYPE, null ).iterateNext(); - // Zotero.debug( doc.textContent ); - var full = text.textContent.split( 'Abstract' ); - var absatt = full[1].split( '[abs]' ); - var abs =absatt[0].replace( /^\s+/, '' ); - item.abstractNote = abs.replace( /\s+$/, '' ); - //Zotero.debug( item.abstractNote ); - - var atts = doc.evaluate( '//div[@id="content"]//a', doc, ns, - XPathResult.ANY_TYPE, null ); - var att = atts.iterateNext(); - while( att ){ - // Zotero.debug( att.textContent + ' VS ' + att.href ); - if( 0 <= att.textContent.search( 'pdf' ) ) { - item.attachments = [ {url:att.href, - title:item.title, - mimeType:"application/pdf"} ]; - break; - } - att = atts.iterateNext(); - } - item.complete(); -} - -function doWeb( doc, url ) { - var arts = new Array(); - if (detectWeb(doc, url) == "multiple") { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) {} : null; - // Search page - var items = new Object(); - var titles = doc.evaluate( '//div[@id="content"]//dt', doc, ns, - XPathResult.ANY_TYPE, null ); - var urls = doc.evaluate( '//div[@id="content"]//dd/a', doc, ns, - XPathResult.ANY_TYPE, null ); - if( titles && urls ) { - var title = titles.iterateNext(); - var url = urls.iterateNext(); - while( title ) { - while( 0 > url.textContent.search( 'abs' ) ) - url = urls.iterateNext(); - // Zotero.debug( title.textContent + ' AT ' + url.href ); - items[url.href] = title.textContent; - title = titles.iterateNext(); - url = urls.iterateNext(); - } - } - items = Zotero.selectItems(items); - for (var item in items) { - arts.push(item); - } - } else { - arts.push(url); - } - - Zotero.Utilities.processDocuments( arts, scrape, function() {Zotero.done();}); - Zotero.wait(); -} diff --git a/translators/nips.js b/translators/nips.js @@ -1,80 +0,0 @@ -{ - "translatorID":"c816f8ad-4c73-4f6d-914e-a6e7212746cf", - "translatorType":4, - "label":"Neural Information Processing Systems", - "creator":"Fei Qi", - "target":"^http://books.nips.cc/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":false, - "lastUpdated":"2009-12-26 06:00:00" -} - -function detectWeb(doc, url) { - var contRe = /(nips\d+)/; - var m = contRe.exec( url ); - if (m) return "multiple"; - return false; -} - -function grabCitation( paper ) { - //Zotero.debug( paper.title ); - //Zotero.debug( paper.pdf ); - //Zotero.debug( paper.bib ); - Zotero.Utilities.HTTP.doGet( paper.bib, function( text ) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4"); - // Zotero.debug( text ); - translator.setString( text ); - translator.setHandler( "itemDone", function( obj, item ) { - item.attachments = [{url:paper.pdf, title:paper.title, mimeType:"application/pdf"}]; - item.complete(); - } ); - translator.translate(); - } ); -} - -function doWeb( doc, url ) { - var n = doc.documentElement.namespaceURI; - var ns = n ? function(prefix) {} : null; - var titleRe = '//table//td/b'; - var urlRe = '//table//td/a'; - - if (detectWeb(doc, url) == "multiple") { - // Retrive items - var items = new Object(); - var arts = new Array(); - var titles = doc.evaluate( titleRe, doc, ns, XPathResult.ANY_TYPE, null); - var urls = doc.evaluate( urlRe, doc, ns, XPathResult.ANY_TYPE, null); - if( titles ) { - var title = titles.iterateNext(); - var url = urls.iterateNext(); - var idx = 0; - while( title && urls ) { - var art = new Object; - items[idx] = title.textContent; - art.title = items[idx]; - while( 0 > url.textContent.search( 'bib' ) ) - { - url = urls.iterateNext(); - } - art.bib = url.href; - art.pdf = url.href.replace( 'bib', 'pdf' ); - // Zotero.debug( art.title ); - // Zotero.debug( art.pdf ); - // Zotero.debug( art.bib ); - // Zotero.debug( url.href ); - arts.push( art ); - idx++; - title = titles.iterateNext(); - url = urls.iterateNext(); - } - } - items = Zotero.selectItems( items ); - for (var item in items) { - grabCitation( arts[item] ); - } - } - Zotero.wait(); -} diff --git a/translators/taz.de.js b/translators/taz.de.js @@ -1,177 +0,0 @@ -{ - "translatorID": "d84574f1-e4d6-4337-934f-bf9d01173bf0", - "label": "taz.de", - "creator": "Martin Meyerhoff", - "target": "^https?://(?:www\\.)?taz\\.de", - "minVersion": "1.0", - "maxVersion": "", - "priority": 100, - "inRepository": "1", - "translatorType": 4, - "lastUpdated": "2011-06-14 17:18:22" -} - -/* -taz.de Translator -Copyright (C) 2011 Martin Meyerhoff - -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 site is rather heterogenous when it comes to where the author is and all that. -Whenever the script doesn't find something it just returns an empty field. -Try on: -http://www.taz.de/ -http://www.taz.de/1/archiv/detailsuche/?tx_hptazsearch_pi1[search_term]=Krise&tx_hptazsearch_pi2[submit_button].x=0&tx_hptazsearch_pi2[submit_button].y=0 -http://www.taz.de/1/debatte/kolumnen/artikel/1/haengt-sie-hoeher-1/ -*/ - -function detectWeb(doc, url) { - - // I use XPaths. Therefore, I need the following block. - - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var taz_ArticleTitle_XPath = ".//h1"; - var taz_Multiple_XPath = ".//*[@id='hauptspalte']/div/ul/li/a/h3"; - var taz_Search_XPath = ".//*[@id='hauptspalte']/div/div/ul/li/a/h3"; - if (doc.evaluate(taz_ArticleTitle_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("newspaperArticle"); - return "newspaperArticle"; - } else if (doc.evaluate(taz_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - return "multiple"; - } else if (doc.evaluate(taz_Search_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - Zotero.debug("multiple"); - return "multiple"; - } -} - -function authorCase(author) { // Turns All-Uppercase-Authors to normally cased Authors - var words = author.split(/\s|-/); - var authorFixed = ''; - for (var i in words) { - words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase(); - authorFixed = authorFixed + words[i] + ' '; - } - return(authorFixed); -} - -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("newspaperArticle"); - newItem.url = doc.location.href; - - - // This is for the title! - - var title_XPath = '//title'; - var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.title = title.split(" - ")[0]; - - // Summary - var description_XPath = '//meta[contains(@name, "description")]'; - var description = doc.evaluate(description_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content; - summary = description.replace(/\sVON.*$/g, ''); - newItem.abstractNote = summary.replace(/KOMMENTAR|KOLUMNE.*$/g, ''); - - // Authors - var author_XPath = "//*[contains(@class, 'sectbody')]/*/span[contains(@class, 'author')]"; - if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ) { - var author = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - } else if (description.match(/^(KOMMENTAR)|(KOLUMNE)\sVON/)){ - Zotero.debug(description); - author = description.replace(/^(KOMMENTAR)|(KOLUMNE)\sVON\s/, ''); - } else { - var author = ""; - } - author = author.replace(/^\s*|\s*$/g, ''); - author = author.replace(".", ". "); // in case a space is missing. - author = author.replace("VON ", ''); - author = author.replace(/\s+/g, ' '); - author = author.split(/\sund\s|\su\.\s|\,\s|\&/); - for (var i in author) { - if (author[i].match(/\s/)) { // only names that contain a space! - author[i] = author[i].replace(/^\s*|\s*$/g, ''); - author[i] = authorCase(author[i]); - newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author")); - } - } - - - - // Section - var section_XPath = ".//*[contains(@class, 'selected')]/ul/li[contains(@class, 'selected')]"; - if (doc.evaluate(section_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ) { - var section= doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - newItem.section = section; - } - - // Date - var date_XPath = ".//div[contains(@class, 'secthead')]"; - var date = doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent; - date = date.replace(/^\s*|\s*$/g, ''); - date = date.substr(0,10); - newItem.date = date; - - newItem.attachments.push({url:doc.location.href, title:doc.title, mimeType:"text/html"}); - newItem.publicationTitle = "die tageszeitung" - - newItem.complete(); - -} - - -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(); - - if (detectWeb(doc, url) == "multiple") { - var items = new Object(); - var taz_Multiple_XPath = ".//*[@id='hauptspalte']/div/ul/li/a"; - var taz_Search_XPath = ".//*[@id='hauptspalte']/div/div/ul/li/a"; - - if (doc.evaluate(taz_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var titles = doc.evaluate(taz_Multiple_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - } else if (doc.evaluate(taz_Search_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ - var titles = doc.evaluate(taz_Search_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null); - } - - - var next_title; - while (next_title = titles.iterateNext()) { - items[next_title.href] = next_title.innerHTML; - items[next_title.href] = items[next_title.href].replace(/(\<h4.*?\>.*?\<\/h4\>\<h3.*?\>)(.*)\<\/h3\>.*/, '$2'); - } - items = Zotero.selectItems(items); - for (var i in items) { - articles.push(i); - } - Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();}); - Zotero.wait(); - } else { - scrape(doc, url); - } -} diff --git a/translators/unAPI.js b/translators/unAPI.js @@ -1,393 +0,0 @@ -{ - "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", - "refer", "bibtex", "rdf_dc"]; -var FORMAT_GUIDS = { - "rdf_zotero":"5e3ad958-ac79-463d-812b-a86a9235c28f", - "rdf_bibliontology":"14763d25-8ba0-45df-8f52-b8d1108e7ac9", - "mods":"0e2235e7-babf-413c-9acf-f27cce5f059c", - "marc":"a6ee60df-1ddc-4aae-bb25-45e0537be973", - "unimarc":"a6ee60df-1ddc-4aae-bb25-45e0537be973", - "ris":"32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7", - "refer":"881f60f2-0802-411a-9228-ce5f47b64c7d", - "bibtex":"9cb70025-a888-4a29-a210-93ec52da40d4", - "rdf_dc":"5e3ad958-ac79-463d-812b-a86a9235c28f" -}; - -var unAPIResolver = false; -var defaultFormat, unAPIIDs; - -/** - * A class to describe an unAPI format description - * @property isSupported {Boolean} Whether Zotero supports a format contained in this description - * @property name {String} The unAPI format name, used to retrieve item descriptions - * @property translatorID {String} The ID of the translator used to read this format - * - * @constructor - * @param {String} aXML unAPI format description XML - */ -UnAPIFormat = function(aXML) { - var parser = new DOMParser(); - var doc = parser.parseFromString(aXML.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, ""), "text/xml"); - - var foundFormat = new Object(); - - // Loop through to determine format name - var nodes = doc.documentElement.getElementsByTagName("format"); - var nNodes = nodes.length; - var node, name, lowerName, format; - for(var i=0; i<nNodes; i++) { - node = nodes[i]; - name = node.getAttribute("name"); - lowerName = name.toLowerCase(); - format = false; - - // Look for formats we can recognize - if(["rdf_zotero", "rdf_bibliontology", "bibtex", "endnote", "rdf_dc"].indexOf(lowerName) != -1) { - format = lowerName; - } else if(lowerName == "rdf_bibliontology") { - format = "rdf_bibliontology"; - } else if(lowerName === "mods" - || node.getAttribute("namespace_uri") === "http://www.loc.gov/mods/v3" - || node.getAttribute("docs") === "http://www.loc.gov/standards/mods/" - || node.getAttribute("type") === "application/mods+xml") { - format = "mods"; - } else if(lowerName.match(/^marc\b/) - || node.getAttribute("type") === "application/marc") { - format = "marc"; - } else if(lowerName.match(/^unimarc\b/) - || node.getAttribute("type") === "application/unimarc") { - format = "unimarc"; - } else if(node.getAttribute("docs") == "http://www.refman.com/support/risformat_intro.asp" - || lowerName.match(/^ris\b/)) { - format = "ris"; - } - - if(format) foundFormat[format] = name; - } - - // Loop through again to determine optimal supported format - for(var i=0; i<RECOGNIZABLE_FORMATS.length; i++) { - if(foundFormat[RECOGNIZABLE_FORMATS[i]]) { - this.isSupported = true; - this.name = foundFormat[RECOGNIZABLE_FORMATS[i]]; - this.translatorID = FORMAT_GUIDS[RECOGNIZABLE_FORMATS[i]]; - return; - } - } - - this.isSupported = false; -} - -/** - * A class encapsulating an UnAPI ID - * @property format {UnAPIFormat} Information regarding the format - * @property items {Zotero.Item[]} Items corresponding to this ID - * - * @constructor - * @param {String} id The ID contained in an abbr tag - */ -UnAPIID = function(id) { - this.id = id; - unAPIIDs[id] = this; -} - -UnAPIID.prototype = { - /** - * Gets the item type for this item - * @param {Function} callback Callback to be passed itemType when it is known - */ - "getItemType":function(callback) { - var me = this; - this.getItems(function(items) { - if(items.length === 0) { - callback(false); - } else if(items.length === 1) { - callback(items[0].itemType); - } else { - callback("multiple"); - } - }); - }, - - /** - * Gets items associated with this ID - * @param {Function} callback Callback to be passed items when they have been retrieved - */ - "getItems":function(callback) { - if(this.items) { - callback(me.items); - return; - } - - var me = this; - this.items = []; - this.isSupported(function(isSupported) { - if(!isSupported) { - callback([]); - return; - } - - Zotero.Utilities.HTTP.doGet(unAPIResolver+"?id="+me.id+"&format="+me.format.name, function(text) { - var translator = Zotero.loadTranslator("import"); - translator.setTranslator(me.format.translatorID); - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - // add item to array - me.items.push(item); - }); - translator.setHandler("done", function(obj) { - // run callback on item array - callback(me.items); - }); - try { - translator.translate(); - } catch(e) { - Zotero.debug("unAPI: Could not parse "+me.format.name+" metadata for ID "+me.id+": "+e); - callback(me.items); - } - }); - }); - }, - - /** - * Determines whether Zotero can handle this ID - * @param {Function} callback Callback to be passed isSupported when it is known - */ - "isSupported":function(callback) { - if(this.hasOwnProperty("format")) { - callback(this.format.isSupported); - return; - } - - var me = this; - - getDefaultFormat(function(defaultFormat) { - // first try default format, since this won't require >1 HTTP request - if(defaultFormat.isSupported) { - me.format = defaultFormat; - callback(true); - } else { - // if no supported default format, try format for this item - Zotero.Utilities.HTTP.doGet(unAPIResolver+"?id="+me.id, function(text) { - me.format = new UnAPIFormat(text); - callback(!!me.format.isSupported); - }); - } - }); - } -} - -/** - * This and the x: prefix in the XPath are to work around an issue with pages - * served as application/xhtml+xml - * - * https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript#Implementing_a_default_namespace_for_XML_documents - */ -function nsResolver() { - return 'http://www.w3.org/1999/xhtml'; -} - -/** - * Extracts UnAPIIDs from a document - * @param {document} A document object from which to extract unAPIIds - * @return {UnAPIID[]} The unAPI ID objects extracted from the document - */ -function getUnAPIIDs(doc) { - // look for a resolver - var newUnAPIResolver = doc.evaluate('//x:link[@rel="unapi-server"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(!newUnAPIResolver) return []; - newUnAPIResolver = newUnAPIResolver.getAttribute("href"); - if(unAPIResolver !== newUnAPIResolver) { - // if unAPI resolver has changed, clear - defaultFormat = false; - unAPIResolver = newUnAPIResolver; - unAPIIDs = []; - } - - // look for abbrs - var abbrs = doc.evaluate('//x:abbr[contains(@class, " unapi-id") or contains(@class, "unapi-id ") or @class="unapi-id"][@title]', - doc, nsResolver, XPathResult.ANY_TYPE, null); - var abbr; - var ids = []; - while(abbr = abbrs.iterateNext()) { - var id = abbr.getAttribute("title"); - ids.push(unAPIIDs[id] ? unAPIIDs[id] : new UnAPIID(id)); - } - - return ids; -} - - -/** - * Retrieves the list of formats available for all items accessible through this unAPI resolver - * @param {Function} callback A callback to be passed the format when it is available - */ -function getDefaultFormat(callback) { - if(defaultFormat) { - callback(defaultFormat); - } else { - Zotero.Utilities.HTTP.doGet(unAPIResolver, function(text) { - // determine format of this item - defaultFormat = new UnAPIFormat(text); - callback(defaultFormat); - }); - } -} -/** - * Determines itemType for detection - */ -function determineDetectItemType(ids, supportedId) { - var id = ids.shift(); - id.isSupported(function(isSupported) { - if(isSupported && supportedId !== undefined) { - // If there are multiple items with valid itemTypes, use "multiple" - Zotero.done("multiple"); - } else if(ids.length) { - // If IDs remain to be handled, handle the next one - determineDetectItemType(ids, (isSupported ? id : supportedId)); - } else { - // If all IDs have been handled, get foundItemType for only supported ID - if(isSupported) { - id.getItemType(Zotero.done); - } else { - Zotero.done(false); - } - } - }); -} - -/** - * Get all items - * @param {UnAPIID[]} ids List of UnAPI IDs - * @param {Function} callback Function to pass item array to when items have been retrieved - * @param {Zotero.Item[]} items Item array; used for recursive calls - **/ -function getAllItems(ids, callback, items) { - var id = ids.shift(); - id.getItems(function(retrievedItems) { - var collectedItems = (items ? items.concat(retrievedItems) : retrievedItems); - - if(ids.length) { - getAllItems(ids, callback, collectedItems); - } else { - callback(collectedItems); - } - }); -} - -function detectWeb(doc, url) { - // get unAPI IDs - var ids = getUnAPIIDs(doc); - if(!ids.length) return false; - - // now we need to see if the server actually gives us bibliographic metadata, and determine the - // type - Zotero.wait(); - - if(!ids.length === 1) { - // Only one item, so we will just get its item type - ids[0].getItemType(Zotero.done); - } else { - // Several items. We will need to call determineDetectItemType - determineDetectItemType(ids); - } -} - -function doWeb(doc, url) { - var ids = getUnAPIIDs(doc); - - Zotero.wait(); - - getAllItems(ids, function(items) { - // get the domain we're scraping, so we can use it for libraryCatalog - domain = doc.location.href.match(/https?:\/\/([^/]+)/); - - if(items.length == 1) { - // If only one item, just complete it - items[0].libraryCatalog = domain[1]; - items[0].complete(); - } else if(items.length > 0) { - // If multiple items, extract their titles - var itemTitles = []; - for(var i in items) { - itemTitles[i] = items[i].title; - } - - // Show item selection dialog - var chosenItems = Zotero.selectItems(itemTitles); - if(!chosenItems) Zotero.done(true); - - // Complete items - for(var i in chosenItems) { - items[i].libraryCatalog = domain[1]; - items[i].complete(); - } - } - - Zotero.done(); - 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 diff --git a/translators/washingtonpost.com.js b/translators/washingtonpost.com.js @@ -1,120 +0,0 @@ -{ - "translatorID":"d1bf1c29-4432-4ada-8893-2e29fc88fd9e", - "translatorType":4, - "label":"washingtonpost.com", - "creator":"Simon Kornblith", - "target":"^http://www\\.washingtonpost\\.com/", - "minVersion":"1.0.0b3.r1", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2007-06-21 20:10:00" -} - -function detectWeb(doc, url) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - // don't say we can scrape when we can't; make sure user is logged in - var signedIn = doc.evaluate('//a[text() = "Sign out" or text() = "Sign Out"]', - doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext(); - if(!signedIn) { - return; - } - - var articleRegexp = /http:\/\/www\.washingtonpost\.com\/wp-dyn\/content\/article\/[0-9]+\/[0-9]+\/[0-9]+\/[^\/]+\.html/ - if(articleRegexp.test(url)) { - return "newspaperArticle"; - } else { - var aTags = doc.getElementsByTagName("a"); - for(var i=0; i<aTags.length; i++) { - if(articleRegexp.test(aTags[i].href)) { - return "multiple"; - } - } - } -} - -function scrape(doc) { - var namespace = doc.documentElement.namespaceURI; - var nsResolver = namespace ? function(prefix) { - if (prefix == 'x') return namespace; else return null; - } : null; - - var newItem = new Zotero.Item("newspaperArticle"); - newItem.publicationTitle = "The Washington Post"; - newItem.ISSN = "0740-5421"; - - newItem.url = doc.location.href; - var metaTags = doc.getElementsByTagName("meta"); - - // Elena's code to grab print version (all pages) - snapshotURL=doc.location.href.replace(".html", "_pf.html"); - newItem.attachments.push({title:"Washington Post Snapshot", mimeType:"text/html", url:snapshotURL, snapshot:true}); - - // grab title from doc title - newItem.title = doc.title.replace(" - washingtonpost.com", ""); - - var byline = doc.evaluate('//div[@id="byline"]', doc, nsResolver, - XPathResult.ANY_TYPE, null).iterateNext(); - // grab authors from byline - if(byline) { - var authors = byline.textContent.substr(3).split(" and "); - for each(var author in authors) { - newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author")); - } - } - - var fonts = doc.evaluate('//div[@id="article"]/p/font/text()', doc, nsResolver, - XPathResult.ANY_TYPE, null); - var font; - while(font = fonts.iterateNext()) { - var pageRe = /([^;]+);(?:[\xA0 ]+Pages?[\xA0 ]+([A-Z0-9\-]+))?/ - // grab pages and date - Zotero.debug(Zotero.Utilities.trimInternal(font.nodeValue)); - var m = pageRe.exec(font.nodeValue); - if(m) { - newItem.date = m[1]; - newItem.pages = m[2]; - break; - } - } - - // grab tags from meta tag - var keywords = doc.getElementsByTagName("meta"); - if(keywords) { - keywords = keywords.namedItem("keywords"); - if(keywords) { - keywords = keywords.getAttribute("content"); - if(keywords) { - newItem.tags = keywords.split(/, ?/); - } - } - } - - newItem.complete(); -} - -function doWeb(doc, url) { - var articleRegexp = /http:\/\/www\.washingtonpost\.com\/wp-dyn\/content\/article\/[0-9]+\/[0-9]+\/[0-9]+\/[^\/]+\.html/ - if(articleRegexp.test(url)) { - scrape(doc); - } else { - var items = Zotero.Utilities.getItemArray(doc, doc, articleRegexp); - items = Zotero.selectItems(items); - - if(!items) { - return true; - } - - var urls = new Array(); - for(var i in items) { - urls.push(i); - } - - Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); }); - Zotero.wait(); - } -} -\ No newline at end of file diff --git a/translators/wsj.js b/translators/wsj.js @@ -1,42 +0,0 @@ -{ - "translatorID":"53f8d182-4edc-4eab-b5a1-141698a1303b", - "translatorType":4, - "label":"Wall Street Journal", - "creator":"Matt Burton", - "target":"http://online\\.wsj\\.com/article/", - "minVersion":"1.0.0b4.r5", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-12-10 00:45:00" -} - -function detectWeb(doc, url){ - return "newspaperArticle"; -} - -function getDatum(text, key){ - var reg = new RegExp(key+":'(.*?)'(?=,|})"); - return unescape(Zotero.Utilities.unescapeHTML(reg.exec(text)[1].replace("+"," ", "g"))); -} - -function doWeb(doc, url){ - var text = doc.documentElement.innerHTML; - var item = new Zotero.Item("newspaperArticle"); - var metadata = text.match(/AT_VARS=({[^}]*})/)[1]; - var authors = getDatum(text, "authors").split(','); - for each (var aut in authors) { - if (aut.length > 0) { - item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author")); - } - } - item.publicationTitle = "wsj.com"; - item.date = getDatum(text, "publicationDate"); - item.abstractNote = getDatum(text, "bodyText"); - item.title = getDatum(text, "articleHeadline").replace("\\",""); - item.url = url; - item.section = getDatum(text, "articleType"); - item.attachments.push({url:url, title:"Wall Street Journal Snapshot", mimeType:"text/html"}); - - item.complete(); -} -\ No newline at end of file diff --git a/translators/zotero.org.js b/translators/zotero.org.js @@ -1,194 +0,0 @@ -{ - "translatorID":"c82c574d-7fe8-49ca-a360-a05d6e34fec0", - "translatorType":4, - "label":"zotero.org", - "creator":"Dan Stillman", - "target":"^https?://[^/]*zotero\\.org/(groups/)?[^/]+/(items(/?[0-9]+?)?|items/collection/[0-9]+)(\\?.*)?$", - "minVersion":"1.0", - "maxVersion":"", - "priority":100, - "inRepository":true, - "lastUpdated":"2009-09-29 23:15:00" -} - -function detectWeb(doc, url) { - // Skip private groups - if (url.match(/\/groups\/[0-9]+\/items/)) { - return false; - } - - var a = doc.evaluate('//li[@id="library-tab"]/a[text()="My Library"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - // Skip current user's library - if (a && url.indexOf(a.href.match(/(^.+)\/items/)[1]) == 0) { - return false; - } - // Library and collections - if (url.match(/\/items\/?(\?.*)?$/) || url.match(/\/items\/collection\/[0-9]+(\?.*)?$/)) { - if (!doc.getElementById("field-table")) { - return false; - } - return "multiple"; - } - - // Individual item - else if (url.match(/\/items\/[0-9]+(\?.*)?$/)) { - // TODO: embed in page, because this is absurd - var typeMap = { - "Note": "note", - "Attachment": "attachment", - "Book": "book", - "Book Section": "bookSection", - "Journal Article": "journalArticle", - "Magazine Article": "magazineArticle", - "Newspaper Article": "newspaperArticle", - "Thesis": "thesis", - "Letter": "letter", - "Manuscript": "manuscript", - "Interview": "interview", - "Film": "film", - "Artwork": "artwork", - "Web Page": "webpage", - "Report": "report", - "Bill": "bill", - "Case": "case", - "Hearing": "hearing", - "Patent": "patent", - "Statute": "statute", - "E-mail": "email", - "Map": "map", - "Blog Post": "blogPost", - "Instant Message": "instantMessage", - "Forum Post": "forumPost", - "Audio Recording": "audioRecording", - "Presentation": "presentation", - "Video Recording": "videoRecording", - "TV Broadcast": "tvBroadcast", - "Radio Broadcast": "radioBroadcast", - "Podcast": "podcast", - "Computer Program": "computerProgram", - "Conference Paper": "conferencePaper", - "Document": "document", - "Encyclopedia Article":"encyclopediaArticle", - "Dictionary Entry": "dictionaryEntry" - }; - var td = doc.evaluate('//div[@id="content"]/div[@class="major-col"]/table//tr[th[text()="Item Type"]]/td', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - return td ? typeMap[td.textContent] : "book"; - } -} - -function xmlToItem(xmlItem) { - // "with ({});" needed to fix default namespace scope issue - // See https://bugzilla.mozilla.org/show_bug.cgi?id=330572 - default xml namespace = 'http://zotero.org/ns/transfer'; with ({}); - var itemType = xmlItem.@itemType; - - // FIXME: translate.js only allow top-level attachments in import mode - if (itemType == 'attachment') { - itemType = 'document'; - } - - var newItem = new Zotero.Item(itemType); - - // Don't auto-set repository - newItem.repository = false; - - for each(var field in xmlItem.field) { - var fieldName = field.@name.toString(); - newItem[fieldName] = field.toString(); - } - - // Item creators - for each(var creator in xmlItem.creator) { - var data = { - creatorType: creator.@creatorType - }; - if (creator.creator.fieldMode == 1) { - data.fieldMode = 1; - data.lastName = creator.creator.name.toString(); - } - else { - data.firstName = creator.creator.firstName.toString(); - data.lastName = creator.creator.lastName.toString(); - } - newItem.creators.push(data); - } - - // Both notes and attachments might have parents and notes - if (itemType == 'note' || itemType == 'attachment') { - newItem.note = xmlItem.note.toString(); - } - - // Attachment metadata - if (itemType == 'attachment') { - //newItem.attachmentLinkMode = parseInt(xmlItem.@linkMode); - newItem.mimeType = xmlItem.@mimeType.toString(); - newItem.charset = xmlItem.@charset.toString(); - var path = xmlItem.path.toString(); - if (path) { - newItem.path = path; - } - } - - newItem.complete(); - -} - - -function doWeb(doc, url) { - var nsAtom = new Namespace('http://www.w3.org/2005/Atom'); - var nsZXfer = new Namespace('http://zotero.org/ns/transfer'); - - if (detectWeb(doc, url) == "multiple") { - var itemRe = /^https?:\/\/[^\/]*zotero\.org\/(?:groups\/)?[^\/]+\/items\/([0-9]+)/; - - var link = doc.evaluate('//link[@type="application/atom+xml" and @rel="alternate"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext(); - var libraryURI = link.getAttribute('href'); - - var column = doc.evaluate('//table[@id="field-table"]//td[1][@class="title"][not(contains(./a, "Unpublished Note"))]', doc, null, XPathResult.ANY_TYPE, null); - var elems = [], td; - while (td = column.iterateNext()) { - elems.push(td); - } - var items = Zotero.Utilities.getItemArray(doc, elems); - - items = Zotero.selectItems(items); - if (!items) { - return true; - } - - var apiURIs = [], itemID, apiURI; - for (var url in items) { - itemID = url.match(itemRe)[1]; - apiURI = libraryURI + "/" + itemID + "?content=full"; - apiURIs.push(apiURI); - } - - Zotero.Utilities.HTTP.doGet(apiURIs, function(text) { - // Strip XML declaration and convert to E4X - var entry = new XML(text.replace(/<\?xml.*\?>/, '')); - xmlToItem(entry.nsAtom::content.nsZXfer::item); - }, function () { Zotero.done(); }); - } - else { - if (url.indexOf("/groups/") == -1) { - var userID = doc.getElementById('libraryUserID').getAttribute('title'); - var apiPrefix = "https://api.zotero.org/users/" + userID + "/"; - var itemRe = /^https?:\/\/[^\/]*zotero\.org\/[^\/]+\/items\/([0-9]+)/; - } - // Group library - else { - var groupID = doc.getElementById('libraryGroupID').getAttribute('title'); - var apiPrefix = "https://api.zotero.org/groups/" + groupID + "/"; - var itemRe = /^https?:\/\/[^\/]*zotero\.org\/groups\/[^\/]+\/items\/([0-9]+)/; - } - var itemID = url.match(itemRe)[1]; - var apiURL = apiPrefix + "items/" + itemID + "?content=full"; - Zotero.Utilities.doGet(apiURL, function (text) { - // Strip XML declaration and convert to E4X - var entry = new XML(text.replace(/<\?xml.*\?>/, '')); - xmlToItem(entry.nsAtom::content.nsZXfer::item); - Zotero.done(); - }); - } - Zotero.wait(); -}