www

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

commit 2bcf3f2c9854d3c6dc21e98e537c1b30ac202970
parent 5eecc5d32f495bbd147a7d4d1473d19c0c27f8cb
Author: Matt Burton <mcburton@gmail.com>
Date:   Wed, 14 Jan 2009 16:39:53 +0000

Fixes #1288, cleans PDF urls, also found another bug in grabbing links from search results

Diffstat:
Mtranslators/Sage Journals Online.js | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/translators/Sage Journals Online.js b/translators/Sage Journals Online.js @@ -29,14 +29,18 @@ function doWeb(doc, url) { } else { var searchx = '//form[@id="search_results"]/div[@class="resultsitem"]/div[2]'; var titlex = './/label'; + } - var linkx = './/a[1]'; + 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; - var link = doc.evaluate(linkx, next_res, null, XPathResult.ANY_TYPE, null).iterateNext().href; - items[link] = title; + // 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) { @@ -53,6 +57,10 @@ function doWeb(doc, url) { 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");