commit 413ed3e749abe30cd3cee97f9cb269519b46ab82
parent 8c8e5f4b403d386257a5bc6865c59225bbc98a9d
Author: Dan Stillman <dstillman@zotero.org>
Date: Thu, 18 Aug 2011 05:07:32 +0000
Update translators from GitHub
Diffstat:
12 files changed, 456 insertions(+), 356 deletions(-)
diff --git a/translators/Ab Imperio.js b/translators/Ab Imperio.js
@@ -11,7 +11,9 @@
"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")};/*
+/* 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
@@ -71,4 +73,4 @@ FW.MultiScraper({ itemType : "multiple",
titles : FW.Xpath('//a[contains(@href,"state=showa")]').text(),
urls : FW.Xpath('//a[contains(@href,"state=showa")]').key('href').text()
}
-});
-\ No newline at end of file
+});
diff --git a/translators/AlterNet.js b/translators/AlterNet.js
@@ -1,182 +1,58 @@
{
- "translatorID":"ea531652-cdeb-4ec2-940e-627d4b107263",
- "translatorType":4,
- "label":"AlterNet",
- "creator":"Jesse Johnson",
- "target":"^http://(?:www\\.)alternet.org",
- "minVersion":"1.0.0b4.r1",
- "maxVersion":"",
- "priority":100,
- "inRepository":true,
- "lastUpdated":"2011-01-11 04:31:00"
+ "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"
}
-function detectWeb(doc, url) {
- // identifies articles according to the presence of an article ID
- // number in the URL
- var index = url.toString().indexOf('.org/') + 5;
- index += url.toString().substr(index).indexOf('/');
- if (index != -1) {
- // ordinary aritcle
- var id = url.toString().substr(index + 1, 5);
- Zotero.Utilities.trimInternal(id);
- if (Number(id)) {
- return "magazineArticle";
- }
- //columnist or blog article
- index += url.toString().substr(index + 1).indexOf('/');
- id = url.toString().substr(index + 2, 5);
- Zotero.Utilities.trimInternal(id);
- if (Number(id) && url.toString().search('blog') == -1) {
- return "magazineArticle";
- }
- else if (Number(id)) {
- return "blogPost";
- }
- }
-
- return null;
-}
-
-function scrape(doc, url, title) {
- var index = url.toString().indexOf('.org/') + 5;
- index += url.toString().substr(index).indexOf('/');
- if (index != -1) {
- // ordinary aritcle
- var id = url.toString().substr(index + 1, 5);
- Zotero.Utilities.trimInternal(id);
- if (Number(id)) {
- var newItem = new Zotero.Item("magazineArticle");
- }
- //columnist or blog article
- index += url.toString().substr(index + 1).indexOf('/');
- id = url.toString().substr(index + 2, 5);
- Zotero.Utilities.trimInternal(id);
- if (Number(id) && url.toString().search('blog') == -1) {
- var newItem = new Zotero.Item("magazineArticle");
- }
- else if (Number(id)) {
- var newItem = new Zotero.Item("blogPost");
- }
- }
-
- newItem.url = url;
- newItem.title = title;
-
- if (newItem.itemType == "magazineArticle") {
- newItem.publicationTitle = "AlterNet";
- newItem.repository = "alternet.org";
- }
- else if (newItem.itemType == "blogPost") {
- newItem.websiteType = "AlterNet Blog";
- }
-
-
- // general scraping variables
- var xpath;
-
-
- // author
- if (newItem.itemType == "magazineArticle") {
- xpath = '//p[@class="storybyline"]//a[contains(@href,"author")]';
- }
- else if (newItem.itemType == "blogPost") {
- xpath = '//p[@class="storybyline"]//a[contains(@href,"bloggers")]';
- }
- temp = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
- if (temp) {
- var author = Zotero.Utilities.trimInternal(temp.textContent);
- if(author.substr(0, 3).toLowerCase() == "by ") {
- author = author.substr(3);
- }
-
- var authors = author.split(",");
- for each (var author in authors) {
- newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
- }
- }
-
- // date
- if (newItem.itemType == "magazineArticle") {
- xpath = '//p[@class="storybyline"]//a[contains(@href,"date")]';
- temp = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
- var date = Zotero.Utilities.strToDate(temp.textContent);
- }
- else if (newItem.itemType == "blogPost") {
- xpath = '//p[@class="storybyline"]/b';
- temp = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
- var begin = temp.textContent.lastIndexOf(" on ");
- temp = temp.textContent.substr(begin + 4);
- var date = Zotero.Utilities.strToDate(temp.substr(0, temp.length - 1));
- }
- if (date != null) {
- var strdate;
-
- date.month = date.month + 1;
-
- strdate = date.year + '-';
- if (date.month < 10) {
- strdate += '0' + date.month;
- }
- else {
- strdate += date.month;
- }
- if (date.day > 10) {
- strdate += '-' + date.day;
- }
- else {
- strdate += '-0' + date.day;
- }
-
- newItem.date = strdate;
- }
-
- // abstract
- xpath = '//div[@class="teaser"]//div[contains(@class,"teaser")]';
- temp = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
- if (temp) {
- newItem.abstractNote = Zotero.Utilities.trimInternal(temp.textContent);
- }
-
- // article snapshot
- // grabs 5-digit article code from url and uses it to derive printable page url for use in article snapshot
- var index = url.toString().indexOf('.org/') + 5;
- index += url.toString().substr(index).indexOf('/');
- if (index != -1) {
- var printurl;
- // ordinary article
- var id = url.toString().substr(index + 1, 5);
- if (Number(id)) {
- printurl = "http://www.alternet.org/module/printversion/" + id;
- newItem.attachments.push({url:printurl, title:"AlterNet Article Snapshot", mimeType:"text/html"});
- }
- // columnist article
- else {
- index += url.toString().substr(index + 1).indexOf('/');
- id = url.toString().substr(index + 2, 5);
- Zotero.Utilities.trimInternal(id);
- if (Number(id)) {
- printurl = "http://www.alternet.org/module/printversion/" + id;
- if (newItem.itemType == "blogPost") {
- printurl += "/?type=blog";
- }
- newItem.attachments.push({url:printurl, title:"AlterNet Article Snapshot", mimeType:"text/html"});
- }
- }
- }
-
- newItem.complete();
-}
-
-
-
-function doWeb(doc, url) {
- // ordinary and columnist articles
- var xpath = '//p[@class="storyheadline"]';
- var title;
- if (title = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
- scrape(doc, url, title.textContent);
- }
-
- return null;
-}
-\ No newline at end of file
+/* 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/Bezneng Gajit.js b/translators/Bezneng Gajit.js
@@ -11,7 +11,27 @@
"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")};function detectWeb(doc, url) { return FW.detectWeb(doc, url); }
+/* 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 */
@@ -45,4 +65,4 @@ choices : {
titles : FW.Xpath('//h2[@class="entry-title"]/a').text().trim(),
urls : FW.Xpath('//h2[@class="entry-title"]/a').key("href")
}
-});
-\ No newline at end of file
+});
diff --git a/translators/EBSCOhost.js b/translators/EBSCOhost.js
@@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
- "lastUpdated": "2011-08-03 01:00:36"
+ "lastUpdated": "2011-08-07 11:11:54"
}
function detectWeb(doc, url) {
@@ -16,19 +16,9 @@ function detectWeb(doc, url) {
var nsResolver = namespace ? function(prefix) {
if (prefix == 'x') { return namespace; } else { return null; }
} : null;
- // The Scientific American Archive breaks this translator, disabling
- try {
- var databases = doc.evaluate("//span[@class = 'selected-databases']", doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
- if(databases.indexOf("Scientific American Archive Online") != -1) {
- return false;
- }
- } catch(e) {
- }
-
// See if this is a search results or folder results page
- var searchResult = doc.evaluate('//ul[@class="result-list" or @class="folder-list"]/li/div[@class="result-list-record" or @class="folder-item"]', doc, nsResolver,
- XPathResult.ANY_TYPE, null).iterateNext();
+ var searchResult = doc.evaluate('//ul[@class="result-list" or @class="folder-list"]/li/div[@class="result-list-record" or @class="folder-item"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
if(searchResult) {
return "multiple";
}
@@ -44,7 +34,9 @@ function detectWeb(doc, url) {
* given the text of the delivery page, downloads an item
*/
function downloadFunction(text, url) {
+ var an = url.match(/_(\d+)_AN/);
var pdf = false;
+ var risDate = false;
var queryString = {};
url.replace(
new RegExp("([^?=&]+)(=([^&]*))?", "g"),
@@ -52,11 +44,16 @@ function downloadFunction(text, url) {
);
pdf = "/ehost/pdfviewer/pdfviewer?sid="+queryString["sid"]+"&vid="+queryString["vid"];
+ if (text.match(/^Y1\s+-(.*)$/m)) {
+ risDate = text.match(/^Y1\s+-(.*)$/m);
+ }
+
if (!text.match(/^TY\s\s-/m)) { text = text+"\nTY - JOUR\n"; }
// load translator for RIS
var translator = Zotero.loadTranslator("import");
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
translator.setString(text);
+ Zotero.debug(text);
translator.setHandler("itemDone", function(obj, item) {
if (text.match(/^L3\s+-\s*(.*)/m)) {
item.DOI = text.match(/^L3\s+\-\s*(.*)/m)[1];
@@ -70,42 +67,56 @@ function downloadFunction(text, url) {
if (text.match(/^T1\s+-/m)) {
item.title = text.match(/^T1\s+-\s*(.*)/m)[1];
}
-
- // If we have a double year, eliminate one
- var year = item.date.match(/\d{4}/);
- if (year && item.date.replace(year[0],"").indexOf(year[0]) !== -1) {
- item.date = item.date.replace(year[0],"");
+
+ // Get the accession number from URL or elsewhere
+ if (an) {
+ an = an[1];
+ item.callNumber = an;
+ } else {
+ an = item.url.match(/AN=([0-9]+)/);
+ if (an) an = an[1];
}
-
- // RIS translator tries to download the link in "UR" this leads to unhappyness
- item.attachments = [];
+ if (risDate) {
+ var year = risDate[1].match(/\d{4}/);
+ var extra = risDate[1].match(/\/([^\/]+)$/);
+ // If we have a double year in risDate, use last section
+ if (year && extra && extra[1].indexOf(year[0]) !== -1) {
+ item.date = extra[1];
+ }
+ }
+
+ // RIS translator tries to download the link in "UR"
+ item.attachments = [];
+
// But keep the stable link as a link attachment
if(item.url) {
- item.attachments.push({url: item.url,
+ // Trim the ⟨=cs suffix -- EBSCO can't find the record with it!
+ item.url = item.url.replace(/(AN=[0-9]+)⟨=[a-z]{2}/,"$1");
+ item.attachments.push({url: item.url+"&scope=cite",
title: "EBSCO Record",
mimeType: "text/html",
snapshot: false});
item.url = "";
}
+ // A lot of extra info is jammed into notes by the RIS translator
item.notes = [];
- Zotero.Utilities.doGet(pdf, function (text) {
- //Z.debug(text);
+ // Since order of requests might matter, let's grab the stable link, then the PDF
+ Zotero.Utilities.doGet(item.url, function (doc) { Zotero.Utilities.doGet(pdf, function (text) {
var realpdf = text.match(/<embed id="pdfEmbed"[^>]*>/);
if(realpdf) {
realpdf = text.match(/<embed[^>]*src="([^"]+)"/);
if (realpdf) {
- realpdf = realpdf[1];
- item.attachments.push({url:realpdf.replace(/&/g, "&"),
+ realpdf = realpdf[1].replace(/&/g, "&").replace(/K=\d+/,"K="+an);
+ Zotero.debug("PDF for "+item.title+": "+realpdf);
+ item.attachments.push({url:realpdf,
title: "EBSCO Full Text",
mimeType:"application/pdf"});
}
}
- }, function () { item.complete(); });
+ }, function () { item.complete(); }); }, function () { return true; });
});
translator.translate();
-
- Zotero.done();
}
var host;
@@ -159,16 +170,15 @@ function doWeb(doc, url) {
var run = function(urls, infos) {
var url, info;
- if (urls.length == 0 || folderInfos.length == 0) {
+ if (urls.length == 0 || infos.length == 0) {
Zotero.done();
return true;
}
url = urls.shift();
info = infos.shift();
Zotero.Utilities.processDocuments(url,
- function (newDoc) { doDelivery(doc, nsResolver, info); },
- function () {run(urls, infos);
- });
+ function (newDoc) { doDelivery(doc, nsResolver, info, function () { run(urls, infos) }); },
+ function () { return true; });
};
run(urls, infos);
@@ -177,30 +187,37 @@ function doWeb(doc, url) {
});
} else {
/* Individual record. Record key exists in attribute for add to folder link in DOM */
- doDelivery(doc, nsResolver, null);
+ doDelivery(doc, nsResolver, null, function () { Zotero.done(); return true; });
+ Zotero.wait();
}
}
-function doDelivery(doc, nsResolver, folderData) {
+function doDelivery(doc, nsResolver, folderData, onDone) {
if(folderData === null) {
/* Get the db, AN, and tag from ep.clientData instead */
var script;
var scripts = doc.evaluate('//script[@type="text/javascript"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
while (script = scripts.iterateNext().textContent) {
- if (script.indexOf("var ep") > -1) { break; }
- script = "";
+ var clientData = script.match(/var ep\s*=\s*({[^;]*});/);
+ if (clientData) break;
}
- }
+ if (!clientData) {return false;}
+ /* We now have the script containing ep.clientData */
- if (script === "") { return; }
- /* We now have the script containing ep.clientData */
-
- /* The JSON is technically invalid, since it doesn't quote the
- attribute names-- we pull out the valid bit inside it. */
- var clientData = script.match(/var ep\s*=\s*({[^;]*});/);
- if (!clientData) { return false; }
- clientData = clientData[1].match(/"currentRecord"\s*:\s*({[^}]*})/);
- /* If this starts throwing exceptions, we should probably start try-elsing it */
- clientData = JSON.parse(clientData[1]);
+ /* 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;
@@ -211,9 +228,8 @@ function doDelivery(doc, nsResolver, folderData) {
);
/* ExportFormat = 1 for RIS file */
- postURL = host+"/ehost/delivery/ExportPanelSave/"+clientData.Db+"_"+clientData.Term+"_"+clientData.Tag+"?sid="+queryString["sid"]+"&vid="+queryString["vid"]+"&bdata="+queryString["bdata"]+"&theExportFormat=1";
-
- Zotero.Utilities.HTTP.doGet(postURL, function (text) { downloadFunction(text, postURL); });
+ postURL = host+"/ehost/delivery/ExportPanelSave/"+folderData.Db+"_"+folderData.Term+"_"+folderData.Tag+"?sid="+queryString["sid"]+"&vid="+queryString["vid"]+"&bdata="+queryString["bdata"]+"&theExportFormat=1";
+ Zotero.Utilities.HTTP.doGet(postURL, function (text) { downloadFunction(text, postURL); }, onDone);
}
/** BEGIN TEST CASES **/
var testCases = [
diff --git a/translators/Google Blogs.js b/translators/Google Blogs.js
@@ -11,6 +11,24 @@
"lastUpdated": "2011-07-30 03:19:03"
}
+/*
+ Google Blogs Translator
+ Copyright (C) 2011 Avram Lyon, ajlyon@gmail.com
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
function detectWeb(doc, url) {
return "multiple";
}
diff --git a/translators/ISI Web of Knowledge.js b/translators/ISI Web of Knowledge.js
@@ -2,7 +2,7 @@
"translatorID": "594ebe3c-90a0-4830-83bc-9502825a6810",
"label": "ISI Web of Knowledge",
"creator": "Michael Berkowitz, Avram Lyon",
- "target": "(WOS_GeneralSearch|product=WOS|product=CABI)",
+ "target": "^https?://[^/]*webofknowledge\\.com/",
"minVersion": "2.1",
"maxVersion": "",
"priority": 100,
@@ -12,9 +12,9 @@
}
function detectWeb(doc, url) {
- if ((doc.title.indexOf("Web of Science Results") != -1) | (doc.title.indexOf("CABI Results") != -1)) {
+ if (url.indexOf("full_record.do") !== -1) {
return "multiple";
- } else if (url.indexOf("full_record.do") != -1) {
+ } else if ((doc.title.indexOf(" Results") !== -1)) {
return "journalArticle";
}
}
@@ -55,13 +55,24 @@ function fetchIds(ids, url) {
var product = url.match("product=([^\&]+)\&")[1];
Zotero.Utilities.processDocuments(ids, function (newDoc) {
var url = newDoc.location.href;
- var sid = newDoc.evaluate('//input[@name="selectedIds"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
- var nid = newDoc.evaluate('//input[@name="SID"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
- var post2 = 'product='+product+'&product_sid=' + nid + '&plugin=&product_st_thomas=http://esti.isiknowledge.com:8360/esti/xrpc&export_ref.x=0&export_ref.y=0';
- var post = 'action=go&mode=quickOutput&product='+product+'&SID=' + nid + '&format=ref&fields=BibAbs&mark_id='+product+'&count_new_items_marked=0&selectedIds=' + sid + '&qo_fields=bib&endnote.x=95&endnote.y=12&save_options=default';
- Zotero.Utilities.doPost('http://apps.isiknowledge.com/OutboundService.do', post, function (text, obj) {
- Zotero.Utilities.doPost('http://pcs.isiknowledge.com/uml/uml_view.cgi', post2, function (text, obj) {
- //Zotero.debug(text);
+ var names = ["recordID", "colName", "SID", "selectedIds", "sortBy", "qid", "product" ];
+ var values = {};
+ var n;
+ for each (n in names) {
+ values[n] = newDoc.evaluate('//input[@name="'+n+'"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
+ }
+ var post2 = 'locale=en_US&fileOpt=fieldtagged'+
+ '&colName=' + values.colName + '&action=saveDataToRef'+
+ '&qid='+values.qid+'&sortBy='+values.sortBy.replace(/;/g,"%3;")+
+ '&SID='+values.SID+'&product='+values.product+'&filters=FUNDING+SUBJECT_CATEGORY+JCR_CATEGORY+LANG+IDS+PAGEC+SABBR+CITREFC+ISSN+PUBINFO+KEYWORDS+CITTIMES+ADDRS+CONFERENCE_SPONSORS+DOCTYPE+ABSTRACT+CONFERENCE_INFO+SOURCE+TITLE+AUTHORS++&numRecords=1&locale=en_US';
+ var post = 'action=go&viewType=fullRecord&product='+values.product
+ +'&mark_id='+values.product+'&colName=' + values.colName
+ +'&recordID='+values.recordID.replace(/;/g,"%3;")
+ +'&sortBy='+values.sortBy.replace(/;/g,"%3;")+'&mode=outputService'
+ +'&qid='+values.qid+'&SID='+values.SID+
+ +'&format=saveToRef&filters=FUNDING+SUBJECT_CATEGORY+JCR_CATEGORY+LANG+IDS+PAGEC+SABBR+CITREFC+ISSN+PUBINFO+KEYWORDS+CITTIMES+ADDRS+CONFERENCE_SPONSORS+DOCTYPE+ABSTRACT+CONFERENCE_INFO+SOURCE+TITLE+AUTHORS++&selectedIds=3&mark_to=&mark_from=&count_new_items_marked=0&value%28record_select_type%29=selrecords&marked_list_candidates=3&LinksAreAllowedRightClick=CitedRefList.do&LinksAreAllowedRightClick=CitingArticles.do&LinksAreAllowedRightClick=OneClickSearch.do&LinksAreAllowedRightClick=full_record.do&fields_selection=FUNDING+SUBJECT_CATEGORY+JCR_CATEGORY+LANG+IDS+PAGEC+SABBR+CITREFC+ISSN+PUBINFO+KEYWORDS+CITTIMES+ADDRS+CONFERENCE_SPONSORS+DOCTYPE+ABSTRACT+CONFERENCE_INFO+SOURCE+TITLE+AUTHORS++&save_options=fieldtagged';
+ Zotero.Utilities.doPost('http://apps.webofknowledge.com/OutboundService.do',post, function (text, obj) {
+ Zotero.Utilities.doPost('http://ets.webofknowledge.com/ETS/saveDataToRef.do',post2, function (text, obj) {
importer.setString(text);
importer.setHandler("itemDone", function (obj, item) {
item.attachments = [{url: url, type: "text/html", title: "ISI Web of Knowledge Record"}];
@@ -87,8 +98,8 @@ function detectImport() {
return false;
}
}
+ }
}
- }
}
function processTag(item, field, content) {
@@ -140,8 +151,8 @@ function processTag(item, field, content) {
}
var year = item.date.match(/\d{4}/);
// If we have a double year, eliminate one
- if (year && item.date.replace(year,"").indexOf(year) !== -1)
- item.date = item.date.replace(year,"");
+ if (year && item.date.replace(year[0],"").indexOf(year[0]) !== -1)
+ item.date = item.date.replace(year[0],"");
} else if (field == "VL") {
item.volume = content;
} else if (field == "IS") {
@@ -863,4 +874,4 @@ var testCases = [
]
}
]
-/** END TEST CASES **/
-\ No newline at end of file
+/** END TEST CASES **/
diff --git a/translators/ProQuest.js b/translators/ProQuest.js
@@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
- "lastUpdated": "2011-08-02 02:41:31"
+ "lastUpdated": "2011-08-03 11:08:32"
}
/*
@@ -102,8 +102,8 @@ function scrape (doc) {
var record_rows = doc.evaluate('//div[@class="display_record_indexing_row"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
var abstract_link = doc.evaluate('//a[@class="formats_base_sprite format_abstract"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
if (!record_rows && abstract_link) {
- Zotero.Utilities.processDocuments(abstract_link.href, scrape, function() {Zotero.done();});
- return true;
+ Zotero.Utilities.processDocuments(abstract_link.href, scrape, function() {Zotero.done();});
+ return true;
}
var url = doc.location.href;
@@ -191,11 +191,15 @@ function scrape (doc) {
case "Copyright":
item.rights = value; break;
case "Database":
+ value = value.replace(/^\d\s+databasesView list\s+Hide list/,'');
+ value = value.replace(/(ProQuest.*)(ProQuest.*)/,'$1; $2');
item.libraryCatalog = value; break;
case "Document URL":
- item.attachments.push({url:value.replace(/\?accountid=[0-9]+$/,''),
+ item.attachments.push({url:value.replace(/\?accountid=[0-9]+$/,'')+"/abstract",
title: "ProQuest Record",
mimeType: "text/html"}); break;
+ case "ProQuest Document ID":
+ item.callNumber = value; break;
case "Language of Publication":
item.language = value; break;
case "Section":
@@ -337,6 +341,7 @@ var testCases = [
"publisher": "Menno Simons College",
"ISSN": "00084697",
"language": "English",
+ "callNumber": "213445241",
"rights": "Copyright Peace Research May 1995",
"proceedingsTitle": "Peace Research",
"libraryCatalog": "ProQuest",
diff --git a/translators/Tatknigafund.js b/translators/Tatknigafund.js
@@ -12,6 +12,24 @@
}
/*
+ 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).
@@ -108,4 +126,4 @@ function doWeb(doc, url) {
item.complete();
}, function() {Zotero.done();});
Zotero.wait();
-}
-\ No newline at end of file
+}
diff --git a/translators/The Hindu.js b/translators/The Hindu.js
@@ -1,47 +1,44 @@
{
- "translatorID":"9499c586-d672-42d6-9ec4-ee9594dcc571",
- "translatorType":4,
- "label":"The Hindu",
- "creator":"Prashant Iyengar and Michael Berkowitz",
- "target":"http://(www.)?hindu.com",
- "minVersion":"1.0.0b4.r5",
- "maxVersion":"",
- "priority":100,
- "inRepository":true,
- "lastUpdated":"2008-05-08 20:30:00"
+ "translatorID": "9499c586-d672-42d6-9ec4-ee9594dcc571",
+ "label": "The Hindu",
+ "creator": "Prashant Iyengar and Michael Berkowitz",
+ "target": "^http://(www\\.)?hindu\\.com",
+ "minVersion": "1.0.0b4.r5",
+ "maxVersion": "",
+ "priority": 100,
+ "inRepository": true,
+ "translatorType": 4,
+ "lastUpdated": "2011-08-16 03:36:22"
}
function detectWeb(doc, url) {
if (doc.evaluate('//h2[@class="r"]/a[@class="l"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
- return "multiple";
- } else {
- return "newspaperArticle";
+ return "multiple";
+ } else {
+ return "newspaperArticle";
}
}
-
function regexMeta(str, item) {
var re = /NAME\=\"([\w\W]*?)\"\s+CONTENT\=\"([\w\W]*?)\"/;
var stuff = str.match(re);
- if (stuff)
- {
- if (stuff[1] == "PAGEHEAD") {
+ if (stuff)
+ {
+ if (stuff[1] == "PAGEHEAD") {
item.section = stuff[2].split(/\s+/)[0];
}
if (stuff[1] == "ZONE") {
item.place = stuff[2].split(/\s+/)[0];
}
+ if (stuff[1] == "EXPORTTIME") {
+ item.date = stuff[2].split(/\s+/)[0];
+ }
if (stuff[1] == "PAGENUMBER") {
item.pages = stuff[2].split(/\s+/)[0];
}
-
-
-
}
}
-
-
function doWeb(doc, url) {
var arts = new Array();
if (detectWeb(doc, url) == "multiple") {
@@ -68,20 +65,17 @@ function doWeb(doc, url) {
var t = /\<TITLE\>[\w\W]*\:([\w\W]*?)<\/TITLE/;
newItem.title = Zotero.Utilities.unescapeHTML(Zotero.Utilities.capitalizeTitle(text.match(t)[1]));
- var ti = /\<FONT color\=black\>(.*)?\<\/FONT\>/;
- newItem.date = text.match(ti)[1];
-
var auth = /\<font class\=storyhead[\w\W]*?justify\>([\w\W]*?)\<p\>/;
if (text.match(auth))
{
- //newItem.author=Zotero.Utilities.cleanAuthor(text.match(auth)[1]);
- cleanauth=Zotero.Utilities.cleanTags(text.match(auth)[1]);
- newItem.creators.push(Zotero.Utilities.cleanAuthor(cleanauth, "author"));
-
+ //newItem.author=Zotero.Utilities.cleanAuthor(text.match(auth)[1]);
+ cleanauth=Zotero.Utilities.cleanTags(text.match(auth)[1]);
+ newItem.creators.push(Zotero.Utilities.cleanAuthor(cleanauth, "author"));
}
- newItem.websiteTitle="The Hindu";
- newItem.edition="Online";
+ newItem.publicationTitle="The Hindu";
+
+ newItem.attachments = [{"title":"The Hindu Snapshot", mimeType:"text/html", url:art}];
//hooray for real meta tags!
var meta = /<META NAME[\w\W]*?\>/g;
@@ -94,4 +88,36 @@ function doWeb(doc, url) {
});
Zotero.wait();
}
-}
-\ No newline at end of file
+}/** 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/Toronto Star.js b/translators/Toronto Star.js
@@ -1,14 +1,15 @@
{
- "translatorID":"6b0b11a6-9b77-4b49-b768-6b715792aa37",
- "translatorType":4,
- "label":"Toronto Star",
- "creator":"Adam Crymble",
- "target":"http://www.thestar.com",
- "minVersion":"1.0.0b4.r5",
- "maxVersion":"",
- "priority":100,
- "inRepository":true,
- "lastUpdated":"2008-08-06 17:00:00"
+ "translatorID": "6b0b11a6-9b77-4b49-b768-6b715792aa37",
+ "label": "Toronto Star",
+ "creator": "Adam Crymble, Avram Lyon",
+ "target": "^http://www\\.thestar\\.com",
+ "minVersion": "2.1.9",
+ "maxVersion": "",
+ "priority": 100,
+ "inRepository": true,
+ "translatorType": 4,
+ "browserSupport": "gcs",
+ "lastUpdated": "2011-08-18 01:03:09"
}
function detectWeb(doc, url) {
@@ -22,6 +23,7 @@ function detectWeb(doc, url) {
//Toronto Star translator. code by Adam Crymble
function scrape(doc, url) {
+ if (!ZU) ZU = Zotero.Utilities;
var namespace = doc.documentElement.namespaceURI;
var nsResolver = namespace ? function(prefix) {
@@ -29,60 +31,32 @@ function scrape(doc, url) {
} : null;
var newItem = new Zotero.Item("newspaperArticle");
-
- if (doc.title.match("TheStar.com | ")) {
- var lineBreak = doc.title.lastIndexOf(" |");
- newItem.section = doc.title.substr(14, lineBreak-14);
+
+ var date = doc.evaluate('//span[@class="ts-label_published"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
+ if(date) {
+ newItem.date = date.textContent.replace(/Published On/,'');
}
- var byLine = doc.evaluate('//div[@id="ctl00_ContentPlaceHolder_article_NavWebPart_Article"]/div/span', doc, nsResolver, XPathResult.ANY_TYPE, null);
+ var abstractNote = doc.evaluate('//meta[@property="og:description"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
+ if(abstractNote) newItem.abstractNote = abstractNote.content;
- var nextEntry;
- while (nextEntry = byLine.iterateNext()) {
- if (nextEntry.textContent.match(" PM") || nextEntry.textContent.match(" AM") && nextEntry.textContent.match(/\d\d\d\d/)) {
- newItem.date = nextEntry.textContent;
- } else {
- newItem.abstractNote = nextEntry.textContent;
- }
+ var authorNode = doc.evaluate('//div[@class="td-author"]/span[@class="ts-label"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
+ var author;
+ while (author = authorNode.iterateNext()) {
+ author = author.textContent;
+ if (author.toUpperCase() == author) author = ZU.capitalizeTitle(author.toLowerCase(),true);
+ newItem.creators.push(ZU.cleanAuthor(author.replace(/^By\s*/,'')));
}
-
- var author1 = new Array();
- var k = 0;
-
- if (doc.evaluate('//span[@class="articleAuthor"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
- var author = doc.evaluate(xPathAuthor, doc, nsResolver, XPathResult.ANY_TYPE, null);
- var authorName;
-
- while (authorName = author.iterateNext()) {
- author1.push(authorName.textContent);
- k++;
- }
- if (k>1) {
- for (k in author1) {
- var words = author1[k].toLowerCase().split(/\s/);
-
- for (var i in words) {
- words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase();
- }
-
- author1[k] = words.join(" ");
- newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[k], "author"));
- }
- } else {
+ var xPathTitle = '//h1[@class="ts-article_header"]';
+ newItem.title = doc.evaluate(xPathTitle, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
- var words = author1[0].toLowerCase().split(/\s/);
- for (var i in words) {
- words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase();
- }
- author1[0] = words.join(" ");
- newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[0], "author"));
- }
- }
+ // 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"});
- 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 Toronto Star";
newItem.ISSN = "0319-0781";
@@ -113,9 +87,74 @@ function doWeb(doc, url) {
for (var i in items) {
articles.push(i);
}
+ Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
+ Zotero.wait();
} else {
- articles = [url];
+ scrape(doc, url);
+ }
+}
+
+/** 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"
+ }
+ ]
}
- Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
- Zotero.wait();
-}
-\ No newline at end of file
+]
+/** END TEST CASES **/
+\ No newline at end of file
diff --git a/translators/Wiley Online Library.js b/translators/Wiley Online Library.js
@@ -8,7 +8,8 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
- "lastUpdated": "2011-07-20 17:14:04"
+ "browserSupport": "g",
+ "lastUpdated": "2011-08-18 01:25:48"
}
function detectWeb(doc, url){
@@ -51,7 +52,13 @@ function doWeb(doc, url){
}
Zotero.Utilities.processDocuments(urls, scrape, function () { Zotero.done(); });
} else { //single article
- scrape(doc, url);
+ if (url.indexOf("/pdf/") != -1) {
+ url = url.replace(/\/pdf\/.+$/,'/abstract');
+ Z.debug("Redirecting to abstract page: "+url);
+ Zotero.Utilities.processDocuments([ url ], scrape, function () { Zotero.done(); });
+ } else {
+ scrape(doc, url);
+ }
}
Zotero.wait();
@@ -424,6 +431,74 @@ var testCases = [
"libraryCatalog": "Wiley Online Library"
}
]
+ },
+ {
+ "type": "web",
+ "url": "http://onlinelibrary.wiley.com/doi/10.1002/14651858.CD007019.pub2/pdf/standard",
+ "items": [
+ {
+ "itemType": "journalArticle",
+ "creators": [
+ {
+ "firstName": "Michelle",
+ "lastName": "Butler",
+ "creatorType": "author"
+ },
+ {
+ "firstName": "Rita",
+ "lastName": "Collins",
+ "creatorType": "author"
+ },
+ {
+ "firstName": "Jonathan",
+ "lastName": "Drennan",
+ "creatorType": "author"
+ },
+ {
+ "firstName": "Phil",
+ "lastName": "Halligan",
+ "creatorType": "author"
+ },
+ {
+ "firstName": "Dónal P",
+ "lastName": "O'Mathúna",
+ "creatorType": "author"
+ },
+ {
+ "firstName": "Timothy J",
+ "lastName": "Schultz",
+ "creatorType": "author"
+ },
+ {
+ "firstName": "Ann",
+ "lastName": "Sheridan",
+ "creatorType": "author"
+ },
+ {
+ "firstName": "Eileen",
+ "lastName": "Vilis",
+ "creatorType": "author"
+ }
+ ],
+ "notes": [],
+ "tags": [],
+ "seeAlso": [],
+ "attachments": [
+ {
+ "url": false,
+ "title": "Wiley Full Text PDF",
+ "mimeType": "application/pdf"
+ }
+ ],
+ "url": "http://onlinelibrary.wiley.com/doi/10.1002/14651858.CD007019.pub2/abstract",
+ "DOI": "10.1002/14651858.CD007019.pub2",
+ "publisher": "John Wiley & Sons, Ltd",
+ "ISSN": "1465-1858",
+ "title": "Hospital nurse staffing models and patient and staff‐related outcomes",
+ "language": "en",
+ "libraryCatalog": "Wiley Online Library"
+ }
+ ]
}
]
/** END TEST CASES **/
diff --git a/translators/eLibrary.ru.js b/translators/eLibrary.ru.js
@@ -8,7 +8,7 @@
"priority": 100,
"inRepository": true,
"translatorType": 4,
- "lastUpdated": "2011-08-02 22:31:22"
+ "lastUpdated": "2011-08-03 10:41:53"
}
/*
@@ -32,7 +32,7 @@
function detectWeb(doc, url){
if (url.match(/\/item.asp/)) {
return "journalArticle";
- } else if (url.match(/\/(query_results|contents|org_items)\.asp/)){
+ } else if (url.match(/\/(query_results|contents|org_items|itembox_items)\.asp/)){
return "multiple";
}
}