diff --git a/chrome/content/zotero/bibliography.js b/chrome/content/zotero/bibliography.js index a52fb3f4d0..5db4ad7537 100644 --- a/chrome/content/zotero/bibliography.js +++ b/chrome/content/zotero/bibliography.js @@ -86,7 +86,8 @@ var Zotero_File_Interface_Bibliography = new function() { // ONLY FOR bibliography.xul: export options if(document.getElementById("save-as-rtf")) { // restore saved bibliographic settings - document.getElementById(Zotero.Prefs.get("export.bibliographySettings")).setAttribute("selected", "true"); + document.getElementById('output-radio').selectedItem = + document.getElementById(Zotero.Prefs.get("export.bibliographySettings")); // disable clipboard on the Mac, because it can't support formatted // output diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js index 1d26cc3987..f9b1f9c92f 100644 --- a/chrome/content/zotero/xpcom/data/item.js +++ b/chrome/content/zotero/xpcom/data/item.js @@ -2484,9 +2484,10 @@ Zotero.Item.prototype.getAttachments = function() { } var sql = "SELECT A.itemID, value AS title FROM itemAttachments A " - + "NATURAL JOIN items I LEFT JOIN itemData ID USING (itemID) " + + "NATURAL JOIN items I LEFT JOIN itemData ID " + + "ON (fieldID=110 AND A.itemID=ID.itemID) " + "LEFT JOIN itemDataValues IDV " - + "ON (fieldID=110 AND ID.valueID=IDV.valueID) " + + "ON (ID.valueID=IDV.valueID) " + "WHERE sourceItemID=?"; if (Zotero.Prefs.get('sortAttachmentsChronologically')) { diff --git a/chrome/content/zotero/xpcom/ingester.js b/chrome/content/zotero/xpcom/ingester.js index 3aa22a8a10..0abe14562a 100644 --- a/chrome/content/zotero/xpcom/ingester.js +++ b/chrome/content/zotero/xpcom/ingester.js @@ -586,10 +586,12 @@ Zotero.OpenURL = new function() { } } } else if(key == "rft.description") { - item.extra = value; + item.abstractNote = value; } else if(key == "rft.rights") { item.rights = value; - } else if(key == "rft.subject") { + } else if(key == "rft.language") { + item.language = value; + } else if(key == "rft.subject") { item.tags.push(value); } else if(key == "rft.type") { if(Zotero.ItemTypes.getID(value)) item.itemType = value; diff --git a/chrome/content/zotero/xpcom/itemTreeView.js b/chrome/content/zotero/xpcom/itemTreeView.js index 388bbcbd7a..316b0d3f22 100644 --- a/chrome/content/zotero/xpcom/itemTreeView.js +++ b/chrome/content/zotero/xpcom/itemTreeView.js @@ -1584,7 +1584,7 @@ Zotero.ItemTreeView.prototype.onDragStart = function (evt,transferData,action) Zotero.QuickCopy.getContentFromItems(items, format, exportCallback); } else if (mode.indexOf('bibliography') == 0) { - var content = Zotero.QuickCopy.getContentFromItems(items, format); + var content = Zotero.QuickCopy.getContentFromItems(items, format, null, evt.shiftKey); transferData.data.addDataForFlavour("text/unicode", content.text); if (content.html) { transferData.data.addDataForFlavour("text/html", content.html); diff --git a/chrome/content/zotero/xpcom/quickCopy.js b/chrome/content/zotero/xpcom/quickCopy.js index b89d1bbb26..92b2f010d1 100644 --- a/chrome/content/zotero/xpcom/quickCopy.js +++ b/chrome/content/zotero/xpcom/quickCopy.js @@ -131,7 +131,7 @@ Zotero.QuickCopy = new function() { * If bibliography format, the process is synchronous and an object * contain properties 'text' and 'html' is returned. */ - function getContentFromItems(items, format, callback) { + function getContentFromItems(items, format, callback, modified) { var [mode, format] = format.split('='); var [mode, contentType] = mode.split('/'); @@ -192,10 +192,25 @@ Zotero.QuickCopy = new function() { var csl = Zotero.Cite.getStyle(format); var itemSet = csl.createItemSet(items); - var bibliography = { - text: csl.formatBibliography(itemSet, contentType == "html" ? "HTML" : "Text"), - html: csl.formatBibliography(itemSet, "HTML") - }; + + // Copy citations if shift key pressed + if (modified) { + var itemIDs = []; + for (var i=0; i =>
- * => … + * => … */ Zotero.Utilities.prototype.htmlSpecialChars = function(str) { if (typeof str != 'string') { @@ -178,7 +178,7 @@ Zotero.Utilities.prototype.htmlSpecialChars = function(str) { case 'BREAK': return '
'; case 'HELLIP': - return '…'; + return '…'; default: return p1; } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index c112f3aa4c..f162a92c45 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1720,6 +1720,7 @@ Zotero.Browser = new function() { // Create a hidden browser var hiddenBrowser = win.document.createElement("browser"); + hiddenBrowser.setAttribute('type', 'content'); hiddenBrowser.setAttribute('disablehistory', 'true'); win.document.documentElement.appendChild(hiddenBrowser); Zotero.debug("created hidden browser (" diff --git a/scrapers.sql b/scrapers.sql index c3b18b4382..59715555f9 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -22,7 +22,7 @@ -- Set the following timestamp to the most recent scraper update date -REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2008-06-17 19:30:00')); +REPLACE INTO version VALUES ('repository', STRFTIME('%s', '2008-07-07 14:50:00')); REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b4.r1', '', '2008-06-16 21:30:00', '1', '100', '4', 'Amazon.com', 'Sean Takats and Michael Berkowitz', '^https?://(?:www\.)?amazon', 'function detectWeb(doc, url) { @@ -1091,6 +1091,1153 @@ REPLACE INTO translators VALUES ('88915634-1af6-c134-0171-56fd198235ed', '1.0.0b Zotero.wait(); }'); +REPLACE INTO translators VALUES ('add79dfd-7951-4c72-af1d-ce1d50aa4fb4', '1.0.0b4.r5', '', '2008-07-07 14:50:00', '0', '100', '4', 'informIT database', 'Adam Crymble', 'http://www.informit.com', +'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; i0 && 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(); +}'); + +REPLACE INTO translators VALUES ('9932d1a7-cc6d-4d83-8462-8f6658b13dc0', '1.0.0b4.r5', '', '2008-07-07 14:50:00', '0', '100', '4', 'Biblio.com', 'Adam Crymble and Michael Berkowitz', 'http://www.biblio.com/', +'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=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(); @@ -11562,7 +12898,7 @@ function doWeb(doc,url) if (row) { //Single Article - var url=row.textContent+"/citation"; + 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'');}); @@ -11749,7 +13085,7 @@ REPLACE INTO translators VALUES ('a1a97ad4-493a-45f2-bd46-016069de4162', '1.0.0b }'); -REPLACE INTO translators VALUES ('b61c224b-34b6-4bfd-8a76-a476e7092d43', '1.0.0b4.r5', '', '2008-05-22 19:00:00', '1', '100', '4', 'SSRN', 'Michael Berkowitz', 'http://papers\.ssrn\.com/', +REPLACE INTO translators VALUES ('b61c224b-34b6-4bfd-8a76-a476e7092d43', '1.0.0b4.r5', '', '2008-07-03 08:00:00', '1', '100', '4', 'SSRN', 'Michael Berkowitz', 'http://papers\.ssrn\.com/', 'function detectWeb(doc, url) { var namespace=doc.documentElement.namespaceURI; var nsResolver=namespace?function(prefix) { @@ -11831,7 +13167,11 @@ REPLACE INTO translators VALUES ('b61c224b-34b6-4bfd-8a76-a476e7092d43', '1.0.0b if (bit.textContent.match(/\d{4}/)) item.date = Zotero.Utilities.trimInternal(bit.textContent); } item.url = doc.location.href; + 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; + } 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;}); @@ -16149,7 +17489,7 @@ function doWeb(doc, url) { Zotero.wait(); }'); -REPLACE INTO translators VALUES ('9c335444-a562-4f88-b291-607e8f46a9bb', '1.0.0b3.r1', '', '2006-12-15 15:11:00', 1, 100, 4, 'Berkeley Library Catalog', 'Simon Kornblith', '^https?://[^/]*berkeley.edu[^/]*/WebZ/(?:html/results.html|FETCH)\?.*sessionid=', +REPLACE INTO translators VALUES ('9c335444-a562-4f88-b291-607e8f46a9bb', '1.0.0b3.r1', '', '2008-07-02 11:00:00', '1', '100', '4', 'Berkeley Library Catalog', 'Simon Kornblith', '^https?://[^/]*berkeley.edu[^/]*/WebZ/(?:html/results.html|FETCH)\?.*sessionid=', 'function detectWeb(doc, url) { var resultsRegexp = /\/WebZ\/html\/results.html/i if(resultsRegexp.test(url)) { @@ -16157,7 +17497,7 @@ REPLACE INTO translators VALUES ('9c335444-a562-4f88-b291-607e8f46a9bb', '1.0.0b } else { return "book"; } -}', +}', 'function reformURL(url) { return url.replace(/fmtclass=[^&]*/, "")+":fmtclass=marc"; } @@ -16198,19 +17538,17 @@ function doWeb(doc, url) { var record = new marc.record(); while(elmt = elmts.iterateNext()) { - var field = Zotero.Utilities.superCleanString(doc.evaluate(''./TD[1]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue); - var value = doc.evaluate(''./TD[2]/text()[1]'', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue; - + 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]; - value = Zotero.Utilities.cleanString(value.substr(5)). - replace(/\$([a-z0-9]) /g, marc.subfieldDelimiter+"$1"); + if (value.match(/^\d{1,2}\s{3}/)) value = Zotero.Utilities.cleanString(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; } @@ -16220,7 +17558,12 @@ function doWeb(doc, url) { 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(); @@ -16229,7 +17572,7 @@ function doWeb(doc, url) { Zotero.wait(); }'); -REPLACE INTO translators VALUES ('d0b1914a-11f1-4dd7-8557-b32fe8a3dd47', '1.0.0b3.r1', '', '2008-06-12 19:30:00', '1', '100', '4', 'EBSCOhost', 'Simon Kornblith', 'https?://[^/]+/(?:bsi|ehost)/(?:results|detail|folder)', +REPLACE INTO translators VALUES ('d0b1914a-11f1-4dd7-8557-b32fe8a3dd47', '1.0.0b3.r1', '', '2008-07-02 11:00:00', '1', '100', '4', 'EBSCOhost', 'Simon Kornblith and Michael Berkowitz', 'https?://[^/]+/(?:bsi|ehost)/(?:results|detail|folder)', 'function detectWeb(doc, url) { var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { @@ -16284,6 +17627,7 @@ function downloadFunction(text) { // load translator for RIS var test = text.match(/UR\s+\-(.*)/g); if (test[0].match("@")) text = text.replace(/UR\s+\-(.*)/, ""); + if (text.match(/AB\s\s\-/)) text = text.replace(/AB\s\s\-/, "N2 -"); var translator = Zotero.loadTranslator("import"); translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7"); translator.setString(text); @@ -17076,7 +18420,7 @@ REPLACE INTO translators VALUES ('8917b41c-8527-4ee7-b2dd-bcbc3fa5eabd', '1.0.0b Zotero.wait(); }'); -REPLACE INTO translators VALUES ('ecddda2e-4fc6-4aea-9f17-ef3b56d7377a', '1.0.0b3.r1', '', '2008-04-02 08:10:00', '1', '100', '4', 'arXiv.org', 'Sean Takats and Michael Berkowitz', 'http://(?:(www|uk)\.)?(?:(arxiv\.org|xxx.lanl.gov)/(?:find/\w|list/\w|abs/)|eprintweb.org/S/(?:search|archive|article)(?!.*refs$)(?!.*cited$))', +REPLACE INTO translators VALUES ('ecddda2e-4fc6-4aea-9f17-ef3b56d7377a', '1.0.0b3.r1', '', '2008-07-03 09:00:00', '1', '100', '4', 'arXiv.org', 'Sean Takats and Michael Berkowitz', 'http://(?:(www|uk)\.)?(?:(arxiv\.org|xxx.lanl.gov)/(?:find/\w|list/\w|abs/)|eprintweb.org/S/(?:search|archive|article)(?!.*refs$)(?!.*cited$))', 'function detectWeb(doc, url) { var searchRe = /^http:\/\/(?:(www|uk)\.)?(?:(arxiv\.org|xxx\.lanl\.gov)\/(?:find|list)|eprintweb.org\/S\/(?:archive|search$))/; if(searchRe.test(url)) { @@ -17086,7 +18430,7 @@ REPLACE INTO translators VALUES ('ecddda2e-4fc6-4aea-9f17-ef3b56d7377a', '1.0.0b } }', 'function getPDF(articleID) { - return {url:"http://www.arxiv.org/pdf/" + articleID + "v1.pdf", + return {url:"http://www.arxiv.org/pdf/" + articleID + ".pdf", mimeType:"application/pdf", title:articleID + " PDF"}; } @@ -17320,7 +18664,7 @@ REPLACE INTO translators VALUES ('232903bc-7307-4058-bb1a-27cfe3e4e655', '1.0.0b Zotero.wait(); }'); -REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b4.r5', '', '2008-05-15 00:30:00', '0', '100', '4', 'Wiley InterScience', 'Sean Takats and Michael Berkowitz', 'https?:\/\/(?:www3\.|www\.)?interscience\.wiley\.com[^\/]*\/(?:search\/|(cgi-bin|journal)\/[0-9]+\/abstract|journal)', +REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b4.r5', '', '2008-07-02 11:00:00', '1', '100', '4', 'Wiley InterScience', 'Sean Takats and Michael Berkowitz', 'https?:\/\/(?:www3\.|www\.)?interscience\.wiley\.com[^\/]*\/(?:search\/|(cgi-bin|journal)\/[0-9]+\/abstract|journal)', 'function detectWeb(doc, url){ var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { @@ -17331,27 +18675,23 @@ REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { return "multiple"; } - if (doc.evaluate(''//div[@id="contentCell"]'', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) { + if (url.match(/journal\/\d+\/(issue|home)$/)) { return "multiple"; } - var m = url.match(/https?:\/\/[^\/]*\/(cgi-bin|journal)(\/abstract)?\/[0-9]+(\/abstract)?/); + var m = url.match(/https?:\/\/[^\/]*\/(cgi-bin|journal)(\/(abstract|summary))?\/[0-9]+\/abstract/); if (m){ return "journalArticle"; } }', 'function doWeb(doc, url){ - Zotero.debug(doc.location.host); var namespace = doc.documentElement.namespaceURI; var nsResolver = namespace ? function(prefix) { if (prefix == ''x'') return namespace; else return null; } : null; - - var m = url.match(/https?:\/\/[^\/]*\/journal\/([0-9]+)\/abstract/); + var host = ''http://'' + doc.location.host + "/"; + Zotero.debug(host); + var m = url.match(/https?:\/\/[^\/]*\/(journal|cgi-bin\/summary)\/([0-9]+)\/(abstract)?/); var ids = new Array(); - /*var xpath = ''//tr[td/input[@name="ID"][@type="checkbox"]]''; - var elmt; - var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null); - elmt = elmts.iterateNext();*/ if(detectWeb(doc, url) == "multiple") { //search var id; var title; @@ -17384,43 +18724,40 @@ REPLACE INTO translators VALUES ('fe728bc9-595a-4f03-98fc-766f1d8d0936', '1.0.0b } } else if (m){ //single article - ids.push(m[1]); + ids.push(m[2]); } - var hostRe = new RegExp("^http(?:s)?://[^/]+"); - var m = hostRe.exec(doc.location.href); - var host = m[0]; - var uri = host+"/tools/citex"; - var poststring = ""; - for each(var id in ids) { - poststring = poststring + "&id=" + id; - } - poststring = "clienttype=1&subtype=1&mode=1&version=1" + poststring; - Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) { - uri = host+"/tools/CitEx"; - poststring = "mode=2&format=3&type=2&file=3&exportCitation.x=16&exportCitation.y=10&exportCitation=submit"; + for each (id in ids) { + var uri = host + ''tools/citex''; + var poststring = "clienttype=1&subtype=1&mode=1&version=1&id=" + id; Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) { - var m = text.match(/%A\s(.*)/); //following lines fix Wiley''s incorrect %A tag (should be separate tags for each author) - if (m){ - var newauthors =""; - var authors = m[1].split(",") - for each (var author in authors){ - if (author != ""){ - newauthors = newauthors + "%A "+Zotero.Utilities.unescapeHTML(Zotero.Utilities.trimInternal(author))+"\n"; + uri = host+"tools/CitEx"; + poststring = "mode=2&format=3&type=2&file=3&exportCitation.x=16&exportCitation.y=10&exportCitation=submit"; + Zotero.Utilities.HTTP.doPost(uri, poststring, function(text) { + var m = text.match(/%A\s(.*)/); //following lines fix Wiley''s incorrect %A tag (should be separate tags for each author) + if (m){ + var newauthors =""; + var authors = m[1].split(",") + for each (var author in authors){ + if (author != ""){ + newauthors = newauthors + "%A "+Zotero.Utilities.unescapeHTML(Zotero.Utilities.trimInternal(author))+"\n"; + } } + text = text.replace(/%A\s.*\n/, newauthors); } - text = text.replace(/%A\s.*\n/, newauthors); - } - var translator = Zotero.loadTranslator("import"); - translator.setTranslator("881f60f2-0802-411a-9228-ce5f47b64c7d"); //EndNote/Refer/BibIX - translator.setString(text); - translator.setHandler("itemDone", function(obj, item) { - item.DOI = item.url.match(/\.org\/(.*)$/)[1]; - item.complete(); + var translator = Zotero.loadTranslator("import"); + translator.setTranslator("881f60f2-0802-411a-9228-ce5f47b64c7d"); //EndNote/Refer/BibIX + translator.setString(text); + translator.setHandler("itemDone", function(obj, item) { + var pdfurl = ''http://download.interscience.wiley.com/cgi-bin/fulltext?ID='' + id + ''&PLACEBO=IE.pdf&mode=pdf''; + item.attachments.push({url:pdfurl, title:"Wiley Interscience PDF", mimeType:"application/pdf"}); + item.DOI = item.url.match(/\.org\/(.*)$/)[1]; + item.complete(); + }); + translator.translate(); + Zotero.done(); }); - translator.translate(); - Zotero.done(); }); - }); + }; Zotero.wait(); }'); @@ -18943,7 +20280,7 @@ function doWeb(doc, url) { Zotero.wait(); }'); -REPLACE INTO translators VALUES ('594ebe3c-90a0-4830-83bc-9502825a6810', '1.0.0b4.r5', '', '2008-03-21 15:30:00', '1', '100', '4', 'ISI Web of Knowledge', 'Michael Berkowitz', '(WOS_GeneralSearch|product=WOS)', +REPLACE INTO translators VALUES ('594ebe3c-90a0-4830-83bc-9502825a6810', '1.0.0b4.r5', '', '2008-07-07 14:50:00', '1', '100', '4', 'ISI Web of Knowledge', 'Michael Berkowitz', '(WOS_GeneralSearch|product=WOS)', 'function detectWeb(doc, url) { if (doc.title.indexOf("Web of Science Results") != -1) { return "multiple"; @@ -18957,11 +20294,9 @@ REPLACE INTO translators VALUES ('594ebe3c-90a0-4830-83bc-9502825a6810', '1.0.0b var items = new Object; var xpath = ''//a[@class="smallV110"]''; var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null); - var next_title = titles.iterateNext(); - while (next_title) { - var id = doc.evaluate(''.//@onclick'', next_title, null, XPathResult.ANY_TYPE, null).iterateNext().value.match(/\?([^'']+)''/)[1]; - items[id] = next_title.textContent; - next_title = titles.iterateNext(); + var next_title; + while (next_title = titles.iterateNext()) { + items[next_title.href.match(/\?(.*)/)[1]] = next_title.textContent; } items = Zotero.selectItems(items); for (var i in items) { @@ -22911,7 +24246,7 @@ function doExport() { } }'); -REPLACE INTO translators VALUES ('9cb70025-a888-4a29-a210-93ec52da40d4', '1.0.0b4.r1', '', '2008-05-20 06:00:00', '1', '200', '3', 'BibTeX', 'Simon Kornblith', 'bib', +REPLACE INTO translators VALUES ('9cb70025-a888-4a29-a210-93ec52da40d4', '1.0.0b4.r1', '', '2008-07-01 14:30:13', '1', '200', '3', 'BibTeX', 'Simon Kornblith', 'bib', 'Zotero.configure("dataMode", "block"); Zotero.addOption("UTF8", true); @@ -24502,7 +25837,9 @@ function processField(item, field, value) { } } else if (field == "comment") { item.notes.push({note:value}); - } + } else if(field == "pdf") { // new code to handle PDF import. absolute file path should be specified in bibtex + item.attachments = [{url:"file://"+value, mimeType:"application/pdf"}]; + } } function getFieldValue(read) { @@ -24897,7 +26234,7 @@ function doExport() { }'); -REPLACE INTO translators VALUES ('a6ee60df-1ddc-4aae-bb25-45e0537be973', '1.0.0b3.r1', '', '2008-05-05 07:45:00', '1', '100', '1', 'MARC', 'Simon Kornblith', 'marc', +REPLACE INTO translators VALUES ('a6ee60df-1ddc-4aae-bb25-45e0537be973', '1.0.0b3.r1', '', '2008-06-29 21:10:00', '1', '100', '1', 'MARC', 'Simon Kornblith', 'marc', 'function detectImport() { var marcRecordRegexp = /^[0-9]{5}[a-z ]{3}$/ var read = Zotero.read(8); @@ -24912,6 +26249,9 @@ var subfieldDelimiter = "\x1F"; /* * CLEANING FUNCTIONS */ + + + // general purpose cleaning function clean(value) { @@ -25089,6 +26429,7 @@ record.prototype.getFieldSubfields = function(tag) { // returns a two-dimensiona // 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) { @@ -25222,6 +26563,8 @@ record.prototype.translate = function(item) { this._associateDBField(item, "300", "a", "pages", pullNumber); // Extract series this._associateDBField(item, "440", "a", "series"); + // Extract series number + this._associateDBField(item, "440", "v", "seriesNumber"); // Extract call number this._associateDBField(item, "084", "ab", "callNumber"); this._associateDBField(item, "082", "a", "callNumber");