Remove translator copies
This commit is contained in:
parent
0a5f4946d3
commit
68553cc6db
354 changed files with 0 additions and 63174 deletions
|
@ -1,230 +0,0 @@
|
|||
{
|
||||
"translatorID": "a9f7b277-e134-4d1d-ada6-8f7942be71a6",
|
||||
"label": "3news.co.nz",
|
||||
"creator": "Sopheak Hean",
|
||||
"target": "^https?://www\\.3news\\.co\\.nz",
|
||||
"minVersion": "1.0",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": false,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-04-21 09:17:38"
|
||||
}
|
||||
|
||||
/*
|
||||
3news.co.nz Translator- Parses 3news.co.nz articles and creates Zotero-based metadata
|
||||
Copyright (C) 2011 Sopheak Hean, University of Waikato, Faculty of Education
|
||||
Contact: maxximuscool@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == "x" ) return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var blog= '//div[@class="newsWrapperDisp"]/div[@class="news"]/span';
|
||||
var blogObject = doc.evaluate(blog, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (blogObject){
|
||||
return "blogPost";
|
||||
} else {
|
||||
var date='//div[@class="ModArticleDisplayC"]/div[@class="newsWrapperFullDisp09"]/div[@class="news"]/span';
|
||||
var dateObject = doc.evaluate(date, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (dateObject){
|
||||
return "newspaperArticle";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function scrape (doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null
|
||||
|
||||
if (detectWeb(doc, url) =="newspaperArticle"){
|
||||
var newItem = new Zotero.Item('newspaperArticle');
|
||||
newItem.url = doc.location.href;
|
||||
newItem.publicationTitle = "3news.co.nz";
|
||||
newItem.language = "English";
|
||||
|
||||
if (dodate(doc, url) !=null){
|
||||
newItem.date = dodate(doc, url);
|
||||
}
|
||||
|
||||
if (doAbstract(doc, url) != null) {
|
||||
newItem.abstractNote= doAbstract(doc, url);
|
||||
}
|
||||
var au = '//div[@id="newsbody"]/p/strong';
|
||||
var author = doAuthor(doc, url, au);
|
||||
var title = '//h1';
|
||||
if (doTitle(doc, url, title) !=null){
|
||||
newItem.title = doTitle(doc, url, title);
|
||||
}
|
||||
if (author != null){
|
||||
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
|
||||
if(doSection(doc,url) !=null){
|
||||
newItem.section = doSection(doc,url);
|
||||
}
|
||||
if(doCopyright(doc,url) !=null){
|
||||
newItem.rights = doCopyright(doc,url);
|
||||
}
|
||||
newItem.attachments.push({title:"3news.co.nz Snapshot", mimeType:"text/html", url:newItem.url});
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
|
||||
else if (detectWeb(doc,url) =="blogPost"){
|
||||
var newItem = new Zotero.Item('blogPost');
|
||||
newItem.url = doc.location.href;
|
||||
//newItem.publicationTitle = "3news.co.nz";
|
||||
newItem.language = "English";
|
||||
if (doAbstract(doc, url) != null) {
|
||||
newItem.abstractNote= doAbstract(doc, url);
|
||||
}
|
||||
if (dodate(doc, url) !=null){
|
||||
newItem.date = dodate(doc, url);
|
||||
}
|
||||
var title = '//h1';
|
||||
if (doTitle(doc, url, title) !=null){
|
||||
newItem.title = doTitle(doc, url, title);
|
||||
}
|
||||
var author ='//div[@class="news"]/p/strong';
|
||||
if (doAuthor(doc, url, author) != null){
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(doAuthor(doc, url, author), "author"));
|
||||
}
|
||||
if(doSection(doc,url) !=null){
|
||||
newItem.section = doSection(doc,url);
|
||||
}
|
||||
if(doCopyright(doc,url) !=null){
|
||||
newItem.rights = doCopyright(doc,url);
|
||||
}
|
||||
newItem.attachments.push({title:"3news.co.nz Snapshot", mimeType:"text/html", url:newItem.url});
|
||||
newItem.complete();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function doSection (doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var section = '//div[@id="newsBreadCrumb"]/span/a[1]';
|
||||
var sectionObject =doc.evaluate(section, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(sectionObject){
|
||||
return sectionObject.textContent;
|
||||
} else return null;
|
||||
}
|
||||
|
||||
function dodate ( doc, url ) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var date='//div[@class="ModArticleDisplayC"]/div/div[@class="news"]/span';
|
||||
var dateObject = doc.evaluate(date, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (dateObject){
|
||||
dateObject = dateObject.textContent.replace(/\s(\d:{0,9})+:(\d{0,9})+([a-zA-Z.]{1,4})/, '');
|
||||
return dateObject;
|
||||
} else return null;
|
||||
}
|
||||
|
||||
function doTitle(doc, url, title){
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var titleObject = doc.evaluate(title, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (titleObject){
|
||||
var articleTitle= titleObject.textContent;
|
||||
return articleTitle;
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
||||
|
||||
function doAuthor(doc, url, author){
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var author2 = author;
|
||||
var authorObject = doc.evaluate(author2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (authorObject){
|
||||
authorObject= authorObject.textContent.replace(/By\s/, '');
|
||||
return authorObject;
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
||||
|
||||
function doAbstract(doc, url){
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
|
||||
var a= "//meta[@name='DESCRIPTION']";
|
||||
var abs= doc.evaluate(a, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (abs){
|
||||
var abstractString = abs.content;
|
||||
return abstractString;
|
||||
|
||||
}
|
||||
else return null;
|
||||
|
||||
}
|
||||
|
||||
function doCopyright(doc, url){
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var CP = '//meta[@name="COPYRIGHT"]';
|
||||
var copyrightObject = doc.evaluate(CP, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (copyrightObject){
|
||||
return copyrightObject.content;
|
||||
|
||||
}
|
||||
else return null;
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "newspaperArticle" || detectWeb(doc, url) == "blogPost") {
|
||||
scrape(doc, url);
|
||||
} else {
|
||||
/** Multiple cannot be done for this translator **/
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
"translatorID":"bbf1617b-d836-4665-9aae-45f223264460",
|
||||
"translatorType":4,
|
||||
"label":"A Contra Corriente",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.ncsu.edu/project/acontracorriente",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-03 19:40:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//tr[td[1]//img][td[3]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var arts = doc.evaluate('//tr[td[1]//img][td[3]]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var art;
|
||||
var selectList = new Object();
|
||||
var items = new Object();
|
||||
while (art = arts.iterateNext()) {
|
||||
var item = new Object();
|
||||
var title = doc.evaluate('.//a', art, null, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
item['title'] = Zotero.Utilities.trimInternal(title.textContent);
|
||||
item['pdfurl'] = title.href;
|
||||
item['author'] = doc.evaluate('.//strong', art, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
selectList[item.title] = item.title;
|
||||
items[item.title] = item;
|
||||
}
|
||||
var selected = Zotero.selectItems(selectList);
|
||||
var voliss = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="red01"]/font[2]/strong', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
voliss = voliss.match(/Vol\.\s+(\d+),\s+No\.\s+(\d+)\.\s+([^|]+)|/);
|
||||
Zotero.debug(voliss);
|
||||
for each (var title in selected) {
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
var olditem = items[title];
|
||||
item.title = olditem.title;
|
||||
item.creators = [Zotero.Utilities.cleanAuthor(olditem.author, "author")];
|
||||
item.volume = voliss[1];
|
||||
item.issue = voliss[2]
|
||||
item.date = Zotero.Utilities.trimInternal(voliss[3]);
|
||||
item.complete();
|
||||
}
|
||||
}
|
|
@ -1,141 +0,0 @@
|
|||
{
|
||||
"translatorID":"a07bb62a-4d2d-4d43-ba08-d9679a0122f8",
|
||||
"translatorType":4,
|
||||
"label":"ABC-CLIO Serials Web",
|
||||
"creator":"Simon Kornblith",
|
||||
"target":"https?://[^/]*serials\\.abc-clio\\.com[^/]*/active/go/ABC-Clio-Serials_v4",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var result = doc.evaluate('//table[@class="rc_main"]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(result) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var availableItems = new Array();
|
||||
var availableAttachments = new Array();
|
||||
|
||||
var elmts = doc.evaluate('//table[@class="rc_main"]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null);
|
||||
var elmt;
|
||||
while(elmt = elmts.iterateNext()) {
|
||||
var title = doc.evaluate('./tbody/tr/td[b/text() = "Title:"]',
|
||||
elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
var checkbox = doc.evaluate('.//input[@type = "checkbox"]',
|
||||
elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(title, checkbox) {
|
||||
checkbox = checkbox.name;
|
||||
availableItems[checkbox] = Zotero.Utilities.trimInternal(title.textContent).substr(6);
|
||||
|
||||
var links = doc.evaluate('./tbody/tr/td[b/text() = "Fulltext: ["]/a',
|
||||
elmt, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var link;
|
||||
|
||||
var attach = new Array();
|
||||
while(link = links.iterateNext()) {
|
||||
attach.push({url:link.href, title:Zotero.Utilities.trimInternal(link.textContent)+" Full Text",
|
||||
mimeType:"text/html"});
|
||||
}
|
||||
availableAttachments[checkbox] = attach;
|
||||
}
|
||||
}
|
||||
|
||||
var items = Zotero.selectItems(availableItems);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var postString = "_defaultoperation=Download+Options&research_field=&research_value=&jumpto=";
|
||||
var attachments = new Array();
|
||||
for(var i in availableItems) {
|
||||
postString += "&_checkboxname="+i+(items[i] ? "&"+i+"=1" : "");
|
||||
if(items[i]) {
|
||||
attachments.push(availableAttachments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Zotero.Utilities.HTTP.doPost(url, postString, function(text) {
|
||||
Zotero.Utilities.HTTP.doPost(url, "_appname=serials&_defaultoperation=Download+Documents&_formname=download&download_format=citation&download_which=tagged&download_where=ris&mailto=&mailreplyto=&mailsubject=&mailmessage=",
|
||||
function(text) {
|
||||
// get link
|
||||
var linkRe = /<a\s+class="button"\s+href="([^"]+)"\s+id="resource_link"/i;
|
||||
var m = linkRe.exec(text);
|
||||
if(!m) {
|
||||
throw("regular expression failed!");
|
||||
}
|
||||
Zotero.Utilities.HTTP.doGet(m[1], function(text) {
|
||||
// load translator for RIS
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
if(item.notes && item.notes[0]) {
|
||||
item.extra = item.notes[0].note;
|
||||
|
||||
delete item.notes;
|
||||
item.notes = undefined;
|
||||
}
|
||||
|
||||
// grab uni data from thesis
|
||||
if(item.itemType == "thesis") {
|
||||
var re = /^(.+?) ([0-9]{4})\. ([0-9]+) pp\.(.*)$/;
|
||||
var m = re.exec(item.extra);
|
||||
if(m) {
|
||||
item.publisher = m[1];
|
||||
item.date = m[2];
|
||||
item.pages = m[3];
|
||||
item.extra = m[4];
|
||||
}
|
||||
}
|
||||
|
||||
// fix periods
|
||||
for(var i in item.creators) {
|
||||
var nameLength = item.creators[i].firstName.length;
|
||||
|
||||
if(item.creators[i].firstName[nameLength-1] == ".") {
|
||||
item.creators[i].firstName = item.creators[i].firstName.substr(0, nameLength-1);
|
||||
}
|
||||
}
|
||||
for(var i in item.tags) {
|
||||
var tagLength = item.tags[i].length;
|
||||
|
||||
if(item.tags[i][tagLength-1] == ".") {
|
||||
item.tags[i] = item.tags[i].substr(0, tagLength-1);
|
||||
}
|
||||
}
|
||||
|
||||
// fix title
|
||||
item.title = Zotero.Utilities.superCleanString(item.title);
|
||||
|
||||
// add attachments
|
||||
item.attachments = attachments.shift();
|
||||
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
Zotero.done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,176 +0,0 @@
|
|||
{
|
||||
"translatorID":"f4a5876a-3e53-40e2-9032-d99a30d7a6fc",
|
||||
"translatorType":4,
|
||||
"label":"ACL",
|
||||
"creator":"Nathan Schneider",
|
||||
"target":"^http://(www[.])?aclweb.org/anthology-new/[^#]+",
|
||||
"minVersion":"1.0.7",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":false,
|
||||
"lastUpdated":"2008-12-06 10:21:05"
|
||||
}
|
||||
|
||||
// based on ACM translator
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return prefix; else return null;
|
||||
} : namespace;
|
||||
|
||||
var bibXpath = "//a[./text() = 'bib']"
|
||||
if(doc.evaluate(bibXpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple"
|
||||
}
|
||||
//commenting out single stuff
|
||||
// if (url.indexOf("/anthology-new/J/")>-1)
|
||||
// return "journalArticle";
|
||||
// else
|
||||
// return "conferencePaper";
|
||||
}
|
||||
|
||||
|
||||
function scrapeIndex(doc, items) {
|
||||
var results;
|
||||
var doImport;
|
||||
|
||||
if (items != null) { // Import user-selected item(s)
|
||||
results = items;
|
||||
doImport = true;
|
||||
}
|
||||
else {
|
||||
bibFileNodes = doc.evaluate('//a[substring(@href, string-length(@href)-3, 4) = ".bib"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
|
||||
results = new Array();
|
||||
doImport = false;
|
||||
|
||||
var bibFileNode = bibFileNodes.iterateNext();
|
||||
|
||||
while (bibFileNode) {
|
||||
var bibFileName = bibFileNode.getAttribute("href");
|
||||
var bibFile = bibFileName.substring(0, bibFileName.length-4);
|
||||
|
||||
var bNodes = doc.evaluate('//a[@href="' + bibFileName + '"]/following-sibling::b[position()=1]', doc, null, XPathResult.ANY_TYPE, null); // These nodes contain author information
|
||||
|
||||
// Extract authors' last names
|
||||
var authorLasts = new Array();
|
||||
|
||||
var bNode = bNodes.iterateNext();
|
||||
var authorsS = bNode.innerHTML; // may include markup: potentially <author>, <first>, <von>, and/or <last> tags
|
||||
authorsS = authorsS.replace(/[<][/]?author[>]/g, "");
|
||||
var authors = authorsS.split("; ");
|
||||
for (var a in authors) {
|
||||
var authorS = authors[a];
|
||||
var m = authorS.match(/[<]von[>]([^<]+)[<][/]von[>]/);
|
||||
var last = "";
|
||||
if (m!=null) // we expect there is a <last> tag if there is a <von> tag
|
||||
last = m[1] + " ";
|
||||
m = authorS.match(/[<]last[>]([^<]+)[<][/]last[>]/);
|
||||
if (m!=null)
|
||||
last += m[1];
|
||||
else {
|
||||
var name = authorS.replace(/[<][^>]+[>]/g, ""); // remove all markup
|
||||
if (name=="Entire volume")
|
||||
last = name;
|
||||
else {
|
||||
var parts = name.split(" ");
|
||||
last = parts[parts.length-1];
|
||||
if (parts.length>1) {
|
||||
var penultInitial = parts[parts.length-2].substr(0,1);
|
||||
if (penultInitial.toUpperCase()!=penultInitial) // e.g. van Dyke
|
||||
last = name[parts.length-2] + " " + last;
|
||||
}
|
||||
}
|
||||
}
|
||||
authorLasts.push(last);
|
||||
}
|
||||
|
||||
// Prepare result for this item, which consists of the relative path to the .bib file (minus the extension)
|
||||
// followed by a space and the authors' last names (abbreviated format)
|
||||
var result = bibFile + " ";
|
||||
|
||||
if (authorLasts.length<3)
|
||||
result += authorLasts.join(" & ");
|
||||
else
|
||||
result += authorLasts[0] + "+";
|
||||
|
||||
results.push(result);
|
||||
bibFileNode = bibFileNodes.iterateNext();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!doImport)
|
||||
return results;
|
||||
|
||||
for (var i in results) {
|
||||
var ii = results[i].indexOf(" ");
|
||||
var fileRelPath = results[i].substring(0, ii);
|
||||
var authorsShort = results[i].substring(ii+1);
|
||||
var fileName = fileRelPath.substring(fileRelPath.lastIndexOf("/")+1);
|
||||
var bibFile = fileRelPath + ".bib";
|
||||
|
||||
var pageurl = doc.location.href;
|
||||
var lastSlash = pageurl.lastIndexOf("/");
|
||||
var dirInUrl = pageurl.substring(0, lastSlash+1);
|
||||
var fileInUrl = pageurl.substring(lastSlash+1, pageurl.indexOf("#", lastSlash));
|
||||
var bib = dirInUrl + fileRelPath + ".bib";
|
||||
var pdf = dirInUrl + fileRelPath + ".pdf";
|
||||
var j = fileRelPath.lastIndexOf("-");
|
||||
var yearShort = fileRelPath.substring(j-2, j);
|
||||
var year = "";
|
||||
if (new Number(yearShort) < 50)
|
||||
year = "20" + yearShort;
|
||||
else
|
||||
year = "19" + yearShort;
|
||||
|
||||
var attachments = new Array();
|
||||
attachments.push({title:authorsShort + " " + year + ".pdf", mimeType:"application/pdf", url:pdf});
|
||||
|
||||
var type = "";
|
||||
if (pageurl.indexOf("/anthology-new/J/")>-1)
|
||||
type = "journalArticle";
|
||||
else
|
||||
type = "conferencePaper";
|
||||
|
||||
if (doImport)
|
||||
callTranslator(bib, type, attachments);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function callTranslator(bibFileURL, type, attachments) {
|
||||
Zotero.Utilities.HTTP.doGet(bibFileURL, function(text) {
|
||||
|
||||
// load BibTex translator
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.itemType = type;
|
||||
item.attachments = attachments;
|
||||
item.repository = "Association for Computational Linguistics"
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var searchResult = true;
|
||||
if(searchResult) {
|
||||
var possibleItems = scrapeIndex(doc, null); // items to present to user
|
||||
|
||||
items = Zotero.selectItems(possibleItems); // items selected by the user
|
||||
if(!items) return true;
|
||||
|
||||
scrapeIndex(doc, items);
|
||||
|
||||
} else {
|
||||
//not implemented yet
|
||||
scrape(doc);
|
||||
}
|
||||
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,415 +0,0 @@
|
|||
{
|
||||
"translatorID": "f3f092bf-ae09-4be6-8855-a22ddd817925",
|
||||
"label": "ACM Digital Library",
|
||||
"creator": "Simon Kornblith, Michael Berkowitz and John McCaffery",
|
||||
"target": "^https?://[^/]*portal\\.acm\\.org[^/]*/(?:results\\.cfm|citation\\.cfm)",
|
||||
"minVersion": "1.0",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": true,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-06-10 01:14:01"
|
||||
}
|
||||
|
||||
/**
|
||||
* The XPath for all the search result <a> elements
|
||||
*/
|
||||
var searchResultX = '//td[@colspan="3"]/a[@class="medium-text" and @target="_self"]';
|
||||
/**
|
||||
* The XPath for all the journal TOC <a> elements
|
||||
*/
|
||||
var tocResultX = '//td[@colspan="1"]/span[@style]/a[contains(@href,"citation.cfm")]';
|
||||
|
||||
/**
|
||||
* The XPath for the tag elements in a justified format tags list
|
||||
*/
|
||||
var justifiedTagX = '//div[@id="divtags"]/p/a';
|
||||
/**
|
||||
* The XPath for the tag elements in an un-justified format tags list
|
||||
*/
|
||||
var unjustifiedTagX = '//div[@id="divtags"]/a';
|
||||
/**
|
||||
* the XPath for the "more tags" link element
|
||||
*/
|
||||
var moreTagsX = '//a[@href="javascript:ColdFusion.Window.show(' + "'thetags'" + ')"]';
|
||||
/**
|
||||
* the XPath for the tag elements in the "more tags" popup
|
||||
*/
|
||||
var moreTagX = '//a/span[@class="small-text"]';
|
||||
/**
|
||||
* the XPath for the title heading element - not strictly necessary, more helpful for debugging
|
||||
*/
|
||||
var titleX = '//div[@class="large-text"]/h1[@class="mediumb-text"]/strong';
|
||||
/**
|
||||
* XPath for Table of Contents headline for journal issue
|
||||
*/
|
||||
var tocX = "//div[@id='citationdetails']//h5[@class='medium-text' and contains(.,'Table of Contents')]";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Scan to see what type of page this is
|
||||
* @param doc The XML document describing the page
|
||||
* @param url The URL of the page being scanned
|
||||
* @return What type of article this page is (multiple, journal or conference proceedings)
|
||||
*/
|
||||
function detectWeb(doc, url) {
|
||||
var nsResolver = getNsResolver(doc);
|
||||
var title = getText(titleX, doc, nsResolver);
|
||||
Zotero.debug("Title: " + title);
|
||||
|
||||
if(url.indexOf("/results.cfm") != -1) {
|
||||
Zotero.debug("Multiple items detected");
|
||||
return "multiple";
|
||||
} else if (url.indexOf("/citation.cfm") != -1) {
|
||||
Zotero.debug("Single item detected");
|
||||
return getArticleType(doc, url, nsResolver);
|
||||
/*
|
||||
var type = getArticleType(doc, url, nsResolver);
|
||||
if (type .indexOf("conferencePaper") != -1) {
|
||||
return "conferencePaper";
|
||||
} else
|
||||
return "journalArticle";
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the page
|
||||
* @param doc The XML document describing the page
|
||||
* @param url The URL of the page being scanned
|
||||
*/
|
||||
function doWeb(doc, url) {
|
||||
var nsResolver = getNsResolver(doc, url);
|
||||
|
||||
//If there are multiple pages
|
||||
if (getArticleType(doc, url) == "multiple") {
|
||||
//If this is a search results page
|
||||
if (url.indexOf("results.cfm") != -1)
|
||||
scrapeMulti(doc, url, nsResolver, "search");
|
||||
else if(getText(tocX, doc, nsResolver) =="Table of Contents")
|
||||
scrapeMulti(doc, url, nsResolver, "toc");
|
||||
Zotero.wait();
|
||||
} //If this is a single page
|
||||
else
|
||||
scrape(doc, url, nsResolver);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrape search results and journal tables of contents
|
||||
* @param doc The XML document describing the page
|
||||
* @param url The URL of the page being scanned
|
||||
* @param nsResolver the namespace resolver function
|
||||
* @param type Type of result-- "search" or "toc"
|
||||
*/
|
||||
function scrapeMulti(doc, url, nsResolver, type) {
|
||||
switch(type) {
|
||||
case "toc":
|
||||
Zotero.debug("Scraping journal TOC");
|
||||
var resultPath= doc.evaluate(tocResultX, doc, null, XPathResult.ANY_TYPE, null);
|
||||
break;
|
||||
case "search":
|
||||
Zotero.debug("Scraping search");
|
||||
default:
|
||||
var resultPath= doc.evaluate(searchResultX, doc, null, XPathResult.ANY_TYPE, null);
|
||||
}
|
||||
|
||||
//Count how mange pages have been scraped
|
||||
var node;
|
||||
var urls = {};
|
||||
//Iterate through all the results
|
||||
while(node= resultPath.iterateNext()) {
|
||||
urls[node.href + '&preflayout=flat'] = node.textContent;
|
||||
}
|
||||
|
||||
var items = Zotero.selectItems(urls);
|
||||
if(!items) return true;
|
||||
|
||||
var i;
|
||||
urls = [];
|
||||
for (i in items) urls.push(i);
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function(){Zotero.done()});
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrape a single page
|
||||
* @param doc The XML document describing the page
|
||||
*/
|
||||
function scrape(doc) {
|
||||
var url = doc.location.href;
|
||||
var nsResolver = getNsResolver(doc, url);
|
||||
|
||||
//Get all the details not scraped from the bibtex file
|
||||
var tags = scrapeKeywords(doc);
|
||||
var attachments = scrapeAttachments(doc, url);
|
||||
var abs = scrapeAbstract(doc);
|
||||
// Type not used, since it was less reliable than BibTeX
|
||||
var type = getArticleType(doc, url, nsResolver);
|
||||
// Manual journal not used. Some pieces are multiply published, see http://portal.acm.org/citation.cfm?id=52400.52432&coll=DL&dl=GUIDECFID=16073284&CFTOKEN=77905982
|
||||
// and also http://forums.zotero.org/discussion/17532/
|
||||
var journal = getText("//meta[@name='citation_journal_title']/@content",doc, nsResolver);
|
||||
//Get the bibtex reference for this document as a string
|
||||
var bibtex = scrapeBibtex(url, nsResolver);
|
||||
|
||||
//Create the new item
|
||||
var newItem = new Zotero.Item(type);
|
||||
|
||||
//Use the bibtex translator to parse the bibtex string
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||
translator.setString(bibtex );
|
||||
//Set the function to run when the bibtex string has been parsed
|
||||
translator.setHandler("itemDone", function(obj, newItem) {
|
||||
//Store all details not parsed from the bibtex
|
||||
if(abs) newItem.abstractNote = abs;
|
||||
newItem.tags = tags;
|
||||
newItem.attachments = attachments;
|
||||
// There were issues with grabbing type from the page;
|
||||
// see http://forums.zotero.org/discussion/17246/
|
||||
//newItem.itemType= type;
|
||||
/*if (journal && journal != newItem.publicationTitle) {
|
||||
newItem.journalAbbreviation = newItem.publicationTitle;
|
||||
newItem.publicationTitle = journal;
|
||||
}*/
|
||||
// If the URL is just a DOI, clear it.
|
||||
if (newItem.url && newItem.url.match(/^http:\/\/doi\.acm\.org\//)) newItem.url = "";
|
||||
if (newItem.DOI) newItem.DOI = newItem.DOI.replace(/^http:\/\/doi\.acm\.org\//, '');
|
||||
var acmid = bibtex.match(/acmid = {(\d+)}/);
|
||||
if(acmid) newItem.extra = "ACM ID: "+ acmid[1];
|
||||
newItem.place = newItem.archiveLocation;
|
||||
newItem.archiveLocation = null;
|
||||
//Complete the parsing of the page
|
||||
newItem.complete();
|
||||
});
|
||||
|
||||
//Trigger the translation
|
||||
translator.translate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrape all keywords attached to this document
|
||||
* @param doc The XML document describing the page
|
||||
* @return an array of all keywords attached to this document
|
||||
*/
|
||||
function scrapeKeywords(doc) {
|
||||
Zotero.debug("Scraping Keywords");
|
||||
//Try scraping keywords from the "more keywords" popup
|
||||
var keywords = scrapeMoreTagsKeywords(doc);
|
||||
|
||||
if (keywords) return keywords;
|
||||
|
||||
keywords = new Array();
|
||||
|
||||
//Otherwise look for the keywords - check justified format
|
||||
var keywordPath = doc.evaluate(justifiedTagX, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var keywordNode = keywordPath.iterateNext();
|
||||
//If justified format didn't work check unjustified
|
||||
if (!keywordNode) {
|
||||
keywordPath = doc.evaluate(unjustifiedTagX, doc, null, XPathResult.ANY_TYPE, null);
|
||||
keywordNode = keywordPath.iterateNext();
|
||||
}
|
||||
//Iterate through all the keywords
|
||||
while(keywordNode) {
|
||||
keywords.push(Zotero.Utilities.trimInternal(keywordNode .textContent.toLowerCase()));
|
||||
Zotero.debug("Keyword: " + keywordNode .textContent.toLowerCase());
|
||||
keywordNode = keywordPath.iterateNext();
|
||||
}
|
||||
|
||||
return keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrape keywords from a "more tags" popup
|
||||
* @param doc The XML document describing the page
|
||||
* @return an array of all the keywords attached to the page which will be used as the tags for the document
|
||||
*/
|
||||
function scrapeMoreTagsKeywords(doc) {
|
||||
var keywords = new Array();
|
||||
|
||||
//Look for a link for a javascript code for a "more tags" popup
|
||||
var morePath = doc.evaluate(moreTagsX, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var moreNode = morePath ? morePath.iterateNext() : null;
|
||||
//If there is no "more tags" popup
|
||||
if (!moreNode)
|
||||
return null;
|
||||
|
||||
var keywordPath = doc.evaluate(moreTagX, doc, null, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var keywordNode;
|
||||
//Iterate through all the keywords
|
||||
while(keywordNode = keywordPath.iterateNext()) {
|
||||
keywords.push(Zotero.Utilities.trimInternal(keywordNode .textContent.toLowerCase()));
|
||||
Zotero.debug("Keyword: " + keywordNode .textContent.toLowerCase());
|
||||
}
|
||||
return keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrape all the relevant attachments from the page.
|
||||
* Firstly grabs a snapshot of the ACM page then looks for any links to the full text
|
||||
* @param doc The XML document describing the page
|
||||
* @param url The URL of the page being scanned
|
||||
* @return an array of all the attachments
|
||||
*/
|
||||
function scrapeAttachments(doc, url) {
|
||||
Zotero.debug("Scraping attachments");
|
||||
var attachments = new Array();
|
||||
|
||||
//Add the scrapeshot of this page
|
||||
attachments.push({title:"ACM Snapshot", mimeType:"text/html", url:url});
|
||||
|
||||
//XPath for the full text links
|
||||
var textPath = doc.evaluate('//a[@name="FullTextPdf" or @name="FullTextHtml" or @name="FullText Html"][not(ancestor::div[@class="flatbody"])]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var textNode;
|
||||
//Iterate through all the links
|
||||
while (textNode= textPath .iterateNext()) {
|
||||
var textURL= textNode.href;
|
||||
|
||||
//If the full text is a pdf
|
||||
if (textNode.name == "FullTextPdf") {
|
||||
Zotero.debug("Text PDF: " + textURL);
|
||||
attachments.push({title:"ACM Full Text PDF", mimeType:"application/pdf", url:textURL});
|
||||
} else { //Otherwise the text is an HTML link
|
||||
Zotero.debug("Text Page: " + textURL);
|
||||
attachments.push({title:"ACM Full Text HTML", mimeType:"text/html", url:textURL});
|
||||
}
|
||||
|
||||
// Break at a reasonable limit
|
||||
if (attachments.length > 20) return attachments;
|
||||
}
|
||||
|
||||
return attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scrape the abstract from the page
|
||||
* @param doc The XML document describing the page
|
||||
* @param url The URL of the page being scanned
|
||||
* @return a string with the text of the abstract
|
||||
*/
|
||||
function scrapeAbstract(doc) {
|
||||
Zotero.debug("Scraping abstract");
|
||||
var text = getText('//div[@class="flatbody" or @class="tabbody"]', doc);
|
||||
return Zotero.Utilities.trimInternal(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text of the bibtex format reference
|
||||
* @param url The URL of the page being scanned
|
||||
* @param nsResolver the namespace resolver function
|
||||
* @return the bibtex reference as a trimmed string
|
||||
*/
|
||||
function scrapeBibtex(url, nsResolver) {
|
||||
Zotero.debug("Scraping full details from bibtex");
|
||||
//Get the ID of this document
|
||||
var id = getId(url);
|
||||
//The link of the bibtex popup
|
||||
var bibtex = "http://portal.acm.org/exportformats.cfm?id=" + id + "&expformat=bibtex";
|
||||
|
||||
Zotero.debug("Bibtex: " + bibtex);
|
||||
|
||||
//Get the xml document which will be loaded into the popup box
|
||||
var texDoc = Zotero.Utilities.retrieveDocument(bibtex);
|
||||
//Find the node with the bibtex text in it
|
||||
var path = texDoc.evaluate('//pre', texDoc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var node = path.iterateNext();
|
||||
|
||||
if (node != null && node.textContent != null) {
|
||||
var ref = node.textContent;
|
||||
Zotero.debug("\nref : " + (ref == null ? "null":ref));
|
||||
ref = Zotero.Utilities.trimInternal(ref);
|
||||
ref = Zotero.Utilities.trim(ref);
|
||||
return ref;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unique identifier of this document
|
||||
* @param url The URL of the page being scanned
|
||||
* @param journal [optional]whether to get the ID of the journal the document is in or of the document itself
|
||||
* @return a string containing the identifier of the document or journal the document is in
|
||||
*/
|
||||
function getId(url, journal) {
|
||||
if (journal=== undefined)
|
||||
journal= false;
|
||||
|
||||
var cfmIndex = url.indexOf(".cfm");
|
||||
var atIndex = url.indexOf('&');
|
||||
|
||||
var id = url.substr(cfmIndex + 8);
|
||||
|
||||
if (atIndex != -1)
|
||||
id = id.replace(url.substring(atIndex), "");
|
||||
|
||||
var dotIndex = id.indexOf('.');
|
||||
if (dotIndex != -1)
|
||||
if (!journal)
|
||||
id = id.replace(id .substring(0, (dotIndex+1)), "");
|
||||
else
|
||||
id = id.replace(id .substring(dotIndex), "");
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find out what kind of document this is
|
||||
* @param doc The XML document describing the page
|
||||
* @param url The URL of the page being scanned
|
||||
* @param nsResolver the namespace resolver function
|
||||
* @return a string with either "multiple", "journalArticle" or "conferencePaper" in it, depending on the type of document
|
||||
*/
|
||||
function getArticleType(doc, url, nsResolver) {
|
||||
var toc = doc.evaluate(tocX, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (url.indexOf("results.cfm") != -1 || toc) {
|
||||
Zotero.debug("Type: multiple");
|
||||
return "multiple";
|
||||
}
|
||||
|
||||
//XPath for the table cell which has either "Journal" or "Proceeding" in it
|
||||
var text = getText('//td[@nowrap="nowrap" and @style="padding-bottom: 0px;"]', doc, nsResolver);
|
||||
|
||||
Zotero.debug("Type: " + text);
|
||||
if (text.indexOf("Proceeding") != -1)
|
||||
return "conferencePaper";
|
||||
else if (text.indexOf("Magazine") != -1)
|
||||
return "magazineArticle";
|
||||
else
|
||||
return "journalArticle";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text from the first node defined by the given xPathString
|
||||
* @param pathString the XPath indicating which node to get the text from
|
||||
* @param doc The XML document describing the page
|
||||
* @param nsResolver the namespace resolver function
|
||||
* @return the text in the defined node or "Unable to scrape text" if the node was not found or if there was no text content
|
||||
*/
|
||||
function getText(pathString, doc, nsResolver) {
|
||||
var path = doc.evaluate(pathString, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var node = path.iterateNext();
|
||||
|
||||
if (node == null || node.textContent == undefined || node.textContent == null) {
|
||||
Zotero.debug("Unable to retrieve text for XPath: "+pathString);
|
||||
return "";
|
||||
}
|
||||
|
||||
return node.textContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a function for returning the namespace of a given document given its prefix
|
||||
* @param nsResolver the namespace resolver function
|
||||
*/
|
||||
function getNsResolver(doc) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace;
|
||||
else return null;
|
||||
} : null;
|
||||
|
||||
return nsResolver;
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
{
|
||||
"translatorID":"938ebe32-2b2e-4349-a5b3-b3a05d3de627",
|
||||
"translatorType":4,
|
||||
"label":"ACS Publications",
|
||||
"creator":"Sean Takats and Michael Berkowitz and Santawort",
|
||||
"target":"http://[^/]*pubs3?.acs.org[^/]*/(?:wls/journals/query/(?:subscriberResults|query)\\.html|acs/journals/toc.page|cgi-bin/(?:article|abstract|sample|asap).cgi)?",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-06-04 19:20:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
if(doc.evaluate('//input[@id="articleListHeader_selectAllToc"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
Zotero.debug("multiple");
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//div[@id="articleHead"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "journalArticle";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function doWeb(doc, url){
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var host = 'http://' + doc.location.host + "/";
|
||||
Zotero.debug(host);
|
||||
var m = url.match(/https?:\/\/[^\/]*\/doi\/(abs|full)\/([^\?]+)/);
|
||||
var dois = new Array();
|
||||
if(detectWeb(doc, url) == "multiple") { //search
|
||||
var doi;
|
||||
var title;
|
||||
var availableItems = new Array();
|
||||
var xpath = '//div[@class="articleBox" or @class="articleBox "]';
|
||||
if (doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var elmt = elmts.iterateNext();
|
||||
do {
|
||||
title = doc.evaluate('./div[@class="articleBoxMeta"]/h2', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
doi = doc.evaluate('./div[@class="articleBoxMeta"]/h2/a/@href', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("/doi/abs/","");
|
||||
if (doi.indexOf("prevSearch") != -1){
|
||||
doi = doi.substring(0,doi.indexOf("?"));
|
||||
}
|
||||
availableItems[doi] = title;
|
||||
} while (elmt = elmts.iterateNext())
|
||||
}
|
||||
var items = Zotero.selectItems(availableItems);
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
for(var i in items) {
|
||||
dois.push(i);
|
||||
}
|
||||
} else if (m){ //single article
|
||||
var doi = m[2];
|
||||
if (doi.match("prevSearch")) {
|
||||
doi = doi.substring(0,doi.indexOf("?"));
|
||||
}
|
||||
Zotero.debug("DOI= "+doi);
|
||||
dois.push(doi);
|
||||
}
|
||||
|
||||
var setupSets = [];
|
||||
for each (doi in dois) {
|
||||
var citUrl = host + 'action/showCitFormats?doi=' + doi;
|
||||
setupSets.push({ doi: doi, citUrl: citUrl });
|
||||
}
|
||||
|
||||
var setupCallback = function () {
|
||||
//get citation export page's source code;
|
||||
if (setupSets.length) {
|
||||
var set = setupSets.shift();
|
||||
Zotero.Utilities.HTTP.doGet(set.citUrl, function(text){
|
||||
//get the exported RIS file name;
|
||||
var downloadFileName = text.match(/name=\"downloadFileName\" value=\"([A-Za-z0-9_]+)\"/)[1];
|
||||
Zotero.debug("downloadfilename= "+downloadFileName);
|
||||
processCallback(set.doi,downloadFileName);
|
||||
});
|
||||
}
|
||||
else {
|
||||
Zotero.done();
|
||||
}
|
||||
}
|
||||
var processCallback = function (doi,downloadFileName) {
|
||||
var baseurl = "http://pubs.acs.org/action/downloadCitation";
|
||||
var post = "doi=" + doi + "&downloadFileName=" + downloadFileName + "&include=abs&format=refman&direct=on&submit=Download+article+citation+data";
|
||||
Zotero.Utilities.HTTP.doPost(baseurl, post,function(text){
|
||||
// Fix the RIS doi mapping
|
||||
text = text.replace("N1 - doi:","M3 - ");
|
||||
Zotero.debug("ris= "+ text);
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
var pdfUrl = host + 'doi/pdf/' + doi;
|
||||
var fullTextUrl = host + 'doi/full/' + doi;
|
||||
item.attachments.push(
|
||||
{title:"ACS Full Text PDF",url:pdfUrl, mimeType:"application/pdf"},
|
||||
{title:"ACS Full Text Snapshot",url:fullTextUrl, mimeType:"text/html"}
|
||||
);
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
setupCallback();
|
||||
});
|
||||
}
|
||||
setupCallback();
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,258 +0,0 @@
|
|||
{
|
||||
"translatorID":"9220fa99-b936-430e-a8ea-43ca6cb04145",
|
||||
"translatorType":4,
|
||||
"label":"AGU Journals",
|
||||
"creator":"Ben Parr",
|
||||
"target":"^https?://(?:www.)?agu.org",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc,url)
|
||||
{
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var xpath;
|
||||
|
||||
//abstract
|
||||
xpath='//p[@id="citation"]';
|
||||
if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext())
|
||||
{ return "journalArticle"; }
|
||||
|
||||
//full text
|
||||
xpath='//frameset[@rows="98, *"]';
|
||||
if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext())
|
||||
{ return "journalArticle"; }
|
||||
|
||||
//issue page
|
||||
xpath='//tr/td/p[@class="title"]';
|
||||
if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext())
|
||||
{ return "multiple"; }
|
||||
|
||||
//Search Page
|
||||
if(doc.title.indexOf("Query Results")>-1)
|
||||
{return "multiple";}
|
||||
}
|
||||
|
||||
|
||||
function fixCaps(s)
|
||||
{
|
||||
if(s!='')
|
||||
{
|
||||
words=Zotero.Utilities.trimInternal(s).toLowerCase().split(" ");
|
||||
for (var j = 0 ; j < words.length ; j++)
|
||||
{
|
||||
if (j==0||(words[j][0] ==words[j][0].toLowerCase()&&words[j]!="or"&&words[j]!="and"&&words[j]!="of"&&words[j]!="in"))
|
||||
{ words[j]= words[j][0].toUpperCase() +words[j].substr(1); }
|
||||
}
|
||||
return words.join(" ");
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
function scrape(doc,url)
|
||||
{
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem=new Zotero.Item("journalArticle");
|
||||
var temp;
|
||||
var xpath;
|
||||
var row;
|
||||
var rows;
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
xpath='//p[@id="title"]';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext();
|
||||
if(temp)
|
||||
{newItem.title=temp.textContent;}
|
||||
|
||||
xpath='//span[@id="published"]';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext();
|
||||
if(temp)
|
||||
{
|
||||
temp=Zotero.Utilities.trimInternal(temp.textContent).split(" ");;
|
||||
newItem.date=temp[1]+" "+temp[0]+", "+temp[2];
|
||||
}
|
||||
|
||||
xpath='//p[@class="author"]';
|
||||
rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
var count=0;
|
||||
while(row=rows.iterateNext())
|
||||
{newItem.creators.push(Zotero.Utilities.cleanAuthor(row.textContent,"author"));
|
||||
count++;}
|
||||
|
||||
xpath='//tr/td/p';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
var temp2=temp.iterateNext();
|
||||
if(temp2)
|
||||
{
|
||||
for(var n=0;n<(3+2*count);n++)
|
||||
{temp2=temp.iterateNext();}
|
||||
newItem.abstractNote=Zotero.Utilities.trimInternal(temp2.textContent);
|
||||
}
|
||||
|
||||
xpath='//p[@id="runhead"]';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext();
|
||||
if(temp)
|
||||
{
|
||||
temp=Zotero.Utilities.trimInternal(temp.textContent).split(", ");
|
||||
newItem.publicationTitle=fixCaps(temp[0]);
|
||||
for(var n=1;temp[n];n++)
|
||||
{
|
||||
if(temp[n].indexOf("VOL")>-1)
|
||||
{newItem.volume=temp[n].replace('VOL. ','');}
|
||||
else if(temp[n].indexOf("NO.")>-1)
|
||||
{newItem.issue=temp[n].replace('NO. ','');}
|
||||
else if(temp[n].indexOf("doi:")>-1)
|
||||
{newItem.DOI=temp[n].replace('doi:','');}
|
||||
else if(temp[n+1])
|
||||
{newItem.pages=temp[n];}
|
||||
}
|
||||
}
|
||||
|
||||
xpath='//p[@id="keywords"]';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext();
|
||||
if(temp)
|
||||
{
|
||||
temp=Zotero.Utilities.trimInternal(temp.textContent.replace('Keywords:',''));
|
||||
newItem.tags=temp.replace('.','').split('; ');
|
||||
}
|
||||
xpath='//p[@id="citation"]/span[@id="journal"]';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext();
|
||||
if(temp)
|
||||
{newItem.journalAbbreviation=temp.textContent;}
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
|
||||
function processList(items)
|
||||
{
|
||||
items = Zotero.selectItems(items);
|
||||
var uris=new Array();
|
||||
|
||||
if (!items)
|
||||
{return true;}
|
||||
|
||||
for (var i in items)
|
||||
{uris.push(i);}
|
||||
|
||||
Zotero.Utilities.processDocuments(uris, scrape,function() {Zotero.done(); });
|
||||
Zotero.wait();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function doWeb(doc,url)
|
||||
{
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
//abstract
|
||||
var xpath='//p[@id="citation"]';
|
||||
if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext())
|
||||
{
|
||||
scrape(doc,url);
|
||||
return true;
|
||||
}
|
||||
|
||||
//full text
|
||||
xpath='//frameset[@rows="98, *"]';
|
||||
if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext())
|
||||
{
|
||||
Zotero.Utilities.processDocuments(url+"0.shtml", scrape, function(){ Zotero.done(); });
|
||||
Zotero.wait();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//issue page
|
||||
xpath='//tr/td/p[@class="title"]';
|
||||
if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext())
|
||||
{
|
||||
var titlerows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
xpath='//tr/td/p[@class="pubdate"]/a';
|
||||
var linkrows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
|
||||
var titlerow;
|
||||
var linkrow;
|
||||
var items=new Array();
|
||||
|
||||
while(titlerow=titlerows.iterateNext())
|
||||
{
|
||||
linkrow=linkrows.iterateNext();
|
||||
while(linkrow.textContent.indexOf("Abstract")<0)
|
||||
{linkrow=linkrows.iterateNext();}
|
||||
items[linkrow.href]=titlerow.textContent;
|
||||
}
|
||||
|
||||
return processList(items);
|
||||
}
|
||||
|
||||
|
||||
//Search page
|
||||
if(doc.title.indexOf("Query Results")>-1)
|
||||
{
|
||||
//FASTFind Search
|
||||
|
||||
xpath='//tr/td/h2';
|
||||
var tt=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE,null).iterateNext().textContent;
|
||||
if(tt.indexOf("FASTFIND")>-1)
|
||||
{
|
||||
xpath='//tr/td[1]/font';
|
||||
var citerows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
xpath='//tr/td[2]/font/a';
|
||||
var linkrows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
|
||||
var citerow;
|
||||
var linkrow;
|
||||
var items=new Array();
|
||||
var temp;
|
||||
var title;
|
||||
|
||||
while(citerow=citerows.iterateNext())
|
||||
{
|
||||
linkrow=linkrows.iterateNext();
|
||||
items[linkrow.href]=Zotero.Utilities.trimInternal(citerow.textContent);
|
||||
}
|
||||
return processList(items);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Advanced Search
|
||||
|
||||
xpath='//tr/td[1]/font/a';
|
||||
var titlerows=doc.evaluate(xpath, doc,nsResolver,XPathResult.ANY_TYPE, null);
|
||||
xpath='//tr/td[2]/font/a';
|
||||
var linkrows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
|
||||
var titlerow;
|
||||
var linkrow;
|
||||
var items=new Array();
|
||||
var temp;
|
||||
|
||||
while(titlerow=titlerows.iterateNext())
|
||||
{
|
||||
linkrow=linkrows.iterateNext();
|
||||
while(linkrow.textContent.indexOf("Abstract")<0)
|
||||
{linkrow=linkrows.iterateNext();}
|
||||
|
||||
items[linkrow.href]=titlerow.textContent;
|
||||
}
|
||||
return processList(items);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
{
|
||||
"translatorID":"0a01d85e-483c-4998-891b-24707728d83e",
|
||||
"translatorType":4,
|
||||
"label":"AJHG",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://(www.)?ajhg.org/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-02-14 23:15:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//div[@class="article_links"]/a[1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (url.indexOf("abstract") != -1 || url.indexOf("fulltext") != -1) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function getID(str) {
|
||||
str = str.match(/\/([^/]+)$/)[1];
|
||||
if (str.indexOf("#") != -1) {
|
||||
str = str.substr(0, str.length - 1);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
if (doc.title.indexOf("Search Results") != -1) {
|
||||
var xpath = '//table[@id="search_results"]/tbody/tr/td[1]';
|
||||
var titlex = './strong';
|
||||
var linkx = './div/a[1]';
|
||||
} else {
|
||||
var xpath = '//div[@id="main_toc"]/dl';
|
||||
var titlex = './dt';
|
||||
var linkx = './dd/div/a[1]';
|
||||
}
|
||||
var blocks = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var next_block;
|
||||
while (next_block = blocks.iterateNext()) {
|
||||
var title = doc.evaluate(titlex, next_block, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
var link = doc.evaluate(linkx, next_block, null, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
items[link] = title;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(getID(i));
|
||||
}
|
||||
} else {
|
||||
articles = [getID(url)];
|
||||
}
|
||||
Zotero.debug(articles);
|
||||
for (var i in articles) {
|
||||
var poststr = 'format=cite-abs&citation-type=RIS&pii=' + articles[i] + '&action=download&Submit=Export';
|
||||
var pdfurl = 'http://download.ajhg.org/AJHG/pdf/PII' + articles[i].replace(/(\(|\)|\-)/g, "") + '.pdf';
|
||||
var newurl = 'http://www.ajhg.org/AJHG/fulltext/' + articles[i];
|
||||
Zotero.Utilities.HTTP.doPost('http://ajhg.org/AJHG/citationexport', poststr, function(text) {
|
||||
var trans = Zotero.loadTranslator("import");
|
||||
trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
trans.setString(text);
|
||||
trans.setHandler("itemDone", function(obj, item) {
|
||||
item.attachments = [
|
||||
{url:newurl, title:"AJHG Snapshot", mimeType:"text/html"},
|
||||
{url:pdfurl, title:"AJHG Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
|
||||
if (item.notes[0]["note"]) {
|
||||
item.abstractNote = item.notes[0]["note"];
|
||||
}
|
||||
item.notes = [];
|
||||
item.complete();
|
||||
});
|
||||
trans.translate();
|
||||
Zotero.done();
|
||||
});
|
||||
}
|
||||
Zotero.wait();
|
||||
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
{
|
||||
"translatorID":"bdaac15c-b0ee-453f-9f1d-f35d00c7a994",
|
||||
"translatorType":4,
|
||||
"label":"AMS Journals",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.ams.org/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/jour(nals|search)/)) {
|
||||
return "multiple";
|
||||
} else if (url.match(/\d{4}\-\d{2}\-\d{2}/)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
if (url.match(/joursearch/)) {
|
||||
var titlex = '//table/tbody/tr/td/span[@class="searchResultsArticleTitle"]';
|
||||
var linkx = '//table/tbody/tr[td/span[@class="searchResultsArticleTitle"]]//a[contains(text(), "Abstract")]';
|
||||
} else {
|
||||
var titlex = '//div[@class="contentList"]/dl/dt[@class="articleTitleInAbstract"]';
|
||||
var linkx = '//div[@class="contentList"]/dl/dd/a[contains(text(), "Abstract")]'
|
||||
}
|
||||
var titles = doc.evaluate(titlex, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate(linkx, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var title, link;
|
||||
while ((title = titles.iterateNext()) && (link = links.iterateNext())) {
|
||||
items[link.href] = Zotero.Utilities.trimInternal(title.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(decodeURIComponent(i));
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.debug(articles);
|
||||
Zotero.Utilities.processDocuments(articles, function(doc) {
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
item.publicationTitle = doc.title;
|
||||
item.ISSN = doc.evaluate('//span[@class="journalISSN"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/\(e\)\s+ISSN:?\s+(.*)\(p\)/)[1];
|
||||
item.title = Zotero.Utilities.trimInternal(doc.evaluate('//p[@class="articleTitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var data = Zotero.Utilities.trimInternal(doc.evaluate('//p[span[@class="bibDataTag"]][1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
data = data.replace(/(Journal|MSC|Posted|Retrieve)/g, "\n$1");
|
||||
Zotero.debug(data);
|
||||
var authors = data.match(/Author\(s\):\s+(.*)\n/)[1].split(/;\s+/);
|
||||
for each (var aut in authors) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
|
||||
}
|
||||
var journalinfo = data.match(/Journal:\s+(.*)\n/)[1].match(/^([^\d]+)(\d+)\s+\((\d+)\),\s+(.*)$/);
|
||||
item.journalAbbreviation = journalinfo[1];
|
||||
item.volume = journalinfo[2];
|
||||
item.pages = journalinfo[4];
|
||||
item.date = Zotero.Utilities.trimInternal(data.match(/Posted:\s+(.*)\n/)[1]);
|
||||
item.url = doc.location.href;
|
||||
item.issue = item.url.match(/(\d+)\/S/)[1];
|
||||
var pdfurl = item.url.replace(/([^/]+)\/home.html$/, "$1/$1.pdf");
|
||||
item.attachments = [
|
||||
{url:item.url, title:item.journalAbbreviation + " Snapshot", mimeType:"text/html"},
|
||||
{url:pdfurl, title:item.journalAbbreviation + " PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
item.abstract = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="bottomCell"]/p[4]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(10));
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
{
|
||||
"translatorID":"a354331-981b-43de-a61-bc26dd1be3a9",
|
||||
"label":"AMS MathSciNet",
|
||||
"creator":"Simon Kornblith",
|
||||
"target":"^https?://www\\.ams\\.org[^/]*/mathscinet/search/(?:publications\\.html|publdoc\\.html)",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":"1",
|
||||
"translatorType":4,
|
||||
"lastUpdated":"2010-06-06 19:00:50"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var tableRows = doc.evaluate('//div[@id="content"]/form/div[@class="headline"]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null);
|
||||
if(tableRows.iterateNext()) {
|
||||
return "multiple"
|
||||
} else if(doc.evaluate('//div[@id="titleSeparator"]/div[@class="navbar"]/span[@class="PageLink"]/a[text() = "Up"]',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var pub = "http://www.ams.org/mathscinet/search/publications.html?fmt=bibtex";
|
||||
|
||||
var tableRows = doc.evaluate('//div[@id="content"]/form/div[@class="headline"]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null);
|
||||
var tableRow = tableRows.iterateNext();
|
||||
if(tableRow) {
|
||||
// search page
|
||||
var items = new Object();
|
||||
var links = new Object();
|
||||
|
||||
do {
|
||||
var id = doc.evaluate('.//input[@type="checkbox"]', tableRow, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
items[id] = doc.evaluate('./div[@class="headlineText"]/span[@class="title"]', tableRow, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
links[id] = doc.evaluate('.//a', tableRow, nsResolver, XPathResult.ANY_TYPE,
|
||||
null).iterateNext().href;
|
||||
} while(tableRow = tableRows.iterateNext())
|
||||
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
if(!items) return true;
|
||||
|
||||
var docLinks = new Array();
|
||||
for(var id in items) {
|
||||
pub += "&b="+id;
|
||||
docLinks.push(links[id]);
|
||||
}
|
||||
} else {
|
||||
var MR = doc.evaluate('//div[@id="content"]/div[@class="doc"]/div[@class="headline"]/strong',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
pub += "&b="+MR.replace(/^MR0*/, "");
|
||||
}
|
||||
|
||||
Zotero.Utilities.HTTP.doGet(pub, function(text) {
|
||||
var m = text.match(/<pre>(?:.|[\r\n])*?<\/pre>/g);
|
||||
var bibTeXString = "";
|
||||
for each(var citation in m) {
|
||||
// kill pre tags
|
||||
citation = citation.substring(5, citation.length-6);
|
||||
bibTeXString += citation;
|
||||
}
|
||||
|
||||
// import using BibTeX
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||
translator.setString(bibTeXString);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
if(docLinks) {
|
||||
item.attachments.push({title:"MathSciNet Snapshot", url:docLinks.shift(), mimeType:"text/html"});
|
||||
} else {
|
||||
item.attachments.push({title:"MathSciNet Snapshot", document:doc});
|
||||
}
|
||||
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
|
||||
Zotero.done();
|
||||
});
|
||||
}
|
|
@ -1,146 +0,0 @@
|
|||
{
|
||||
"translatorID": "1e1e35be-6264-45a0-ad2e-7212040eb984",
|
||||
"label": "APA PsycNET",
|
||||
"creator": "Michael Berkowitz",
|
||||
"target": "^http://psycnet\\.apa\\.org/",
|
||||
"minVersion": "2.1",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"browserSupport": "gcs",
|
||||
"inRepository": true,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-08-22 22:43:11"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/search\.searchResults/)) {
|
||||
return false;
|
||||
//return "multiple";
|
||||
} else if (url.match(/search\.displayRecord/)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function associateXPath(xpath, doc, ns) {
|
||||
return Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//div[@class="srhcTitle"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
while (title = titles.iterateNext()) {
|
||||
items[title.href] = title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
arts.push(i);
|
||||
}
|
||||
Zotero.Utilities.processDocuments(arts, scrape, function() {Zotero.done();});
|
||||
} else {
|
||||
scrape(doc);
|
||||
}
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
function scrape (doc) {
|
||||
var namespace = null;
|
||||
var newurl = doc.location.href;
|
||||
if (doc.evaluate('//input[@name="id"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var id = doc.evaluate('//input[@name="id"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var lstSelectedUIDs = doc.evaluate('//input[@name="lstUIDs"][@id="srhLstUIDs"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var get = 'http://psycnet.apa.org/index.cfm?fa=search.export'
|
||||
var post = 'id=' + id + '&lstUIDs=' + lstSelectedUIDs + '&lstSelectedUIDs=&records=records&displayFormat=&exportFormat=referenceSoftware&printDoc=0';
|
||||
// http://psycnet.apa.org/index.cfm?fa=search.exportFormat&singlerecord=1
|
||||
// id=&lstSelectedUIDs=&lstUIDs=2004-16644-010&records=records&displayFormat=&exportFormat=referenceSoftware&printDoc=0
|
||||
Zotero.Utilities.HTTP.doPost(get, post, function(text) {
|
||||
// http://psycnet.apa.org/index.cfm?fa=search.export
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
//Z.debug(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
//item.url = newurl;
|
||||
//item.attachments = [{url:newurl, title:"APA PsycNET Snapshot", mimeType:"text/html"}];
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
} else {
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
item.title = associateXPath('//div[@id="rdcTitle"]', doc, nsResolver);
|
||||
var authors = associateXPath('//div[@id="rdcAuthors"]', doc, nsResolver).split(/;\s+/);
|
||||
for each (var aut in authors) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true));
|
||||
}
|
||||
var voliss = associateXPath('//div[@id="rdcSource"]', doc, nsResolver).match(/^([^\.]+)\.\s+(\d+\s+\w+)\s+Vol\s+(\d+)\((\d+)\)\s+(.*)$/);
|
||||
item.publicationTitle = voliss[1];
|
||||
item.date = voliss[2];
|
||||
item.volume = voliss[3];
|
||||
item.issue = voliss[4];
|
||||
item.pages = voliss[5];
|
||||
item.abstractNote = associateXPath('//div[@id="rdRecord"]/div[@class="rdRecordSection"][2]', doc, nsResolver);
|
||||
item.complete();
|
||||
}
|
||||
}/** BEGIN TEST CASES **/
|
||||
var testCases = [
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://psycnet.apa.org/index.cfm?fa=search.displayRecord&uid=2004-16644-010",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "journalArticle",
|
||||
"creators": [
|
||||
{
|
||||
"lastName": "Hervey",
|
||||
"firstName": "Aaron S.",
|
||||
"creatorType": "author"
|
||||
},
|
||||
{
|
||||
"lastName": "Epstein",
|
||||
"firstName": "Jeffery N.",
|
||||
"creatorType": "author"
|
||||
},
|
||||
{
|
||||
"lastName": "Curry",
|
||||
"firstName": "John F.",
|
||||
"creatorType": "author"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [
|
||||
"attention-deficit/hyperactivity disorder",
|
||||
"adults",
|
||||
"behavioral inhibition",
|
||||
"neuropsychological performance",
|
||||
"developmental considerations",
|
||||
"neuropsychological deficits",
|
||||
"empirical methods"
|
||||
],
|
||||
"seeAlso": [],
|
||||
"attachments": [],
|
||||
"itemID": "2004-16644-010",
|
||||
"title": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder: A Meta-Analytic Review.",
|
||||
"publicationTitle": "Neuropsychology",
|
||||
"volume": "18",
|
||||
"issue": "3",
|
||||
"pages": "485-503",
|
||||
"date": "2004",
|
||||
"publisher": "US: American Psychological Association",
|
||||
"ISBN": "1931-1559 (Electronic); 0894-4105 (Print)",
|
||||
"ISSN": "1931-1559 (Electronic); 0894-4105 (Print)",
|
||||
"abstractNote": "A comprehensive, empirically based review of the published studies addressing neuropsychological performance in adults diagnosed with attention-deficit/hyperactivity disorder (ADHD) was conducted to identify patterns of performance deficits. Findings from 33 published studies were submitted to a meta-analytic procedure producing sample-size-weighted mean effect sizes across test measures. Results suggest that neuropsychological deficits are expressed in adults with ADHD across multiple domains of functioning, with notable impairments in attention, behavioral inhibition, and memory, whereas normal performance is noted in simple reaction time. Theoretical and developmental considerations are discussed, including the role of behavioral inhibition and working memory impairment. Future directions for research based on these findings are highlighted, including further exploration of specific impairments and an emphasis on particular tests and testing conditions. (PsycINFO Database Record (c) 2010 APA, all rights reserved)",
|
||||
"DOI": "10.1037/0894-4105.18.3.485",
|
||||
"libraryCatalog": "APA PsycNET",
|
||||
"shortTitle": "Neuropsychology of Adults With Attention-Deficit/Hyperactivity Disorder"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
/** END TEST CASES **/
|
File diff suppressed because one or more lines are too long
|
@ -1,65 +0,0 @@
|
|||
{
|
||||
"translatorID":"2c310a37-a4dd-48d2-82c9-bd29c53c1c76",
|
||||
"translatorType":4,
|
||||
"label":"APS",
|
||||
"creator":"Eugeniy Mikhailov and Michael Berkowitz",
|
||||
"target":"https?://(?:www\\.)?(prola|prl|pra|prb|prc|prd|pre|prst-ab|prst-per|rmp)\\.aps\\.org[^/]*/(toc|abstract|forward|showrefs|supplemental)/",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":null,
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
// Works for all APS journals: http://publish.aps.org/
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
// toc indicates table of contents, forward is a "Citing articles" page
|
||||
if (/\/toc\//.test(url) || (/\/forward\//.test(url))){
|
||||
return "multiple";
|
||||
} else {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, "abstract");
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
arts.push(i);
|
||||
}
|
||||
} else {
|
||||
arts = [url];
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(arts, function(newDoc) {
|
||||
Zotero.debug(newDoc.title);
|
||||
// Use abstract only if we have one
|
||||
if (newDoc.evaluate('//div[contains(@class, "aps-abstractbox")]/p', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext()) var abs = Zotero.Utilities.trimInternal(newDoc.evaluate('//div[contains(@class, "aps-abstractbox")]/p', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var urlRIS = newDoc.location.href;
|
||||
urlRIS = urlRIS.replace(/(abstract|forward|showrefs|supplemental)/,"export");
|
||||
var post = "type=ris";
|
||||
var snapurl = newDoc.location.href;
|
||||
var pdfurl = snapurl.replace(/(abstract|forward|showrefs|supplemental)/, "pdf");
|
||||
Zotero.Utilities.HTTP.doPost(urlRIS, post, function(text) {
|
||||
// load translator for RIS
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
if (item.itemID) {
|
||||
item.DOI = item.itemID;
|
||||
}
|
||||
item.attachments = [
|
||||
{url:snapurl, title:"APS Snapshot", mimeType:"text/html"},
|
||||
{url:pdfurl, title:"APS Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
if (abs) item.abstractNote = abs;
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
}, null, 'UTF-8');
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
{
|
||||
"translatorID":"72cb2536-3211-41e0-ae8b-974c0385e085",
|
||||
"translatorType":4,
|
||||
"label":"ARTFL Encyclopedie",
|
||||
"creator":"Sean Takats",
|
||||
"target":"/cgi-bin/philologic31/(getobject\\.pl\\?c\\.[0-9]+:[0-9]+\\.encyclopedie|search3t\\?dbname=encyclopedie0507)",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.indexOf("getobject.pl") != -1){
|
||||
return "encyclopediaArticle";
|
||||
} else {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function reconcileAuthor(author){
|
||||
var authorMap = {
|
||||
"Venel":"Venel, Gabriel-François",
|
||||
"d'Aumont":"d'Aumont, Arnulphe",
|
||||
"de La Chapelle":"de La Chapelle, Jean-Baptiste",
|
||||
"Bourgelat":"Bourgelat, Claude",
|
||||
"Dumarsais":"Du Marsais, César Chesneau",
|
||||
"Mallet":"Mallet, Edme-François",
|
||||
"Toussaint":"Toussaint, François-Vincent",
|
||||
"Daubenton":"Daubenton, Louis-Jean-Marie",
|
||||
"d'Argenville": "d'Argenville, Antoine-Joseph Desallier",
|
||||
"Tarin":"Tarin, Pierre",
|
||||
"Vandenesse":"de Vandenesse, Urbain",
|
||||
"Blondel": "Blondel, Jacques-François",
|
||||
"Le Blond":"Le Blond, Guillaume",
|
||||
"Rousseau":"Rousseau, Jean-Jacques",
|
||||
"Eidous":"Eidous, Marc-Antoine",
|
||||
"d'Alembert":"d'Alembert, Jean le Rond",
|
||||
"Louis":"Louis, Antoine",
|
||||
"Bellin":"Bellin, Jacques-Nicolas",
|
||||
"Diderot":"Diderot, Denis",
|
||||
"Diderot1":"Diderot, Denis",
|
||||
"Diderot2":"Diderot, Denis",
|
||||
"de Jaucourt":"de Jaucourt, Chevalier Louis",
|
||||
"Jaucourt":"de Jaucourt, Chevalier Louis",
|
||||
"d'Holbach":"d'Holbach, Baron"
|
||||
/* not yet mapped
|
||||
Yvon
|
||||
Forbonnais
|
||||
Douchet and Beauzée
|
||||
Boucher d'Argis
|
||||
Lenglet Du Fresnoy
|
||||
Cahusac
|
||||
Pestré
|
||||
Daubenton, le Subdélégué
|
||||
Goussier
|
||||
de Villiers
|
||||
Barthès
|
||||
Morellet
|
||||
Malouin
|
||||
Ménuret de Chambaud
|
||||
Landois
|
||||
Le Roy
|
||||
*/
|
||||
}
|
||||
if(authorMap[author]) {
|
||||
author = authorMap[author];
|
||||
}
|
||||
// remove ARTFL's trailing 5 for odd contributors (e.g. Turgot5)
|
||||
if (author.substr(author.length-1, 1)=="5"){
|
||||
author = author.substr(0, author.length-1);
|
||||
}
|
||||
return author;
|
||||
}
|
||||
|
||||
function scrape (doc){
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var url = doc.location.href;
|
||||
var newItem = new Zotero.Item("encyclopediaArticle");
|
||||
var xpath = '/html/body/div[@class="text"]/font';
|
||||
var titleElmt = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (titleElmt) {
|
||||
var title = titleElmt.textContent;
|
||||
} else {
|
||||
xpath = '/html/body/div[@class="text"]/b';
|
||||
var title = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
newItem.title = title;
|
||||
newItem.encyclopediaTitle = "Encyclopédie, ou Dictionnaire raisonné des sciences, des arts et des métiers";
|
||||
newItem.shortTitle = "Encyclopédie";
|
||||
newItem.date = "1751-1772";
|
||||
newItem.publisher = "Briasson";
|
||||
newItem.place = "Paris";
|
||||
newItem.url = url;
|
||||
|
||||
newItem.attachments.push({title:"ARTFL Snapshot", mimeType:"text/html", url:url, snapshot:true});
|
||||
|
||||
// get author and tags
|
||||
var hostRegexp = new RegExp("^(https?://[^/]+)/");
|
||||
var hMatch = hostRegexp.exec(url);
|
||||
var host = hMatch[1];
|
||||
var getString1 = "/cgi-bin/philologic31/search3t?dbname=encyclopedie0507&word=&dgdivhead=";
|
||||
var getString2 = "&dgdivocauthor=&dgdivocplacename=&dgdivocsalutation=&dgdivocclassification=&dgdivocpartofspeech=&dgdivtype=&CONJUNCT=PHRASE&DISTANCE=3&PROXY=or+fewer&OUTPUT=conc&POLESPAN=5&KWSS=1&KWSSPRLIM=500";
|
||||
|
||||
Zotero.Utilities.HTTP.doGet(host+getString1+title+getString2, function(text){
|
||||
var tagRe = new RegExp('>'+title+'</a>[^\[]*\\[([^\\]]*)\]', 'i');
|
||||
var m = tagRe.exec(text);
|
||||
if(m[1] != "unclassified"){
|
||||
var tagstring = m[1].replace("&", "&", "g");
|
||||
var tags = tagstring.split(";")
|
||||
for(var j in tags) {
|
||||
newItem.tags.push(Zotero.Utilities.trimInternal(tags[j]));
|
||||
}
|
||||
}
|
||||
var authorRe = new RegExp('>'+title+'</a>,([^,]*),', "i");
|
||||
var m = authorRe.exec(text);
|
||||
var author = m[1];
|
||||
author = Zotero.Utilities.trimInternal(author);
|
||||
// reconcile author
|
||||
author = reconcileAuthor(author);
|
||||
if (author!="NA"){ // ignore unknown authors
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author", true));
|
||||
}
|
||||
newItem.creators.push({firstName:"Denis", lastName:"Diderot", creatorType:"editor"});
|
||||
newItem.creators.push({firstName:"Jean le Rond", lastName:"d'Alembert", creatorType:"editor"});
|
||||
newItem.complete();
|
||||
}, function() {Zotero.done();}, null);
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
if (url.indexOf("getobject.pl") != -1){
|
||||
// single article
|
||||
scrape(doc);
|
||||
} else {
|
||||
//search page
|
||||
var items = new Object();
|
||||
var xpath = '/html/body/div[@class="text"]/p/a';
|
||||
var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var elmt;
|
||||
while (elmt = elmts.iterateNext()){
|
||||
var title = elmt.textContent;
|
||||
var link = elmt.href;
|
||||
if (title && link){
|
||||
items[link] = title;
|
||||
}
|
||||
}
|
||||
var items = Zotero.selectItems(items);
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); });
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,274 +0,0 @@
|
|||
{
|
||||
"translatorID":"5278b20c-7c2c-4599-a785-12198ea648bf",
|
||||
"translatorType":4,
|
||||
"label":"ARTstor",
|
||||
"creator":"Ameer Ahmed and Michael Berkowitz",
|
||||
"target":"http://[^/]artstor.org[^/]*",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-11-13 07:10:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/(S|s)earch/) && (doc.evaluate('//div[@id="thumbContentWrap"]/div', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/\w+/))) return "multiple"
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
if (url.indexOf("|")!=-1){
|
||||
scrape(doc, url);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove this when we drop support for Fx3
|
||||
if (!JSON) {
|
||||
var JSON = new function() {
|
||||
this.parse = function (arg) {
|
||||
var j;
|
||||
if (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/.test(arg.
|
||||
replace(/\\./g, '@').
|
||||
replace(/"[^"\\\n\r]*"/g, ''))) {
|
||||
// Friendly AMO reviewer: This is the official json.org library and is safe.
|
||||
j = eval('(' + arg + ')');
|
||||
return j;
|
||||
}
|
||||
throw new SyntaxError('parseJSON');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url){
|
||||
var savedItems = new Array();
|
||||
var saved = 0;
|
||||
var urlstub = url.substring(url.indexOf('.org/')+5,url.length);
|
||||
urlstub = url.substring(0,url.indexOf('.org/')+5) + urlstub.substring(0, urlstub.indexOf('/')+1)
|
||||
var suburl = url.substring(url.indexOf('|')+1, url.length);
|
||||
var groupname = suburl.substring(0, suburl.indexOf("|"));
|
||||
var searchterm = '//*[@id="thumbSubTitle"]';
|
||||
var stt = doc.evaluate(searchterm, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
var st = stt.firstChild.nodeValue;
|
||||
var pageNn = '//*[@id="pageNo"]';
|
||||
var stt = doc.evaluate(pageNn, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
var pg;
|
||||
if (stt.value==1){
|
||||
pg = 1;
|
||||
} else if (stt.value==2){
|
||||
pg = 25;
|
||||
} else {
|
||||
pg = ((stt.value-1) * 24) + 1;
|
||||
}
|
||||
var groupid;
|
||||
//check if user is on search page if not construct the query using the 2nd pattern
|
||||
if (groupname.indexOf("search")!=-1){
|
||||
groupid = "1/" + pg + "/24/0?tn=1&name=&id=all&kw=" +st + "&type=1";
|
||||
}else {
|
||||
groupid = suburl.substring(suburl.indexOf('|')+1, suburl.indexOf('||')) + "//thumbnails/" + pg + "/24/0";
|
||||
}
|
||||
// Initial query to get results from the service - primary purpose is to get objectids. which in turn are required for the 2nd service call, which exposes the actual metadata
|
||||
Zotero.Utilities.HTTP.doGet(urlstub + "secure/" + groupname + "//" + groupid, function(text) {
|
||||
var json = JSON.parse(text);
|
||||
items = new Object();
|
||||
for(var i=0; i<json.thumbnails.length; i++) {
|
||||
child = json.thumbnails[i];
|
||||
var tmpUrl = urlstub + "secure/metadata/" + child.objectId + "?_method=Infolder";
|
||||
//here we are saving the url service call to get each objects metadata
|
||||
savedItems[saved] = tmpUrl;
|
||||
items[tmpUrl]=child.objectId;
|
||||
saved++;
|
||||
}
|
||||
// GET VALUES FROM THE WEB
|
||||
var xpath = '//div[@id="thumbContentWrap"]';
|
||||
var elmts = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
var webitems = new Object();
|
||||
var selectedNums = new Array();
|
||||
var si=0;
|
||||
var c = elmts.getElementsByTagName('*');
|
||||
var title = "";
|
||||
for(var i=0; i<c.length; i++) {
|
||||
var child = c[i];
|
||||
if (child.id.indexOf("_imageHolder")!=-1){
|
||||
var csss = child.style;
|
||||
var glow = csss.getPropertyValue('border');
|
||||
}
|
||||
if (child.id.indexOf("_thumb1")!=-1){
|
||||
title = child.title;
|
||||
}
|
||||
if (child.id.indexOf("_thumb2")!=-1){
|
||||
title+= " :: " + child.title;
|
||||
}
|
||||
if (child.id.indexOf("_thumb3")!=-1){
|
||||
var childtitle = child.title;
|
||||
var dialogTitle = title;
|
||||
if (childtitle.length>1) {
|
||||
dialogTitle+=" " + childtitle;
|
||||
}
|
||||
var sitem = child.id.substring(6,child.id.indexOf("_"));
|
||||
webitems[sitem-1] = dialogTitle;
|
||||
if (glow.indexOf(75)!=-1){
|
||||
selectedNums[si]=sitem-1;
|
||||
si++;
|
||||
}
|
||||
title = null;
|
||||
}
|
||||
}
|
||||
// GET VALUES FROM THE WEB
|
||||
var tcount=0;
|
||||
var newitems = null;
|
||||
if (selectedNums.length>0){
|
||||
newitems = new Object();
|
||||
for (j=0; j<selectedNums.length;j++){
|
||||
var numnum = selectedNums[j];
|
||||
for (var x in items){
|
||||
if (numnum==tcount){
|
||||
newitems[x] = webitems[tcount];
|
||||
tcount=0;
|
||||
break;
|
||||
} else {
|
||||
tcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tcount = 0;
|
||||
for (var x in items){
|
||||
items[x] = webitems[tcount];
|
||||
tcount++;
|
||||
}
|
||||
}
|
||||
if (newitems!=null){
|
||||
items = newitems;
|
||||
}
|
||||
//show dialogbox
|
||||
var items = Zotero.selectItems(items);
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
//this gets called when an object is selected in the dialog box, fires off a get on the service url
|
||||
Zotero.Utilities.HTTP.doGet(urls, function(text) {
|
||||
var json = JSON.parse(text);
|
||||
var newArticle = new Zotero.Item('artwork');
|
||||
for (var i=0; i<json.metaData.length; i++) {
|
||||
child = json.metaData[i];
|
||||
// MISSING CULTURE!!!
|
||||
if (child.fieldName.indexOf("Title")!=-1){
|
||||
if (newArticle.title!=null){
|
||||
newArticle.title+= ";" + child.fieldValue;
|
||||
} else {
|
||||
newArticle.title = child.fieldValue;
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Creator")!=-1){
|
||||
if (child.fieldValue != "") {
|
||||
if (child.fieldValue.match(/,/)) {
|
||||
var aut = child.fieldValue.match(/^([^,]+),\s+(.*)$/);
|
||||
if (aut[1].match(/\s/)) {
|
||||
newArticle.notes.push({note:"Artist information: " + aut[2]});
|
||||
newArticle.creators.push(Zotero.Utilities.cleanAuthor(aut[1], "artist"));
|
||||
} else {
|
||||
var extras = aut[2].match(/^([^,]+),\s+(.*)$/);
|
||||
newArticle.creators.push({firstName:extras[1], lastName:aut[1], creatorType:"author"});
|
||||
newArticle.notes.push({note:"Artist information: " + extras[2]});
|
||||
}
|
||||
} else {
|
||||
newArticle.creators.push(Zotero.Utilities.cleanAuthor(child.fieldValue, "artist"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Culture")!=-1){
|
||||
newArticle.creators.push(Zotero.Utilities.cleanAuthor(child.fieldValue, "producer", true));
|
||||
}
|
||||
if (child.fieldName.indexOf("Rights")!=-1){
|
||||
if (newArticle.rights!=null){
|
||||
newArticle.rights+= ";" + child.fieldValue.replace(/<wbr\/>/g, "");
|
||||
} else {
|
||||
newArticle.rights = child.fieldValue.replace(/<wbr\/>/g, "");
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Subject")!=-1){
|
||||
newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue));
|
||||
}
|
||||
if (child.fieldName.indexOf("Location")!=-1){
|
||||
newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue));
|
||||
}
|
||||
if (child.fieldName.indexOf("Style Period")!=-1){
|
||||
newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue));
|
||||
}
|
||||
if (child.fieldName.indexOf("Work Type")!=-1){
|
||||
newArticle.tags.push(Zotero.Utilities.trimInternal(child.fieldValue));
|
||||
}
|
||||
if (child.fieldName.indexOf("Material")!=-1 || child.fieldName.indexOf("Technique")!=-1 ){
|
||||
if (newArticle.artworkMedium!=null){
|
||||
newArticle.artworkMedium+= ";" + Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
} else {
|
||||
newArticle.artworkMedium = Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Measurements")!=-1){
|
||||
if (newArticle.artworkSize!=null){
|
||||
newArticle.artworkSize+= ";" + Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
} else {
|
||||
newArticle.artworkSize = Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Date")!=-1){
|
||||
if (newArticle.date!=null){
|
||||
newArticle.date+= ";" + Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
} else {
|
||||
//bug here!! when date parser fails, entire object is not saved in Zotero - works in Scaffold, fails in Zotero! to patch remove all occurrences of B.C
|
||||
newArticle.date = Zotero.Utilities.trimInternal(child.fieldValue.replace(/B.C./i, ""));
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Repository")!=-1){
|
||||
if (newArticle.repository!=null){
|
||||
newArticle.repository+= ";" + Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
} else {
|
||||
newArticle.repository = Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Source")!=-1){
|
||||
if (newArticle.archiveLocation!=null){
|
||||
newArticle.archiveLocation+= ";" + Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
} else {
|
||||
newArticle.archiveLocation = Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Description")!=-1){
|
||||
if (newArticle.abstractNote!=null){
|
||||
newArticle.abstractNote+= ";" + Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
} else {
|
||||
newArticle.abstractNote = Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
}
|
||||
}
|
||||
if (child.fieldName.indexOf("Collection")!=-1){
|
||||
if (newArticle.extra!=null){
|
||||
newArticle.extra+= ";" + Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
} else {
|
||||
newArticle.extra = Zotero.Utilities.trimInternal(child.fieldValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
var objectId = json.objectId;
|
||||
//this is called to get the url stub for the ARTstor viewer
|
||||
Zotero.Utilities.HTTP.doGet(urlstub + "secure/metadata/" + objectId + "?_method=FpHtml", function(dom) {
|
||||
var testurl = dom.substring(dom.lastIndexOf('<td class="data">')+21,dom.lastIndexOf('</td>'));
|
||||
var t2 = "http://www.artstor.org";
|
||||
var tmp2 = testurl.replace(/<wbr\/>/g, "");
|
||||
tmp2 = tmp2.substring(0, tmp2.indexOf("&userId"));
|
||||
//build ARTstorImageURL
|
||||
artstorimgurl = t2+tmp2;
|
||||
newArticle.url = artstorimgurl;
|
||||
newArticle.callNumber = objectId;
|
||||
newArticle.complete();
|
||||
Zotero.done();
|
||||
});
|
||||
Zotero.wait();
|
||||
});
|
||||
Zotero.wait();
|
||||
});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
{
|
||||
"translatorID":"303bdfc5-11b8-4107-bca1-63ca97701a0f",
|
||||
"translatorType":4,
|
||||
"label":"ASCE",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"^http://ascelibrary.aip.org/.+",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2007-09-06 19:30:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//div[@id="sr-content-wrap"]//div[@class="sr-right"]/p[@class="sr-art-title"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function getRIS(doc, url) {
|
||||
var newx = '//div[@id="sci-art-options-box"]//input[@name="SelectCheck"]';
|
||||
var key = doc.evaluate(newx, doc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
Zotero.debug(key);
|
||||
var citation = 'http://ascelibrary.aip.org/getabs/servlet/GetCitation?source=scitation&PrefType=ARTICLE&PrefAction=Add+Selected&SelectCheck=' + key + '&fn=open_refworks&downloadcitation=+Go+';
|
||||
Zotero.Utilities.HTTP.doGet(citation, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
text = text.replace(/RT/, "TY");
|
||||
text = text.replace(/VO/, "VL");
|
||||
text = text.replace(/LK/, "UR");
|
||||
text = text.replace(/YR/, "PY");
|
||||
Zotero.debug(text);
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text.replace(/([A-Z][A-Z\d]\s)/g, "$1 - "));
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.attachments = [
|
||||
{url:item.url, title:"ASCE Snapshot", mimeType:"text/html"},
|
||||
{url:"http://ascelibrary.aip.org/getpdf/servlet/GetPDFServlet?filetype=pdf&id=" + key + "&idtype=cvips&prog=search", title:"EAS Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
//item.itemType = "journalArticle";
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
Zotero.wait();
|
||||
Zotero.done();
|
||||
});
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var articles = new Array();
|
||||
var items = new Object();
|
||||
var xpath = '//div[@class="sr-right"]/p[@class="sr-art-title"]/a';
|
||||
if (doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
while (new_title = titles.iterateNext()) {
|
||||
items[new_title.href] = new_title.textContent;
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
for (var i in items) {
|
||||
articles.push(i)
|
||||
}
|
||||
} else {
|
||||
var newx = '//div[@id="sci-art-options-box"]//input[@name="SelectCheck"]';
|
||||
var stuff = doc.evaluate(newx, doc, null, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
Zotero.debug(stuff);
|
||||
articles.push(url);
|
||||
}
|
||||
|
||||
Zotero.debug(articles);
|
||||
Zotero.Utilities.processDocuments(articles, getRIS, function() {Zotero.done});
|
||||
Zotero.wait();
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
|
@ -1,91 +0,0 @@
|
|||
{
|
||||
"translatorID":"252c6a50-0900-41c5-a66b-ec456137c43c",
|
||||
"translatorType":4,
|
||||
"label":"AcademicJournals.net",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.academicjournals.net/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match('articleno=')) {
|
||||
return "journalArticle";
|
||||
} else if (url.match('issueno=') || url.match('current.php')) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return prefix; else return null;
|
||||
} : namespace;
|
||||
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//tr[2]/td//table/tbody/tr[1]/td[2]/font', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
var links = doc.evaluate('//tr[4]/td[2]/div/a[@class="links"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var link;
|
||||
while ((title = titles.iterateNext()) && (link = links.iterateNext())) {
|
||||
items[link.href] = Zotero.Utilities.trimInternal(title.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
arts.push(i);
|
||||
}
|
||||
} else {
|
||||
arts = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(arts, function(doc) {
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
item.url = doc.location.href;
|
||||
//title
|
||||
item.title = Zotero.Utilities.trimInternal(doc.evaluate('//td[2]/table/tbody/tr/td/div/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
|
||||
//voliss, etc.
|
||||
var voliss = doc.evaluate('//table/tbody/tr/td[2]/font/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
voliss = voliss.match(/^([^\d]+)(\d+)\s+\((\d+)\):\s+([\d\-]+),\s+(\d+)/);
|
||||
Zotero.debug(voliss);
|
||||
item.publicationTitle = voliss[1];
|
||||
item.volume = voliss[2];
|
||||
item.issue = voliss[3];
|
||||
item.pages = voliss[4];
|
||||
item.date = voliss[5];
|
||||
|
||||
//authors
|
||||
var authorsx = doc.evaluate('//td[2]/font/a[@class="links"]/font', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var author;
|
||||
var authors = new Array();
|
||||
while (author = authorsx.iterateNext()) {
|
||||
authors.push(author.textContent);
|
||||
}
|
||||
for each (var aut in authors) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
|
||||
}
|
||||
|
||||
item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//table/tbody/tr/td/div/table/tbody/tr/td[2]/div/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
|
||||
//attachments
|
||||
var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
item.attachments = [
|
||||
{url:item.url, title:"AcademicJournals.net Snapshot", mimeType:"text/html"},
|
||||
{url:pdfurl, title:"AcademicJournals.net PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
|
||||
//tags
|
||||
var tagspath = doc.evaluate('//tbody/tr/td/table/tbody/tr[2]/td/font/a[@class="links"]/font', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var tag;
|
||||
var tags = new Array();
|
||||
while (tag = tagspath.iterateNext()) {
|
||||
tags.push(tag.textContent);
|
||||
}
|
||||
item.tags = tags;
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
}
|
|
@ -1,117 +0,0 @@
|
|||
{
|
||||
"translatorID":"138de272-0d2a-4ab5-8cfb-0fd879958d04",
|
||||
"translatorType":4,
|
||||
"label":"AdvoCAT",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"^http://(142.57.32.51|library.lsuc.on.ca)",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-25 17:40:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.location.href.match("Search_Code")) {
|
||||
return "multiple";
|
||||
} else if (doc.title.match("Record View")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var fieldTitle;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var headers = doc.evaluate('//table[2]/tbody/tr/th', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//table[2]/tbody/tr/th)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var contents = doc.evaluate('//table[2]/tbody/tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (i=0; i<xPathCount.numberValue; i++) {
|
||||
|
||||
fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, '');
|
||||
if (!fieldTitle.match(/\w/)) {
|
||||
fieldTitle = "Blank" + i;
|
||||
}
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
}
|
||||
|
||||
if (dataTags["MainAuthor:"]) {
|
||||
var author = dataTags["MainAuthor:"];
|
||||
if (author.match(", ") && !author.match(":")) {
|
||||
var authors = author.split(", ");
|
||||
author = authors[1] + " " + authors[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: author, creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["Published:"]) {
|
||||
|
||||
if (dataTags["Published:"].match(": ")) {
|
||||
var place1 = dataTags["Published:"].indexOf(": ");
|
||||
newItem.place = dataTags["Published:"].substr(0, place1);
|
||||
var publisher1 = dataTags["Published:"].substr(place1 + 2);
|
||||
|
||||
if (publisher1.match(", ")) {
|
||||
var date1 = publisher1.lastIndexOf(", ");
|
||||
newItem.date = publisher1.substr(date1 +2);
|
||||
newItem.publisher = publisher1.substr(0, date1);
|
||||
} else {
|
||||
newItem.publisher = publisher1;
|
||||
}
|
||||
} else {
|
||||
newItem.publisher = publisher1;
|
||||
}
|
||||
}
|
||||
associateData (newItem, dataTags, "Title:", "title");
|
||||
associateData (newItem, dataTags, "Database:", "repository");
|
||||
associateData (newItem, dataTags, "Description:", "pages");
|
||||
associateData (newItem, dataTags, "Edition:", "edition");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//form[2]/table/tbody/tr/td[3]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
{
|
||||
"translatorID":"9d822257-2eec-4674-b6d0-2504f54c8890",
|
||||
"translatorType":4,
|
||||
"label":"African Journals Online",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.ajol.info",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-04-18 08:55:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/viewarticle.php/)) {
|
||||
return "journalArticle";
|
||||
} else if (url.match(/search.php/) || url.match(/viewissue.php/)) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function getID(str) {
|
||||
return str.match(/(&|\?)id=(\d+)&?/)[2];
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
if (url.match(/search.php/)) {
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, "viewarticle.php?");
|
||||
} else if (url.match("viewissue.php")) {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//span[@class="toctitle"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//a[text() = "Abstract"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
var link;
|
||||
while ((title = titles.iterateNext()) && (link = links.iterateNext())) {
|
||||
items[link.href] = Zotero.Utilities.trimInternal(title.textContent);
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(getID(i));
|
||||
}
|
||||
} else {
|
||||
articles = [getID(url)];
|
||||
}
|
||||
Zotero.debug(articles);
|
||||
for each (var id in articles) {
|
||||
var getstr = 'http://www.ajol.info/rst/rst.php?op=capture_cite&id=' + id + '&cite=refman';
|
||||
Zotero.Utilities.HTTP.doGet(getstr, function(text) {
|
||||
// load translator for RIS
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
var pubinfo = item.publicationTitle.match(/(.*);([^;]+)$/);
|
||||
item.publicationTitle = pubinfo[1];
|
||||
var voliss = pubinfo[2].toLowerCase();
|
||||
if (voliss.match(/v/)) item.volume = voliss.match(/v(ol\.)?\s+(\d+)/)[2];
|
||||
if (voliss.match(/n/)) item.issue = voliss.match(/n(o\.)?\s+(\d+)/)[2];
|
||||
if (voliss.match(/p(age)?/)) item.pages = voliss.match(/\d+\-\d+/)[0];
|
||||
item.date = voliss.match(/\(([^)]+)\)/)[1];
|
||||
item.attachments[0].title = "African Journals Online Snapshot";
|
||||
item.attachments[0].mimeType = "text/html";
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
{
|
||||
"translatorID":"4f62425a-c99f-4ce1-b7c1-5a3ac0d636a3",
|
||||
"translatorType":4,
|
||||
"label":"AfroEuropa",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://journal.afroeuropa.eu/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-05-20 19:10:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//tr[td/a[2]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (url.match(/article\/view\//)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function makeExport(site, str) {
|
||||
var nums = str.match(/\d+(\/\d+)?/)[0];
|
||||
if (!nums.match(/\//)) nums += "/0";
|
||||
return site + 'rt/captureCite/' + nums + '/referenceManager';
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var n = doc.documentElement.namespaceURI;
|
||||
var ns = n ? function(prefix) {
|
||||
if (prefix == 'x') return n; else return null;
|
||||
} : null;
|
||||
|
||||
var site = url.match(/^http:\/\/([^/]*\/)+index\.php\/[^/]*\//)[0];
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var xpath = '//tr[td/a]';
|
||||
if (url.match(/search/)) {
|
||||
var titlex = './td[2]';
|
||||
var linkx = './td[3]/a[1]';
|
||||
} else if (url.match(/issue/)) {
|
||||
var titlex = './td[1]';
|
||||
var linkx = './td[2]/a[1]';
|
||||
}
|
||||
var items = new Object();
|
||||
var results = doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var result;
|
||||
while (result = results.iterateNext()) {
|
||||
var title = Zotero.Utilities.trimInternal(doc.evaluate(titlex, result, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var link = doc.evaluate(linkx, result, ns, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
items[makeExport(site, link)] = title;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
arts.push(i);
|
||||
}
|
||||
} else {
|
||||
arts = [makeExport(cite, url)];
|
||||
}
|
||||
Zotero.Utilities.HTTP.doGet(arts, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.title = Zotero.Utilities.capitalizeTitle(item.title);
|
||||
var voliss = item.publicationTitle.split(/;\s+/);
|
||||
item.publicationTitle = Zotero.Utilities.trimInternal(voliss[0]);
|
||||
voliss = voliss[1].match(/(\d+),\s+No\s+(\d+)\s+\((\d+)\)/);
|
||||
item.volume = voliss[1];
|
||||
item.issue = voliss[2];
|
||||
item.date = voliss[3];
|
||||
var auts = new Array();
|
||||
for each (var aut in item.creators) {
|
||||
auts.push(aut.lastName);
|
||||
}
|
||||
item.creators = new Array();
|
||||
for each (var aut in auts) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
|
||||
}
|
||||
item.attachments[0].mimeType = "text/html";
|
||||
item.attachments[0].title = "AfroEuropa Snapshot";
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
{
|
||||
"translatorID":"b8a86e36-c270-48c9-bdd1-22aaa167ef46",
|
||||
"translatorType":4,
|
||||
"label":"Agencia del ISBN",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.mcu.es/webISBN",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//div[@class="isbnResultado"]/div[@class="isbnResDescripcion"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//div[@class="fichaISBN"]/div[@class="cabecera"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var books = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var boxes = doc.evaluate('//div[@class="isbnResultado"]/div[@class="isbnResDescripcion"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var box;
|
||||
while (box = boxes.iterateNext()) {
|
||||
var book = doc.evaluate('./p/span/strong/a', box, null, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
items[book.href] = book.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
books.push(i);
|
||||
}
|
||||
} else {
|
||||
books = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(books, function(newDoc) {
|
||||
var data = new Object();
|
||||
var rows = newDoc.evaluate('//div[@class="fichaISBN"]/table/tbody/tr', newDoc, null, XPathResult.ANY_TYPE, null);
|
||||
var next_row;
|
||||
while (next_row = rows.iterateNext()) {
|
||||
var heading = newDoc.evaluate('./th', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
var value = newDoc.evaluate('./td', next_row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
data[heading.replace(/\W/g, "")] = value;
|
||||
}
|
||||
var isbn = Zotero.Utilities.trimInternal(newDoc.evaluate('//span[@class="cabTitulo"]/strong', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var item = new Zotero.Item("book");
|
||||
item.ISBN = isbn;
|
||||
item.title = Zotero.Utilities.trimInternal(data['Ttulo']);
|
||||
|
||||
author = data['Autores'];
|
||||
if (author) {
|
||||
var authors = author.match(/\b.*,\s+\w+[^([]/g);
|
||||
for each (aut in authors) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(Zotero.Utilities.trimInternal(aut), "author", true));
|
||||
}
|
||||
}
|
||||
if (data['Publicacin']) item.publisher = Zotero.Utilities.trimInternal(data['Publicacin']);
|
||||
if (data['FechaEdicin']) item.date = Zotero.Utilities.trimInternal(data['FechaEdicin']);
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
{
|
||||
"translatorID":"0a84a653-79ea-4c6a-8a68-da933e3b504a",
|
||||
"translatorType":4,
|
||||
"label":"Alexander Street Press",
|
||||
"creator":"John West and Michael Berkowitz",
|
||||
"target":"http://(?:www\\.)alexanderstreet",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if( url.indexOf("object.details.aspx") != -1 ) {
|
||||
var zitemtype = doc.getElementById("ctl00_ctl00_MasterContentBody_ContentPlaceHolder1_txtZType").value;
|
||||
switch (zitemtype.toLowerCase()) {
|
||||
case "book":
|
||||
return "book";
|
||||
break;
|
||||
case "chapter":
|
||||
return "bookSection";
|
||||
break;
|
||||
case "journal":
|
||||
return "journalArticle";
|
||||
break;
|
||||
case "manuscript":
|
||||
return "manuscript";
|
||||
break;
|
||||
case "audio":
|
||||
return "audioRecording";
|
||||
break;
|
||||
case "video":
|
||||
return "videoRecording";
|
||||
break;
|
||||
case "issue":
|
||||
return "journalArticle";
|
||||
break;
|
||||
case "article":
|
||||
return "journalArticle";
|
||||
break;
|
||||
case "series":
|
||||
return "interview";
|
||||
break;
|
||||
case "session":
|
||||
return "interview";
|
||||
break;
|
||||
default:
|
||||
return "document";
|
||||
}
|
||||
} else if (url.indexOf("results.aspx") != -1) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
// set prefix for serverside control
|
||||
var p = "ctl00_ctl00_MasterContentBody_ContentPlaceHolder1_txtZ";
|
||||
|
||||
// get values from hidden inputs
|
||||
var ztype = GetItemType(doc.getElementById(p+"Type").value);
|
||||
var ztitle = doc.getElementById(p+"Title").value;
|
||||
var zbooktitle = doc.getElementById(p+"BookTitle").value;
|
||||
var znotes = doc.getElementById(p+"Notes").value;
|
||||
var zurl = doc.getElementById(p+"URL").value;
|
||||
var zrights = doc.getElementById(p+"Rights").value;
|
||||
var zseries = doc.getElementById(p+"Series").value;
|
||||
var zvolume = doc.getElementById(p+"Volume").value;
|
||||
var zissue = doc.getElementById(p+"Issue").value;
|
||||
var zedition = doc.getElementById(p+"Edition").value;
|
||||
var zplace = doc.getElementById(p+"Place").value;
|
||||
var zpublisher = doc.getElementById(p+"Publisher").value;
|
||||
var zpages = doc.getElementById(p+"Pages").value;
|
||||
var zrepository = doc.getElementById(p+"Repository").value;
|
||||
var zlabel = doc.getElementById(p+"Label").value;
|
||||
var zrunningTime = doc.getElementById(p+"RunningTime").value;
|
||||
var zlanguage = doc.getElementById(p+"Language").value;
|
||||
var zauthor = doc.getElementById(p+"Author").value;
|
||||
var zeditor = doc.getElementById(p+"Editor").value;
|
||||
var ztranslator = doc.getElementById(p+"Translator").value;
|
||||
var zinterviewee = doc.getElementById(p+"Interviewee").value;
|
||||
var zinterviewer = doc.getElementById(p+"Interviewer").value;
|
||||
var zrecipient = doc.getElementById(p+"Recipient").value;
|
||||
var zdirector = doc.getElementById(p+"Director").value;
|
||||
var zscriptwriter = doc.getElementById(p+"ScriptWriter").value;
|
||||
var zproducer = doc.getElementById(p+"Producer").value;
|
||||
var zcastMember = doc.getElementById(p+"CastMember").value;
|
||||
var zperformer = doc.getElementById(p+"Performer").value;
|
||||
var zcomposer = doc.getElementById(p+"Composer").value;
|
||||
|
||||
// create Zotero item
|
||||
var newArticle = new Zotero.Item(ztype);
|
||||
|
||||
// populate Zotero item
|
||||
newArticle.title = ztitle;
|
||||
newArticle.bookTitle = zbooktitle;
|
||||
newArticle.notes = znotes;
|
||||
newArticle.url = zurl;
|
||||
newArticle.place = zplace;
|
||||
newArticle.publisher = zpublisher;
|
||||
newArticle.pages = zpages;
|
||||
newArticle.rights = zrights;
|
||||
newArticle.series = zseries;
|
||||
newArticle.volume = zvolume;
|
||||
newArticle.issue = zissue;
|
||||
newArticle.edition = zedition;
|
||||
newArticle.repository = zrepository;
|
||||
newArticle.label = zlabel;
|
||||
newArticle.runningTime = zrunningTime;
|
||||
newArticle.language = zlanguage;
|
||||
newArticle.editor = zeditor;
|
||||
newArticle.translator = ztranslator;
|
||||
newArticle.interviewee = zinterviewee;
|
||||
newArticle.interviewer = zinterviewer;
|
||||
newArticle.recipient = zrecipient;
|
||||
newArticle.director = zdirector;
|
||||
newArticle.scriptwriter = zscriptwriter;
|
||||
newArticle.producer = zproducer;
|
||||
newArticle.castMember = zcastMember;
|
||||
newArticle.performer = zperformer;
|
||||
newArticle.composer = zcomposer;
|
||||
var aus = zauthor.split(";");
|
||||
for (var i=0; i< aus.length ; i++) {
|
||||
newArticle.creators.push(Zotero.Utilities.cleanAuthor(aus[i], "author", true));
|
||||
}
|
||||
|
||||
newArticle.attachments = [{url:doc.location.href, title:"Alexander Street Press Snapshot", mimeType:"text/html"}];
|
||||
if (doc.evaluate('//a[contains(@href, "get.pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var pdfurl = doc.evaluate('//a[contains(@href, "get.pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
newArticle.attachments.push({url:pdfurl, title:"Alexander Street Press PDF", mimeType:"application/pdf"});
|
||||
} else if (doc.evaluate('//a[contains(@href, "get.jpg")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var imgurl = doc.evaluate('//a[contains(@href, "get.jpg")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.replace(/.{2}$/, "01");
|
||||
newArticle.attachments.push({url:imgurl, title:"Alexander Street Press Pg 1", mimeType:"image/jpg"});
|
||||
newArticle.notes = [{note:"Further page images can be found by following the URL of the 'Alexander Street Press Pg 1' attachment and iterating the final digits of the URL"}];
|
||||
}
|
||||
// save Zotero item
|
||||
newArticle.complete();
|
||||
|
||||
}
|
||||
|
||||
function GetItemType(zitemtype) {
|
||||
switch (zitemtype.toLowerCase()) {
|
||||
case "book":
|
||||
return "book";
|
||||
break;
|
||||
case "chapter":
|
||||
return "bookSection";
|
||||
break;
|
||||
case "journal":
|
||||
return "journalArticle";
|
||||
break;
|
||||
case "manuscript":
|
||||
return "manuscript";
|
||||
break;
|
||||
case "audio":
|
||||
return "audioRecording";
|
||||
break;
|
||||
case "video":
|
||||
return "videoRecording";
|
||||
break;
|
||||
case "issue":
|
||||
return "journalArticle";
|
||||
break;
|
||||
case "article":
|
||||
return "journalArticle";
|
||||
break;
|
||||
case "series":
|
||||
return "interview";
|
||||
break;
|
||||
case "session":
|
||||
return "interview";
|
||||
break;
|
||||
default:
|
||||
return "document";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var xpath = '//tbody/tr/td[2][@class="data"]/a[1]';
|
||||
var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
{
|
||||
"translatorID":"34B1E0EA-FD02-4069-BAE4-ED4D98674A5E",
|
||||
"translatorType":4,
|
||||
"label":"allAfrica.com",
|
||||
"creator":"Matt Bachtell",
|
||||
"target":"^http://allafrica\\.com/stories/*",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":false,
|
||||
"lastUpdated":"2009-05-05 07:15:00"
|
||||
}
|
||||
|
||||
|
||||
function detectWeb (doc, url) {
|
||||
|
||||
return "newspaperArticle";
|
||||
|
||||
}
|
||||
|
||||
function doWeb (doc, url){
|
||||
scrape(doc,url);
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var title = doc.evaluate("/html/body/div[3]/div/h1[@class='headline']", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
var date = doc.evaluate("/html/body/div[3]/div/p[@class='date']", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
// zotero entry creation code
|
||||
var newItem = new Zotero.Item('newspaperArticle');
|
||||
newItem.title = title;
|
||||
newItem.date = date;
|
||||
newItem.url = url;
|
||||
|
||||
//AUTHORS
|
||||
try{
|
||||
var authors = doc.evaluate("/html/body/div[3]/div/p[@class='reporter']", doc, null, XPathResult.ANY_TYPE,null).iterateNext().textContent;
|
||||
if (authors.match(/ &| And/)){
|
||||
var aus = authors.split(" And");
|
||||
for (var i=0; i < aus.length ; i++){
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(aus[i], "author"));
|
||||
}
|
||||
}
|
||||
else if(authors.match(", ")){
|
||||
var aus = authors.split(/[,| And| & ]/);
|
||||
for (var i=0; i < aus.length; i++){
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(aus[i], "author"));
|
||||
}
|
||||
}
|
||||
else{
|
||||
var author = authors;
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
}
|
||||
catch(e){
|
||||
// DO NOTHING
|
||||
}
|
||||
|
||||
//SOURCE
|
||||
try{
|
||||
var newspaper_source = doc.evaluate("/html/body/div[3]/div/p/a/img/@alt", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.publicationTitle = newspaper_source;
|
||||
}
|
||||
catch(e){
|
||||
var newspaper_source = doc.evaluate("/html/body/div[3]/div/p", doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.publicationTitle = newspaper_source;
|
||||
}
|
||||
newItem.complete();
|
||||
|
||||
} // end scrape
|
File diff suppressed because one or more lines are too long
|
@ -1,191 +0,0 @@
|
|||
{
|
||||
"translatorID":"e8fc7ebc-b63d-4eb3-a16c-91da232f7220",
|
||||
"translatorType":4,
|
||||
"label":"Aluka",
|
||||
"creator":"Sean Takats",
|
||||
"target":"https?://(?:www\\.)aluka.org/action/(?:showMetadata\\?doi=[^&]+|doSearch\\?|doBrowseResults\\?)",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-02-12 10:00:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url){
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var xpath = '//a[@class="title"]';
|
||||
|
||||
if (url.match(/showMetadata\?doi=[^&]+/)){
|
||||
return "document";
|
||||
} else if(doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
// Aluka types we can import
|
||||
// TODO: Improve support for other Aluka item types?
|
||||
// Correspondence, Circulars, Newsletters, Interviews, Pamphlets, Policy Documents, Posters, Press Releases, Reports, Testimonies, Transcripts
|
||||
var typeMap = {
|
||||
"Books":"book",
|
||||
"Aluka Essays":"report",
|
||||
"photograph":"artwork",
|
||||
"Photographs":"artwork",
|
||||
"Panoramas":"artwork",
|
||||
"Journals (Periodicals)":"journalArticle",
|
||||
"Articles":"journalArticle",
|
||||
"Correspondence":"letter",
|
||||
"Interviews":"interview",
|
||||
"Reports":"report"
|
||||
}
|
||||
|
||||
function doWeb(doc, url){
|
||||
var urlString = "http://www.aluka.org/action/showPrimeXML?doi=" ;
|
||||
var uris = new Array();
|
||||
var m = url.match(/showMetadata\?doi=([^&]+)/);
|
||||
if (m) { //single page
|
||||
uris.push(urlString+ m[1]);
|
||||
} else { //search results page
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var xpath = '//a[@class="title"]';
|
||||
var items = new Object();
|
||||
var elmts = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var elmt;
|
||||
while (elmt = elmts.iterateNext()) {
|
||||
var title = elmt.textContent;
|
||||
var link = elmt.href;
|
||||
var m = link.match(/showMetadata\?doi=([^&]+)/);
|
||||
if (title && m){
|
||||
items[m[1]] = title;
|
||||
}
|
||||
}
|
||||
|
||||
var items = Zotero.selectItems(items);
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(var i in items) {
|
||||
uris.push(urlString + i);
|
||||
}
|
||||
}
|
||||
// http://www.aluka.org/action/showPrimeXML?doi=10.5555/AL.SFF.DOCUMENT.cbp1008
|
||||
|
||||
Zotero.Utilities.HTTP.doGet(uris, function(text) {
|
||||
text = text.replace(/<\?xml[^>]*\?>/, ""); // strip xml header
|
||||
text = text.replace(/(<[^>\.]*)\.([^>]*>)/g, "$1_$2"); // replace dots in tags with underscores
|
||||
var xml = new XML(text);
|
||||
var metadata = xml..MetadataDC;
|
||||
var itemType = "Unknown";
|
||||
if (metadata.length()){
|
||||
itemType = "document";
|
||||
if (metadata[0].Type.length()){
|
||||
var value = metadata[0].Type[0].text().toString();
|
||||
if(typeMap[value]) {
|
||||
itemType = typeMap[value];
|
||||
} else {
|
||||
Zotero.debug("Unmapped Aluka Type: " + value);
|
||||
}
|
||||
}
|
||||
var newItem = new Zotero.Item(itemType);
|
||||
var title = "";
|
||||
if (metadata[0].Title.length()){
|
||||
var title = Zotero.Utilities.trimInternal(metadata[0].Title[0].text().toString());
|
||||
if (title == ""){
|
||||
title = " ";
|
||||
}
|
||||
newItem.title = title;
|
||||
}
|
||||
if (metadata[0].Title_Alternative.length()){
|
||||
newItem.extra = Zotero.Utilities.trimInternal(metadata[0].Title_Alternative[0].text().toString());
|
||||
}
|
||||
for(var i=0; i<metadata[0].Subject_Enriched.length(); i++) {
|
||||
newItem.tags.push(Zotero.Utilities.trimInternal(metadata[0].Subject_Enriched[i].text().toString()));
|
||||
}
|
||||
for(var i=0; i<metadata[0].Coverage_Spatial.length(); i++) {
|
||||
newItem.tags.push(Zotero.Utilities.trimInternal(metadata[0].Coverage_Spatial[i].text().toString()));
|
||||
}
|
||||
for(var i=0; i<metadata[0].Coverage_Temporal.length(); i++) {
|
||||
newItem.tags.push(Zotero.Utilities.trimInternal(metadata[0].Coverage_Temporal[i].text().toString()));
|
||||
}
|
||||
// TODO: decide whether to uncomment below code to import species data as tags
|
||||
// for(var i=0; i<xml..TopicName.length(); i++) {
|
||||
// newItem.tags.push(Zotero.Utilities.trimInternal(xml..TopicName[i].text().toString()));
|
||||
// }
|
||||
|
||||
if (metadata[0].Date.length()){
|
||||
var date = metadata[0].Date[0].text().toString();
|
||||
if (date.match(/^\d{8}$/)){
|
||||
date = date.substr(0, 4) + "-" + date.substr(4, 2) + "-" + date.substr(6, 2);
|
||||
}
|
||||
newItem.date = date;
|
||||
}
|
||||
if (metadata[0].Creator.length()){
|
||||
var authors = metadata[0].Creator;
|
||||
var type = "author";
|
||||
for(var j=0; j<authors.length(); j++) {
|
||||
Zotero.debug("author: " + authors[j]);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j].text().toString(),type,true));
|
||||
}
|
||||
}
|
||||
if (metadata[0].Contributor.length()){
|
||||
var authors = metadata[0].Contributor;
|
||||
var type = "contributor";
|
||||
for(var j=0; j<authors.length(); j++) {
|
||||
Zotero.debug("author: " + authors[j]);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j].text().toString(),type,true));
|
||||
}
|
||||
}
|
||||
if (metadata[0].Publisher.length()){
|
||||
newItem.publisher = Zotero.Utilities.trimInternal(metadata[0].Publisher[0].text().toString());
|
||||
}
|
||||
if (metadata[0].Format_Medium.length()){
|
||||
newItem.medium = Zotero.Utilities.trimInternal(metadata[0].Format_Medium[0].text().toString());
|
||||
}
|
||||
if (metadata[0].Language.length()){
|
||||
newItem.language = Zotero.Utilities.trimInternal(metadata[0].Language[0].text().toString());
|
||||
}
|
||||
if (metadata[0].Description.length()){
|
||||
newItem.abstractNote = metadata[0].Description[0].text().toString();
|
||||
}
|
||||
if (metadata[0].Format_Extent.length()){
|
||||
newItem.pages = Zotero.Utilities.trimInternal(metadata[0].Format_Extent[0].text().toString());
|
||||
}
|
||||
var doi = xml..DOI;
|
||||
if (doi.length()){
|
||||
newItem.DOI = doi[0];
|
||||
var newUrl = "http://www.aluka.org/action/showMetadata?doi=" + doi[0];
|
||||
newItem.attachments.push({title:"Aluka Link", snapshot:false, mimeType:"text/html", url:newUrl});
|
||||
var pdfUrl = "http://ts-den.aluka.org/delivery/aluka-contentdelivery/pdf/" + doi[0] + "?type=img&q=high";
|
||||
newItem.attachments.push({url:pdfUrl});
|
||||
newItem.url = newUrl;
|
||||
}
|
||||
var rights = xml..Rights.Attribution;
|
||||
if (rights.length()){
|
||||
newItem.rights = rights[0];
|
||||
}
|
||||
if (metadata[0].Rights.length()){
|
||||
newItem.rights = Zotero.Utilities.trimInternal(metadata[0].Rights[0].text().toString());
|
||||
}
|
||||
if (metadata[0].Source.length()){
|
||||
newItem.repository = "Aluka: " + Zotero.Utilities.trimInternal(metadata[0].Source[0].text().toString());
|
||||
}
|
||||
if (metadata[0].Relation.length()){
|
||||
newItem.callNumber = Zotero.Utilities.trimInternal(metadata[0].Relation[0].text().toString());
|
||||
}
|
||||
newItem.complete();
|
||||
} else {
|
||||
Zotero.debug("No Dublin Core XML data");
|
||||
return false;
|
||||
}
|
||||
Zotero.done();
|
||||
});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,673 +0,0 @@
|
|||
{
|
||||
"translatorID": "96b9f483-c44d-5784-cdad-ce21b984fe01",
|
||||
"label": "Amazon.com",
|
||||
"creator": "Sean Takats and Michael Berkowitz",
|
||||
"target": "^https?://(?:www\\.)?amazon",
|
||||
"minVersion": "2.1",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": true,
|
||||
"translatorType": 4,
|
||||
"browserSupport": "gcs",
|
||||
"lastUpdated": "2011-07-19 00:16:21"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var suffixRe = new RegExp("https?://(?:www\.)?amazon\.([^/]+)/");
|
||||
var suffixMatch = suffixRe.exec(url);
|
||||
var suffix = suffixMatch[1];
|
||||
var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/|s\\?|[^/]+/lm/|gp/richpub/)');
|
||||
Zotero.debug(searchRe.test(doc.location.href));
|
||||
if(searchRe.test(doc.location.href)) {
|
||||
return "multiple";
|
||||
} else {
|
||||
var xpath = '//input[@name="ASIN"]';
|
||||
if(doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var elmt = doc.evaluate('//input[@name="storeID"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(elmt) {
|
||||
var storeID = elmt.value;
|
||||
Zotero.debug("store id: " + storeID);
|
||||
if (storeID=="books"){
|
||||
return "book";
|
||||
}
|
||||
else if (storeID=="music"){
|
||||
return "audioRecording";
|
||||
}
|
||||
else if (storeID=="dvd"|storeID=="video"){
|
||||
return "videoRecording";
|
||||
}
|
||||
else {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
else {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var suffix;
|
||||
function doWeb(doc, url) {
|
||||
var suffixRe = new RegExp("https?://(?:www\.)?amazon\.([^/]+)/");
|
||||
var suffixMatch = suffixRe.exec(url);
|
||||
suffix = suffixMatch[1];
|
||||
|
||||
var searchRe = new RegExp('^https?://(?:www\.)?amazon\.' + suffix + '/(gp/search/|exec/obidos/search-handle-url/|s/|s\\?|[^/]+/lm/|gp/richpub/)');
|
||||
var m = searchRe.exec(doc.location.href);
|
||||
var uris = new Array();
|
||||
if (suffix == "co.jp"){
|
||||
suffix = "jp";
|
||||
}
|
||||
if (suffix == ".com") suffix = "com";
|
||||
if(m) {
|
||||
var availableItems = new Array();
|
||||
|
||||
|
||||
if(doc.location.href.match(/gp\/richpub\//)){ // Show selector for Guides
|
||||
var xpath = '//a[(contains(@href, "ref=cm_syf_dtl_pl") or contains(@href, "ref=cm_syf_dtl_top")) and preceding-sibling::b]';
|
||||
} else if (doc.location.href.match(/\/lm\//)) { // Show selector for Lists
|
||||
var xpath = '//span[@id="lm_asinlink95"]//a'
|
||||
} else { // Show selector for Search results
|
||||
var xpath = '//div[@class="productTitle"]/a | //a[span[@class="srTitle"]] | //div[@class="title"]/a[@class="title"]';
|
||||
}
|
||||
var elmts = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var elmt = elmts.iterateNext();
|
||||
var asins = new Array();
|
||||
var i = 0;
|
||||
var asinRe = new RegExp('/(dp|product)/([^/]+)/');
|
||||
do {
|
||||
var link = elmt.href;
|
||||
var searchTitle = elmt.textContent;
|
||||
if (asinRe.exec(link)) {
|
||||
var asinMatch = asinRe.exec(link);
|
||||
availableItems[i] = searchTitle;
|
||||
asins[i] = asinMatch[2];
|
||||
i++;
|
||||
}
|
||||
} while (elmt = elmts.iterateNext());
|
||||
|
||||
Zotero.selectItems(availableItems, function(items) {
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for(var i in items) {
|
||||
var timestamp = encodeURIComponent(generateISODate());
|
||||
var params = "AWSAccessKeyId=AKIAIPYIWJ24AGZJ64AA&ItemId=" + Zotero.Utilities.trim(asins[i]) + "&Operation=ItemLookup&ResponseGroup=ItemAttributes&Service=AWSECommerceService&Timestamp="+timestamp+"&Version=2006-06-28";
|
||||
var signString = "GET\necs.amazonaws."+suffix+"\n/onca/xml\n"+params;
|
||||
var signature = b64_hmac_sha256("054vk/Lt3LJMxch1srIHUbvI+2T/fZ6E5c0qwlbj", signString);
|
||||
signature = encodeURIComponent(signature);
|
||||
uris.push("http://ecs.amazonaws." + suffix + "/onca/xml?"+params+"&Signature="+signature+"%3D"); //wants the %3D for some reason
|
||||
}
|
||||
|
||||
Zotero.Utilities.HTTP.doGet(uris, parseXML, function() {Zotero.done();}, null);
|
||||
});
|
||||
|
||||
} else {
|
||||
var elmts = doc.evaluate('//input[@name = "ASIN"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var elmt;
|
||||
while(elmt = elmts.iterateNext()) {
|
||||
var asin = elmt.value;
|
||||
}
|
||||
var timestamp = encodeURIComponent(generateISODate());
|
||||
var params = "AWSAccessKeyId=AKIAIPYIWJ24AGZJ64AA&ItemId=" + Zotero.Utilities.trim(asin) + "&Operation=ItemLookup&ResponseGroup=ItemAttributes&Service=AWSECommerceService&Timestamp="+timestamp+"&Version=2006-06-28";
|
||||
var signString = "GET\necs.amazonaws."+suffix+"\n/onca/xml\n"+params;
|
||||
var signature = b64_hmac_sha256("054vk/Lt3LJMxch1srIHUbvI+2T/fZ6E5c0qwlbj", signString);
|
||||
signature = encodeURIComponent(signature);
|
||||
uris.push("http://ecs.amazonaws." + suffix + "/onca/xml?"+params+"&Signature="+signature+"%3D"); //wants the %3D for some reason
|
||||
Zotero.Utilities.HTTP.doGet(uris, parseXML, function() {Zotero.done();}, null);
|
||||
}
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
function parseXML(text) {
|
||||
text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, "");
|
||||
var texts = text.split("<Items>");
|
||||
texts = texts[1].split("</ItemLookupResponse>");
|
||||
text = "<Items>" + texts[0];
|
||||
var xml = (new DOMParser()).parseFromString(text, "text/xml");
|
||||
var publisher = "";
|
||||
|
||||
if (!ZU.xpath(xml, "//Errors").length) {
|
||||
var publisher = getXPathNodeTrimmed(xml, "Publisher");
|
||||
var binding = getXPathNodeTrimmed(xml, "Binding");
|
||||
var productGroup = getXPathNodeTrimmed(xml, "ProductGroup");
|
||||
|
||||
if (productGroup=="Book") {
|
||||
var newItem = new Zotero.Item("book");
|
||||
newItem.publisher = publisher;
|
||||
}
|
||||
else if (productGroup == "Music") {
|
||||
var newItem = new Zotero.Item("audioRecording");
|
||||
newItem.label = publisher;
|
||||
newItem.audioRecordingType = binding;
|
||||
getCreatorNodes(xml, "Artist", newItem, "performer");
|
||||
}
|
||||
else if (productGroup == "DVD" | productGroup == "Video") {
|
||||
var newItem = new Zotero.Item("videoRecording");
|
||||
newItem.studio = publisher;
|
||||
newItem.videoRecordingType = binding;
|
||||
getCreatorNodes(xml, "Actor", newItem, "castMember");
|
||||
getCreatorNodes(xml, "Director", newItem, "director");
|
||||
}
|
||||
else{
|
||||
var newItem = new Zotero.Item("book");
|
||||
newItem.publisher = publisher;
|
||||
}
|
||||
|
||||
newItem.runningTime = getXPathNodeTrimmed(xml, "RunningTime");
|
||||
|
||||
// Retrieve authors and other creators
|
||||
getCreatorNodes(xml, "Author", newItem, "author");
|
||||
if (newItem.creators.length == 0){
|
||||
getCreatorNodes(xml, "Creator", newItem, "author");
|
||||
}
|
||||
|
||||
newItem.date = getXPathNodeTrimmed(xml, "PublicationDate");
|
||||
if (!newItem.date){
|
||||
newItem.date = getXPathNodeTrimmed(xml, "ReleaseDate");
|
||||
}
|
||||
newItem.edition = getXPathNodeTrimmed(xml, "Edition");
|
||||
newItem.ISBN = getXPathNodeTrimmed(xml, "ISBN");
|
||||
newItem.numPages = getXPathNodeTrimmed(xml, "NumberOfPages");
|
||||
var title = getXPathNodeTrimmed(xml, "Title");
|
||||
if(title.lastIndexOf("(") != -1 && title.lastIndexOf(")") == title.length-1) {
|
||||
title = title.substring(0, title.lastIndexOf("(")-1);
|
||||
}
|
||||
var ASIN = getXPathNodeTrimmed(xml, "ASIN");
|
||||
if (ASIN){
|
||||
var url = "http://www.amazon." + suffix + "/dp/" + ASIN;
|
||||
newItem.attachments.push({title:"Amazon.com Link", snapshot:false, mimeType:"text/html", url:url});
|
||||
}
|
||||
|
||||
newItem.extra = getXPathNodeTrimmed(xml, "OriginalReleaseDate");
|
||||
|
||||
newItem.title = title;
|
||||
newItem.complete();
|
||||
}
|
||||
}
|
||||
|
||||
function getXPathNodeTrimmed(xml, name) {
|
||||
var node = ZU.xpath(xml, "//"+name);
|
||||
var val = "";
|
||||
if(node.length){
|
||||
val = Zotero.Utilities.trimInternal(node[0].textContent);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
function getCreatorNodes(xml, name, newItem, creatorType) {
|
||||
var nodes = ZU.xpath(xml, "//"+name);
|
||||
for(var i=0; i<nodes.length; i++) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(nodes[i].textContent, creatorType));
|
||||
}
|
||||
}
|
||||
|
||||
function generateISODate(){
|
||||
var ts = new Date();
|
||||
var isodate = ts.getUTCFullYear()+"-"+Zotero.Utilities.lpad(ts.getUTCMonth()+1, "0", 2)+"-"+Zotero.Utilities.lpad(ts.getUTCDate(), "0", 2)+"T"+Zotero.Utilities.lpad(ts.getUTCHours(), "0", 2)+":"+Zotero.Utilities.lpad(ts.getUTCMinutes(), "0", 2)+":"+Zotero.Utilities.lpad(ts.getUTCSeconds(), "0", 2)+"Z";
|
||||
return isodate;
|
||||
}
|
||||
|
||||
/*
|
||||
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
|
||||
* in FIPS 180-2
|
||||
* Version 2.2 Copyright Angel Marin, Paul Johnston 2000 - 2009.
|
||||
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
|
||||
* Distributed under the BSD License
|
||||
* See http://pajhome.org.uk/crypt/md5 for details.
|
||||
* Also http://anmar.eu.org/projects/jssha2/
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configurable variables. You may need to tweak these to be compatible with
|
||||
* the server-side, but the defaults work in most cases.
|
||||
*/
|
||||
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
|
||||
var b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
|
||||
|
||||
/*
|
||||
* These are the functions you'll usually want to call
|
||||
* They take string arguments and return either hex or base-64 encoded strings
|
||||
*/
|
||||
function hex_sha256(s) { return rstr2hex(rstr_sha256(str2rstr_utf8(s))); }
|
||||
function b64_sha256(s) { return rstr2b64(rstr_sha256(str2rstr_utf8(s))); }
|
||||
function any_sha256(s, e) { return rstr2any(rstr_sha256(str2rstr_utf8(s)), e); }
|
||||
function hex_hmac_sha256(k, d)
|
||||
{ return rstr2hex(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d))); }
|
||||
function b64_hmac_sha256(k, d)
|
||||
{ return rstr2b64(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d))); }
|
||||
function any_hmac_sha256(k, d, e)
|
||||
{ return rstr2any(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d)), e); }
|
||||
|
||||
/*
|
||||
* Perform a simple self-test to see if the VM is working
|
||||
*/
|
||||
function sha256_vm_test()
|
||||
{
|
||||
return hex_sha256("abc").toLowerCase() ==
|
||||
"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad";
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the sha256 of a raw string
|
||||
*/
|
||||
function rstr_sha256(s)
|
||||
{
|
||||
return binb2rstr(binb_sha256(rstr2binb(s), s.length * 8));
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the HMAC-sha256 of a key and some data (raw strings)
|
||||
*/
|
||||
function rstr_hmac_sha256(key, data)
|
||||
{
|
||||
var bkey = rstr2binb(key);
|
||||
if(bkey.length > 16) bkey = binb_sha256(bkey, key.length * 8);
|
||||
|
||||
var ipad = Array(16), opad = Array(16);
|
||||
for(var i = 0; i < 16; i++)
|
||||
{
|
||||
ipad[i] = bkey[i] ^ 0x36363636;
|
||||
opad[i] = bkey[i] ^ 0x5C5C5C5C;
|
||||
}
|
||||
|
||||
var hash = binb_sha256(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
|
||||
return binb2rstr(binb_sha256(opad.concat(hash), 512 + 256));
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to a hex string
|
||||
*/
|
||||
function rstr2hex(input)
|
||||
{
|
||||
try { hexcase } catch(e) { hexcase=0; }
|
||||
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
|
||||
var output = "";
|
||||
var x;
|
||||
for(var i = 0; i < input.length; i++)
|
||||
{
|
||||
x = input.charCodeAt(i);
|
||||
output += hex_tab.charAt((x >>> 4) & 0x0F)
|
||||
+ hex_tab.charAt( x & 0x0F);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to a base-64 string
|
||||
*/
|
||||
function rstr2b64(input)
|
||||
{
|
||||
try { b64pad } catch(e) { b64pad=''; }
|
||||
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var output = "";
|
||||
var len = input.length;
|
||||
for(var i = 0; i < len; i += 3)
|
||||
{
|
||||
var triplet = (input.charCodeAt(i) << 16)
|
||||
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
|
||||
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
|
||||
for(var j = 0; j < 4; j++)
|
||||
{
|
||||
if(i * 8 + j * 6 > input.length * 8) output += b64pad;
|
||||
else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
|
||||
}
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to an arbitrary string encoding
|
||||
*/
|
||||
function rstr2any(input, encoding)
|
||||
{
|
||||
var divisor = encoding.length;
|
||||
var remainders = Array();
|
||||
var i, q, x, quotient;
|
||||
|
||||
/* Convert to an array of 16-bit big-endian values, forming the dividend */
|
||||
var dividend = Array(Math.ceil(input.length / 2));
|
||||
for(i = 0; i < dividend.length; i++)
|
||||
{
|
||||
dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Repeatedly perform a long division. The binary array forms the dividend,
|
||||
* the length of the encoding is the divisor. Once computed, the quotient
|
||||
* forms the dividend for the next step. We stop when the dividend is zero.
|
||||
* All remainders are stored for later use.
|
||||
*/
|
||||
while(dividend.length > 0)
|
||||
{
|
||||
quotient = Array();
|
||||
x = 0;
|
||||
for(i = 0; i < dividend.length; i++)
|
||||
{
|
||||
x = (x << 16) + dividend[i];
|
||||
q = Math.floor(x / divisor);
|
||||
x -= q * divisor;
|
||||
if(quotient.length > 0 || q > 0)
|
||||
quotient[quotient.length] = q;
|
||||
}
|
||||
remainders[remainders.length] = x;
|
||||
dividend = quotient;
|
||||
}
|
||||
|
||||
/* Convert the remainders to the output string */
|
||||
var output = "";
|
||||
for(i = remainders.length - 1; i >= 0; i--)
|
||||
output += encoding.charAt(remainders[i]);
|
||||
|
||||
/* Append leading zero equivalents */
|
||||
var full_length = Math.ceil(input.length * 8 /
|
||||
(Math.log(encoding.length) / Math.log(2)))
|
||||
for(i = output.length; i < full_length; i++)
|
||||
output = encoding[0] + output;
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a string as utf-8.
|
||||
* For efficiency, this assumes the input is valid utf-16.
|
||||
*/
|
||||
function str2rstr_utf8(input)
|
||||
{
|
||||
var output = "";
|
||||
var i = -1;
|
||||
var x, y;
|
||||
|
||||
while(++i < input.length)
|
||||
{
|
||||
/* Decode utf-16 surrogate pairs */
|
||||
x = input.charCodeAt(i);
|
||||
y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
|
||||
if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF)
|
||||
{
|
||||
x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Encode output as utf-8 */
|
||||
if(x <= 0x7F)
|
||||
output += String.fromCharCode(x);
|
||||
else if(x <= 0x7FF)
|
||||
output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
|
||||
0x80 | ( x & 0x3F));
|
||||
else if(x <= 0xFFFF)
|
||||
output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
|
||||
0x80 | ((x >>> 6 ) & 0x3F),
|
||||
0x80 | ( x & 0x3F));
|
||||
else if(x <= 0x1FFFFF)
|
||||
output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
|
||||
0x80 | ((x >>> 12) & 0x3F),
|
||||
0x80 | ((x >>> 6 ) & 0x3F),
|
||||
0x80 | ( x & 0x3F));
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a string as utf-16
|
||||
*/
|
||||
function str2rstr_utf16le(input)
|
||||
{
|
||||
var output = "";
|
||||
for(var i = 0; i < input.length; i++)
|
||||
output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
|
||||
(input.charCodeAt(i) >>> 8) & 0xFF);
|
||||
return output;
|
||||
}
|
||||
|
||||
function str2rstr_utf16be(input)
|
||||
{
|
||||
var output = "";
|
||||
for(var i = 0; i < input.length; i++)
|
||||
output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
|
||||
input.charCodeAt(i) & 0xFF);
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert a raw string to an array of big-endian words
|
||||
* Characters >255 have their high-byte silently ignored.
|
||||
*/
|
||||
function rstr2binb(input)
|
||||
{
|
||||
var output = Array(input.length >> 2);
|
||||
for(var i = 0; i < output.length; i++)
|
||||
output[i] = 0;
|
||||
for(var i = 0; i < input.length * 8; i += 8)
|
||||
output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (24 - i % 32);
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert an array of big-endian words to a string
|
||||
*/
|
||||
function binb2rstr(input)
|
||||
{
|
||||
var output = "";
|
||||
for(var i = 0; i < input.length * 32; i += 8)
|
||||
output += String.fromCharCode((input[i>>5] >>> (24 - i % 32)) & 0xFF);
|
||||
return output;
|
||||
}
|
||||
|
||||
/*
|
||||
* Main sha256 function, with its support functions
|
||||
*/
|
||||
function sha256_S (X, n) {return ( X >>> n ) | (X << (32 - n));}
|
||||
function sha256_R (X, n) {return ( X >>> n );}
|
||||
function sha256_Ch(x, y, z) {return ((x & y) ^ ((~x) & z));}
|
||||
function sha256_Maj(x, y, z) {return ((x & y) ^ (x & z) ^ (y & z));}
|
||||
function sha256_Sigma0256(x) {return (sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22));}
|
||||
function sha256_Sigma1256(x) {return (sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25));}
|
||||
function sha256_Gamma0256(x) {return (sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3));}
|
||||
function sha256_Gamma1256(x) {return (sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10));}
|
||||
function sha256_Sigma0512(x) {return (sha256_S(x, 28) ^ sha256_S(x, 34) ^ sha256_S(x, 39));}
|
||||
function sha256_Sigma1512(x) {return (sha256_S(x, 14) ^ sha256_S(x, 18) ^ sha256_S(x, 41));}
|
||||
function sha256_Gamma0512(x) {return (sha256_S(x, 1) ^ sha256_S(x, 8) ^ sha256_R(x, 7));}
|
||||
function sha256_Gamma1512(x) {return (sha256_S(x, 19) ^ sha256_S(x, 61) ^ sha256_R(x, 6));}
|
||||
|
||||
var sha256_K = new Array
|
||||
(
|
||||
1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993,
|
||||
-1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987,
|
||||
1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522,
|
||||
264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986,
|
||||
-1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585,
|
||||
113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291,
|
||||
1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885,
|
||||
-1035236496, -949202525, -778901479, -694614492, -200395387, 275423344,
|
||||
430227734, 506948616, 659060556, 883997877, 958139571, 1322822218,
|
||||
1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872,
|
||||
-1866530822, -1538233109, -1090935817, -965641998
|
||||
);
|
||||
|
||||
function binb_sha256(m, l)
|
||||
{
|
||||
var HASH = new Array(1779033703, -1150833019, 1013904242, -1521486534,
|
||||
1359893119, -1694144372, 528734635, 1541459225);
|
||||
var W = new Array(64);
|
||||
var a, b, c, d, e, f, g, h;
|
||||
var i, j, T1, T2;
|
||||
|
||||
/* append padding */
|
||||
m[l >> 5] |= 0x80 << (24 - l % 32);
|
||||
m[((l + 64 >> 9) << 4) + 15] = l;
|
||||
|
||||
for(i = 0; i < m.length; i += 16)
|
||||
{
|
||||
a = HASH[0];
|
||||
b = HASH[1];
|
||||
c = HASH[2];
|
||||
d = HASH[3];
|
||||
e = HASH[4];
|
||||
f = HASH[5];
|
||||
g = HASH[6];
|
||||
h = HASH[7];
|
||||
|
||||
for(j = 0; j < 64; j++)
|
||||
{
|
||||
if (j < 16) W[j] = m[j + i];
|
||||
else W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]),
|
||||
sha256_Gamma0256(W[j - 15])), W[j - 16]);
|
||||
|
||||
T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)),
|
||||
sha256_K[j]), W[j]);
|
||||
T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = safe_add(d, T1);
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = safe_add(T1, T2);
|
||||
}
|
||||
|
||||
HASH[0] = safe_add(a, HASH[0]);
|
||||
HASH[1] = safe_add(b, HASH[1]);
|
||||
HASH[2] = safe_add(c, HASH[2]);
|
||||
HASH[3] = safe_add(d, HASH[3]);
|
||||
HASH[4] = safe_add(e, HASH[4]);
|
||||
HASH[5] = safe_add(f, HASH[5]);
|
||||
HASH[6] = safe_add(g, HASH[6]);
|
||||
HASH[7] = safe_add(h, HASH[7]);
|
||||
}
|
||||
return HASH;
|
||||
}
|
||||
|
||||
function safe_add (x, y)
|
||||
{
|
||||
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
|
||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
||||
return (msw << 16) | (lsw & 0xFFFF);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** BEGIN TEST CASES **/
|
||||
var testCases = [
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.amazon.com/Test-William-Sleator/dp/0810989891/ref=sr_1_1?ie=UTF8&qid=1308010556&sr=8-1",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "book",
|
||||
"creators": [
|
||||
{
|
||||
"firstName": "William",
|
||||
"lastName": "Sleator",
|
||||
"creatorType": "author"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{
|
||||
"title": "Amazon.com Link",
|
||||
"snapshot": false,
|
||||
"mimeType": "text/html",
|
||||
"url": false
|
||||
}
|
||||
],
|
||||
"publisher": "Amulet Books",
|
||||
"date": "2010-04-01",
|
||||
"edition": "Reprint",
|
||||
"ISBN": "0810989891",
|
||||
"numPages": "320",
|
||||
"title": "Test",
|
||||
"libraryCatalog": "Amazon.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dstripbooks&field-keywords=foot&x=0&y=0",
|
||||
"items": "multiple"
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.amazon.com/Loveless-My-Bloody-Valentine/dp/B000002LRJ/ref=ntt_mus_ep_dpi_1",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "audioRecording",
|
||||
"creators": [
|
||||
{
|
||||
"firstName": "My Bloody",
|
||||
"lastName": "Valentine",
|
||||
"creatorType": "performer"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{
|
||||
"title": "Amazon.com Link",
|
||||
"snapshot": false,
|
||||
"mimeType": "text/html",
|
||||
"url": false
|
||||
}
|
||||
],
|
||||
"label": "Sire / London/Rhino",
|
||||
"audioRecordingType": "Audio CD",
|
||||
"date": "1991-11-05",
|
||||
"extra": "1991-11-05",
|
||||
"title": "Loveless",
|
||||
"libraryCatalog": "Amazon.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.amazon.com/Adaptation-Superbit-Collection-Nicholas-Cage/dp/B00005JLRE/ref=sr_1_1?ie=UTF8&qid=1309683150&sr=8-1",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "videoRecording",
|
||||
"creators": [
|
||||
{
|
||||
"firstName": "Nicholas",
|
||||
"lastName": "Cage",
|
||||
"creatorType": "castMember"
|
||||
},
|
||||
{
|
||||
"firstName": "Chris",
|
||||
"lastName": "Cooper",
|
||||
"creatorType": "castMember"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{
|
||||
"title": "Amazon.com Link",
|
||||
"snapshot": false,
|
||||
"mimeType": "text/html",
|
||||
"url": false
|
||||
}
|
||||
],
|
||||
"studio": "Sony Pictures Home Entertainment",
|
||||
"videoRecordingType": "DVD",
|
||||
"runningTime": "114",
|
||||
"date": "2003-05-20",
|
||||
"ISBN": "0767879805",
|
||||
"extra": "2002-12-06",
|
||||
"title": "Adaptation",
|
||||
"libraryCatalog": "Amazon.com"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.amazon.com/s?ie=UTF8&keywords=The%20Harvard%20Concise%20Dictionary%20of%20Music%20and%20Musicians&index=blended&Go=o",
|
||||
"items": "multiple"
|
||||
}
|
||||
]
|
||||
/** END TEST CASES **/
|
|
@ -1,96 +0,0 @@
|
|||
{
|
||||
"translatorID":"75edc5a1-6470-465a-a928-ccb77d95eb72",
|
||||
"translatorType":4,
|
||||
"label":"American Institute of Aeronautics and Astronautics",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.aiaa.org/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-05-12 19:00:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//td/div[@class="title"]/b/div[@class="centerHeadlines"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var n = doc.documentElement.namespaceURI;
|
||||
var ns = n ? function(prefix) {
|
||||
if (prefix == 'x') return n; else return null;
|
||||
} : null;
|
||||
|
||||
var items = new Object();
|
||||
var oldItems = doc.evaluate('//table/tbody/tr/td[div[@class="title"]]', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var nextItem;
|
||||
while (nextItem = oldItems.iterateNext()) {
|
||||
var data = new Object();
|
||||
data['title'] = Zotero.Utilities.trimInternal(doc.evaluate('./div[@class="title"]//div[@class="centerHeadlines"]', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
data['pages'] = Zotero.Utilities.trimInternal(doc.evaluate('./div[@class="title"]//div[@class="centerHeadlinesSub2"]', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/[\d\w]+\-[\d\w]+/)[0]);
|
||||
data['authors'] = Zotero.Utilities.trimInternal(doc.evaluate('./ul/i', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var extra = Zotero.Utilities.trimInternal(doc.evaluate('./ul', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var extra = extra.replace(data['authors'], "");
|
||||
data['extra'] = Zotero.Utilities.trimInternal(extra);
|
||||
var pdf = doc.evaluate('.//a', nextItem, ns, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
Zotero.debug(pdf);
|
||||
data['pdfurl'] = pdf;
|
||||
items[data['title']] = data;
|
||||
}
|
||||
var volume;
|
||||
var issue;
|
||||
var date;
|
||||
if (doc.evaluate('//td[2]/table/tbody/tr/td[1]/strong', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var voliss = Zotero.Utilities.trimInternal(doc.evaluate('//td[2]/table/tbody/tr/td[1]/strong', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
voliss = voliss.match(/(\d+)\s+vol\.\s*(\d+)\s+no\.\s*(\d+)/);
|
||||
volume = voliss[2];
|
||||
issue = voliss[3];
|
||||
date = voliss[1];
|
||||
} else if (doc.evaluate('//select', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var voliss = Zotero.Utilities.trimInternal(doc.evaluate('//select[@name="volume"]/option[@selected]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var issue = Zotero.Utilities.trimInternal(doc.evaluate('//select[@name="issue"]/option[@selected]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
voliss = voliss.match(/vol\.\s*(\d+)\s*\-\s*(\d+)/);
|
||||
volume = voliss[1];
|
||||
date = voliss[2];
|
||||
}
|
||||
if (doc.evaluate('//tr[1]/td/b/div[@class="centerHeadlines"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var journal = Zotero.Utilities.trimInternal(doc.evaluate('//tr[1]/td/b/div[@class="centerHeadlines"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var ISSN = Zotero.Utilities.trimInternal(doc.evaluate('//tr[1]/td/font[@class="centerHeadlinesSub2"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/(\(|\))/g, ""));
|
||||
} else if (doc.evaluate('//div[@class="centerHeadlinesTitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var journal = Zotero.Utilities.trimInternal(doc.evaluate('//div[@class="centerHeadlinesTitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var ISSN = Zotero.Utilities.trimInternal(doc.evaluate('//tr/td[1]/table/tbody/tr[2]/td/div', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/ISSN\s*([\d\-]+)/)[1]);
|
||||
}
|
||||
var searchItems = new Array();
|
||||
for (var i in items) {
|
||||
searchItems.push(i);
|
||||
}
|
||||
|
||||
searchItems = Zotero.selectItems(searchItems);
|
||||
for (var i in items) {
|
||||
for each (var title in searchItems) {
|
||||
if (i == title) {
|
||||
var data = items[i];
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
item.volume = volume;
|
||||
item.issue = issue;
|
||||
item.date = date;
|
||||
item.title = data['title'];
|
||||
item.pages = data['pages'];
|
||||
item.publicationTitle = Zotero.Utilities.capitalizeTitle(journal);
|
||||
item.ISSN = ISSN;
|
||||
if (data['authors'].match(/\w+/)) {
|
||||
var authors = data['authors'].split(/(\band\b|,|;)/);
|
||||
for each (var aut in authors) {
|
||||
if (aut.match(/\w+/) && aut != "and") {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
|
||||
}
|
||||
}
|
||||
}
|
||||
item.attachments = [{url:data['pdfurl'], title:"AIAA PDF (first page)", mimeType:"application/pdf"}];
|
||||
item.complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,235 +0,0 @@
|
|||
{
|
||||
"translatorID":"0dda3f89-15de-4479-987f-cc13f1ba7999",
|
||||
"translatorType":4,
|
||||
"label":"Ancestry.com US Federal Census",
|
||||
"creator":"Elena Razlogova",
|
||||
"target":"^https?://search.ancestry.com/(.*)usfedcen|1890orgcen|1910uscenindex",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var result = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext();
|
||||
|
||||
var rows = doc.evaluate('//div[@class="g_container"]/div[@class="g_panelWrap"]/div[@class="g_panelCore"]/div[@class="s_container"]/div[@class="p_rsltList"]/table/tbody/tr[@class="tblrow record"]',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var row;
|
||||
while(row = rows.iterateNext()) {
|
||||
links = doc.evaluate('.//a', row, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var linkNo=0;
|
||||
while(link=links.iterateNext()) {
|
||||
linkNo=linkNo+1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if(result && linkNo == 2) {
|
||||
return "multiple";
|
||||
} else {
|
||||
var indivRe = /indiv=1/;
|
||||
var m = indivRe.exec(doc.location.href);
|
||||
var indiv = 0;
|
||||
if(m) {
|
||||
indiv = 1;
|
||||
}
|
||||
|
||||
checkURL = doc.location.href.replace("pf=", "");
|
||||
if(doc.location.href == checkURL && indiv == 1) {
|
||||
return "bookSection";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this US Federal Census scraper is a hack - so far there is no proper item type in Zotero for this kind of data (added to trac as a low priority ticket)
|
||||
// this scraper creates proper citation for the census as a whole (should be cited as book)
|
||||
// but also adds name, city, and state for a particular individual to the citation to make scanning for names & places easier in the middle pane
|
||||
// (that's why the resulting item type is a book section)
|
||||
// it also adds all searchable text as a snapshot and a scan of the census record as an image
|
||||
|
||||
function scrape(doc) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
// get initial census data; a proper census record item type should have separate fields for all of these except perhaps dbid
|
||||
var info = doc.evaluate('//div[@class="facets"][@id="connect"]/div[@class="g_box"]/p/a',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
|
||||
if(info) {
|
||||
|
||||
info = info.toString();
|
||||
var data = new Array();
|
||||
var parts = info.split(/[?&]/);
|
||||
for each(var part in parts) {
|
||||
var index = part.indexOf("=");
|
||||
if(index !== -1) {
|
||||
data[part.substr(0, index)] = part.substr(index+1);
|
||||
}
|
||||
}
|
||||
|
||||
if(data.ln) {
|
||||
var lastName = data.ln.replace(/\+/g, " ");
|
||||
var firstName = data.fn.replace(/\+/g, " ");
|
||||
} else {
|
||||
var lastName = data.fn.replace(/\+/g, " ");
|
||||
var firstName = "";
|
||||
}
|
||||
var dOb = data.by; // this does not get saved yet because no field is available; the info is in the snapshot
|
||||
if(data.rfd) {
|
||||
var yearRe = /([0-9]{4})/;
|
||||
var m = yearRe.exec(data.rfd);
|
||||
if(m) {
|
||||
var year = m[1];
|
||||
}
|
||||
} else { var year = data.ry; }
|
||||
var state = data.rs.replace(/\+/g, " ");
|
||||
var county = data.rcnty.replace(/\+/g, " "); // this does not get saved yet because no field is available; the info is in the snapshot
|
||||
var city = data.rcty.replace(/\+/g, " ");
|
||||
var dbid = data.dbid;
|
||||
}
|
||||
|
||||
// set census number for citation - let me know if this can be done in a better way
|
||||
var censusYear = 0;
|
||||
var censusNo = "";
|
||||
var censusNos = new Array("1790", "First", "1800", "Second", "1810", "Third", "1820", "Fourth", "1830", "Fifth", "1840", "Sixth", "1850", "Seventh", "1860", "Eighth", "1870", "Ninth",
|
||||
"1880", "Tenth", "1890", "Eleventh", "1900", "Twelfth", "1910", "Thirteenth", "1920", "Fourteenth", "1930", "Fifteenth")
|
||||
for(var i in censusNos) {
|
||||
if(censusYear == 1) { censusNo = censusNos[i] };
|
||||
if(censusNos[i] == year) { censusYear = 1 } else {censusYear= 0 };
|
||||
}
|
||||
|
||||
//begin adding item
|
||||
var newItem = new Zotero.Item("bookSection");
|
||||
newItem.title = city+", "+state; // this is not proper citation but is needed to easily scan for placenames in middle pane
|
||||
newItem.publicationTitle = censusNo+" Census of the United States, "+year;
|
||||
newItem.publisher = "National Archives and Records Administration";
|
||||
newItem.place = "Washington, DC";
|
||||
newItem.date = year;
|
||||
|
||||
// get snapshot with all searchable text and a simplified link to the record for the URL field
|
||||
var dbRe = /db=([0-9a-z]+)/;
|
||||
var m = dbRe.exec(doc.location.href);
|
||||
if(m) {
|
||||
db = m[1];
|
||||
}
|
||||
var snapshotRe = /\&h=([0-9]+)/;
|
||||
var m = snapshotRe.exec(doc.location.href);
|
||||
if(m) {
|
||||
snapshotURL = "http://search.ancestry.com/cgi-bin/sse.dll?db="+db+"&indiv=1&pf=1&h="+m[1];
|
||||
newItem.attachments.push({title:"Ancestry.com Snapshot", mimeType:"text/html", url:snapshotURL, snapshot:true});
|
||||
cleanURL = "http://search.ancestry.com/cgi-bin/sse.dll?indiv=1&db="+db+"&fh=0&h="+m[1];
|
||||
newItem.url = cleanURL;
|
||||
}
|
||||
|
||||
// add particular individual being surveyed as contributor - this is not proper citation but is needed so one could easily scan for names in middle pane
|
||||
var creator = new Array();
|
||||
creator.firstName = firstName;
|
||||
creator.lastName = lastName;
|
||||
creator.creatorType = "author";
|
||||
newItem.creators.push(creator);
|
||||
|
||||
//add proper author for citation
|
||||
var creator = new Array();
|
||||
creator.lastName = "United States of America, Bureau of the Census";
|
||||
creator.creatorType = "contributor";
|
||||
newItem.creators.push(creator);
|
||||
|
||||
// get scan of the census image
|
||||
var scanInfo = doc.evaluate('//div[@id="record-main"]/table[@class="p_recTable"]/tbody/tr/td[2][@class="recordTN"]/a',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
|
||||
if(scanInfo) {
|
||||
var scanRe = /iid=([A-Z0-9_-]+)/;
|
||||
var m = scanRe.exec(scanInfo);
|
||||
if(m) {
|
||||
scanURL = "http://content.ancestry.com/Browse/print_u.aspx?dbid="+dbid+"&iid="+m[1];
|
||||
Zotero.debug("scan url: " + scanURL);
|
||||
}
|
||||
}
|
||||
|
||||
if(scanURL){
|
||||
Zotero.Utilities.HTTP.doGet(scanURL, function(text) {
|
||||
Zotero.debug("running doGet");
|
||||
Zotero.debug(text);
|
||||
var imageRe = /950 src="([^"]+)"/;
|
||||
var m = imageRe.exec(text);
|
||||
if(m) {
|
||||
imageURL = m[1];
|
||||
Zotero.debug("image url: " + imageURL);
|
||||
newItem.attachments.push({title:"Ancestry.com Image", mimeType:"image/jpeg", url:imageURL, snapshot:true});
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
Zotero.done();
|
||||
});
|
||||
} else {
|
||||
newItem.complete();
|
||||
Zotero.done();
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var resultsRegexp = /&h=/;
|
||||
if(resultsRegexp.test(url)) {
|
||||
scrape(doc);
|
||||
} else {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
// get census year for links to items
|
||||
var yearRe = /db=([0-9]+)/;
|
||||
var m = yearRe.exec(doc.location.href);
|
||||
if(m) {
|
||||
year = m[1];
|
||||
}
|
||||
|
||||
var dbRe = /db=([0-9a-z]+)/;
|
||||
var m = dbRe.exec(doc.location.href);
|
||||
if(m) {
|
||||
db = m[1];
|
||||
}
|
||||
|
||||
//select items
|
||||
var items = new Array();
|
||||
var listElts = doc.evaluate('//tr[@class="tblrow record keySelect"] | //tr[@class="tblrow record"] | //tr[@class="tblrowalt record"]',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var recid;
|
||||
var link;
|
||||
var name;
|
||||
while (listElt = listElts.iterateNext()) {
|
||||
recInfo = doc.evaluate('.//a', listElt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
var recidRe = /recid=([0-9]+)/;
|
||||
var m = recidRe.exec(recInfo);
|
||||
if(m) {
|
||||
recid = m[1];
|
||||
}
|
||||
link = "http://search.ancestry.com/cgi-bin/sse.dll?indiv=1&db="+db+"&fh=0&h="+recid;
|
||||
name = doc.evaluate('.//span[@class="srchHit"]', listElt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
items[link] = Zotero.Utilities.trimInternal(name);
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
if(!items) return true;
|
||||
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); });
|
||||
Zotero.wait();
|
||||
|
||||
}
|
||||
}
|
|
@ -1,157 +0,0 @@
|
|||
{
|
||||
"translatorID":"f6717cbb-2771-4043-bde9-dbae19129bb3",
|
||||
"translatorType":4,
|
||||
"label":"Archeion",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://archeion-aao",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-24 05:15:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//td[@class="full"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//div[@class="main"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
//Archeion translator. code by Adam Crymble
|
||||
//The way the site is formatted, I can't split the creators up logically. I have left them off for now.
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
newItem = new Zotero.Item("book");
|
||||
|
||||
var xPathHeadings = doc.evaluate('//th', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathContent = doc.evaluate('//table[@class="results"]/tbody/tr/td', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//th)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var fieldTitle;
|
||||
var dataTags = new Object();
|
||||
var multiAuthorCheck = new Array();
|
||||
|
||||
|
||||
for (var i = 0; i < xPathCount.numberValue; i++) {
|
||||
fieldTitle=xPathHeadings.iterateNext().textContent.replace(/\s+/g, '');
|
||||
|
||||
//This was Michael Berkowitz's suggested Fix.
|
||||
|
||||
/*var ts = doc.getElementsByTagName(("table"), 1) = ts.length, ar = [];
|
||||
while ((i--)) {
|
||||
if (ts[i].className&&ts[i].className.match("results")) {
|
||||
ar[ar.length] = ts[i].getElementsByTagName("td")[0].split(/\<br\>/);
|
||||
}
|
||||
}
|
||||
Zotero.debug(ar[0][0]); */
|
||||
|
||||
//COULDN"T SPLIT BY ("\n") TO SEPARATE MULTIPLE CREATORS.
|
||||
if (fieldTitle == "Creator:" | fieldTitle == "Créateur:") {
|
||||
fieldTitle == "Creator:";
|
||||
|
||||
var authorContent = xPathContent.iterateNext().textContent;
|
||||
//Zotero.debug(authorContent);
|
||||
|
||||
//if (authorContent.match(' (*) ')) {
|
||||
// Zotero.debug(doc.title);
|
||||
//}
|
||||
|
||||
|
||||
|
||||
//var test = authorContent.split(/\<br\>/);
|
||||
//Zotero.debug(test);
|
||||
|
||||
authors = authorContent.match(/\w+,?\s+[\w\(\)\.]+/g);
|
||||
|
||||
//Zotero.debug(authors);
|
||||
|
||||
|
||||
for (i = 0; i < authors.length; i++) {
|
||||
|
||||
var author = authors[i].split(", ");
|
||||
|
||||
if (author.length < 2) {
|
||||
|
||||
dataTags["Creator:"] = author[0];
|
||||
newItem.creators.push({lastName: dataTags["Creator:"], creatorType: "creator"});
|
||||
|
||||
} else {
|
||||
|
||||
dataTags["Creator:"] = (author[1] + (" ") + author[0]);
|
||||
//Zotero.debug(authorArranged);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Creator:"], "creator"));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent);
|
||||
//Zotero.debug(fieldTitle);
|
||||
}
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Datesofmaterial:", "date");
|
||||
associateData (newItem, dataTags, "Repository:", "repository");
|
||||
associateData (newItem, dataTags, "ReferenceNumber:", "callNumber");
|
||||
associateData (newItem, dataTags, "PhysicalDescription:", "extra");
|
||||
associateData (newItem, dataTags, "Scopeandcontent", "abstractNote");
|
||||
|
||||
associateData (newItem, dataTags, "Dates:", "date");
|
||||
associateData (newItem, dataTags, "Centred'archives:", "repository");
|
||||
associateData (newItem, dataTags, "Numéroderéférence:", "callNumber");
|
||||
associateData (newItem, dataTags, "Descriptionmatérielle:", "extra");
|
||||
associateData (newItem, dataTags, "Portéeetcontenu", "abstractNote");
|
||||
|
||||
newItem.title = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var xPathLinks = doc.evaluate('//td[@class="full"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var linksCounter = doc.evaluate('count (//td[@class="full"]/a)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathTitles = doc.evaluate('//table[@class="results"]/tbody/tr[1]/td', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_link;
|
||||
for (var i = 0; i < linksCounter.numberValue; i++) {
|
||||
next_link = xPathLinks.iterateNext().href;
|
||||
items[next_link] = xPathTitles.iterateNext().textContent;
|
||||
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
{
|
||||
"translatorID":"dedcae51-073c-48fb-85ce-2425e97f128d",
|
||||
"translatorType":4,
|
||||
"label":"Archive Ouverte en Sciences de l'Information et de la Communication (AOSIC)",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://archivesic.ccsd.cnrs.fr/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.title.toLowerCase().match("fulltext search")) {
|
||||
return "multiple";
|
||||
} else if (url.match(/sic_\d+/)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
var metaTags = {
|
||||
"DC.relation":"url",
|
||||
"DC.date":"date",
|
||||
"DC.description":"abstractNote",
|
||||
"DC.creator":"creators",
|
||||
"DC.title":"title"
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, /sic_\d+\/fr\//);
|
||||
items = Zotero.selectItems(items)
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, function(doc) {
|
||||
var xpath = '//meta[@name]';
|
||||
var data = new Object();
|
||||
var metas = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var meta;
|
||||
while (meta = metas.iterateNext()) {
|
||||
if (data[meta.name]) {
|
||||
data[meta.name] = data[meta.name] + ";" + meta.content;
|
||||
} else {
|
||||
data[meta.name] = meta.content;
|
||||
}
|
||||
}
|
||||
Zotero.debug(data);
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
for (var tag in metaTags) {
|
||||
if (tag == "DC.creator") {
|
||||
var authors = data['DC.creator'].split(";");
|
||||
for each (var aut in authors) {
|
||||
aut = aut.replace(/^([^,]+),\s+(.*)$/, "$2 $1");
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
|
||||
}
|
||||
} else {
|
||||
item[metaTags[tag]] = data[tag];
|
||||
}
|
||||
}
|
||||
var pdfurl = doc.evaluate('//a[contains(@href, ".pdf")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.match(/url=([^&]+)&/)[1];
|
||||
Zotero.debug(pdfurl);
|
||||
item.attachments = [
|
||||
{url:item.url, title:"AOSIC Snapshot", mimeType:"text/html"},
|
||||
{url:pdfurl, title:"AOSIC Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
{
|
||||
"translatorID":"d9a16cf3-8b86-4cab-8610-dbd913ad1a44",
|
||||
"translatorType":4,
|
||||
"label":"Archives Canada-France",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://bd.archivescanadafrance.org",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-24 05:30:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
if (doc.location.href.match("doc.xsp?")) {
|
||||
return "book";
|
||||
} else if (doc.evaluate('//li/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//td[1][@class="icones"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var fieldTitle;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
var xPathHeaders = '//td[2]/div[@class="ead-c"]/div[@class="ead-did"]/table[@class="ead-did"]/tbody/tr/td[1]';
|
||||
|
||||
if (doc.evaluate(xPathHeaders, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var headers = doc.evaluate(xPathHeaders, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var contents = doc.evaluate('//td[2][@class="did-content"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
while (fieldTitle = headers.iterateNext()) {
|
||||
fieldTitle = fieldTitle.textContent.replace(/\s+/g, '');
|
||||
if (fieldTitle == "Origination" || fieldTitle == "Origine") {
|
||||
fieldTitle = "Origination";
|
||||
}
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
}
|
||||
|
||||
if (dataTags["Origination"]) {
|
||||
var author = dataTags["Origination"];
|
||||
if (!author.match(", ")) {
|
||||
newItem.creators.push({lastName: author, creatorType: "author"});
|
||||
} else {
|
||||
var authors = author.split(", ");
|
||||
author = authors[1] + " " + authors[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (doc.evaluate('//h1[@class="doc-title"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.title = doc.evaluate('//h1[@class="doc-title"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
} else if (doc.evaluate('//td[2]/div[@class="notice"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.title = doc.evaluate('//td[2]/div[@class="notice"]/p', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
} else {
|
||||
newItem.title = doc.title + " Title Not Found";
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "PhysicalDescription", "pages");
|
||||
associateData (newItem, dataTags, "Descriptionmatérielle", "pages");
|
||||
|
||||
associateData (newItem, dataTags, "Repository", "repository");
|
||||
associateData (newItem, dataTags, "Lieudeconservation", "repository");
|
||||
|
||||
associateData (newItem, dataTags, "LanguageoftheMaterial", "language");
|
||||
associateData (newItem, dataTags, "Langue", "language");
|
||||
|
||||
associateData (newItem, dataTags, "Identifier", "callNumber");
|
||||
associateData (newItem, dataTags, "Cote", "callNumber");
|
||||
|
||||
associateData (newItem, dataTags, "Datesextrêmes", "date");
|
||||
associateData (newItem, dataTags, "Dates", "date");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
|
||||
var items = new Object();
|
||||
|
||||
if (doc.evaluate('//td[1][@class="icones"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var titles = doc.evaluate('//td[2][@class="ressource"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var titlesCount = doc.evaluate('count (//td[2][@class="ressource"])', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//td[1][@class="icones"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_link;
|
||||
|
||||
for (var i = 0; i < titlesCount.numberValue; i++) {
|
||||
next_link = links.iterateNext().href;
|
||||
if (!next_link.match("doc.xsp")) {
|
||||
next_link = links.iterateNext().href;
|
||||
}
|
||||
items[next_link] = titles.iterateNext().textContent;
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.evaluate('//li/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var titles = doc.evaluate('//li/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
|
||||
} else if (doc.evaluate('//div[@class="ancestor"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
|
||||
var link = doc.evaluate('//div[@class="ancestor"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
|
||||
articles = [link];
|
||||
} else {
|
||||
articles = [url]
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
{
|
||||
"translatorID":"18bc329c-51af-497e-a7cf-aa572fae363d",
|
||||
"translatorType":4,
|
||||
"label":"Archives Canada",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://(www.)?archivescanada.ca",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-20 20:45:00"
|
||||
}
|
||||
|
||||
function detectWeb (doc, url) {
|
||||
if (doc.location.href.match("RouteRqst")) {
|
||||
return "multiple";
|
||||
} else if (doc.location.href.match("ItemDisplay")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var cainNo;
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var data = doc.evaluate('//td/p', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var dataCount = doc.evaluate('count (//td/p)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (i=0; i<dataCount.numberValue; i++) {
|
||||
data1 = data.iterateNext().textContent.replace(/^\s*|\s*$/g, '').split(":");
|
||||
fieldTitle = data1[0].replace(/\s+/g, '');
|
||||
|
||||
if (fieldTitle == "PROVENANCE") {
|
||||
|
||||
var multiAuthors = data1[1].split(/\n/);
|
||||
|
||||
for (var j = 0; j < multiAuthors.length; j++) {
|
||||
if (multiAuthors[j].match(",")) {
|
||||
|
||||
var authorName = multiAuthors[j].replace(/^\s*|\s*$/g, '').split(",");
|
||||
|
||||
authorName[0] = authorName[0].replace(/\s+/g, '');
|
||||
dataTags["PROVENANCE"] = (authorName[1] + (" ") + authorName[0]);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["PROVENANCE"], "author"));
|
||||
|
||||
} else {
|
||||
|
||||
newItem.creators.push({lastName: multiAuthors[j].replace(/^\s*|\s*$/g, ''), creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
|
||||
} else if (fieldTitle == "SUBJECTS" | fieldTitle == "MATIÈRES") {
|
||||
tagsContent = data1[1].split(/\n/);
|
||||
|
||||
} else {
|
||||
|
||||
dataTags[fieldTitle] = data1[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.evaluate('//tr[3]/td/table/tbody/tr[1]/td/table/tbody/tr[2]/td/table/tbody/tr/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
cainNo = doc.evaluate('//tr[3]/td/table/tbody/tr[1]/td/table/tbody/tr[2]/td/table/tbody/tr/td[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.extra = cainNo.replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
newItem.tags[i] = tagsContent[i].replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "TITLE", "title" );
|
||||
associateData (newItem, dataTags, "REPOSITORY", "repository" );
|
||||
associateData (newItem, dataTags, "RETRIEVALNUMBER", "callNumber" );
|
||||
associateData (newItem, dataTags, "DATES", "date" );
|
||||
associateData (newItem, dataTags, "SCOPEANDCONTENT", "abstractNote" );
|
||||
associateData (newItem, dataTags, "LANGUAGE", "language" );
|
||||
|
||||
associateData (newItem, dataTags, "LANGUE", "language" );
|
||||
associateData (newItem, dataTags, "TITRE", "title" );
|
||||
associateData (newItem, dataTags, "CENTRED'ARCHIVES", "repository" );
|
||||
associateData (newItem, dataTags, "NUMÉROD'EXTRACTION", "callNumber" );
|
||||
associateData (newItem, dataTags, "PORTÉEETCONTENU", "abstractNote" );
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//td[3]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,152 +0,0 @@
|
|||
{
|
||||
"translatorID":"f39dbd1c-229e-4abb-8414-a09fdbda37b7",
|
||||
"translatorType":4,
|
||||
"label":"Archives Network of Alberta",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://208.38.46.62:8080/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-29 21:10:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
var xPathH3 = doc.evaluate('//h3', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
if (xPathH3.match("Search Results")) {
|
||||
return "multiple";
|
||||
} else if (xPathH3.match("Display")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
//Archives Network of Alberta translator. Code by Adam Crymble
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var dataTags = new Object();
|
||||
var manyAuthors = new Array();
|
||||
var tagsContent = new Array();
|
||||
var tagsContent1 = new Array();
|
||||
|
||||
var xPathHeaders = doc.evaluate('//td[1][@class="datalabel"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathContent = doc.evaluate('//td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//td[1][@class="datalabel"])', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (var i = 0; i < xPathCount.numberValue; i++) {
|
||||
fieldTitle = xPathHeaders.iterateNext().textContent.replace(/\s+/g, '');
|
||||
|
||||
if (fieldTitle =="Provenance:") {
|
||||
|
||||
dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
|
||||
if (dataTags[fieldTitle].match("; ")) {
|
||||
manyAuthors = dataTags[fieldTitle].split("; ");
|
||||
} else {
|
||||
manyAuthors.push(dataTags[fieldTitle]);
|
||||
}
|
||||
Zotero.debug(manyAuthors);
|
||||
|
||||
for (var j = 0; j < manyAuthors.length; j++) {
|
||||
if (manyAuthors[j].match(", ")) {
|
||||
var authorName = manyAuthors[j].split(",");
|
||||
authorName[0] = authorName[0].replace(/^\s*|\s*$/g, '');
|
||||
authorName[1] = authorName[1].replace(/^\s*|\s*$/g, '');
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor((authorName[1] + (" ") + authorName[0]), "author"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: manyAuthors[j], creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
|
||||
} else if (fieldTitle == "Partof:") {
|
||||
|
||||
dataTags[fieldTitle] = ("Part of " + Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')));
|
||||
|
||||
} else if (fieldTitle == "OnlineFindingAid:") {
|
||||
dataTags[fieldTitle] = ("Online Finding Aid: " + xPathContent.iterateNext().textContent);
|
||||
Zotero.debug(dataTags["OnlineFindingAid:"]);
|
||||
|
||||
} else if (fieldTitle == "Names:") {
|
||||
dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
tagsContent = dataTags[fieldTitle].split(";");
|
||||
|
||||
} else if (fieldTitle == "Topic:") {
|
||||
dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
tagsContent1 = dataTags[fieldTitle].split(", ");
|
||||
|
||||
} else {
|
||||
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < tagsContent.length; i++) {
|
||||
tagsContent[i] = tagsContent[i].replace(/^\s*|\s*$/g, '');
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
|
||||
for (i = 0; i < tagsContent1.length; i++) {
|
||||
|
||||
newItem.tags.push(tagsContent1[i]);
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Title:", "title");
|
||||
associateData (newItem, dataTags, "Dates:", "date");
|
||||
associateData (newItem, dataTags, "Physicaldesc.:", "pages");
|
||||
associateData (newItem, dataTags, "Repository:", "repository");
|
||||
associateData (newItem, dataTags, "Scope/Content:", "abstractNote");
|
||||
associateData (newItem, dataTags, "Partof:", "series");
|
||||
associateData (newItem, dataTags, "OnlineFindingAid:", "extra");
|
||||
associateData (newItem, dataTags, "Language:", "language");
|
||||
associateData (newItem, dataTags, "RecordNo.:", "callNumber");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var xPathTitles = doc.evaluate('//tr[1]/td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var nextTitle;
|
||||
|
||||
var xPathLinks = doc.evaluate('//td[1][@class="dataleft"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
|
||||
while (nextTitle = xPathTitles.iterateNext()) {
|
||||
items[xPathLinks.iterateNext().href] = nextTitle.textContent;
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,160 +0,0 @@
|
|||
{
|
||||
"translatorID":"661fc39a-2500-4710-8285-2d67ddc00a69",
|
||||
"translatorType":4,
|
||||
"label":"Artefacts Canada",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://daryl.chin.gc.ca",
|
||||
"minVersion":"1.0",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-09-02 13:55:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var multi1 = '';
|
||||
var single1 = '';
|
||||
|
||||
if (doc.evaluate('//div[@id="mainContent"]/table/tbody/tr/td[1]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
|
||||
multi1 = doc.evaluate('//div[@id="mainContent"]/table/tbody/tr/td[1]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
var xpath = '//tbody/tr[1]/td[2]/span';
|
||||
if (doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
single1 = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
if (multi1.match("Search Results") || multi1.match("Résultats de recherche")) {
|
||||
return "multiple";
|
||||
} else if (single1.match("Document") || single1.match("Enregistrement")) {
|
||||
return "artwork";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var fieldTitle;
|
||||
|
||||
var newItem = new Zotero.Item("artwork");
|
||||
|
||||
var headers = doc.evaluate('//td[1][@class="leftResTitle"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var contents = doc.evaluate('//td[2][@class="pageText"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
while (fieldTitle = headers.iterateNext()) {
|
||||
fieldTitle = fieldTitle.textContent.replace(/\s+/g, '');
|
||||
if (fieldTitle == "Titre:") {
|
||||
fieldTitle = "Title:";
|
||||
} else if (fieldTitle == "Nomdel'objet:") {
|
||||
fieldTitle = "NameofObject:";
|
||||
} else if (fieldTitle == "Sujetouimage:") {
|
||||
fieldTitle = "Subject/Image:";
|
||||
} else if (fieldTitle == "Numérod'accession:") {
|
||||
fieldTitle = "AccessionNumber:";
|
||||
} else if (fieldTitle == "Artisteouartisan:") {
|
||||
fieldTitle = "Artist/Maker:";
|
||||
} else if (fieldTitle == "Fabricant:") {
|
||||
fieldTitle = "Manufacturer:";
|
||||
}
|
||||
|
||||
dataTags[fieldTitle] = contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '')
|
||||
}
|
||||
|
||||
Zotero.debug(dataTags);
|
||||
|
||||
if (dataTags["Artist/Maker:"]) {
|
||||
if (dataTags["Artist/Maker:"].match(", ")) {
|
||||
var authors = dataTags["Artist/Maker:"].split(", ");
|
||||
authors = authors[0] + ' ' + authors[1];
|
||||
newItem.creators.push(authors, "creator");
|
||||
} else {
|
||||
newItem.creators.push(dataTags["Artist/Make:"], "creator");
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["Manufacturer:"]) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Manufacturer:"], "creator"));
|
||||
}
|
||||
|
||||
if (dataTags["AccessionNumber:"]) {
|
||||
newItem.locInArchive = "Accession Number: " + dataTags["AccessionNumber:"];
|
||||
}
|
||||
|
||||
if (dataTags["Subject/Image:"]) {
|
||||
if (dataTags["Subject/Image:"].match(/\n/)) {
|
||||
var subjects = dataTags["Subject/Image:"].split(/\n/);
|
||||
for (var i = 0; i < subjects.length; i++) {
|
||||
newItem.tags[i] = subjects[i];
|
||||
}
|
||||
} else {
|
||||
newItem.tags[0] = dataTags["Subject/Image:"].match(/\n/);
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["Title:"]) {
|
||||
associateData (newItem, dataTags, "Title:", "title");
|
||||
associateData (newItem, dataTags, "NameofObject:", "medium");
|
||||
} else if (dataTags["NameofObject:"]) {
|
||||
associateData (newItem, dataTags, "NameofObject:", "title");
|
||||
} else {
|
||||
newItem.title = "No Title Found";
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "LatestProductionDate:", "date");
|
||||
associateData (newItem, dataTags, "Datedefindeproduction:", "date");
|
||||
|
||||
associateData (newItem, dataTags, "Institution:", "repository");
|
||||
associateData (newItem, dataTags, "Établissement:", "repository");
|
||||
|
||||
associateData (newItem, dataTags, "Description:", "description");
|
||||
|
||||
associateData (newItem, dataTags, "Medium:", "medium");
|
||||
associateData (newItem, dataTags, "Médium:", "medium");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//tr[1]/td[2][@class="pageText"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//td/a[@class="moreInfoink"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
|
||||
items[links.iterateNext().href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
{
|
||||
"translatorID":"5ed5ab01-899f-4a3b-a74c-290fb2a1c9a4",
|
||||
"translatorType":4,
|
||||
"label":"AustLII and NZLII",
|
||||
"creator":"Bill McKinney",
|
||||
"target":"http:\\/\\/www\\.(?:austlii\\.edu\\.au|nzlii\\.org)\\/(?:\\/cgi-bin\\/disp\\.pl\\/)?(?:au|nz)\\/cases\\/.+",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2007-06-18 18:15:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var austliiRegexp = /^http:\/\/www\.(?:austlii\.edu\.au|nzlii\.org)\/(?:\/cgi-bin\/disp\.pl\/)?(?:au|nz)\/cases\/.+/
|
||||
if(austliiRegexp.test(url)) {
|
||||
return "book";
|
||||
} else {
|
||||
var aTags = doc.getElementsByTagName("a");
|
||||
for(var i=0; i<aTags.length; i++) {
|
||||
if(articleRegexp.test(aTags[i].href)) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function scrape(doc) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("case");
|
||||
newItem.title = doc.title;
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
var titleRegexp = /^(.+)\s+\[(\d+)\]\s+(\w+)\s(\d+)\s+\((\d+)\s+(\w+)\s+(\d+)\)/
|
||||
var titleMatch = titleRegexp .exec(doc.title);
|
||||
if (titleMatch ) {
|
||||
newItem.caseName = titleMatch[1] + " [" + titleMatch[2] + "] " + titleMatch[3] + " " + titleMatch[4];
|
||||
newItem.dateDecided = titleMatch[7] + " " + titleMatch[6] + " " + titleMatch[5];
|
||||
newItem.court = titleMatch[3];
|
||||
} else {
|
||||
newItem.caseName = doc.title;
|
||||
newItem.dateDecided = "not found";
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var austliiRegexp = /^http:\/\/www\.(?:austlii\.edu\.au|nzlii\.org)\/(?:\/cgi-bin\/disp\.pl\/)?(?:au|nz)\/cases\/.+/
|
||||
if(austliiRegexp.test(url)) {
|
||||
scrape(doc);
|
||||
} else {
|
||||
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, austliiRegexp);
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); });
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
{
|
||||
"translatorID":"0aea3026-a246-4201-a4b5-265f75b9a6a7",
|
||||
"translatorType":4,
|
||||
"label":"Australian Dictionary of Biography",
|
||||
"creator":"Tim Sherratt and Michael Berkowitz",
|
||||
"target":"http://www.adb.online.anu.edu.au",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/adbp-ent_search|browse_people|browse_authors/)) {
|
||||
return "multiple";
|
||||
} else if (url.match(/biogs\/AS*\d+b.htm/)) {
|
||||
return "bookSection";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == "x") return namespace; else return null;
|
||||
} : null;
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var records = new Array();
|
||||
var items = new Object();
|
||||
if (url.match(/browse_people/)) {
|
||||
var titles = doc.evaluate('//ul[@class="pb-results"]/li', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//ul[@class="pb-results"]/li/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
} else if (url.match(/browse_authors/)) {
|
||||
var titles = doc.evaluate('//div[@id="content"]/dl/dd', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//div[@id="content"]/dl/dd/a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
} else if (url.match(/adbp-ent_search/)) {
|
||||
var titles = doc.evaluate('//div[@id="content"]/ol/li', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//div[@id="content"]/ol/li//a[1]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
}
|
||||
var title;
|
||||
var link;
|
||||
while ((link = links.iterateNext()) && (title = titles.iterateNext())) {
|
||||
items[link.href] = Zotero.Utilities.trimInternal(title.textContent);
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
records.push(i);
|
||||
}
|
||||
} else {
|
||||
records = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(records, function(doc) {
|
||||
var item = new Zotero.Item("bookSection");
|
||||
var author = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="content"]/p[strong="Author"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().lastChild.textContent);
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
item.title = Zotero.Utilities.trimInternal(doc.evaluate('//h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var pubdetails = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="content"]/p[strong="Print Publication Details"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
pubdetails = pubdetails.match(/Volume (\d+), ([\w ]+), (\d{4}), p+\.*\s+([\d-]+)/);
|
||||
item.volume = RegExp.$1;
|
||||
item.publisher = RegExp.$2;
|
||||
item.date = RegExp.$3;
|
||||
item.pages = RegExp.$4;
|
||||
item.url = doc.location.href;
|
||||
item.bookTitle = "Australian Dictionary of Biography";
|
||||
item.place = "Melbourne";
|
||||
item.repository = "Australian Dictionary of Biography";
|
||||
var tags = doc.evaluate('//li/a[starts-with(@title, "find people with the occupation")]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
while (tag = tags.iterateNext()) {
|
||||
item.tags.push(tag.textContent);
|
||||
}
|
||||
item.attachments = [
|
||||
{url:item.url, title: "Snapshot - " + item.title, mimeType:"text/html"},
|
||||
];
|
||||
item.complete();
|
||||
|
||||
}, function() {Zotero.done();});
|
||||
}
|
|
@ -1,106 +0,0 @@
|
|||
{
|
||||
"translatorID":"5ae63913-669a-4792-9f45-e089a37de9ab",
|
||||
"translatorType":4,
|
||||
"label":"BAILII",
|
||||
"creator":"Bill McKinney",
|
||||
"target":"http:\\/\\/www\\.bailii\\.org(?:\\/cgi\\-bin\\/markup\\.cgi\\?doc\\=)?\\/\\w+\\/cases\\/.+",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2007-06-18 18:15:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var liiRegexp= /^http:\/\/www\.bailii\.org(?:\/cgi\-bin\/markup\.cgi\?doc\=)?\/\w+\/cases\/.+/
|
||||
if(liiRegexp.test(url)) {
|
||||
return "book";
|
||||
} else {
|
||||
var aTags = doc.getElementsByTagName("a");
|
||||
for(var i=0; i<aTags.length; i++) {
|
||||
if(articleRegexp.test(aTags[i].href)) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("case");
|
||||
newItem.title = doc.title;
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
var titleRegexp = /^(.+)\s+\[(\d+)\]\s+(.+)\s+\((\d+)\s+(\w+)\s+(\d+)\)/
|
||||
var titleMatch = titleRegexp .exec(doc.title);
|
||||
if (titleMatch ) {
|
||||
newItem.caseName = titleMatch[1] + " [" + titleMatch[2] + "] " + titleMatch[3];
|
||||
newItem.dateDecided = titleMatch[4] + " " + titleMatch[5] + " " + titleMatch[6];
|
||||
} else {
|
||||
newItem.caseName = doc.title;
|
||||
newItem.dateDecided = "not found";
|
||||
}
|
||||
|
||||
var courtRegexp = /cases\/([^\/]+)\/([^\/]+)\//
|
||||
var courtMatch = courtRegexp.exec(doc.location.href);
|
||||
if (courtMatch) {
|
||||
var divRegexp = /\w+/
|
||||
var divMatch = divRegexp.exec(courtMatch[2]);
|
||||
if (divMatch) {
|
||||
newItem.court = courtMatch[1] + " (" + courtMatch[2] + ")";
|
||||
} else {
|
||||
newItem.court = courtMatch[1];
|
||||
}
|
||||
} else {
|
||||
newItem.court = "not found";
|
||||
}
|
||||
|
||||
// judge
|
||||
var panel = doc.getElementsByTagName("PANEL");
|
||||
if (panel.length > 0) {
|
||||
var tmp = panel[0].innerHTML;
|
||||
newItem.creators.push({lastName:tmp, creatorType:"judge", fieldMode:true});
|
||||
|
||||
}
|
||||
// citation
|
||||
var cite = doc.getElementsByTagName("CITATION");
|
||||
if (cite.length > 0) {
|
||||
var tmpc = cite[0].childNodes[0].innerHTML;
|
||||
newItem.notes.push({note:tmpc});
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var liiRegexp= /http:\/\/www\.bailii\.org(?:\/cgi\-bin\/markup\.cgi\?doc\=)?\/\w+\/cases\/.+/
|
||||
if(liiRegexp.test(url)) {
|
||||
scrape(doc);
|
||||
} else {
|
||||
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, liiRegexp);
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); });
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
{
|
||||
"translatorID":"f4130157-93f7-4493-8f24-a7c85549013d",
|
||||
"translatorType":4,
|
||||
"label":"BBC",
|
||||
"creator":"Ben Parr",
|
||||
"target":"^https?://(?:www|news?)\\.bbc\\.co.uk",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2007-08-27 05:00:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url)
|
||||
{
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var xpath;
|
||||
|
||||
xpath='//meta[@name="Headline"]';
|
||||
if(content=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext())
|
||||
{ return "newspaperArticle"; }
|
||||
|
||||
xpath='//font[@class="poshead"]/b';
|
||||
if(doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext())
|
||||
{ return "newspaperArticle"; }
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function scrape(doc,url,title)
|
||||
{
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
|
||||
newItem.url=url;
|
||||
newItem.repository="bbc.co.uk";
|
||||
newItem.publicationTitle="BBC";
|
||||
newItem.title=title;
|
||||
|
||||
xpath='//meta[@name="OriginalPublicationDate"]/@content';
|
||||
var temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(temp)
|
||||
{
|
||||
temp=temp.value;
|
||||
temp=temp.split(" ")[0];
|
||||
newItem.date=temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
xpath='//font[@class="postxt"][@size="1"]';
|
||||
var rows=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null);
|
||||
var row;
|
||||
while(row=rows.iterateNext())
|
||||
{
|
||||
temp=row.textContent;
|
||||
if(temp.substr(0,9)=="Created: ")
|
||||
{
|
||||
newItem.date=temp.substr(9);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
xpath='//meta[@name="Section"]/@content';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(temp)
|
||||
{ newItem.section=temp.value; }
|
||||
|
||||
xpath='//meta[@name="Description"]/@content';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(temp)
|
||||
{ newItem.abstractNote=temp.value; }
|
||||
else
|
||||
{
|
||||
xpath='//meta[@name="description"]/@content';
|
||||
temp=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(temp)
|
||||
{ newItem.abstractNote=temp.value; }
|
||||
}
|
||||
|
||||
newItem.attachments.push({url:url, title:"BBC News Snapshot",mimeType:"text/html"});
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
|
||||
|
||||
function doWeb(doc,url)
|
||||
{
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var xpath='//meta[@name="Headline"]/@content';
|
||||
var title;
|
||||
if(title=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext())
|
||||
{ scrape(doc,url,title.value) }
|
||||
else
|
||||
{
|
||||
xpath='//font[@class="poshead"]/b';
|
||||
if(title=doc.evaluate(xpath, doc, nsResolver,XPathResult.ANY_TYPE, null).iterateNext())
|
||||
{ scrape(doc,url,title.textContent) }
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,147 +0,0 @@
|
|||
{
|
||||
"translatorID":"c76d6c19-b4c6-4e51-bd7a-0a81752305ae",
|
||||
"translatorType":4,
|
||||
"label":"BC Archival Information Network",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://(mayne.)?aabc.bc.ca/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-20 20:45:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
|
||||
var entryType = (doc.evaluate('/html/body/h3', doc, nsResolver, XPathResult.ANY_TYPE, null));
|
||||
if (entryType.iterateNext()) {
|
||||
var entryType1 = entryType.iterateNext().textContent;
|
||||
|
||||
if (entryType1.match("Search") && entryType1 != ("Search Results - BCAUL Repositories")) {
|
||||
return "multiple";
|
||||
} else if (entryType1.match("Display") && entryType1 != ("Display - BCAUL Repositories") && doc.location.href.match("display")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BCAIN translator. Code by Adam Crymble
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var dataTags = new Object();
|
||||
var manyAuthors = new Array();
|
||||
var tagsContent = new Array();
|
||||
|
||||
var xPathHeaders = doc.evaluate('//td[1][@class="datalabel"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathContent = doc.evaluate('//td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//td[1][@class="datalabel"])', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
Zotero.debug(xPathCount.numberValue);
|
||||
|
||||
for (var i = 0; i < xPathCount.numberValue; i++) {
|
||||
fieldTitle = xPathHeaders.iterateNext().textContent.replace(/\s+/g, '');
|
||||
|
||||
if (fieldTitle =="Provenance:") {
|
||||
|
||||
dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
|
||||
if (dataTags[fieldTitle].match("; ")) {
|
||||
manyAuthors = dataTags[fieldTitle].split("; ");
|
||||
} else {
|
||||
manyAuthors.push(dataTags[fieldTitle]);
|
||||
}
|
||||
|
||||
for (var j = 0; j < manyAuthors.length; j++) {
|
||||
if (manyAuthors[j].match(", ")) {
|
||||
var authorName = manyAuthors[j].split(",");
|
||||
authorName[0] = authorName[0].replace(/^\s*|\s*$/g, '');
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor((authorName[1] + (" ") + authorName[0]), "author"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: dataTags["Provenance:"], creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
|
||||
} else if (fieldTitle == "Partof:") {
|
||||
|
||||
dataTags[fieldTitle] = ("Part of " + Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '')));
|
||||
|
||||
} else if (fieldTitle == "OnlineFindingAid:") {
|
||||
dataTags[fieldTitle] = ("Online Finding Aid: " + xPathContent.iterateNext().textContent);
|
||||
Zotero.debug(dataTags["OnlineFindingAid:"]);
|
||||
|
||||
} else if (fieldTitle == "Names:") {
|
||||
dataTags[fieldTitle] = (xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
tagsContent = dataTags[fieldTitle].split(";");
|
||||
|
||||
} else {
|
||||
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
tagsContent[i] = tagsContent[i].replace(/^\s*|\s*$/g, '');
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Title:", "title");
|
||||
associateData (newItem, dataTags, "Dates:", "date");
|
||||
associateData (newItem, dataTags, "Physicaldesc.:", "pages");
|
||||
associateData (newItem, dataTags, "Repository:", "repository");
|
||||
associateData (newItem, dataTags, "Scope/Content:", "abstractNote");
|
||||
associateData (newItem, dataTags, "Partof:", "series");
|
||||
associateData (newItem, dataTags, "OnlineFindingAid:", "extra");
|
||||
|
||||
newItem.notes.push({title:"Title", note:"To view this entry in your browser, please go to'http://aabc.bc.ca/WWW.aabc.archbc/access' and search for the entry Title "});
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var xPathTitles = doc.evaluate('//tr[1]/td[2][@class="datatext"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var nextTitle;
|
||||
|
||||
var xPathLinks = doc.evaluate('//td[1][@class="dataleft"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var nextLink;
|
||||
|
||||
while (nextTitle = xPathTitles.iterateNext()) {
|
||||
items[xPathLinks.iterateNext().href] = nextTitle.textContent;
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
{
|
||||
"translatorID":"ab961e61-2a8a-4be1-b8a3-044f20d52d78",
|
||||
"translatorType":4,
|
||||
"label":"BIBSYS",
|
||||
"creator":"Ramesh Srigiriraju",
|
||||
"target":"^http://ask\\.bibsys\\.no/ask/action",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2007-07-31 16:45:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var multireg=new RegExp("^http://ask\.bibsys\.no/ask/action/result");
|
||||
if(multireg.test(url))
|
||||
return "multiple";
|
||||
var singlereg=new RegExp("^http://ask\.bibsys\.no/ask/action/show");
|
||||
if(singlereg.test(url))
|
||||
return "book";
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace=doc.documentElement.namespaceURI;
|
||||
var nsResolver=namespace?function(prefix) {
|
||||
return (prefix=="x")?namespace:null;
|
||||
}:null;
|
||||
var multireg=new RegExp("http://ask\.bibsys\.no/ask/action/result");
|
||||
if(multireg.test(url)) {
|
||||
var titlpath='//tr/td[@width="49%"][@align="left"][@valign="top"]/a/text()';
|
||||
var titles=doc.evaluate(titlpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var codepath='//tr/td/input[@type="checkbox"][@name="valg"]/@value';
|
||||
var codes=doc.evaluate(codepath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var items=new Array();
|
||||
var title;
|
||||
titles.iterateNext();
|
||||
while(title=titles.iterateNext())
|
||||
items[codes.iterateNext().nodeValue]=title.nodeValue;
|
||||
items=Zotero.selectItems(items);
|
||||
var string="http://ask.bibsys.no/ask/action/result?control=ctr_top";
|
||||
for(var codes in items)
|
||||
string+="&valg="+codes;
|
||||
string+="&control=ctr_bottom&eksportFormat=refmanager&eksportEpostAdresse=&eksportEpostFormat=fortekst&cmd=sendtil";
|
||||
Zotero.Utilities.HTTP.doGet(string, function(text) {
|
||||
var trans=Zotero.loadTranslator("import");
|
||||
trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
trans.setString(text);
|
||||
trans.translate();
|
||||
Zotero.done();
|
||||
});
|
||||
Zotero.wait();
|
||||
}
|
||||
var singlereg=new RegExp("http://ask\.bibsys\.no/ask/action/show");
|
||||
if(singlereg.test(url)) {
|
||||
var urlstring="http://ask.bibsys.no/ask/action/show";
|
||||
var data="visningsformat=fortekst_m_eksemplarer&eksportFormat=refmanager&eksportEpostAdresse=&eksportEpostFormat=fortekst&cmd=sendtil";
|
||||
Zotero.Utilities.HTTP.doPost(urlstring, data, function(text) {
|
||||
var trans=Zotero.loadTranslator("import");
|
||||
trans.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
trans.setString(text);
|
||||
trans.translate();
|
||||
Zotero.done();
|
||||
});
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
{
|
||||
"translatorID":"cae7d3ec-bc8d-465b-974f-8b0dcfe24290",
|
||||
"translatorType":4,
|
||||
"label":"BIUM",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://hip.bium.univ-paris5.fr/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//td/a[@class="itemTitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//td[1]/span[@class="uportal-channel-strong"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
function makeMARCurl(link, rsId, rrsId, query) {
|
||||
return 'http://hip.bium.univ-paris5.fr/uPortal/Print?link=' + link + '&xslFileName=com/dynix/hip/uportal/channels/standard/FullMarc.xsl&F=/searching/getmarcdata&responseSessionId=' + rsId + '&responseResultSetId=' + rrsId + '&searchGroup=BIUM-13&query=' + query + '&searchTargets=16&locale=fr_FR';
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var n = doc.documentElement.namespaceURI;
|
||||
var ns = n ? function(prefix) {
|
||||
if (prefix == 'x') return n; else return null;
|
||||
} : null;
|
||||
|
||||
var books = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var links = doc.evaluate('//a[@class="itemTitle"]', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var link;
|
||||
while (link = links.iterateNext()) {
|
||||
items[link.href] = Zotero.Utilities.trimInternal(link.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
var rsId = doc.evaluate('//input[@name="responseSessionId"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var rrsId = doc.evaluate('//input[@name="responseResultSetId"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var query = doc.evaluate('//input[@name="query"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var linkRE = new RegExp("'([^']+)'", "g");
|
||||
for (var i in items) {
|
||||
var link = linkRE.exec(i)[1];
|
||||
Zotero.debug(link);
|
||||
books.push(makeMARCurl(link, rsId, rrsId, query));
|
||||
}
|
||||
} else {
|
||||
var link = url.match(/link=([^&]+)/)[1];
|
||||
var rsId = url.match(/responseSessionId=([^&]+)/)[1];
|
||||
var rrsId = url.match(/responseResultSetId=([^&]+)/)[1];
|
||||
var query = url.match(/query=([^&]+)/)[1];
|
||||
books = [makeMARCurl(link, rsId, rrsId, query)];
|
||||
}
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973");
|
||||
var marc = translator.getTranslatorObject();
|
||||
Zotero.Utilities.processDocuments(books, function(doc) {
|
||||
var rows = doc.evaluate('//center/table/tbody/tr', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var row;
|
||||
var record = new marc.record();
|
||||
while (row = rows.iterateNext()) {
|
||||
var field = Zotero.Utilities.trimInternal(doc.evaluate('./td[1]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(":", ""));
|
||||
if (field) {
|
||||
var value = doc.evaluate('./td[2]', row, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
if (value.split(/\n/)[1]) value = Zotero.Utilities.trimInternal(value.split(/\n/)[1]);
|
||||
if (field == "LDR") {
|
||||
record.leader = value;
|
||||
} else if (field != "FMT") {
|
||||
value = value.replace(/\¤([a-z])/g, marc.subfieldDelimiter+ "$1");
|
||||
var code = field.substring(0, 3);
|
||||
var ind = "";
|
||||
if (field.length > 3) {
|
||||
ind = field[3];
|
||||
if (field.length > 4) {
|
||||
ind += field[4];
|
||||
}
|
||||
}
|
||||
record.addField(code, ind, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
var item = new Zotero.Item();
|
||||
record.translate(item);
|
||||
|
||||
var oldauthors = item.creators;
|
||||
var newauthors = new Array();
|
||||
for each (var aut in oldauthors) {
|
||||
if (aut.lastName.match(/^[A-Z][^\s]+\s[^\s]+/)) newauthors.push(Zotero.Utilities.cleanAuthor(aut.lastName.match(/^[A-Z][^\s]+\s[^\s]+/)[0].replace(/^([^\s]+)\s+(.*)$/, "$2 $1"), "author"));
|
||||
}
|
||||
item.creators = newauthors;
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,212 +0,0 @@
|
|||
{
|
||||
"translatorID":"ecd1b7c6-8d31-4056-8c15-1807b2489254",
|
||||
"label":"BOCC",
|
||||
"creator":"José Antonio Meira da Rocha",
|
||||
"target":"^http:\\/\\/[^/]*bocc[^/]*/(?:_listas|_esp)",
|
||||
"minVersion":"1.0",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"translatorType":4,
|
||||
"lastUpdated":"2010-09-20 18:12:01"
|
||||
}
|
||||
|
||||
/* Translator for Biblioteca Online de Ciências da Comunicação (BOCC,
|
||||
Communication Science Online Library, http://www.bocc.ubi.pt/) */
|
||||
|
||||
/*
|
||||
BOCC Translator - Parses BOCC indexes and creates Zotero-based metadata.
|
||||
Copyright (C) 2010 José Antonio Meira da Rocha
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// Standard Zotero function
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate("//table[@class='ag']/tbody/tr[1]/td[@class='agenda']", doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
Zotero.debug("multiple");
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////
|
||||
function getAuthors(newItem, itemsAutors) {
|
||||
//Formatting and saving "Author" field
|
||||
if (items["AUTOR"]) {
|
||||
var author = itemsAutors["AUTOR"];
|
||||
if (author.match(";")) {
|
||||
var authors = author.split(";");
|
||||
for (var i in authors) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author"));
|
||||
}
|
||||
} else {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Standard Zotero translator entry point
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var articles = new Array();
|
||||
var items = new Object();
|
||||
var itemsAutors = new Object();
|
||||
var itemDate = new Object();
|
||||
var nextTitle;
|
||||
var urls = new Array();
|
||||
var bloco;
|
||||
var lines = new Array();
|
||||
var resite = /^http:\/\/[^\/]*bocc[^\/]*\/(?:_listas|_esp)/;
|
||||
var site = resite.exec(url);
|
||||
site = site[0];
|
||||
site = site.replace("/_esp", "");
|
||||
site = site.replace("/_listas", "");
|
||||
Zotero.debug('Site===>'+site+'<===');
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
// Return XPathResult object
|
||||
// accessible with .iterateNext() method
|
||||
var content = doc.evaluate("//table[@class='ag']/tbody/tr[1]/td[@class='agenda']", doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
// All articles are in same <td>
|
||||
// Get the first <td> data
|
||||
bloco = content.iterateNext().innerHTML;
|
||||
lines = bloco.split('<br><br>');
|
||||
//Zotero.debug('Artigo===>'+lines[0]+'<===');
|
||||
///////////////////////////////////////////////
|
||||
// Try get tags
|
||||
var tematica = doc.evaluate("//title", doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
tematica = tematica.iterateNext().textContent;
|
||||
//Zotero.debug('<Title>===>'+tematica+'<===');
|
||||
var isTematica = tematica.match('Temática');
|
||||
if (isTematica) {
|
||||
// Get tematicas list to build tags list
|
||||
var tematicanum;
|
||||
var tematicasnums = doc.evaluate('//a[@class="tematica"]/@href', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var tematicasname;
|
||||
var tematicasnames = doc.evaluate('//a[@class="tematica"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var tematicas = new Object();
|
||||
while (tematicanum = tematicasnums.iterateNext()) {
|
||||
tematicanum = tematicanum.textContent;
|
||||
tematicanum = tematicanum.match(/=[\d]+$/)[0];
|
||||
tematicanum = tematicanum.replace('=','');
|
||||
tematicaname = tematicasnames.iterateNext().textContent;
|
||||
tematicas[tematicanum] = tematicaname;
|
||||
}
|
||||
////////////////////////////////////////////
|
||||
// Get current tematica
|
||||
var tagsContent = new Array();
|
||||
|
||||
|
||||
tematica = tematica.match(/:\s[\d]*\s-/)[0];
|
||||
tematica = tematica.replace(': ','');
|
||||
tematica = tematica.replace(' -','');
|
||||
tematicaname = tematicas[tematica];
|
||||
//Zotero.debug('Tematica ===>'+tematicaname+'<===');
|
||||
// Build tags
|
||||
if (tematicaname.match(' e ')) {
|
||||
tagsContent = tematicaname.split(' e ');
|
||||
if (tagsContent[0].match(',')) {
|
||||
var temp = tagsContent[0].split(',');
|
||||
tagsContent.push(temp[1]);
|
||||
tagsContent[0] = temp[0];
|
||||
}
|
||||
} else {
|
||||
tagsContent[0] = tematicaname;
|
||||
}
|
||||
//for (var i in tagsContent) {
|
||||
// Zotero.debug('Tag ===>'+i+'='+tagsContent[i]+'<===');
|
||||
//}
|
||||
} // if (isTematica)
|
||||
/////////////////////////////////////////////
|
||||
var title;
|
||||
var docurl;
|
||||
var autores = new Array();
|
||||
var reurl = /href="([^"]+)/ ;
|
||||
var reautor= /autor.php[^>]+"agenda">([^<]+)/g ;
|
||||
var redate = /(\d\d\d\d$)/g ;
|
||||
for (var n in lines) {
|
||||
title = Zotero.Utilities.cleanTags(lines[n].split('<br>')[0]);
|
||||
title = Zotero.Utilities.trimInternal(Zotero.Utilities.trim(title));
|
||||
title = Zotero.Utilities.unescapeHTML(title);
|
||||
docurl = reurl.exec(lines[n]);
|
||||
if (docurl) {
|
||||
if (docurl[1].match('autor')) {
|
||||
docurl = '';
|
||||
} else {
|
||||
items[docurl[1]] = title;
|
||||
autores = lines[n].match(reautor);
|
||||
for(var i in autores){
|
||||
autores[i] = autores[i].split('>')[1];
|
||||
}
|
||||
itemsAutors[docurl[1]] = autores ;
|
||||
date = lines[n].match(redate);
|
||||
//Zotero.debug('Data===>'+date[0]+'<===');
|
||||
itemDate[docurl[1]] = date[0] ;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Zotero.debug('URL===>'+docurl[1]+'<===');
|
||||
/* Zotero.selectItems()
|
||||
* Presents items to select in the select box.
|
||||
* Assumes window.arguments[0].dataIn is an object with
|
||||
* URLs as keys and descriptions as values
|
||||
*/
|
||||
items = Zotero.selectItems(items);
|
||||
for (var n in items) {
|
||||
Zotero.debug('Item '+n+' ==>'+items[n]+'<==');
|
||||
};
|
||||
|
||||
var filetitle;
|
||||
var filemime;
|
||||
for (var item in items) {
|
||||
var newItem = new Zotero.Item("journalArticle");
|
||||
newItem.title = items[item];
|
||||
newItem.date = itemDate[item];
|
||||
newItem.publicationTitle = "Biblioteca Online de Ciências da Comunicação";
|
||||
newItem.ISSN = '1646-3137';
|
||||
newItem.journalAbbreviation = 'BOCC' ;
|
||||
// http://www.bocc.ubi.pt
|
||||
newItem.url = site+item.replace("..", "");
|
||||
fileurl = site+item.replace("..", "")
|
||||
Zotero.debug('Doc ===>'+fileurl+'<===');
|
||||
if (fileurl.match('.html$|.htm$|.HTML$|.HTM$')) {
|
||||
filetitle = 'Anexo HTML';
|
||||
filemime = 'text/html';
|
||||
};
|
||||
if (fileurl.match('.pdf$|.PDF$')) {
|
||||
filetitle = 'Anexo PDF';
|
||||
filemime = 'application/pdf';
|
||||
};
|
||||
Zotero.debug('File title ===>'+filetitle+'<===');
|
||||
Zotero.debug('File mime ===>'+filemime+'<===');
|
||||
newItem.attachments.push(
|
||||
{url:fileurl, title:filetitle, mimeType:filemime}
|
||||
);
|
||||
temp = itemsAutors[item];
|
||||
for (var i in temp) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(temp[i], "author"));
|
||||
}
|
||||
if (isTematica) {
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
}
|
||||
newItem.complete();
|
||||
}
|
||||
//debug
|
||||
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
{
|
||||
"translatorID":"2a5dc3ed-ee5e-4bfb-baad-36ae007e40ce",
|
||||
"translatorType":4,
|
||||
"label":"Berkeley Electronic Press",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.bepress.com/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match("cgi/query.cgi")) {
|
||||
return "multiple";
|
||||
} else if (url.match(/vol[\d+]\/iss[\d]+/)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
var tagMap = {
|
||||
journal_title:"publicationTitle",
|
||||
title:"title",
|
||||
date:"date",
|
||||
volume:"volume",
|
||||
issue:"issue",
|
||||
abstract_html_url:"url",
|
||||
doi:"DOI"
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//table[@id="query"]/tbody/tr/td[4]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.debug(articles);
|
||||
Zotero.Utilities.processDocuments(articles, function(newDoc) {
|
||||
var metatags = new Object();
|
||||
var metas = newDoc.evaluate('//meta[contains(@name, "bepress_citation")]', newDoc, null, XPathResult.ANY_TYPE, null);
|
||||
var next_meta;
|
||||
while (next_meta = metas.iterateNext()) {
|
||||
metatags[next_meta.name.replace("bepress_citation_", "")] = next_meta.content;
|
||||
}
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
|
||||
//regularly mapped tags
|
||||
for (var tag in tagMap) {
|
||||
if (metatags[tag]) {
|
||||
item[tagMap[tag]] = metatags[tag];
|
||||
}
|
||||
}
|
||||
|
||||
//authors
|
||||
var authors = metatags['authors'].split(";");
|
||||
for each (var author in authors) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
|
||||
//attachments
|
||||
item.attachments = [
|
||||
{url:item.url, title:item.title, mimeType:"text/html"},
|
||||
{url:metatags['pdf_url'], title:"Berkeley Electronic Press Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,95 +0,0 @@
|
|||
{
|
||||
"translatorID":"9c335444-a562-4f88-b291-607e8f46a9bb",
|
||||
"translatorType":4,
|
||||
"label":"Berkeley Library Catalog",
|
||||
"creator":"Simon Kornblith",
|
||||
"target":"^https?://[^/]*berkeley.edu[^/]*/WebZ/(?:html/results.html|FETCH)\\?.*sessionid=",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var resultsRegexp = /\/WebZ\/html\/results.html/i
|
||||
if(resultsRegexp.test(url)) {
|
||||
return "multiple";
|
||||
} else {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
function reformURL(url) {
|
||||
return url.replace(/fmtclass=[^&]*/, "")+":fmtclass=marc";
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var resultsRegexp = /\/WebZ\/html\/results.html/i
|
||||
|
||||
if(resultsRegexp.test(url)) {
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, "/WebZ/FETCH", "^[0-9]*$");
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(reformURL(i));
|
||||
}
|
||||
} else {
|
||||
var urls = [reformURL(url)];
|
||||
}
|
||||
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973");
|
||||
var marc = translator.getTranslatorObject();
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, function(newDoc) {
|
||||
var uri = newDoc.location.href;
|
||||
|
||||
var namespace = newDoc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var elmts = newDoc.evaluate('//table/tbody/tr[@valign="top"]',
|
||||
newDoc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var record = new marc.record();
|
||||
while(elmt = elmts.iterateNext()) {
|
||||
var field = Zotero.Utilities.superCleanString(newDoc.evaluate('./TD[1]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue);
|
||||
var value = newDoc.evaluate('./TD[2]/text()[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().nodeValue;
|
||||
// remove spacing
|
||||
value = value.replace(/^\s+/, "");
|
||||
value = value.replace(/\s+$/, "");
|
||||
if(field == 0) {
|
||||
record.leader = "00000"+value;
|
||||
} else {
|
||||
var ind = value[3]+value[5];
|
||||
if (value.match(/^\d{1,2}\s{3}/)) value = Zotero.Utilities.trimInternal(value.replace(/^\d{1,2}\s{3}/, ""));
|
||||
value = value.replace(/\$([a-z0-9]) /g, marc.subfieldDelimiter+"$1");
|
||||
if(value[0] != marc.subfieldDelimiter) {
|
||||
value = marc.subfieldDelimiter+"a"+value;
|
||||
}
|
||||
record.addField(field, ind, value);
|
||||
}
|
||||
}
|
||||
|
||||
var newItem = new Zotero.Item();
|
||||
record.translate(newItem);
|
||||
var oldTags = newItem.tags;
|
||||
var newTags = new Array();
|
||||
for each (var tag in oldTags) {
|
||||
if (newTags.indexOf(tag) == -1) newTags.push(tag)
|
||||
}
|
||||
newItem.tags = newTags;
|
||||
newItem.repository = "Berkeley Library Catalog";
|
||||
|
||||
newItem.complete();
|
||||
}, function() { Zotero.done(); }, null);
|
||||
|
||||
Zotero.wait();
|
||||
}
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
@ -1,125 +0,0 @@
|
|||
{
|
||||
"translatorID":"9932d1a7-cc6d-4d83-8462-8f6658b13dc0",
|
||||
"translatorType":4,
|
||||
"label":"Biblio.com",
|
||||
"creator":"Adam Crymble and Michael Berkowitz",
|
||||
"target":"http://www.biblio.com/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-07 14:50:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.location.href.match("bookseller_search") || doc.location.href.match("bookstores") || doc.location.href.match("textbooks")) {
|
||||
|
||||
} else if (doc.location.href.match("search")) {
|
||||
return "multiple";
|
||||
} else if (doc.location.href.match("books")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
//Biblio.com translator. Code by Adam Crymble.
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var contents = new Array();
|
||||
var multiAuthors = new Array();
|
||||
var fieldTitle;
|
||||
var author1;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var content = doc.evaluate('//div[@class="smalltext1"][@id="infobox"]/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//div[@class="smalltext1"][@id="infobox"]/ul/li)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (i=0; i<xPathCount.numberValue; i++) {
|
||||
|
||||
contents = content.iterateNext().textContent.split(": ");
|
||||
fieldTitle = contents[0].replace(/\s*/g, '');
|
||||
dataTags[fieldTitle] = contents[1].replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
|
||||
//Authors
|
||||
if (doc.evaluate('//td[2]/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var authors = doc.evaluate('//td[2]/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
if (authors.match(/\w/)) {
|
||||
if (authors.match(/^ by/)) {
|
||||
authors = authors.substr(4);
|
||||
if (authors.match(/;/)) {
|
||||
multiAuthors = authors.split(";");
|
||||
Zotero.debug(multiAuthors);
|
||||
for each (var aut in multiAuthors) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(aut, "author", true));
|
||||
}
|
||||
} else {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "author", true));
|
||||
}
|
||||
} else {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "author"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//extra
|
||||
if (dataTags["Quantityavailable"]) {
|
||||
newItem.extra = "Quantity Available: " + dataTags["Quantityavailable"];
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Publisher", "publisher");
|
||||
associateData (newItem, dataTags, "Place", "place");
|
||||
associateData (newItem, dataTags, "Datepublished", "date");
|
||||
associateData (newItem, dataTags, "ISBN10", "ISBN");
|
||||
associateData (newItem, dataTags, "ISBN13", "ISBN");
|
||||
associateData (newItem, dataTags, "Pages", "pages");
|
||||
associateData (newItem, dataTags, "Edition", "edition");
|
||||
|
||||
newItem.title = doc.evaluate('//tbody/tr[1]/td[2]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s&+/g, '');
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//table[@class="search-result"]/tbody/tr/td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
if (next_title.textContent.match(/\w/)) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,234 +0,0 @@
|
|||
{
|
||||
"translatorID":"39ea814e-8fdb-486c-a88d-59479f341066",
|
||||
"translatorType":4,
|
||||
"label":"Bibliotheque UQAM",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://www.manitou.uqam.ca",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-24 05:15:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
if (doc.evaluate('//center/table/tbody/tr[1]/td/input', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.title.match("détails")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == "x" ) return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var contents;
|
||||
var newItemAuthors1 = new Array();
|
||||
var newItemAuthors2 = new Array();
|
||||
|
||||
var xPathHeadings = doc.evaluate('//p/table/tbody/tr/td[1]/b', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathContents = doc.evaluate('//p/table/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//p/table/tbody/tr/td[1]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var dump = xPathHeadings.iterateNext();
|
||||
|
||||
for (i=0; i<xPathCount.numberValue-1; i++) {
|
||||
|
||||
fieldTitle=xPathHeadings.iterateNext().textContent.replace(/\s+/g, '');
|
||||
contents = xPathContents.iterateNext().textContent;
|
||||
|
||||
if (fieldTitle == "Titres:") {
|
||||
fieldTitle = "Titre:";
|
||||
}
|
||||
|
||||
//determines media type
|
||||
if (fieldTitle == "Titre:") {
|
||||
|
||||
dataTags[fieldTitle] = contents.replace(/^\s*|\s*$/g, '');
|
||||
|
||||
if (contents.match("enregistrement sonore")) {
|
||||
var newItem = new Zotero.Item("audioRecording");
|
||||
} else if (contents.match("musique")) {
|
||||
var newItem = new Zotero.Item("audioRecording");
|
||||
} else if (contents.match("enregistrement vidéo")) {
|
||||
var newItem = new Zotero.Item("videoRecording");
|
||||
} else {
|
||||
var newItem = new Zotero.Item("book");
|
||||
}
|
||||
}
|
||||
|
||||
//gets author(s).
|
||||
if (fieldTitle == "Auteur:") {
|
||||
fieldTitle = "author";
|
||||
|
||||
dataTags[fieldTitle] = contents;
|
||||
if (dataTags[fieldTitle].match(",")) {
|
||||
var authorName = dataTags["author"].split(",");
|
||||
authorName[0] = authorName[0].replace(/^\s*|\s*$/g, '');
|
||||
dataTags["author"] = (authorName[1] + (" ") + authorName[0]);
|
||||
} else {
|
||||
var parenthesis = dataTags["author"].indexOf("(");
|
||||
if (parenthesis > 0) {
|
||||
dataTags["author"] = dataTags["author"].substr(0, parenthesis);
|
||||
}
|
||||
dataTags["author"] = dataTags["author"].replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
|
||||
} else if (fieldTitle == "Auteurs:") {
|
||||
|
||||
dataTags[fieldTitle] = contents;
|
||||
|
||||
var multiAuthors = dataTags["Auteurs:"].split(/\n/);
|
||||
for (var j = 0; j < multiAuthors.length; j++) {
|
||||
var parenthesis = multiAuthors[j].indexOf("(");
|
||||
|
||||
if (parenthesis > 0) {
|
||||
multiAuthors[j] = multiAuthors[j].substr(0, parenthesis);
|
||||
}
|
||||
|
||||
if (multiAuthors[j] != "" && multiAuthors[j] != ' ') {
|
||||
if (multiAuthors[j].match(", ")) {
|
||||
var authorName = multiAuthors[j].split(",");
|
||||
newItemAuthors1.push(authorName[1] + (" ") + authorName[0]);
|
||||
} else {
|
||||
newItemAuthors2.push(multiAuthors[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (fieldTitle == "Éditeur:") {
|
||||
dataTags[fieldTitle] = contents;
|
||||
var imprintSplit = dataTags["Éditeur:"].split(": ");
|
||||
if (imprintSplit.length > 1) {
|
||||
newItem.place = imprintSplit[0].replace(/^\s*|\s*$/g, '');
|
||||
var publisherDate = imprintSplit[1].split(", ");
|
||||
|
||||
newItem.publisher = publisherDate[0].replace(/^\s*|\s*$/g, '');
|
||||
|
||||
if (publisherDate.length > 1) {
|
||||
|
||||
newItem.date = publisherDate[1].replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
} else {
|
||||
newItem.publisher = dataTags["Éditeur:"];
|
||||
}
|
||||
|
||||
} else if (fieldTitle == "Sujet:") {
|
||||
dataTags[fieldTitle] = contents;
|
||||
|
||||
if (dataTags["Sujet:"].match("\n")) {
|
||||
|
||||
tagsContent = (dataTags["Sujet:"].split(/\n/));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
dataTags[fieldTitle] = contents.replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
}
|
||||
|
||||
//pushes tags
|
||||
|
||||
for (var y = 0; y < tagsContent.length; y++) {
|
||||
if (tagsContent[y]!='' && tagsContent[y]!= " ") {
|
||||
var parenthesis = tagsContent[y].indexOf("(");
|
||||
if (parenthesis > 0) {
|
||||
tagsContent[y] = tagsContent[y].substr(0, parenthesis);
|
||||
}
|
||||
newItem.tags[y] = tagsContent[y];
|
||||
}
|
||||
}
|
||||
|
||||
//because newItem is not defined until after the authors have, authors must be put into Zotero outside the main for loop.
|
||||
if (dataTags["author"]) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["author"], "author"));
|
||||
}
|
||||
|
||||
for (var i = 0; i < newItemAuthors1.length; i++) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(newItemAuthors1[i], "author"));
|
||||
}
|
||||
|
||||
for (var i = 0; i < newItemAuthors2.length; i++) {
|
||||
newItem.creators.push({lastName: newItemAuthors2[i], creatorType: "creator"});
|
||||
}
|
||||
|
||||
//trims title as best as possible
|
||||
if (dataTags["Titre:"].match(/\[/)) {
|
||||
var splitter = dataTags["Titre:"].indexOf("[");
|
||||
}
|
||||
|
||||
if (dataTags["Titre:"].match("/")) {
|
||||
var splitter1 = dataTags["Titre:"].indexOf("/");
|
||||
}
|
||||
|
||||
if (splitter1 > -1 && splitter > -1) {
|
||||
if (splitter1 > splitter) {
|
||||
dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter);
|
||||
} else {
|
||||
dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter1);
|
||||
}
|
||||
} else if (splitter1 > -1) {
|
||||
dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter1);
|
||||
} else if (splitter > -1) {
|
||||
dataTags["Titre:"] = dataTags["Titre:"].substr(0, splitter);
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Titre:", "title");
|
||||
associateData (newItem, dataTags, "Numéro:", "ISBN");
|
||||
associateData (newItem, dataTags, "Description:", "pages");
|
||||
associateData (newItem, dataTags, "Banque:", "repository");
|
||||
associateData (newItem, dataTags, "Langue:", "language");
|
||||
associateData (newItem, dataTags, "Localisation:", "Loc. in Archive");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('/html/body/table/tbody/tr/td/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
var dump = titles.iterateNext();
|
||||
}
|
||||
|
||||
var next_title;
|
||||
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
Zotero.debug(next_title.href);
|
||||
Zotero.debug(next_title.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,151 +0,0 @@
|
|||
{
|
||||
"translatorID":"1eb5eb03-26ab-4015-bd0d-65487734744a",
|
||||
"translatorType":4,
|
||||
"label":"Bibliotheque et Archives Nationale du Quebec (Pistard)",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://pistard.banq.qc.ca",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-08-06 17:00:00"
|
||||
}
|
||||
|
||||
function detectWeb (doc, url) {
|
||||
|
||||
if (doc.title.match("Liste détaillée des fonds")) {
|
||||
return "multiple";
|
||||
} else if (doc.title.match("Description fonds")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
//Bibliotheque et Archives National du Quebec. Code by Adam Crymble
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var fieldTitle;
|
||||
var tagsContent= new Array();
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var headers = doc.evaluate('//strong', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//strong)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var contents = doc.evaluate('//div[@id="Content"]/div/table', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
var headersArray = new Array();
|
||||
var oneHeader = '';
|
||||
|
||||
if (xPathCount.numberValue > 1) {
|
||||
for (var i = 0; i < xPathCount.numberValue; i++) {
|
||||
fieldTitle = headers.iterateNext().textContent;
|
||||
headersArray.push(fieldTitle);
|
||||
}
|
||||
} else {
|
||||
oneHeader = (headers.iterateNext().textContent);
|
||||
}
|
||||
|
||||
var contentsArray = new Array();
|
||||
var j = 0;
|
||||
|
||||
if (oneHeader.length<1) {
|
||||
|
||||
for (var i = headersArray.length-1; i> -1; i--) {
|
||||
|
||||
var fieldIndex = contents.indexOf(headersArray[i]);
|
||||
var removeHeader = headersArray[i].length;
|
||||
|
||||
contentsArray.push(contents.substr(fieldIndex));
|
||||
contents = contents.substr(0, fieldIndex);
|
||||
fieldTitle = headersArray[i].replace(/\s+/g, '');
|
||||
|
||||
dataTags[fieldTitle] = contentsArray[j].substr(removeHeader).replace(/^\s*|\s+$/g, '');
|
||||
j++;
|
||||
}
|
||||
}
|
||||
Zotero.debug(dataTags);
|
||||
|
||||
if (dataTags["Titre,Dates,Quantité"]) {
|
||||
if (dataTags["Titre,Dates,Quantité"].match(/\n/)) {
|
||||
var splitTitle = dataTags["Titre,Dates,Quantité"].split(/\n/);
|
||||
if (splitTitle[0].match(/\w/)) {
|
||||
newItem.title = splitTitle[0].replace(/^\s*|\s+$/g, '');
|
||||
}
|
||||
for (var i = 0; i < splitTitle.length; i++) {
|
||||
if (splitTitle[i].match("/ ")) {
|
||||
var author = splitTitle[i].replace(/^\s*|\s+$/g, '').substr(2);
|
||||
newItem.creators.push({lastName: author, creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newItem.title = doc.title;
|
||||
}
|
||||
|
||||
|
||||
var k = 0;
|
||||
if (dataTags["Termesrattachés"]) {
|
||||
|
||||
if (dataTags["Termesrattachés"].match(/\n/)) {
|
||||
tagsContent = dataTags["Termesrattachés"].split(/\n/);
|
||||
for (var i in tagsContent) {
|
||||
if (tagsContent[i].match(/\w/)) {
|
||||
newItem.tags[k] = tagsContent[i].replace(/^\s+|\s*$/g, '');
|
||||
k++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newItem.tags[0] = dataTags["Termesrattachés"];
|
||||
}
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Languedesdocuments", "language");
|
||||
associateData (newItem, dataTags, "Cote:", "callNumber");
|
||||
associateData (newItem, dataTags, "Collation", "pages");
|
||||
associateData (newItem, dataTags, "Centre:", "place");
|
||||
associateData (newItem, dataTags, "Portéeetcontenu", "abstractNote");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
if (next_title.href.match("description_fonds")) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,264 +0,0 @@
|
|||
{
|
||||
"translatorID":"59cce211-9d77-4cdd-876d-6229ea20367f",
|
||||
"translatorType":4,
|
||||
"label":"Bibliothèque et Archives nationales du Québec",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://catalogue.banq.qc.ca",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-12-12 12:35:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.title.match("Search")) {
|
||||
return "multiple";
|
||||
} else if (doc.title.match("Recherche")) {
|
||||
return "multiple";
|
||||
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("book")) {
|
||||
return "book";
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mmusic")) {
|
||||
return "book";
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("manalytic")) {
|
||||
return "book";
|
||||
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("msdisc")) {
|
||||
return "audioRecording";
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("msound")) {
|
||||
return "audioRecording";
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mscas")) {
|
||||
return "audioRecording";
|
||||
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mvdisc")) {
|
||||
return "videoRecording";
|
||||
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mpaint")) {
|
||||
return "artwork";
|
||||
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mserial")) {
|
||||
return "report";
|
||||
|
||||
} else if (doc.evaluate('//td[2]/a/img', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src.match("mcomponent")) {
|
||||
return "newspaperArticle";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Bibliotheque et Archives National du Quebec. Code by Adam Crymble
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var fieldTitle;
|
||||
var contents;
|
||||
var descriptionField;
|
||||
var tagsContent= new Array();
|
||||
var inField = 0;
|
||||
|
||||
//determines media type
|
||||
if (detectWeb(doc, url) == "book") {
|
||||
var newItem = new Zotero.Item("book");
|
||||
descriptionField = "pages";
|
||||
} else if (detectWeb(doc, url) == "audioRecording") {
|
||||
var newItem = new Zotero.Item("audioRecording");
|
||||
descriptionField = "runningTime";
|
||||
} else if (detectWeb(doc, url) == "videoRecording") {
|
||||
var newItem = new Zotero.Item("videoRecording");
|
||||
descriptionField = "runningTime";
|
||||
} else if (detectWeb(doc, url) == "artwork") {
|
||||
var newItem = new Zotero.Item("artwork");
|
||||
descriptionField = "artworkSize";
|
||||
} else if (detectWeb(doc, url) == "report") {
|
||||
var newItem = new Zotero.Item("report");
|
||||
descriptionField = "pages";
|
||||
} else if (detectWeb(doc, url) == "newspaperArticle") {
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
descriptionField = "pages"
|
||||
}
|
||||
|
||||
//determines language
|
||||
var lang = doc.evaluate('//td[2]/a/img', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var langCount = doc.evaluate('count (//td[2]/a/img)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var lang1 = lang.iterateNext().src;
|
||||
|
||||
if (langCount.numberValue > 1) {
|
||||
lang1 = lang.iterateNext().src;
|
||||
|
||||
if (lang1.match("lfre")) {
|
||||
newItem.language = "French";
|
||||
} else if (lang1.match("leng")) {
|
||||
newItem.language = "English";
|
||||
}
|
||||
}
|
||||
|
||||
//scraping XPaths
|
||||
var xPathHeadings = doc.evaluate('//td/table/tbody/tr/td[2]/b', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathContents = doc.evaluate('//td[2]/table/tbody/tr/td/table/tbody/tr/td[4]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//td/table/tbody/tr/td[2]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
if (doc.evaluate('//td/table/tbody/tr/td[2]/b', doc, nsResolver, XPathResult.ANY_TYPE, null)) {
|
||||
|
||||
for (i=0; i<xPathCount.numberValue; i++) {
|
||||
|
||||
fieldTitle = xPathHeadings.iterateNext().textContent.replace(/\s+/g, '');
|
||||
contents = xPathContents.iterateNext().textContent;
|
||||
|
||||
if (contents.match("[*]") && fieldTitle!= "Publisher" && fieldTitle!= "Éditeur") {
|
||||
var removeTagExcess = contents.indexOf("[");
|
||||
contents = contents.substr(0, removeTagExcess);
|
||||
}
|
||||
|
||||
if (fieldTitle == "Author" | fieldTitle == "Auteur") {
|
||||
fieldTitle = "Author";
|
||||
dataTags[fieldTitle] = (contents);
|
||||
var authorName = dataTags["Author"].split(",");
|
||||
authorName[0] = authorName[0].replace(/\s+/g, '');
|
||||
|
||||
dataTags["Author"] = (authorName[1] + (" ") + authorName[0]);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Author"], "author"));
|
||||
|
||||
//publishing info
|
||||
} else if (fieldTitle == "Publisher" | fieldTitle == "Éditeur") {
|
||||
fieldTitle = "Publisher";
|
||||
|
||||
dataTags["Publisher"] = (contents);
|
||||
|
||||
if (dataTags["Publisher"].match(":")) {
|
||||
|
||||
var place1 = dataTags["Publisher"].split(":");
|
||||
dataTags["Place"] = place1[0].replace(/^\s*|\[|\]/g,'');
|
||||
|
||||
var publish = place1[1].split(",");
|
||||
dataTags["Publish"] = (publish[0].replace(/^\s*|\[|\]/g,''));
|
||||
|
||||
place1[1] = place1[1].replace(/^\s*|\s*$|\[|\]/g, '');
|
||||
if (place1[1].match("/?")) {
|
||||
var dateLength = place1[1].length-5;
|
||||
} else {
|
||||
var dateLength = place1[1].length-4;
|
||||
}
|
||||
dataTags["Date"] = place1[1].substr(dateLength);
|
||||
} else {
|
||||
dataTags["Date"] = (contents);
|
||||
}
|
||||
|
||||
//tags
|
||||
} else if (fieldTitle == "Subjects" | fieldTitle == "Sujets") {
|
||||
fieldTitle = "Subjects";
|
||||
tagsContent = contents.split("\n");
|
||||
|
||||
//source
|
||||
} else if (fieldTitle == "Source") {
|
||||
dataTags[fieldTitle] = (contents.replace(/^\s*|\s*$/g, ''));
|
||||
dataTags["Source"] = ("Source: " + dataTags["Source"]);
|
||||
Zotero.debug(doc.title);
|
||||
//normal
|
||||
} else {
|
||||
dataTags[fieldTitle] = (contents.replace(/^\s*|\s*$/g, ''));
|
||||
}
|
||||
}
|
||||
|
||||
//series
|
||||
if (fieldTitle == "Series" | fieldTitle == "Collection") {
|
||||
fieldTitle = "Series";
|
||||
dataTags[fieldTitle] = (contents.replace(/\s\s\s*/g, ''));
|
||||
}
|
||||
|
||||
//makes tags
|
||||
for (i = 0; i < tagsContent.length; i++) {
|
||||
if (tagsContent[i] != ("") && tagsContent[i] !=(" ")) {
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Description", descriptionField);
|
||||
|
||||
associateData (newItem, dataTags, "Title", "title");
|
||||
associateData (newItem, dataTags, "Place", "place");
|
||||
associateData (newItem, dataTags, "Publish", "publisher");
|
||||
associateData (newItem, dataTags, "Date", "date");
|
||||
associateData (newItem, dataTags, "Source", "extra");
|
||||
associateData (newItem, dataTags, "ISBN", "ISBN");
|
||||
associateData (newItem, dataTags, "Localinf.", "rights");
|
||||
associateData (newItem, dataTags, "Series", "series");
|
||||
associateData (newItem, dataTags, "Notes", "abstractNote");
|
||||
associateData (newItem, dataTags, "Numbering", "reportNumber");
|
||||
|
||||
associateData (newItem, dataTags, "Titre", "title");
|
||||
associateData (newItem, dataTags, "Numérotation", "reportNumber");
|
||||
|
||||
}
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var next_title = new Array();
|
||||
var links1 = new Array();
|
||||
var y = 0;
|
||||
var next_title1 = new Array();
|
||||
|
||||
var titlesCount = doc.evaluate('count (//p/table/tbody/tr/td/b)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var numAndTitle= doc.evaluate('//p/table/tbody/tr/td/b', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//p/table/tbody/tr/td/a[img]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var multipleTest = 0;
|
||||
|
||||
for (j=0; j < titlesCount.numberValue; j++) {
|
||||
|
||||
next_title[j] = numAndTitle.iterateNext().textContent;
|
||||
next_title[j] = next_title[j].substr(0, next_title[j].length-1);
|
||||
|
||||
if (/^\d*$/.test(next_title[j])) {
|
||||
multipleTest = 0;
|
||||
} else if (multipleTest < 1) {
|
||||
multipleTest++;
|
||||
next_title1[y] = next_title[j];
|
||||
y++;
|
||||
Zotero.debug(next_title1[0]);
|
||||
|
||||
} else if (multipleTest > 1) {
|
||||
multipleTest = 0;
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < 10; j++) {
|
||||
links1[j] = links.iterateNext().href;
|
||||
//Zotero.debug(links1[0]);
|
||||
items[links1] = next_title1[j];
|
||||
}
|
||||
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
|
||||
}
|
|
@ -1,736 +0,0 @@
|
|||
{
|
||||
"translatorID":"47533cd7-ccaa-47a7-81bb-71c45e68a74d",
|
||||
"label":"Bibliothèque nationale de France",
|
||||
"creator":"Florian Ziche",
|
||||
"target":"^https?://[^/]*catalogue\\.bnf\\.fr",
|
||||
"minVersion":"2.0",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"translatorType":4,
|
||||
"lastUpdated":"2011-02-22 09:55:00"
|
||||
}
|
||||
|
||||
/*
|
||||
* Bibliothèque nationale de France Translator
|
||||
* Copyright (C) 2010 Florian Ziche, ziche@noos.fr
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
/* Bnf namespace. */
|
||||
var BnfClass = function() {
|
||||
//Private members
|
||||
|
||||
/* MARC translator. */
|
||||
var marc;
|
||||
|
||||
var that = this;
|
||||
|
||||
/* Load MARC translator. */
|
||||
function loadMarcTranslator() {
|
||||
if(!marc) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973");
|
||||
marc = translator.getTranslatorObject();
|
||||
}
|
||||
return marc;
|
||||
};
|
||||
|
||||
/* Map MARC responsibility roles to Zotero creator types.
|
||||
See http://archive.ifla.org/VI/3/p1996-1/appx-c.htm.
|
||||
*/
|
||||
function getCreatorType(aut) {
|
||||
switch(aut['4']) {
|
||||
case "005":
|
||||
case "250":
|
||||
case "275":
|
||||
case "590": //performer
|
||||
case "755": //vocalist
|
||||
return "performer";
|
||||
case "040":
|
||||
case "130": //book designer
|
||||
case "740": //type designer
|
||||
case "750": //typographer
|
||||
case "350": //engraver
|
||||
case "360": //etcher
|
||||
case "430": //illuminator
|
||||
case "440": //illustrator
|
||||
case "510": //lithographer
|
||||
case "530": //metal engraver
|
||||
case "600": //photographer
|
||||
case "705": //sculptor
|
||||
case "760": //wood engraver
|
||||
return "artist";
|
||||
case "070":
|
||||
case "305":
|
||||
case "330":
|
||||
case undefined:
|
||||
return "author";
|
||||
case "020":
|
||||
case "210":
|
||||
case "212":
|
||||
return "commenter";
|
||||
case "180":
|
||||
return "cartographer";
|
||||
case "220":
|
||||
case "340":
|
||||
return "editor";
|
||||
case "230":
|
||||
return "composer";
|
||||
case "245":
|
||||
return "inventor";
|
||||
case "255":
|
||||
case "695": //scientific advisor
|
||||
case "727": //thesis advisor
|
||||
return "counsel";
|
||||
case "300":
|
||||
return "director";
|
||||
case "400": //funder
|
||||
case "723": //sponsor
|
||||
return "sponsor";
|
||||
case "460":
|
||||
return "interviewee";
|
||||
case "470":
|
||||
return "interviewer";
|
||||
case "480": //librettist
|
||||
case "520": //lyricist
|
||||
return "wordsBy";
|
||||
case "605":
|
||||
return "presenter";
|
||||
case "630":
|
||||
return "producer";
|
||||
case "635":
|
||||
return "programmer";
|
||||
case "660":
|
||||
return "recipient";
|
||||
case "090": //author of dialog
|
||||
case "690": //scenarist
|
||||
return "scriptwriter";
|
||||
case "730":
|
||||
return "translator";
|
||||
//Ignore (no matching Zotero creatorType):
|
||||
case "320": //donor
|
||||
case "610": //printer
|
||||
case "650": //publisher
|
||||
return undefined;
|
||||
//Default
|
||||
case "205":
|
||||
default:
|
||||
return "contributor";
|
||||
}
|
||||
};
|
||||
|
||||
/* Fix creators (MARC translator is not perfect). */
|
||||
function getCreators(record, item) {
|
||||
//Clear creators
|
||||
item.creators = new Array();
|
||||
// Extract creators (700, 701 & 702)
|
||||
for (var i = 700; i < 703; i++) {
|
||||
var authorTag = record.getFieldSubfields(i);
|
||||
for (var j in authorTag) {
|
||||
var aut = authorTag[j];
|
||||
var authorText = "";
|
||||
if (aut.b) {
|
||||
authorText = aut['a'] + ", " + aut['b'];
|
||||
} else {
|
||||
authorText = aut['a'];
|
||||
}
|
||||
var type = getCreatorType(aut);
|
||||
if(type) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(authorText, type, true));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Extract corporate creators (710, 711 & 712)
|
||||
for (var i = 710; i < 713; i++) {
|
||||
var authorTag = record.getFieldSubfields(i);
|
||||
for (var j in authorTag) {
|
||||
if (authorTag[j]['a']) {
|
||||
var type = getCreatorType(authorTag[j]);
|
||||
if(type) {
|
||||
item.creators.push({
|
||||
lastName: authorTag[j]['a'],
|
||||
creatorType: type,
|
||||
fieldMode: true});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//Translate BnF types to Zotero item types.
|
||||
function getItemType(type) {
|
||||
switch(type) {
|
||||
case "Enregistrement sonore":
|
||||
return "audioRecording";
|
||||
case "Image fixe":
|
||||
case "Image fixe numérisée":
|
||||
return "artwork";
|
||||
case "Images animées":
|
||||
return "film";
|
||||
case "Ressource électronique":
|
||||
return "computerProgram";
|
||||
case "Document cartographique":
|
||||
return "map";
|
||||
case "Document d'archives":
|
||||
return "document";
|
||||
case "Texte manuscrit":
|
||||
return "manuscript";
|
||||
case "Multimédia multisupport":
|
||||
case "Musique imprimé":
|
||||
case "Texte imprimé":
|
||||
default:
|
||||
return "book";
|
||||
}
|
||||
};
|
||||
|
||||
//Add tag, if not present yet
|
||||
function addTag(item, tag) {
|
||||
for(var t in item.tags) {
|
||||
if(item.tags[t] == tag) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
item.tags.push(tag);
|
||||
};
|
||||
|
||||
//Tagging
|
||||
function getTags(record, item) {
|
||||
var pTag = record.getFieldSubfields("600");
|
||||
if(pTag) {
|
||||
for(var j in pTag) {
|
||||
var tagText = false;
|
||||
var person = pTag[j];
|
||||
tagText = person.a;
|
||||
if(person.b) {
|
||||
tagText += ", " + person.b;
|
||||
}
|
||||
if(person.f) {
|
||||
tagText += " (" + person.f + ")";
|
||||
}
|
||||
addTag(item, tagText);
|
||||
}
|
||||
}
|
||||
pTag = record.getFieldSubfields("601");
|
||||
if(pTag) {
|
||||
for(var j in pTag) {
|
||||
var tagText = false;
|
||||
var person = pTag[j];
|
||||
tagText = person.a;
|
||||
addTag(item, tagText);
|
||||
}
|
||||
}
|
||||
pTag = record.getFieldSubfields("605");
|
||||
if(pTag) {
|
||||
for(var j in pTag) {
|
||||
var tagText = false;
|
||||
var person = pTag[j];
|
||||
tagText = person.a;
|
||||
addTag(item, tagText);
|
||||
}
|
||||
}
|
||||
pTag = record.getFieldSubfields("606");
|
||||
if(pTag) {
|
||||
for(var j in pTag) {
|
||||
var tagText = false;
|
||||
var person = pTag[j];
|
||||
tagText = person.a;
|
||||
addTag(item, tagText);
|
||||
}
|
||||
}
|
||||
pTag = record.getFieldSubfields("607");
|
||||
if(pTag) {
|
||||
for(var j in pTag) {
|
||||
var tagText = false;
|
||||
var person = pTag[j];
|
||||
tagText = person.a;
|
||||
addTag(item, tagText);
|
||||
}
|
||||
}
|
||||
pTag = record.getFieldSubfields("602");
|
||||
if(pTag) {
|
||||
for(var j in pTag) {
|
||||
var tagText = false;
|
||||
var person = pTag[j];
|
||||
tagText = person.a;
|
||||
if(person.f) {
|
||||
tagText += " (" + person.f + ")";
|
||||
}
|
||||
addTag(item, tagText);
|
||||
}
|
||||
}
|
||||
pTag = record.getFieldSubfields("604");
|
||||
if(pTag) {
|
||||
for(var j in pTag) {
|
||||
var tagText = false;
|
||||
var person = pTag[j];
|
||||
tagText = person.a;
|
||||
if(person.b) {
|
||||
tagText += ", " + person.b;
|
||||
}
|
||||
if(person.f) {
|
||||
tagText += " (" + person.f + ")";
|
||||
}
|
||||
if(person.t) {
|
||||
tagText += ", " + person.t;
|
||||
}
|
||||
addTag(item, tagText);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Get series (repeatable)
|
||||
function getSeries(record, item) {
|
||||
var seriesText = false;
|
||||
var seriesTag = record.getFieldSubfields("225");
|
||||
if(seriesTag && seriesTag.length > 1) {
|
||||
for(var j in seriesTag) {
|
||||
var series = seriesTag[j];
|
||||
if(seriesText) {
|
||||
seriesText += "; ";
|
||||
}
|
||||
else {
|
||||
seriesText = "";
|
||||
}
|
||||
seriesText += series.a;
|
||||
if(series.v) {
|
||||
seriesText += ", " + series.v;
|
||||
}
|
||||
}
|
||||
if(seriesText) {
|
||||
delete item.seriesNumber;
|
||||
item.series = seriesText;
|
||||
}
|
||||
}
|
||||
//Try 461
|
||||
if(!item.series) {
|
||||
seriesTag = record.getFieldSubfields("461");
|
||||
if(seriesTag) {
|
||||
for(var j in seriesTag) {
|
||||
var series = seriesTag[j];
|
||||
if(seriesText) {
|
||||
seriesText += "; ";
|
||||
}
|
||||
else {
|
||||
seriesText = "";
|
||||
}
|
||||
seriesText += series.t;
|
||||
}
|
||||
}
|
||||
if(seriesText) {
|
||||
delete item.seriesNumber;
|
||||
item.series = seriesText;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Add extra text
|
||||
function addExtra(noteText, extra) {
|
||||
if(extra) {
|
||||
if(noteText) {
|
||||
if(!/\.$/.exec(noteText)) {
|
||||
noteText += ". ";
|
||||
}
|
||||
else {
|
||||
noteText += " ";
|
||||
}
|
||||
}
|
||||
else {
|
||||
noteText = "";
|
||||
}
|
||||
noteText += Zotero.Utilities.trim(extra);
|
||||
}
|
||||
return noteText;
|
||||
}
|
||||
|
||||
//Assemble extra information
|
||||
function getExtra(record, item) {
|
||||
var noteText = false;
|
||||
//Material description
|
||||
var noteTag = record.getFieldSubfields("215");
|
||||
if(noteTag) {
|
||||
for(var j in noteTag) {
|
||||
var note = noteTag[j];
|
||||
noteText = addExtra(noteText, note.c);
|
||||
noteText = addExtra(noteText, note.d);
|
||||
noteText = addExtra(noteText, note.e);
|
||||
}
|
||||
}
|
||||
//Note
|
||||
noteTag = record.getFieldSubfields("300");
|
||||
if(noteTag) {
|
||||
for(var j in noteTag) {
|
||||
var note = noteTag[j];
|
||||
noteText = addExtra(noteText, note.a);
|
||||
}
|
||||
}
|
||||
//Edition history notes
|
||||
noteTag = record.getFieldSubfields("305");
|
||||
if(noteTag) {
|
||||
for(var j in noteTag) {
|
||||
var note = noteTag[j];
|
||||
noteText = addExtra(noteText, note.a);
|
||||
}
|
||||
}
|
||||
if(noteText) {
|
||||
if(!/\.$/.exec(noteText)) {
|
||||
noteText += ".";
|
||||
}
|
||||
item.extra = noteText;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//Get title from 200
|
||||
function getTitle(record, item) {
|
||||
var titleTag = record.getFieldSubfields("200");
|
||||
if(titleTag) {
|
||||
titleTag = titleTag[0];
|
||||
var titleText = titleTag.a;
|
||||
if(titleTag.e) {
|
||||
if(!/^[,\.:;-]/.exec(titleTag.e)) {
|
||||
titleText += ": ";
|
||||
}
|
||||
titleText += titleTag.e;
|
||||
}
|
||||
if(titleTag.h) {
|
||||
titleText += ", " + titleTag.h;
|
||||
if(titleTag.i) {
|
||||
titleText += ": " + titleTag.i;
|
||||
}
|
||||
}
|
||||
else if(titleTag.i) {
|
||||
titleText += ", " + titleTag.i;
|
||||
}
|
||||
item.title = titleText;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//Do BnF specific Unimarc postprocessing
|
||||
function postprocessMarc(record, newItem) {
|
||||
//Type
|
||||
var t = record.getFieldSubfields("200");
|
||||
if(t && t[0].b) {
|
||||
newItem.itemType = getItemType(t[0].b);
|
||||
}
|
||||
|
||||
//Title
|
||||
getTitle(record, newItem);
|
||||
|
||||
//Fix creators
|
||||
getCreators(record, newItem);
|
||||
|
||||
//Store perennial url from 009 as attachment and accession number
|
||||
var url = record.getField("009");
|
||||
if(url && url.length > 0 && url[0][1]) {
|
||||
newItem.accessionNumber = url[0][1];
|
||||
newItem.attachments = [
|
||||
{
|
||||
url: url[0][1],
|
||||
title: "Bnf catalogue entry",
|
||||
mimeType: "text/html",
|
||||
snapshot:false
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
//Country (102a)
|
||||
record._associateDBField(newItem, "102", "a", "country");
|
||||
|
||||
//Try to retrieve volumes/pages from 215d
|
||||
if(!newItem.pages) {
|
||||
var dimTag = record.getFieldSubfields("215");
|
||||
for (var j in dimTag) {
|
||||
var dim = dimTag[j];
|
||||
if(dim.a) {
|
||||
var pages = /[^\d]*(\d+)\s+p\..*/.exec(dim.a);
|
||||
if(pages) {
|
||||
newItem.numPages = pages[1];
|
||||
}
|
||||
var vols= /[^\d]*(\d+)\s+vol\..*/.exec(dim.a);
|
||||
if(vols) {
|
||||
newItem.numberOfVolumes = vols[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Series
|
||||
getSeries(record, newItem);
|
||||
|
||||
//Extra
|
||||
getExtra(record, newItem);
|
||||
|
||||
//Tagging
|
||||
getTags(record, newItem);
|
||||
|
||||
//Repository
|
||||
newItem.libraryCatalog = "French National Library Online Catalog (http://catalogue.bnf.fr)";
|
||||
};
|
||||
|
||||
|
||||
//Public members
|
||||
|
||||
/* Get the UNIMARC URL for a given single result page. */
|
||||
this.reformURL = function(url) {
|
||||
return url.replace(/&FormatAffichage=[^&]*/, "")
|
||||
.replace(/&idNoeud=[^&]*/, "") + "&FormatAffichage=4";
|
||||
};
|
||||
|
||||
|
||||
/* Get the results table from a list page, if any. Looks for //table[@class="ListeNotice"]. */
|
||||
this.getResultsTable = function(doc) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
try {
|
||||
var xPath = '//table[@class="ListeNotice"]';
|
||||
var xPathObject = doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
return xPathObject;
|
||||
} catch(x) {
|
||||
Zotero.debug(x.lineNumber + " " + x.message);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/* Get the DC type from the web page. Returns the first DC.type from meta tags.
|
||||
2010-10-01: No DC meta tags any more... simply test for //td[@class="texteNotice"] cells and return "printed text".
|
||||
*/
|
||||
this.getDCType = function(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
try {
|
||||
// var xPath = '//head/meta[@name="DC.type" and @lang="eng"]/@content';
|
||||
var xPath = '//td[@class="texteNotice"]';
|
||||
var xPathObject = doc.evaluate(xPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();;
|
||||
return xPathObject ? "printed text" : undefined;
|
||||
} catch(x) {
|
||||
Zotero.debug(x.lineNumber + " " + x.message);
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/* Translate a DC type to a corresponding Zotero item type. Currently obsolete. */
|
||||
this.translateDCType = function(type) {
|
||||
switch(type) {
|
||||
case "printed text":
|
||||
case "text":
|
||||
return "book";
|
||||
case "sound recording":
|
||||
return "audioRecording";
|
||||
default:
|
||||
return type;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* Get selectable search items from a list page.
|
||||
Loops through //td[@class="mn_partienoticesynthetique"], extracting the single items URLs from
|
||||
their onclick attribute, thier titles by assembling the spans for each cell.
|
||||
*/
|
||||
this.getSelectedItems = function(doc) {
|
||||
var items = new Object();
|
||||
|
||||
var baseUri = /^(https?:\/\/[^\/]+)/.exec(doc.location.href)[1];
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var cellPath = '//td[@class="mn_partienoticesynthetique"]';
|
||||
var spanPath = './/span';
|
||||
var cells = doc.evaluate(cellPath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var cell = undefined;
|
||||
var regexLink = /\s*window.location='([^']+)'\s*/;
|
||||
|
||||
//Cell loop
|
||||
while(cell = cells.iterateNext()) {
|
||||
//Get link
|
||||
var link = cell.attributes.item("onclick").textContent;
|
||||
var url = baseUri + regexLink.exec(link)[1];
|
||||
//Get title
|
||||
var title = "";
|
||||
var span = undefined;
|
||||
var spans = doc.evaluate(spanPath, cell, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
//Span loop
|
||||
while(span = spans.iterateNext()) {
|
||||
if(title.length > 0) {
|
||||
title += " – ";
|
||||
}
|
||||
title += Zotero.Utilities.trim(span.textContent);
|
||||
}
|
||||
items[url] = title;
|
||||
}
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
|
||||
//Check for Gallica URL (digital version available), if found, set item.url
|
||||
function checkGallica(doc, item) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var url = false;
|
||||
//Check for links containing the "Visualiser" img
|
||||
var elmts = doc.evaluate('//a[img[@src="/images/boutons/bouton_visualiser.gif"]]',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
if(elmts) {
|
||||
var link;
|
||||
while(link = elmts.iterateNext()) {
|
||||
url = link.href;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(url) {
|
||||
item.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Process UNIMARC URL. */
|
||||
this.processMarcUrl = function(newDoc) {
|
||||
var namespace = newDoc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
|
||||
/* Init MARC record. */
|
||||
var marc = loadMarcTranslator();
|
||||
var record = new marc.record();
|
||||
|
||||
/* Get table cell containing MARC code. */
|
||||
var elmts = newDoc.evaluate('//td[@class="texteNotice"]/text()',
|
||||
newDoc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
/* Line loop. */
|
||||
var elmt, tag, content;
|
||||
var ind = "";
|
||||
|
||||
while(elmt = elmts.iterateNext()) {
|
||||
var line = Zotero.Utilities.superCleanString(elmt.nodeValue);
|
||||
if(line.length == 0) {
|
||||
continue;
|
||||
}
|
||||
if(line.substring(0, 6) == " ") {
|
||||
content += " "+line.substring(6);
|
||||
continue;
|
||||
} else {
|
||||
if(tag) {
|
||||
record.addField(tag, ind, content);
|
||||
}
|
||||
}
|
||||
line = line.replace(/[_\t\xA0]/g," "); // nbsp
|
||||
tag = line.substr(0, 3);
|
||||
if(tag[0] != "0" || tag[1] != "0") {
|
||||
ind = line.substr(3, 2);
|
||||
content = line.substr(5).replace(/\$([a-z]|[0-9])/g, marc.subfieldDelimiter+"$1");
|
||||
content = content.replace(/ˆ([^‰]+)‰/g, "$1");
|
||||
} else {
|
||||
if(tag == "000") {
|
||||
tag = undefined;
|
||||
record.leader = "00000"+line.substr(8);
|
||||
} else {
|
||||
content = line.substr(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Create item
|
||||
var newItem = new Zotero.Item();
|
||||
record.translate(newItem);
|
||||
|
||||
//Do specific Unimarc postprocessing
|
||||
postprocessMarc(record, newItem);
|
||||
|
||||
//Check for Gallica URL
|
||||
checkGallica(newDoc, newItem);
|
||||
|
||||
newItem.complete();
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
/* Global BnfClass object. */
|
||||
var Bnf = new BnfClass();
|
||||
|
||||
|
||||
/* Translator API implementation. */
|
||||
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var resultRegexp = /ID=[0-9]+/i;
|
||||
//Single result ?
|
||||
if(resultRegexp.test(url)) {
|
||||
var type = Bnf.getDCType(doc, url);
|
||||
return Bnf.translateDCType(type);
|
||||
}
|
||||
//Muliple result ?
|
||||
else if(Bnf.getResultsTable(doc)) {
|
||||
return "multiple";
|
||||
}
|
||||
//No items
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
function doWeb(doc, url) {
|
||||
/* Check type. */
|
||||
var type = detectWeb(doc, url);
|
||||
if(!type) {
|
||||
return;
|
||||
}
|
||||
/* Build array of MARC URLs. */
|
||||
var urls = undefined;
|
||||
switch(type) {
|
||||
case "multiple":
|
||||
var items = Bnf.getSelectedItems(doc);
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
/* Let user select items. */
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(Bnf.reformURL(i));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
urls = [Bnf.reformURL(url)];
|
||||
}
|
||||
|
||||
/* Loop through URLs. */
|
||||
if(urls.length > 0) {
|
||||
Zotero.Utilities.processDocuments(urls,
|
||||
function(doc) {
|
||||
Bnf.processMarcUrl.call(Bnf, doc);
|
||||
},
|
||||
function() { Zotero.done(); },
|
||||
null);
|
||||
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
{
|
||||
"translatorID":"4c9dbe33-e64f-4536-a02f-f347fa1f187d",
|
||||
"translatorType":4,
|
||||
"label":"BioInfoBank",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://lib.bioinfo.pl/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-04-03 19:45:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
return "multiple";
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var pmids = new Array();
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//div[@class="css_pmid"]/div[@class="css_pmid_title"]/a', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
while (title = titles.iterateNext()) {
|
||||
items[title.href] = Zotero.Utilities.trimInternal(title.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
pmids.push(i.match(/pmid:(\d+)/)[1]);
|
||||
}
|
||||
var newUri = "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=PubMed&retmode=xml&rettype=citation&id="+pmids.join(",");
|
||||
Zotero.Utilities.HTTP.doGet(newUri, function(text) {
|
||||
// Remove xml parse instruction and doctype
|
||||
text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, "");
|
||||
|
||||
var xml = new XML(text);
|
||||
for(var i=0; i<xml.PubmedArticle.length(); i++) {
|
||||
var newItem = new Zotero.Item("journalArticle");
|
||||
|
||||
var citation = xml.PubmedArticle[i].MedlineCitation;
|
||||
|
||||
var PMID = citation.PMID.text().toString();
|
||||
newItem.extra = "PMID: "+PMID;
|
||||
// add attachments
|
||||
if(doc) {
|
||||
newItem.attachments.push({document:doc, title:"PubMed Snapshot"});
|
||||
} else {
|
||||
var url = "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=pubmed&cmd=Retrieve&dopt=AbstractPlus&list_uids="+PMID;
|
||||
newItem.attachments.push({url:url, title:"PubMed Snapshot",
|
||||
mimeType:"text/html"});
|
||||
}
|
||||
|
||||
var article = citation.Article;
|
||||
if(article.ArticleTitle.length()) {
|
||||
var title = article.ArticleTitle.text().toString();
|
||||
if(title.substr(-1) == ".") {
|
||||
title = title.substring(0, title.length-1);
|
||||
}
|
||||
newItem.title = title;
|
||||
}
|
||||
|
||||
if (article.Pagination.MedlinePgn.length()){
|
||||
newItem.pages = article.Pagination.MedlinePgn.text().toString();
|
||||
}
|
||||
|
||||
if(article.Journal.length()) {
|
||||
var issn = article.Journal.ISSN.text().toString();
|
||||
if(issn) {
|
||||
newItem.ISSN = issn.replace(/[^0-9]/g, "");
|
||||
}
|
||||
|
||||
newItem.journalAbbreviation = Zotero.Utilities.superCleanString(citation.MedlineJournalInfo.MedlineTA.text().toString());
|
||||
if(article.Journal.Title.length()) {
|
||||
newItem.publicationTitle = Zotero.Utilities.superCleanString(article.Journal.Title.text().toString());
|
||||
} else if(citation.MedlineJournalInfo.MedlineTA.length()) {
|
||||
newItem.publicationTitle = newItem.journalAbbreviation;
|
||||
}
|
||||
|
||||
if(article.Journal.JournalIssue.length()) {
|
||||
newItem.volume = article.Journal.JournalIssue.Volume.text().toString();
|
||||
newItem.issue = article.Journal.JournalIssue.Issue.text().toString();
|
||||
if(article.Journal.JournalIssue.PubDate.length()) { // try to get the date
|
||||
if(article.Journal.JournalIssue.PubDate.Day.text().toString() != "") {
|
||||
newItem.date = article.Journal.JournalIssue.PubDate.Month.text().toString()+" "+article.Journal.JournalIssue.PubDate.Day.text().toString()+", "+article.Journal.JournalIssue.PubDate.Year.text().toString();
|
||||
} else if(article.Journal.JournalIssue.PubDate.Month.text().toString() != "") {
|
||||
newItem.date = article.Journal.JournalIssue.PubDate.Month.text().toString()+" "+article.Journal.JournalIssue.PubDate.Year.text().toString();
|
||||
} else if(article.Journal.JournalIssue.PubDate.Year.text().toString() != "") {
|
||||
newItem.date = article.Journal.JournalIssue.PubDate.Year.text().toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(article.AuthorList.length() && article.AuthorList.Author.length()) {
|
||||
var authors = article.AuthorList.Author;
|
||||
for(var j=0; j<authors.length(); j++) {
|
||||
var lastName = authors[j].LastName.text().toString();
|
||||
var firstName = authors[j].FirstName.text().toString();
|
||||
if(firstName == "") {
|
||||
var firstName = authors[j].ForeName.text().toString();
|
||||
}
|
||||
if(firstName || lastName) {
|
||||
newItem.creators.push({lastName:lastName, firstName:firstName});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (citation.MeshHeadingList && citation.MeshHeadingList.MeshHeading) {
|
||||
var keywords = citation.MeshHeadingList.MeshHeading;
|
||||
for (var k = 0 ; k < keywords.length() ; k++) {
|
||||
newItem.tags.push(keywords[k].DescriptorName.text().toString());
|
||||
}
|
||||
}
|
||||
newItem.abstractNote = article.Abstract.AbstractText.toString()
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
Zotero.done();
|
||||
});
|
||||
}
|
|
@ -1,140 +0,0 @@
|
|||
{
|
||||
"translatorID":"1a3e63b2-0adf-4c8e-928b-c58c2594b45d",
|
||||
"translatorType":4,
|
||||
"label":"BioMed Central and More",
|
||||
"creator":"Ben Parr",
|
||||
"target":"http://[^/]*(jcmr-online|respiratory-research|bio-diglib|nuclear-receptor|medimmunol|kinetoplastids|filariajournal|cellandchromosome|actavetscand|aidsrestherapy|almob|ann-clinmicrob|annals-general-psychiatry|asir-journal|arthritis-research|apfmj|anzhealthpolicy|behavioralandbrainfunctions|biodatamining|biology-direct|biomagres|biomedical-engineering-online|bpsmedicine|biotechnologyforbiofuels|biomedcentral|breast-cancer-research|cancerci|cbmjournal|cardiab|cardiovascularultrasound|casesjournal|lipidsignaling.cbdjournals|biosignaling|celldiv|cerebrospinalfluidresearch|journal.chemistrycentral|capmh|cmjournal|chiroandosteo|clinicalmolecularallergy|cpementalhealth|comparative-hepatology|conflictandhealth|resource-allocation|coughjournal|ccforum|cytojournal|diagnosticpathology|dynamic-med|ete-online|ehjournal|epi-perspectives|epigeneticsandchromatin|fibrogenesis|frontiersinzoology|gvt-journal|genomebiology|genomemedicine|geochemicaltransactions|globalizationandhealth|gutpathogens|harmreductionjournal|head-face-med|hqlo|health-policy-systems|human-resources-health|immunityageing|immunome-research|implementationscience|infectagentscancer|intarchmed|internationalbreastfeedingjournal|equityhealthj|ijbnpa|ij-healthgeographics|ijmhs|issoonline|jautoimdis|jbioleng|jbiol|j-biomed-discovery|jbppni|carcinogenesis|cardiothoracicsurgery|jcmr-online|jcircadianrhythms|ethnobiomed|jexpclinassistreprod|jeccr|jfootankleres|jhoonline|jibtherapies|journal-inflammation|jmedicalcasereports|jmolecularsignaling|jnanobiotechnology|jnrbm|jneuroengrehab|jneuroinflammation|occup-med|josr-online|jissn|translational-medicine|traumamanagement|lipidworld|malariajournal|microbialcellfactories|molecularbrain|molecular-cancer|molecularcytogenetics|molecularneurodegeneration|molecularpain|neuraldevelopment|nonlinearbiomedphys|nutritionandmetabolism|nutritionj|ojrd|om-pc|parasitesandvectors|particleandfibretoxicology|pathogeneticsjournal|pssjournal|ped-rheum|peh-med|plantmethods|pophealthmetrics|proteomesci|ro-journal|rbej|reproductive-health-journal|respiratory-research|retrovirology|salinesystems|the-scientist|scoliosisjournal|scfbm|substanceabusepolicy|tbiomed|thrombosisjournal|thyroidresearchjournal|tobaccoinduceddiseases|trialsjournal|urooncologyjournal|virologyj|wjes|wjso)\\.(com|org|net)",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-15 19:45:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc,url)
|
||||
{
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == "x" ) return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var xpath='//meta[@name="citation_fulltext_html_url"]';
|
||||
|
||||
//Single
|
||||
if (doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext())
|
||||
{return "journalArticle";}
|
||||
|
||||
|
||||
//Multiple
|
||||
xpath='//a[@class="hiddenlink"][span[@class="xcitationtitle"][b]]';
|
||||
xpath+=' | //span[@class="xcitationtitle2"]/a[@class="hiddenlink"]';
|
||||
xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]';
|
||||
xpath+=' | //p[@class="bodytext"]/a[@class="hiddenblack"][b]';
|
||||
xpath+=' | //div[@class="bodytext"]/a[@class="hiddenblack"][b]';
|
||||
xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]';
|
||||
|
||||
var rows=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var row;
|
||||
var link;
|
||||
while(row=rows.iterateNext())
|
||||
{
|
||||
link=row.href;
|
||||
if(link.indexOf("pubmed")<0 && link.substr(link.length-4)!=".pdf" && link.indexOf("blogs.")<0)
|
||||
{return "multiple";}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function parseRIS(getURL)
|
||||
{
|
||||
Zotero.Utilities.HTTP.doGet(getURL, function(text){
|
||||
// load translator for RIS
|
||||
var translator = Zotero.loadTranslator ("import");
|
||||
translator.setHandler("itemDone", function(obj, newItem) {
|
||||
var doi = newItem.DOI;
|
||||
var splitURL = newItem.url.split('/');
|
||||
|
||||
if(splitURL.length>=3 && doi){
|
||||
var doiSuffix = doi.slice(doi.indexOf('/')+1);
|
||||
var pdfURL = splitURL[0] + '/' + splitURL[1] + '/' + splitURL[2];
|
||||
pdfURL += '/content/pdf/' + doiSuffix + '.pdf';
|
||||
var source = splitURL[2].replace(/^www./i,'').replace(/\.[\w]+$/i,'');
|
||||
newItem.attachments = [
|
||||
//{url:newItem.url+'/abstract', title:source + " Abstract Snapshot", mimeType:"text/html"},
|
||||
{url:newItem.url, title:source + " Snapshot", mimeType:"text/html"},
|
||||
{url:pdfURL, title:source + " PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
}
|
||||
newItem.complete();
|
||||
});
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.translate();
|
||||
Zotero.done();
|
||||
}, function() {});
|
||||
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
function doWeb(doc,url)
|
||||
{
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == "x" ) return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var xpath='//meta[@name="citation_fulltext_html_url"]/@content';
|
||||
var rows;
|
||||
var row=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (row)
|
||||
{
|
||||
//Single Article
|
||||
var url=row.textContent+"/citation/";
|
||||
Zotero.Utilities.HTTP.doPost(url, 'include=cit&format=refman&direct=on&submit=Download+references&action=submit', function(text)
|
||||
{parseRIS(url+'?include=cit&format=refman&direct=on&submit=Download+references&action=submit');});
|
||||
|
||||
Zotero.wait();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//Multiple
|
||||
xpath='//a[@class="hiddenlink"][span[@class="xcitationtitle"][b]]';
|
||||
xpath+=' | //span[@class="xcitationtitle2"]/a[@class="hiddenlink"]';
|
||||
xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]';
|
||||
xpath+=' | //p[@class="bodytext"]/a[@class="hiddenblack"][b]';
|
||||
xpath+=' | //div[@class="bodytext"]/a[@class="hiddenblack"][b]';
|
||||
xpath+=' | //div[@class="bodytext"]/a[@class="hiddenlink"][font/b]';
|
||||
|
||||
rows=doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var items=new Array();
|
||||
var link;
|
||||
var t;
|
||||
while(row=rows.iterateNext())
|
||||
{
|
||||
link=row.href;
|
||||
if(link.indexOf("pubmed")<0 && link.substr(link.length-4)!=".pdf" && link.indexOf("blogs.")<0)
|
||||
{
|
||||
t=link.split('/');
|
||||
if(t[t.length-1].indexOf("comments#")>-1)
|
||||
{link=t.slice(0,t.length-1).join('/');}
|
||||
items[link.replace("/abstract","")+"/citation"]=row.textContent;
|
||||
}
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
var uris=new Array();
|
||||
if (!items)
|
||||
{return true;}
|
||||
|
||||
for (var i in items)
|
||||
{uris.push(i);}
|
||||
|
||||
Zotero.Utilities.HTTP.doPost(uris, "include=cit&format=refman&direct=on&submit=Download+references&action=submit", function(text)
|
||||
{
|
||||
for (var j = 0 ; j < uris.length ; j++)
|
||||
{parseRIS(uris[j] + "?include=cit&format=refman&direct=on&submit=Download+references&action=submit");}
|
||||
});
|
||||
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
{
|
||||
"translatorID":"7cb0089b-9551-44b2-abca-eb03cbf586d9",
|
||||
"translatorType":4,
|
||||
"label":"BioOne",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://[^/]*www.bioone.org[^/]*/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.indexOf("searchtype") != -1) {
|
||||
return "multiple";
|
||||
} else if (url.indexOf("get-document") != -1 || url.indexOf("get-abstract") != -1) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function createCitationURL(str) {
|
||||
str = str.match(/doi=([^&]+)/)[1];
|
||||
return "http://www.bioone.org/perlserv/?request=cite-builder&doi=" + str;
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var host = doc.location.host;
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var results = doc.evaluate('//div[@class="content"]/table/tbody/tr/td[3][@class="group"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var next_result;
|
||||
while (next_result = results.iterateNext()) {
|
||||
var title = doc.evaluate('.//span[@class="title"]', next_result, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
var link = doc.evaluate('.//tr[4]/td/a[1]', next_result, null, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
items[link] = title;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(createCitationURL(i));
|
||||
}
|
||||
} else {
|
||||
articles = [createCitationURL(url)];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, function(newDoc) {
|
||||
var newlink = newDoc.evaluate('//a[contains(@href, "refman")]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
Zotero.Utilities.HTTP.doGet(newlink, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.url = decodeURIComponent(item.url);
|
||||
item.DOI = item.url.match(/http:\/\/dx\.doi\.org\/(.*)$/)[1];
|
||||
var pdfurl = 'http://' + host + '/perlserv/?request=get-pdf&doi=' + item.DOI;
|
||||
item.attachments = [
|
||||
{url:item.url, title:item.title, mimeType:"text/html"},
|
||||
{url:pdfurl, title:"BioOne Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
{
|
||||
"translatorID":"60d97c99-47f0-4323-98b6-5699faf827b1",
|
||||
"translatorType":4,
|
||||
"label":"Blackwell Compass",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.blackwell-compass.com/subject/[^/]+/.+",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.indexOf("search_results") != -1 || url.indexOf("section_home") != -1) {
|
||||
return "multiple";
|
||||
} else {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var URIs = new Array();
|
||||
var items = new Object();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
|
||||
var xpath = '//div[@class="article-holder"]//h4[@class="article"]/a';
|
||||
var articles = doc.evaluate(xpath, doc, namespace, XPathResult.ANY_TYPE, null);
|
||||
var next_art = articles.iterateNext();
|
||||
while (next_art) {
|
||||
items[next_art.href] = next_art.textContent;
|
||||
next_art = articles.iterateNext();
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
for (var i in items) {
|
||||
URIs.push(i);
|
||||
}
|
||||
} else {
|
||||
URIs.push(url);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(URIs, function(doc, urll) {
|
||||
var doi = doc.evaluate('//div[@id="content"]/p/span[@class="guide"]/a[substring(@href, 1, 4) = "http"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href.match(/doi\/[^/]*\/([^&]*)/)[1];
|
||||
Zotero.Utilities.HTTP.doGet('http://www.blackwell-synergy.com/action/downloadCitation?doi=' + doi + '&include=cit&format=refman&direct=on&submit=Download+references', function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.attachments = [
|
||||
{url:item.url, title:"Blackwell Compass Snapshot", mimeType:"text/html"},
|
||||
{url:item.url.replace("/doi/abs", "/doi/pdf"), title:"Blackwell Compass Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
|
||||
item.complete();
|
||||
|
||||
});
|
||||
|
||||
translator.translate();
|
||||
});
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
{
|
||||
"translatorID":"cb48083-4d9-4ed-ac95-2e93dceea0ec",
|
||||
"translatorType":4,
|
||||
"label":"Blackwell Synergy",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"https?://www\\.blackwell-synergy\\.com[^/]*/(?:action/doSearch|doi/|links/doi/)",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-04-28 17:50:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if(url.indexOf("doSearch") != -1) {
|
||||
return "multiple";
|
||||
} else {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function titleCase(str) {
|
||||
var skipWords = ["but", "or", "yet", "so", "for", "and", "nor", "a", "an", "the", "at", "by", "from", "in", "into", "of", "on", "to", "with", "up", "down", "as"];
|
||||
var words = str.toLowerCase().split(/\s+/);
|
||||
var newstr = "";
|
||||
for each (var word in words) {
|
||||
if (skipWords.indexOf(word.replace(/[^a-zA-Z]+/, "")) != -1) {
|
||||
newstr += " " + word;
|
||||
} else if (word.indexOf("-") != -1) {
|
||||
newword = word.split("-");
|
||||
newstr += " " + newword[0][0].toUpperCase() + newword[0].substr(1) + "-" + newword[1][0].toUpperCase() + newword[1].substr(1);
|
||||
} else {
|
||||
newstr += " " + word[0].toUpperCase() + word.substr(1);
|
||||
}
|
||||
}
|
||||
return Zotero.Utilities.trimInternal(newstr);
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var host = doc.location.host;
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var rows = doc.evaluate('//div[@class="toc_item"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var row;
|
||||
while (row = rows.iterateNext()) {
|
||||
var title = Zotero.Utilities.trimInternal(doc.evaluate('.//label', row, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var id = doc.evaluate('.//input[@name="doi"]', row, null, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
items[id] = title;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [decodeURIComponent(url).match(/doi\/(abs\/)?([^\?]+)(\?|$)/)[2]];
|
||||
}
|
||||
|
||||
var post = "";
|
||||
for each (var doi in articles) {
|
||||
post += "doi=" + encodeURIComponent(doi) + "&"
|
||||
}
|
||||
post += "include=abs&format=refman&submit=Download+references";
|
||||
Zotero.Utilities.HTTP.doPost('http://www.blackwell-synergy.com/action/downloadCitation', post, function(text) {
|
||||
text = text.replace(/(Y1\s+\-\s+)(\d{4}\/\d{2}).*\n/, "$1$2\n");
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.DOI = Zotero.Utilities.trimInternal(item.notes[0]['note'].substr(4));
|
||||
item.notes = new Array();
|
||||
item.attachments = [
|
||||
{url:item.url, title:"Blackwell Synergy Snapshot", mimeType:"text/html"},
|
||||
{url:item.url.replace(/\/\/[^/]*/, "//" + host).replace("/doi/abs", "/doi/pdf"), title:"Blackwell Synergy Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
// use fulltext if possible
|
||||
var oldCreators = item.creators;
|
||||
item.creators = []
|
||||
for each (var author in oldCreators) {
|
||||
if (author["lastName"] != "") {
|
||||
item.creators.push({firstName:titleCase(author.firstName), lastName:titleCase(author.lastName), creatorType:"author"});
|
||||
}
|
||||
}
|
||||
item.title = titleCase(item.title);
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
|
||||
Zotero.done();
|
||||
});
|
||||
}
|
|
@ -1,156 +0,0 @@
|
|||
{
|
||||
"translatorID": "e8e10bd4-fd6f-4297-a060-a8e0a479043f",
|
||||
"label": "Blaetter fuer deutsche und internationale Politik",
|
||||
"creator": "Martin Meyerhoff",
|
||||
"target": "^http://www\\.blaetter\\.de",
|
||||
"minVersion": "1.0",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": "1",
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-03-31 15:50:04"
|
||||
}
|
||||
|
||||
/*
|
||||
Blätter für deutsche und internationale Politik
|
||||
Copyright (C) 2011 Martin Meyerhoff
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
// I use XPaths. Therefore, I need the following block.
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var Blaetter_ArticleTools_XPath = ".//div[contains(@id, 'node')]/h2";
|
||||
var Blaetter_Multiple_XPath = ".//div[contains(@class, 'teaser') and not(contains(@class, 'dossier'))]/h3[@class='headline']/a";
|
||||
|
||||
if (doc.evaluate(Blaetter_ArticleTools_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
Zotero.debug("magazineArticle");
|
||||
return "magazineArticle";
|
||||
} else if (doc.evaluate(Blaetter_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
Zotero.debug("multiple");
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("magazineArticle");
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
|
||||
// This is for the title
|
||||
|
||||
var title_XPath =".//h2[@class='headline']";
|
||||
var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.title = title;
|
||||
|
||||
// Author
|
||||
var author_XPath = ".//h4[@class='author']/a";
|
||||
if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null)){
|
||||
var author_obj = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var next_author;
|
||||
while (next_author= author_obj.iterateNext()) {
|
||||
Zotero.debug(next_author.textContent);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(next_author.textContent, "author"));
|
||||
}
|
||||
}
|
||||
|
||||
// Tags
|
||||
var tags_XPath = ".//p[@class='credit']/a[@class='rb']";
|
||||
if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null)){
|
||||
var tags_obj = doc.evaluate(tags_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var next_tag;
|
||||
while (next_tag= tags_obj.iterateNext()) {
|
||||
newItem.tags.push(next_tag.textContent);
|
||||
}
|
||||
}
|
||||
|
||||
// Attachment. If there's a PDF available, grab it, otherwise just take the HTML site.
|
||||
var pdfurl_XPath = "//ul/li[contains(@class, 'download')]/a";
|
||||
if (doc.evaluate(pdfurl_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()){
|
||||
var pdfurl = doc.evaluate(pdfurl_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
newItem.attachments.push({url:pdfurl, title:doc.title, mimeType:"application/pdf"});
|
||||
|
||||
} else {
|
||||
newItem.attachments.push({url:doc.location.href, title:doc.title, mimeType:"text/html"});
|
||||
|
||||
}
|
||||
|
||||
// Publication Title
|
||||
newItem.publicationTitle = "Blätter für deutsche und internationale Politik";
|
||||
// Issue, Year and Date
|
||||
var credit_XPath = ".//p[@class='credit']";
|
||||
if (doc.evaluate(credit_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var credit= doc.evaluate(credit_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.date = credit.replace(/.*(\d+)\/(\d\d\d\d?).*\n.*/g, '$2-$1-00'); // Standard Date Format
|
||||
newItem.date = newItem.date.replace(/-(\d)-/, '-0$1-'); // If Month is single-digit, add a zero before it.
|
||||
newItem.pages= credit.replace(/.*,\sSeite\s(\d+-\d+).*\n.*/g, '$1');
|
||||
} else if (doc.location.href.match("/dokumente/") ){
|
||||
var title2_XPath =".//h3[@class='subtitle']";
|
||||
// Zotero doesn't have a field for subtitle, so just add a colon and then the subtitle.
|
||||
var title2 = doc.evaluate(title2_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.title = newItem.title + ": " + title2.replace(/(.*)(,\s\d+\.\d+\.\d\d\d\d)$/, '$1');
|
||||
// And the date is in there as well...
|
||||
newItem.date = title2.replace(/(.*,\s)(\d+\.\d+\.\d\d\d\d)$/, '$2');
|
||||
}
|
||||
|
||||
var summary_XPath = ".//meta[@name='description']";
|
||||
var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content;
|
||||
newItem.abstractNote = Zotero.Utilities.unescapeHTML(summary);
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var Blaetter_Multiple_XPath = ".//div[contains(@class, 'teaser') and not(contains(@class, 'dossier'))]/h3[@class='headline']/a";
|
||||
if (doc.evaluate(Blaetter_Multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
var titles = doc.evaluate(Blaetter_Multiple_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
}
|
||||
var next_title;
|
||||
|
||||
while (next_title = titles.iterateNext()) {
|
||||
Zotero.debug(next_title.textContent);
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
} else {
|
||||
scrape(doc, url);
|
||||
}
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
{
|
||||
"translatorID": "6f9aa90d-6631-4459-81ef-a0758d2e3921",
|
||||
"label": "Blogger",
|
||||
"creator": "Adam Crymble",
|
||||
"target": "blogspot\\.com",
|
||||
"minVersion": "1.0.0b4.r5",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": true,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-05-27 20:13:50"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var result = doc.evaluate('//h3[contains(@class,"post-title") and contains(@class,"entry-title")]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var entry = result.iterateNext();
|
||||
if (entry && result.iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (entry) {
|
||||
return "blogPost";
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Blogger translator. Code by Adam Crymble
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var tagsContent = new Array();
|
||||
|
||||
var newItem = new Zotero.Item("blogPost");
|
||||
|
||||
//title
|
||||
if (doc.evaluate('//h3[@class="post-title entry-title"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
|
||||
newItem.title = doc.evaluate('//h3[@class="post-title entry-title"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
} else {
|
||||
newItem.title = doc.title;
|
||||
}
|
||||
|
||||
//author, if available
|
||||
if (doc.evaluate('//span[@class="post-author vcard"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var author = doc.evaluate('//span[@class="post-author vcard"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, '');
|
||||
var author = author.toLowerCase();
|
||||
|
||||
if (author.match(/\sby\s/)) {
|
||||
var shortenAuthor = author.indexOf(" by");
|
||||
author = author.substr(shortenAuthor + 3).replace(/^\s*|\s$/g, '');
|
||||
}
|
||||
var words = author.split(/\s/);
|
||||
for (var i in words) {
|
||||
words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase();
|
||||
}
|
||||
author = words.join(" ");
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
|
||||
//date, if available
|
||||
if (doc.evaluate('//h2[@class="date-header"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.date = doc.evaluate('//h2[@class="date-header"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
}
|
||||
|
||||
//tags, if available
|
||||
if (doc.evaluate('//span[@class="post-labels"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var tags = doc.evaluate('//span[@class="post-labels"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var tags1;
|
||||
while (tags1 = tags.iterateNext()) {
|
||||
tagsContent.push(tags1.textContent);
|
||||
}
|
||||
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
}
|
||||
|
||||
var blogTitle1 = doc.title.split(":");
|
||||
newItem.blogTitle = blogTitle1[0];
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//h3[@class="post-title entry-title"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var titles1 = doc.evaluate('//li[@class="archivedate expanded"]/ul[@class="posts"]/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
|
||||
while (next_title = titles1.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
{
|
||||
"translatorID": "4e7119e0-02be-4848-86ef-79a64185aad8",
|
||||
"label": "Bookmarks",
|
||||
"creator": "Avram Lyon",
|
||||
"target": "html",
|
||||
"minVersion": "2.1b6",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": true,
|
||||
"translatorType": 3,
|
||||
"browserSupport": "gscn",
|
||||
"lastUpdated": "2011-07-09 18:52:34"
|
||||
}
|
||||
|
||||
/*
|
||||
Browser bookmarks translator
|
||||
Copyright (C) 2011 Avram Lyon, ajlyon@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* This translator imports and exports browser bookmark files in the standard
|
||||
* "Netscape Bookmark Format".
|
||||
* See http://msdn.microsoft.com/en-us/library/aa753582%28VS.85%29.aspx
|
||||
* This code draws from the CSL style for bookmark export, by Rintze Zelle
|
||||
* http://www.zotero.org/styles/bookmark-export
|
||||
* Input looks like:
|
||||
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||
<!-- This is an automatically generated file.
|
||||
It will be read and overwritten.
|
||||
DO NOT EDIT! -->
|
||||
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
|
||||
<TITLE>Bookmarks</TITLE>
|
||||
<H1>Bookmarks Menu</H1>
|
||||
<DL>
|
||||
<DT><A HREF="http://www.example.com/">Example Site</A></DT>
|
||||
<DD>Longer title</DD>
|
||||
</DL>
|
||||
*/
|
||||
|
||||
const MAX_DETECT_LINES = 150;
|
||||
|
||||
function detectImport() {
|
||||
var text = "";
|
||||
var line;
|
||||
var match;
|
||||
var re = /<DT>\s*<A[^>]*HREF="([^"]+)"[^>]*>([^<\n]+)/gi;
|
||||
var i = 0;
|
||||
while((line = Zotero.read()) !== false && (i++ < MAX_DETECT_LINES)) {
|
||||
text += line;
|
||||
match = re.exec(text);
|
||||
if (match) {
|
||||
Zotero.debug("Found a match with line: "+line);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function doImport() {
|
||||
var line;
|
||||
var hits;
|
||||
var item = false;
|
||||
var itemIncomplete = false;
|
||||
var collection = false;
|
||||
var re = /([A-Za-z_]+)="([^"]+)"/g;
|
||||
while((line = Zotero.read()) !== false) {
|
||||
if (line.indexOf("<DT>") !== -1 && line.indexOf("<A") !== -1) {
|
||||
if (itemIncomplete) item.complete();
|
||||
itemIncomplete = true;
|
||||
//Zotero.debug(line);
|
||||
item = new Zotero.Item("webpage");
|
||||
if (collection) collection.children.push(item);
|
||||
item.title = line.match(/>([^<]*)<\/A>/)[1];
|
||||
//Zotero.debug(item.title);
|
||||
while(hits = re.exec(line)) {
|
||||
if (!hits) {
|
||||
Zotero.debug("RE no match in "+line);
|
||||
continue;
|
||||
}
|
||||
switch (hits[1]) {
|
||||
case "HREF": item.url = hits[2];
|
||||
break;
|
||||
case "TAGS": item.tags = hits[2].split(','); break;
|
||||
case "ICON": break;
|
||||
case "ICON_URI": break;
|
||||
case "ADD_DATE":
|
||||
item.accessDate = convertDate(hits[2]);
|
||||
break;
|
||||
default: item.extra = item.extra ? item.extra + "; "+ [hits[1], hits[2]].join("=") :
|
||||
[hits[1], hits[2]].join("=");
|
||||
}
|
||||
}
|
||||
if (item.url.match(/^place:/)) {
|
||||
item = false;
|
||||
itemIncomplete = false;
|
||||
}
|
||||
} else if (line.indexOf("<DT>") !== -1 && line.indexOf("<H3") !== -1) {
|
||||
if (collection) {
|
||||
collection.complete();
|
||||
}
|
||||
collection = new Zotero.Collection();
|
||||
collection.name = Zotero.Utilities.unescapeHTML(line.match(/<H3[^>]*>([^<]*)<\/H3>/i)[1]);
|
||||
Zotero.debug("Starting collection: "+ collection.name);
|
||||
collection.type = "collection";
|
||||
collection.children = new Array();
|
||||
} else if (line.substr(0,4) == "<DD>") {
|
||||
if (itemIncomplete) item.abstractNote = item.abstractNote ? item.abstractNote + " " + line.substr(4) : line.substr(4);
|
||||
else Zotero.debug("Discarding description line without item: " + line);
|
||||
} else {
|
||||
//Zotero.debug("Discarding line: " + line);
|
||||
}
|
||||
}
|
||||
if (item && itemIncomplete) item.complete();
|
||||
if (collection) collection.complete();
|
||||
}
|
||||
|
||||
function convertDate(timestamp){
|
||||
var d = new Date(timestamp*1000);
|
||||
function pad(n){return n<10 ? '0'+n : n};
|
||||
return d.getUTCFullYear()+'-'
|
||||
+ pad(d.getUTCMonth()+1)+'-'
|
||||
+ pad(d.getUTCDate())+' '
|
||||
+ pad(d.getUTCHours())+':'
|
||||
+ pad(d.getUTCMinutes())+':'
|
||||
+ pad(d.getUTCSeconds())+' UTC';
|
||||
}
|
||||
|
||||
|
||||
|
||||
function doExport() {
|
||||
var item;
|
||||
|
||||
var header = '<!DOCTYPE NETSCAPE-Bookmark-file-1>\n'+
|
||||
'<!-- This is an automatically generated file.\n'+
|
||||
' It will be read and overwritten.\n'+
|
||||
' DO NOT EDIT! -->\n'+
|
||||
'<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">\n'+
|
||||
'<TITLE>Bookmarks</TITLE>\n'+
|
||||
'<H1>Bookmarks Menu</H1>\n'+
|
||||
'<DL>\n';
|
||||
var footer = '</DL>';
|
||||
//var tags = "";
|
||||
|
||||
Zotero.write(header);
|
||||
while (item = Zotero.nextItem()) {
|
||||
// TODO Be more verbose, making an informative title and including more metadata
|
||||
//tags = item.tags.forEach(function (tag) {return tag.tag}).join(",");
|
||||
if (item.url) Zotero.write(' <DT><A HREF="'+item.url+'">'+item.title+'</A>\n');
|
||||
else Zotero.debug("Skipping item without URL: "+item.title);
|
||||
}
|
||||
Zotero.write(footer);
|
||||
}
|
||||
|
||||
|
||||
/** BEGIN TEST CASES **/
|
||||
var testCases = []
|
||||
/** END TEST CASES **/
|
|
@ -1,171 +0,0 @@
|
|||
{
|
||||
"translatorID":"f9373e49-e6ac-46f7-aafe-bb24a2fbc3f0",
|
||||
"translatorType":4,
|
||||
"label":"Bracero History Archive",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://braceroarchive.org",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-09-02 13:40:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.title.match("Item")) {
|
||||
return "book";
|
||||
} else if (doc.evaluate('//div[@class="item-meta"]/h2/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
//Bracero History Archive translator; Code by Adam Crymble
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var fieldTitle;
|
||||
var contents1;
|
||||
|
||||
var headers = doc.evaluate('//h3', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var contents = doc.evaluate('//div[@class="field"]/div', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//div[@class="field"]/div)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (i=0; i<xPathCount.numberValue -1; i++) {
|
||||
|
||||
fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, '');
|
||||
contents1 = contents.iterateNext().textContent.replace(/^\s*|\s*$/g, '');
|
||||
|
||||
if (contents1.match("Empty")) {
|
||||
contents1 = '';
|
||||
}
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents1);
|
||||
}
|
||||
|
||||
//media type?
|
||||
if (dataTags["TypeName"]) {
|
||||
if (dataTags["TypeName"].match("Oral History")) {
|
||||
Zotero.debug(doc.title);
|
||||
var newItem = new Zotero.Item("audioRecording");
|
||||
} else {
|
||||
var newItem = new Zotero.Item("book");
|
||||
}
|
||||
} else {
|
||||
var newItem = new Zotero.Item("book");
|
||||
}
|
||||
|
||||
//creators
|
||||
if (dataTags["Interviewee"] && dataTags["Interviewee"] != '') {
|
||||
if (dataTags["Interviewee"].match(", ")) {
|
||||
var authors = dataTags["Interviewee"].split(", ");
|
||||
authors = authors[1] + ' ' + authors[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "interviewee"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: dataTags["Interviewee"], creatorType: "interviewee"});
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["Interviewer"] && dataTags["Interviewer"] != '') {
|
||||
if (dataTags["Interviewer"].match(", ")) {
|
||||
var authors = dataTags["Interviewer"].split(", ");
|
||||
authors = authors[1] + ' ' + authors[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "interviewer"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: dataTags["Interviewee"], creatorType: "interviewer"});
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["Creator"] && dataTags["Creator"] != '') {
|
||||
if (dataTags["Creator"].match(", ")) {
|
||||
var authors = dataTags["Creator"].split(", ");
|
||||
authors = authors[1] + ' ' + authors[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "creator"));
|
||||
} else {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["Creator"], "creator"));
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["AdditionalCreator"] && dataTags["AdditionalCreator"] != '') {
|
||||
if (dataTags["AdditionalCreator"].match(", ")) {
|
||||
var authors = dataTags["AdditionalCreator"].split(", ");
|
||||
authors = authors[1] + ' ' + authors[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors, "creator"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: dataTags["AdditionalCreator"], creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
|
||||
//associate
|
||||
associateData (newItem, dataTags, "Description", "abstractNote");
|
||||
associateData (newItem, dataTags, "Date", "date");
|
||||
associateData (newItem, dataTags, "Publisher", "publisher");
|
||||
associateData (newItem, dataTags, "Source", "place");
|
||||
associateData (newItem, dataTags, "Location", "place");
|
||||
associateData (newItem, dataTags, "RightsHolder", "rights");
|
||||
associateData (newItem, dataTags, "Language", "lang");
|
||||
associateData (newItem, dataTags, "Title:", "title");
|
||||
associateData (newItem, dataTags, "FileNameIdentifier", "callNumber");
|
||||
|
||||
//tags
|
||||
var tags1;
|
||||
var tagsContent = new Array();
|
||||
|
||||
if (doc.evaluate('//li[@class="tag"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var xPathTags = doc.evaluate('//li[@class="tag"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
while (tags1 = xPathTags.iterateNext()) {
|
||||
tagsContent.push(tags1.textContent);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
|
||||
//title
|
||||
newItem.title = doc.evaluate('//h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
var fullRecord = "view=full";
|
||||
var extraChar = "?";
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//div[@class="item-meta"]/h2/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href + extraChar + fullRecord] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
"translatorID":"635c1246-e0c8-40a0-8799-a73a0b013ad8",
|
||||
"translatorType":4,
|
||||
"label":"Bryn Mawr Classical Review",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://ccat.sas.upenn.edu/bmcr/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/by_reviewer/) || url.match(/by_author/) || url.match(/recent.html/) || url.match(/\/\d{4}\/$/)) {
|
||||
return "multiple";
|
||||
} else if (url.match(/[\d\-]+\.html$/)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var ns = doc.documentElement.namespaceURI;
|
||||
var nsResolver = ns ? function(prefix) {
|
||||
if (prefix == 'x') return ns; else return null;
|
||||
} : null;
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
if (doc.evaluate('//table/tbody/tr/td/ul/li/i', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var boxes = doc.evaluate('//table/tbody/tr/td/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var box;
|
||||
while (box = boxes.iterateNext()) {
|
||||
var link = doc.evaluate('./a', box, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
var title = doc.evaluate('./i', box, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
items[link] = title;
|
||||
}
|
||||
} else if (doc.evaluate('//table/tbody/tr/td/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var title = doc.evaluate('//table/tbody/tr/td/ul/li', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var next;
|
||||
while (next = title.iterateNext()) {
|
||||
items[next.href] = Zotero.Utilities.trimInternal(next.textContent);
|
||||
}
|
||||
} else if (url.match(/google\.com/)) {
|
||||
var titles = doc.evaluate('//h2[@class="r"]/a[@class="l"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
while (title = titles.iterateNext()) {
|
||||
items[title.href] = title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
arts.push(i);
|
||||
}
|
||||
} else {
|
||||
arts = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(arts, function(doc) {
|
||||
var item = new Zotero.Item("journalArticle");
|
||||
var title = doc.evaluate('//h3/i', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
item.title = "Review of: " + Zotero.Utilities.trimInternal(title);
|
||||
var data = doc.evaluate('//h3[i]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
var title = title.replace("(", "\\(").replace(")", "\\)");
|
||||
var author = doc.evaluate('//b[contains(text(), "Reviewed")]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.match(/Reviewed by\s+([^,]+),/)[1];
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
var splitRe = new RegExp(title);
|
||||
var authors = data.split(splitRe)[0].replace(/\([^)]+\)/, "").split(/(,|and)\s+/);
|
||||
Zotero.debug(authors);
|
||||
Zotero.debug(authors);
|
||||
for each (var aut in authors) {
|
||||
if (aut.match(/\w/) && (aut != "and")) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "reviewedAuthor"));
|
||||
}
|
||||
}
|
||||
item.url = doc.location.href;
|
||||
item.attachments = [{url:item.url, title:item.title, mimeType:"text/html"}];
|
||||
if (doc.evaluate('/html/body/center/table/tbody/tr/td/center/table/tbody/tr/td/center/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
item.date = Zotero.Utilities.trimInternal(doc.evaluate('/html/body/center/table/tbody/tr/td/center/table/tbody/tr/td/center/font', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("Bryn Mawr Classical Review ", "").replace(/\./g, "/"));
|
||||
} else {
|
||||
item.date = Zotero.Utilities.trimInternal(doc.evaluate('/html/body/h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace("Bryn Mawr Classical Review ", "").replace(/\./g, "/"))
|
||||
}
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
{
|
||||
"translatorID":"e8d40f4b-c4c9-41ca-a59f-cf4deb3d3dc5",
|
||||
"translatorType":4,
|
||||
"label":"Business Standard",
|
||||
"creator":"Prashant Iyengar and Michael Berkowitz",
|
||||
"target":"http://www.business-standard.com",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/googlesearch/)) {
|
||||
return "multiple";
|
||||
} else if (url.match(/common/)) {
|
||||
return "newspaperArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var links = doc.evaluate('//a[@class="NewsHead"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var link;
|
||||
var items = new Object();
|
||||
while (link = links.iterateNext()) {
|
||||
items[link.href] = Zotero.Utilities.cleanTags(link.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
arts.push(i);
|
||||
}
|
||||
} else {
|
||||
arts = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(arts, function(doc) {
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
newItem.publicationTitle = "The Business Standard";
|
||||
newItem.url = doc.location.href;
|
||||
newItem.websiteTitle="The Business Standard";
|
||||
newItem.edition="Online";
|
||||
newItem.title = Zotero.Utilities.cleanTags(doc.title);
|
||||
|
||||
|
||||
if (doc.evaluate('//td[@class="author"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var bits = doc.evaluate('//td[@class="author"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\s+\/\s+/);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(bits[0], "author"));
|
||||
extras = Zotero.Utilities.trimInternal(bits[1]).match(/^(.*)(\s\w+\s+\d+,\s*\d+)$/);
|
||||
newItem.place = extras[1];
|
||||
newItem.date = Zotero.Utilities.trimInternal(extras[2]);
|
||||
newItem.complete();
|
||||
} else if (doc.evaluate('//td[@class="NewsSummary"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var author = Zotero.Utilities.trimInternal(doc.evaluate('//td[@class="NewsSummary"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
var printurl = 'http://www.business-standard.com/general/printpage.php?autono=' + newItem.url.match(/autono=(\d+)/)[1];
|
||||
Zotero.debug(printurl);
|
||||
Zotero.Utilities.HTTP.doGet(printurl, function(text) {
|
||||
var date = text.match(/<td class=author>([^<]+)</)[1];
|
||||
newItem.date = Zotero.Utilities.trimInternal(date.split(" ")[1]);
|
||||
newItem.complete();
|
||||
});
|
||||
}
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
{
|
||||
"translatorID":"fb342bae-7727-483b-a871-c64c663c2fae",
|
||||
"translatorType":4,
|
||||
"label":"BusinessWeek",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://(www\\.)?businessweek.com",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.title == "BusinessWeek Search Results") {
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//meta[@name="headline"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "magazineArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var results = doc.evaluate('//div[@class="result"]/h3[@class="story"]/a', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var result;
|
||||
var items = new Object();
|
||||
while (result = results.iterateNext()) {
|
||||
items[result.href] = Zotero.Utilities.trimInternal(result.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.debug(articles);
|
||||
Zotero.Utilities.processDocuments(articles, function(newDoc) {
|
||||
var metaTags = new Object();
|
||||
var metas = newDoc.evaluate('//meta', newDoc, null, XPathResult.ANY_TYPE, null);
|
||||
var meta;
|
||||
while (meta = metas.iterateNext()) {
|
||||
metaTags[meta.name] = meta.content;
|
||||
}
|
||||
Zotero.debug(metaTags);
|
||||
var item = new Zotero.Item("magazineArticle");
|
||||
item.title = metaTags['headline'];
|
||||
item.abstractNote = metaTags['abstract'];
|
||||
item.tags = metaTags['keywords'].split(/\s*,\s*/);
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(metaTags['author'], "author"));
|
||||
item.publicationTitle = "BusinessWeek: " + metaTags['channel'];
|
||||
item.url = newDoc.location.href;
|
||||
item.date = metaTags['pub_date'].replace(/(\d{4})(\d{2})(\d{2})/, "$2/$3/$1");
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
{
|
||||
"translatorID":"a29d22b3-c2e4-4cc0-ace4-6c2326144332",
|
||||
"translatorType":4,
|
||||
"label":"CABI - CAB Abstracts",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://www.cabi.org/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-29 21:10:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//div/table/tbody/tr[1]/td/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//span[@class="PageSubTitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
//CAB Abstracts translator. Code by Adam Crymble
|
||||
//only designed for "book" entries. People, projects, sites, etc are ignored by Zotero.
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
//authors
|
||||
if (doc.evaluate('//td[@class="smallwebtext"]/table/tbody/tr/td[1]/span[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var xPathAuthors = doc.evaluate('//td[@class="smallwebtext"]/table/tbody/tr/td[1]/span[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPath1Count = doc.evaluate('count (//td[@class="smallwebtext"]/table/tbody/tr/td[1]/span[@class="MenuBar"])', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var nameTest = 0;
|
||||
|
||||
for (var j = 0; j < xPath1Count.numberValue; j++) {
|
||||
authors = xPathAuthors.iterateNext().textContent
|
||||
if (authors.match("by ")) {
|
||||
var shortenAuthor = authors.indexOf("by ")+3;
|
||||
|
||||
authors = authors.substr(shortenAuthor).split("; ");
|
||||
|
||||
for (var i = 0; i < authors.length; i++) {
|
||||
|
||||
shortenAuthor = authors[i].indexOf(",");
|
||||
authors[i] = (authors[i].substr(0, shortenAuthor));
|
||||
var givenName = (authors[i].split(/\s/));
|
||||
authors[i] = '';
|
||||
|
||||
for (var k = 0; k < givenName.length; k++) {
|
||||
if (givenName[k].length == 1) {
|
||||
authors[i] = (authors[i] + givenName[k] + ".");
|
||||
} else {
|
||||
|
||||
authors[i] = (authors[i] + " " + givenName[k]);
|
||||
}
|
||||
}
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//imprint info
|
||||
var info = new Array();
|
||||
if (doc.evaluate('//td[3]/table/tbody/tr/td[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var xPathImprint = doc.evaluate('//td[3]/table/tbody/tr/td[@class="MenuBar"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var imprint = xPathImprint.iterateNext().textContent.split(/\n/);
|
||||
|
||||
|
||||
for (var i = 0; i < imprint.length; i++) {
|
||||
imprint[i] = imprint[i].replace(/^\s*|\s*$/g, '');
|
||||
if (imprint[i].match(/\w/)) {
|
||||
info.push(imprint[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < info.length; i++) {
|
||||
if (info[i].match("pages")) {
|
||||
var cutPages = info[i].indexOf("pages");
|
||||
newItem.pages = info[i].substr(0, cutPages);
|
||||
} else if (info[i].match("Date:")) {
|
||||
newItem.date = info[i].substr(10);
|
||||
} else if (info[i].match("ISBN: ")) {
|
||||
newItem.ISBN = info[i].substr(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newItem.title = doc.title;
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//tr[1]/td/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var mediaType = doc.evaluate('//strong', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var dump = mediaType.iterateNext();
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = mediaType.iterateNext().textContent;
|
||||
if (items[next_title.href].match("Book")) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
{
|
||||
"translatorID":"31649d9d-8f7e-4b87-8678-b3e68ee98f39",
|
||||
"translatorType":4,
|
||||
"label":"CARL/ABRC OAI Harvester",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://carl-abrc-oai",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-09-02 13:40:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.title.match("Search")) {
|
||||
return "multiple";
|
||||
} else if (doc.title.match("Browse")) {
|
||||
return "multiple";
|
||||
} else if (doc.title.match("Record")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var allAuthors = new Array();
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var metaTagHTML = doc.getElementsByTagName("meta");
|
||||
|
||||
for (var i = 0 ; i < metaTagHTML.length ; i++) {
|
||||
dataTags[metaTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(metaTagHTML[i].getAttribute("content"));
|
||||
if (metaTagHTML[i].getAttribute("name") == "DC.Creator") {
|
||||
allAuthors.push(dataTags["DC.Creator"]);
|
||||
}
|
||||
|
||||
}
|
||||
Zotero.debug(allAuthors);
|
||||
|
||||
for (var i = 0; i < allAuthors.length; i++) {
|
||||
|
||||
|
||||
if (allAuthors[i].match(",")) {
|
||||
var authorName = allAuthors[i].split(",");
|
||||
allAuthors[i] = (authorName[1] + (" ") + authorName[0]);
|
||||
|
||||
if (allAuthors[i].match("; ; ")) {
|
||||
|
||||
allAuthors[i] = allAuthors[i].replace("; ;", '');
|
||||
}
|
||||
|
||||
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(allAuthors[i], "author"));
|
||||
} else {
|
||||
if (allAuthors[i].match("; ; ")) {
|
||||
|
||||
allAuthors[i] = allAuthors[i].replace("; ;", '');
|
||||
}
|
||||
|
||||
newItem.creators.push({lastName: allAuthors[i], creatorType: "creator"});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
associateData (newItem, dataTags, "DC.Title", "title");
|
||||
associateData (newItem, dataTags, "DC.Description", "abstractNote");
|
||||
associateData (newItem, dataTags, "DC.Publisher", "publisher");
|
||||
associateData (newItem, dataTags, "DC.Contributor", "extra");
|
||||
associateData (newItem, dataTags, "DC.Date", "date");
|
||||
associateData (newItem, dataTags, "DC.Language", "language");
|
||||
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//span[@class="title"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//div[@class="main"]/div/div/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[links.iterateNext().href] = next_title.textContent;
|
||||
links.iterateNext();
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,787 +0,0 @@
|
|||
{
|
||||
"translatorID":"5c95b67b-41c5-4f55-b71a-48d5d7183063",
|
||||
"label":"CNKI",
|
||||
"creator":"Ace Strong <acestrong@gmail.com> and Heromyth <zxpmyth@yahoo.com.cn>",
|
||||
"target":"^https?://(?:(?:(dlib|epub|acad|apj1|law1|www)\\.cnki\\.net)|(?:[0-9\\.]+))/(?:grid2008|kns50|Kns55|kcms)",
|
||||
"minVersion":"2.0rc1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":"1",
|
||||
"translatorType":4,
|
||||
"lastUpdated":"2010-12-10 14:32:46"
|
||||
}
|
||||
|
||||
/*
|
||||
CNKI(China National Knowledge Infrastructure) Translator
|
||||
Copyright (C) 2009-2010 TAO Cheng, acestrong@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// #######################
|
||||
// ##### Sample URLs #####
|
||||
// #######################
|
||||
|
||||
/*
|
||||
* The starting point for an search is the URL below.
|
||||
* In testing, I tried the following:
|
||||
*
|
||||
* - A search listing of journals
|
||||
* - A search listing of phd thesis
|
||||
* - A search listing of master thesis
|
||||
* - A search listing of conference papers
|
||||
* - A search listing of newspaper articles
|
||||
* - A journal paper page
|
||||
* - A phd thesis page
|
||||
* - A master thesis page
|
||||
* - A conference paper page
|
||||
* - A newspaper article page
|
||||
*/
|
||||
// http://epub.cnki.net/grid2008/index/ZKCALD.htm
|
||||
|
||||
|
||||
// #################################
|
||||
// #### Local utility functions ####
|
||||
// #################################
|
||||
|
||||
function detectCode(url) {
|
||||
var pattern = /(?:dbcode|dbname)=([A-Za-z]{4})/i;
|
||||
if (pattern.test(url)) {
|
||||
var code = pattern.exec(url)[1];
|
||||
return code;
|
||||
} else {
|
||||
// parse from source page
|
||||
var page = Zotero.Utilities.retrieveSource(url);
|
||||
pattern = /id="nowdbname"[^>]*?>(.*?)<\/SPAN>/i;
|
||||
if (pattern.test(page)) {
|
||||
var dbname = pattern.exec(page)[1];
|
||||
// Zotero.debug(dbname);
|
||||
if (dbname == "中国期刊全文数据库") {
|
||||
return "CJFD";
|
||||
}
|
||||
}
|
||||
}
|
||||
return "NONE";
|
||||
}
|
||||
|
||||
function getResolver(doc) {
|
||||
var namespace, resolver;
|
||||
namespace = doc.documentElement.namespaceURI;
|
||||
if (namespace) {
|
||||
resolver = function(prefix) {
|
||||
if (prefix == 'x') {
|
||||
return namespace;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
} else {
|
||||
resolver = null;
|
||||
}
|
||||
return resolver;
|
||||
}
|
||||
|
||||
function trimTags(text) {
|
||||
var pattern = /(<.*?>)/g;
|
||||
text = text.replace(pattern, "");
|
||||
return text;
|
||||
}
|
||||
|
||||
function trimMultiline(text) {
|
||||
var pattern = /(\s{2,})/g;
|
||||
text = text.replace(pattern, "\n");
|
||||
return text;
|
||||
}
|
||||
|
||||
// #############################
|
||||
// ##### Scraper functions #####
|
||||
// #############################
|
||||
|
||||
// work for journalArticle
|
||||
function scrapeAndParse1(url) {
|
||||
// Zotero.debug("journalArticle");
|
||||
Zotero.Utilities.doGet(url, function(page) {
|
||||
var pattern;
|
||||
|
||||
// 类型 & URL
|
||||
var itemType = "journalArticle";
|
||||
var newItem = new Zotero.Item(itemType);
|
||||
// Zotero.debug(url);
|
||||
newItem.url = url;
|
||||
|
||||
// 标题/Title
|
||||
pattern = /<span (?:id="chTitle"|class='datatitle')>(.*?)<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
var title = trimTags(pattern.exec(page)[1]);
|
||||
newItem.title = title;
|
||||
// Zotero.debug("title: "+title);
|
||||
}
|
||||
|
||||
// 作者/Authors
|
||||
var authorNames;
|
||||
pattern = /【作者】(?:[\s\S]*?)GetLinkListEx\('(.*?);','/;
|
||||
if (pattern.test(page)) {
|
||||
authorNames = pattern.exec(page)[1].split(";");
|
||||
} else {
|
||||
pattern = /【作者】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
authorNames = trimTags(pattern.exec(page)[1]).split(";");
|
||||
}
|
||||
}
|
||||
if (authorNames) {
|
||||
for (var i=0; i<authorNames.length; i++) {
|
||||
var authorName = Zotero.Utilities.trim(authorNames[i]);
|
||||
if (authorName.length > 0) {
|
||||
newItem.creators.push(
|
||||
Zotero.Utilities.cleanAuthor(authorNames[i],
|
||||
"author", true));
|
||||
}
|
||||
}
|
||||
// Zotero.debug("authorNames:\n"+authorNames);
|
||||
}
|
||||
|
||||
// 摘要/Abstract
|
||||
var abst;
|
||||
pattern = /【摘要】\s*<[^>]*>(.*?)<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
} else {
|
||||
pattern = /【摘要】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
}
|
||||
}
|
||||
if (abst) {
|
||||
// Zotero.debug("abstract:\n"+abst);
|
||||
newItem.abstractNote = Zotero.Utilities.trim(abst);
|
||||
}
|
||||
|
||||
pattern = /【Abstract】\s*<[^>]*>(.*?)<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
} else {
|
||||
pattern = /【英文摘要】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
}
|
||||
}
|
||||
if (abst) {
|
||||
// Zotero.debug("abstract:\n"+abst);
|
||||
if (newItem.abstractNote===undefined) {
|
||||
newItem.abstractNote = Zotero.Utilities.trim(abst);
|
||||
} else {
|
||||
newItem.abstractNote = newItem.abstractNote + "\n"
|
||||
+ Zotero.Utilities.trim(abst);
|
||||
}
|
||||
}
|
||||
// Zotero.debug(newItem.abstractNote);
|
||||
|
||||
// 关键词/Keywords
|
||||
var tags;
|
||||
pattern = /【关键词】(?:[\s\S]*?)KeywordFilter\('(.*?)'\),'kw'/;
|
||||
if (pattern.test(page)) {
|
||||
tags = pattern.exec(page)[1].split(";");
|
||||
} else {
|
||||
pattern = /【(?:中文)?关键词】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
}
|
||||
}
|
||||
if (tags) {
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
var tag = Zotero.Utilities.trim(tags[i]);
|
||||
if (tag.length>0 && newItem.tags.indexOf(tag)<0) {
|
||||
newItem.tags.push(tag);
|
||||
}
|
||||
}
|
||||
// Zotero.debug("tags:\n"+tags);
|
||||
}
|
||||
pattern = /【Key words】(?:[\s\S]*?)GetLinkList\('(.*?)','kw'/;
|
||||
if (pattern.test(page)) {
|
||||
tags = pattern.exec(page)[1].split(";");
|
||||
} else {
|
||||
pattern = /【英文关键词】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
}
|
||||
}
|
||||
if (tags) {
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
var tag = Zotero.Utilities.trim(tags[i]);
|
||||
if (tag.length>0 && newItem.tags.indexOf(tag)<0) {
|
||||
newItem.tags.push(tag);
|
||||
}
|
||||
}
|
||||
// Zotero.debug("tags:\n"+tags);
|
||||
}
|
||||
|
||||
// 文献出处 & DOI & 出版时间
|
||||
pattern = /【(?:文献出处|刊名)】([\s\S]*?)<\/a>/;
|
||||
if (pattern.test(page)) {
|
||||
var publicationTitle = trimTags(pattern.exec(page)[1]);
|
||||
newItem.publicationTitle = Zotero.Utilities.trim(publicationTitle);
|
||||
// Zotero.debug("publicationTitle: "+publicationTitle);
|
||||
}
|
||||
var doi;
|
||||
pattern = /【DOI】(.*?)<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
doi= pattern.exec(page)[1];
|
||||
} else {
|
||||
pattern = /【DOI】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
doi= trimTags(pattern.exec(page)[1]);
|
||||
}
|
||||
}
|
||||
if (doi) {
|
||||
newItem.DOI = Zotero.Utilities.trim(doi);
|
||||
// Zotero.debug("doi: "+doi);
|
||||
}
|
||||
pattern = /【(?:文献出处|刊名)】(?:[\s\S]*?)(\d{4})年\s*([0-9A-Z]{2})(卷|期)/;
|
||||
if (pattern.test(page)) {
|
||||
var date = pattern.exec(page)[1];
|
||||
newItem.date = date;
|
||||
var val = pattern.exec(page)[2];
|
||||
var attr = pattern.exec(page)[3];
|
||||
if (attr == "卷") {
|
||||
newItem.volume = val;
|
||||
} else {
|
||||
newItem.issue = val;
|
||||
}
|
||||
// Zotero.debug("date: "+date);
|
||||
// Zotero.debug("val: "+val);
|
||||
// Zotero.debug("attr: "+attr);
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
});
|
||||
}
|
||||
|
||||
// work for thesis
|
||||
function scrapeAndParse2(url) {
|
||||
// Zotero.debug("thesis");
|
||||
Zotero.Utilities.doGet(url, function(page) {
|
||||
var pattern;
|
||||
|
||||
// 类型 & URL
|
||||
var itemType = "thesis";
|
||||
var newItem = new Zotero.Item(itemType);
|
||||
// Zotero.debug(url);
|
||||
newItem.url = url;
|
||||
var code = detectCode(url);
|
||||
if (code == "CDFD") {
|
||||
newItem.thesisType = "博士论文"
|
||||
} else {
|
||||
newItem.thesisType = "硕士论文"
|
||||
}
|
||||
// Zotero.debug(newItem.thesisType);
|
||||
|
||||
|
||||
// 标题/Title
|
||||
pattern = /<span (?:id="chTitle"|class='datatitle')>(.*?)<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
var title = pattern.exec(page)[1];
|
||||
pattern = /(<.*?>)/g;
|
||||
title = title.replace(pattern, "");
|
||||
newItem.title = title;
|
||||
// Zotero.debug("title: "+title);
|
||||
}
|
||||
|
||||
// 作者/Author
|
||||
pattern = /【作者】([\s\S]*?)<\/a>/;
|
||||
if (pattern.test(page)) {
|
||||
var authorNames = trimTags(pattern.exec(page)[1]).split(";");
|
||||
for (var i=0; i<authorNames.length; i++) {
|
||||
newItem.creators.push(
|
||||
Zotero.Utilities.cleanAuthor(authorNames[i],
|
||||
"author", true));
|
||||
}
|
||||
// Zotero.debug("authorNames:\n"+authorNames);
|
||||
}
|
||||
|
||||
// 导师/Tutors
|
||||
pattern = /【导师】([\s\S]*?)<\/a>/;
|
||||
if (pattern.test(page)) {
|
||||
var directors = trimTags(pattern.exec(page)[1]).split(";");
|
||||
for (var i=0; i<directors.length; i++) {
|
||||
newItem.creators.push(
|
||||
Zotero.Utilities.cleanAuthor(trimTags(directors[i]),
|
||||
"director", true));
|
||||
}
|
||||
// Zotero.debug("directors: "+directors);
|
||||
}
|
||||
|
||||
// 摘要/Abstract
|
||||
var abst;
|
||||
pattern = /ReplaceFont\('ChDivSummary','(.*?)(?='\);ReplaceFont)/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
} else {
|
||||
pattern = /【中文摘要】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
}
|
||||
}
|
||||
if (abst) {
|
||||
// Zotero.debug("abstract:\n"+abst);
|
||||
newItem.abstractNote = trimMultiline(abst);
|
||||
}
|
||||
pattern = /ReplaceFont\('EnDivSummary','(.*?)(?='\);if)/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
} else {
|
||||
pattern = /【英文摘要】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
abst = trimTags(pattern.exec(page)[1]);
|
||||
}
|
||||
}
|
||||
if (abst) {
|
||||
// Zotero.debug("abstract:\n"+abst);
|
||||
if (newItem.abstractNote===undefined) {
|
||||
newItem.abstractNote = Zotero.Utilities.trim(abst);
|
||||
} else {
|
||||
newItem.abstractNote = newItem.abstractNote + "\n"
|
||||
+ trimMultiline(abst);
|
||||
}
|
||||
}
|
||||
// Zotero.debug(newItem.abstractNote);
|
||||
|
||||
// 关键词/Keywords
|
||||
var tags;
|
||||
pattern = /【关键词】\s*<span[^>]*>(.*?)<\/a>*<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
} else {
|
||||
pattern = /【关键词】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
}
|
||||
}
|
||||
if (tags) {
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
var tag = Zotero.Utilities.trim(tags[i]);
|
||||
if (tag.length>0 && newItem.tags.indexOf(tag)<0) {
|
||||
newItem.tags.push(tag);
|
||||
}
|
||||
}
|
||||
// Zotero.debug("tags:\n"+tags);
|
||||
}
|
||||
pattern = /【Key words】\s*<span[^>]*>(.*?)<\/a>*<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
} else {
|
||||
pattern = /【英文关键词】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
}
|
||||
}
|
||||
if (tags) {
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
var tag = Zotero.Utilities.trim(tags[i]);
|
||||
if (tag.length>0 && newItem.tags.indexOf(tag)<0) {
|
||||
newItem.tags.push(tag);
|
||||
}
|
||||
}
|
||||
// Zotero.debug("tags:\n"+tags);
|
||||
}
|
||||
// Zotero.debug(newItem.tags);
|
||||
|
||||
// 出版学校 & DOI & 出版时间
|
||||
var university;
|
||||
pattern = /【网络出版投稿人】\s*<a[^>]*>(.*?)<\/a>/;
|
||||
if (pattern.test(page)) {
|
||||
university = pattern.exec(page)[1];
|
||||
} else {
|
||||
pattern = /【网络出版投稿人】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
university = Zotero.Utilities.trim(
|
||||
trimTags(pattern.exec(page)[1]));
|
||||
}
|
||||
}
|
||||
if (university) {
|
||||
pattern = /(.*?)((.*?))/;
|
||||
if (pattern.test(university)) {
|
||||
newItem.university = pattern.exec(university)[1];
|
||||
newItem.place = pattern.exec(university)[2];
|
||||
} else {
|
||||
newItem.publisher = university;
|
||||
}
|
||||
// Zotero.debug("university: "+university);
|
||||
}
|
||||
var doi;
|
||||
pattern = /【DOI】(.*?)<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
doi= pattern.exec(page)[1];
|
||||
} else {
|
||||
pattern = /【DOI】([\s\S]*?)<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
var doi= trimTags(pattern.exec(page)[1]);
|
||||
}
|
||||
}
|
||||
if (doi) {
|
||||
newItem.DOI = Zotero.Utilities.trim(doi);
|
||||
// Zotero.debug("doi: "+doi);
|
||||
}
|
||||
var date;
|
||||
pattern = /【网络出版投稿时间】(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
date = pattern.exec(page)[1];
|
||||
} else {
|
||||
pattern = /【网络出版投稿时间】([\s\S]*?)\s*<\/tr>/;
|
||||
if (pattern.test(page)) {
|
||||
date = trimTags(pattern.exec(page)[1]);
|
||||
}
|
||||
}
|
||||
if (date) {
|
||||
newItem.date = Zotero.Utilities.trim(date);
|
||||
// Zotero.debug("date: "+date);
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
});
|
||||
}
|
||||
|
||||
// work for conferencePaper
|
||||
function scrapeAndParse3(url) {
|
||||
// Zotero.debug("conferencePaper");
|
||||
Zotero.Utilities.doGet(url, function(page) {
|
||||
var pattern;
|
||||
|
||||
// 类型 & URL
|
||||
var itemType = "conferencePaper";
|
||||
var newItem = new Zotero.Item(itemType);
|
||||
// Zotero.debug(url);
|
||||
newItem.url = url;
|
||||
|
||||
// 标题/Title
|
||||
pattern = /<span id="chTitle">(.*?)<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
var title = trimTags(pattern.exec(page)[1]);
|
||||
newItem.title = title;
|
||||
// Zotero.debug("title: "+title);
|
||||
}
|
||||
|
||||
// 作者/Authors
|
||||
pattern = /【作者】(.*?)<\/p>/;
|
||||
if (pattern.test(page)) {
|
||||
var authorNames = trimTags(pattern.exec(page)[1]).split(";");
|
||||
for (var i=0; i<authorNames.length; i++) {
|
||||
newItem.creators.push(
|
||||
Zotero.Utilities.cleanAuthor(
|
||||
Zotero.Utilities.trim(authorNames[i]),
|
||||
"author", true));
|
||||
}
|
||||
// Zotero.debug("authorNames:\n"+authorNames);
|
||||
}
|
||||
|
||||
// 摘要/Abstract
|
||||
var abst;
|
||||
pattern = /ReplaceFont\('ChDivSummary','(.*?)(?='\);ReplaceFont)/;
|
||||
if (pattern.test(page)) {
|
||||
abst = pattern.exec(page)[1];
|
||||
// Zotero.debug("raw:\n"+abst);
|
||||
pattern = /(<.*?>)/g;
|
||||
abst = abst.replace(pattern, "");
|
||||
// Zotero.debug("after:\n"+abst);
|
||||
newItem.abstractNote = Zotero.Utilities.trim(abst);
|
||||
}
|
||||
|
||||
pattern = /ReplaceFont\('EnDivSummary','(.*?)(?='\);if)/;
|
||||
if (pattern.test(page)) {
|
||||
abst = pattern.exec(page)[1];
|
||||
// Zotero.debug("raw:\n"+abst);
|
||||
if (abst != undefined && abst != null) {
|
||||
pattern = /(<.*?>)/g;
|
||||
abst = abst.replace(pattern, "");
|
||||
// Zotero.debug("after:\n"+abst);
|
||||
|
||||
if (newItem.abstractNote===undefined) {
|
||||
newItem.abstractNote = Zotero.Utilities.trim(abst);
|
||||
} else {
|
||||
newItem.abstractNote = newItem.abstractNote + "\n"
|
||||
+ Zotero.Utilities.trim(abst);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Zotero.debug("abst:\n"+newItem.abstractNote);
|
||||
|
||||
// 关键词/Keywords
|
||||
pattern = /【关键词】\s*<span[^>]*>(.*?)<\/a>*<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
var tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
var tag = Zotero.Utilities.trim(tags[i]);
|
||||
if (tag.length>0 && newItem.tags.indexOf(tag)<0) {
|
||||
newItem.tags.push(tag);
|
||||
}
|
||||
}
|
||||
// Zotero.debug("tags:\n"+tags);
|
||||
}
|
||||
pattern = /【Key words】\s*<span[^>]*>(.*?)<\/a>*<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
var tags = trimTags(pattern.exec(page)[1]).split(";");
|
||||
for (var i=0; i<tags.length; i++) {
|
||||
var tag = Zotero.Utilities.trim(tags[i]);
|
||||
if (tag.length>0 && newItem.tags.indexOf(tag)<0) {
|
||||
newItem.tags.push(tag);
|
||||
}
|
||||
}
|
||||
// Zotero.debug("tags:\n"+tags);
|
||||
}
|
||||
// Zotero.debug(newItem.tags);
|
||||
|
||||
// 会议名称 & 会议录名称 & 会议地点 & 会议时间
|
||||
pattern = /【会议名称】(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var conferenceName = trimTags(pattern.exec(page)[1]);
|
||||
newItem.conferenceName = conferenceName;
|
||||
// Zotero.debug("conferenceName: "+conferenceName);
|
||||
}
|
||||
pattern = /【会议录名称】(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var proceedingsTitle = trimTags(pattern.exec(page)[1]);
|
||||
newItem.proceedingsTitle = proceedingsTitle;
|
||||
// Zotero.debug("proceedingsTitle: "+proceedingsTitle);
|
||||
}
|
||||
pattern = /【会议地点】(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var place = trimTags(pattern.exec(page)[1]);
|
||||
newItem.place = place;
|
||||
// Zotero.debug("place: "+place);
|
||||
}
|
||||
pattern = /【会议时间】(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var date = trimTags(pattern.exec(page)[1]);
|
||||
newItem.date = date;
|
||||
// Zotero.debug("date: "+date);
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
});
|
||||
}
|
||||
|
||||
// work for newspaperArticle
|
||||
function scrapeAndParse4(url) {
|
||||
// Zotero.debug("newspaperArticle");
|
||||
Zotero.Utilities.doGet(url, function(page) {
|
||||
var pattern;
|
||||
|
||||
// 类型 & URL
|
||||
var itemType = "newspaperArticle";
|
||||
var newItem = new Zotero.Item(itemType);
|
||||
// Zotero.debug(url);
|
||||
newItem.url = url;
|
||||
|
||||
// 标题/Title
|
||||
pattern = /<span id="chTitle">(.*?)<\/span>/;
|
||||
if (pattern.test(page)) {
|
||||
var title = trimTags(pattern.exec(page)[1]);
|
||||
newItem.title = title;
|
||||
// Zotero.debug("title: "+title);
|
||||
}
|
||||
|
||||
// 副标题/引题
|
||||
var shortTitle;
|
||||
pattern = /<p>【(?:副标题|引题)】(.*?)(?=<\/p>)/;
|
||||
if (pattern.test(page)) {
|
||||
shortTitle = pattern.exec(page)[1];
|
||||
// Zotero.debug("shortTitle: "+shortTitle);
|
||||
newItem.shortTitle = Zotero.Utilities.trimInternal(shortTitle);
|
||||
}
|
||||
// Zotero.debug(newItem.shortTitle);
|
||||
|
||||
// 作者/Authors
|
||||
pattern = /【作\s*者】(.*?)<\/p>/;
|
||||
if (pattern.test(page)) {
|
||||
var authorNames = trimTags(pattern.exec(page)[1]).split(";");
|
||||
for (var i=0; i<authorNames.length; i++) {
|
||||
newItem.creators.push(
|
||||
Zotero.Utilities.cleanAuthor(
|
||||
Zotero.Utilities.trim(authorNames[i]),
|
||||
"author", true));
|
||||
}
|
||||
// Zotero.debug("authorNames:\n"+authorNames);
|
||||
}
|
||||
|
||||
// 正文快照/Abstract
|
||||
var abst;
|
||||
pattern = /<p>【正文快照】(.*?)(?=<\/p>)/;
|
||||
if (pattern.test(page)) {
|
||||
abst = pattern.exec(page)[1];
|
||||
// Zotero.debug("abst:\n"+abst);
|
||||
newItem.abstractNote = Zotero.Utilities.trimInternal(abst);
|
||||
}
|
||||
// Zotero.debug(newItem.abstractNote);
|
||||
|
||||
// 报纸名称 & DOI & 出版时间 & 版名 & 版号
|
||||
pattern = /【报纸名称】\s*<[^>]*>(.*?)<\/a>/;
|
||||
if (pattern.test(page)) {
|
||||
var publicationTitle = trimTags(pattern.exec(page)[1]);
|
||||
newItem.publicationTitle = publicationTitle;
|
||||
// Zotero.debug("publicationTitle: "+publicationTitle);
|
||||
}
|
||||
pattern = /【DOI】\s*(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var doi = pattern.exec(page)[1];
|
||||
newItem.DOI = doi;
|
||||
// Zotero.debug("doi: "+doi);
|
||||
}
|
||||
pattern = /【报纸日期】\s*(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var date = pattern.exec(page)[1];
|
||||
newItem.date = date;
|
||||
// Zotero.debug("date: "+date);
|
||||
}
|
||||
pattern = /【版名】\s*(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var section = pattern.exec(page)[1];
|
||||
newItem.section = section;
|
||||
// Zotero.debug("section: "+section);
|
||||
}
|
||||
pattern = /【版号】\s*(.*?)\s*<\/li>/;
|
||||
if (pattern.test(page)) {
|
||||
var edition = pattern.exec(page)[1];
|
||||
newItem.edition = edition;
|
||||
// Zotero.debug("edition: "+edition);
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
});
|
||||
}
|
||||
|
||||
// #########################
|
||||
// ##### API functions #####
|
||||
// #########################
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var pattern = /detail.aspx/;
|
||||
|
||||
if (pattern.test(url)) {
|
||||
var code = detectCode(url).toUpperCase();
|
||||
// Zotero.debug(code);
|
||||
if (code == "CJFQ" || code == "CJFD") {
|
||||
return "journalArticle";
|
||||
} else if (code == "CDFD") {
|
||||
return "thesis";
|
||||
} else if (code == "CMFD" || code == "CLKM") {
|
||||
return "thesis";
|
||||
} else if (code == "CPFD") {
|
||||
return "conferencePaper";
|
||||
} else if (code == "CCND") {
|
||||
return "newspaperArticle";
|
||||
} else if (code == "NONE") {
|
||||
Zotero.debug("Not support yet.");
|
||||
}
|
||||
}
|
||||
|
||||
pattern = /brief/;
|
||||
if (pattern.test(url)) {
|
||||
return "multiple"
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var nsResolver = getResolver(doc);
|
||||
var urls, tds, pages;
|
||||
|
||||
// Zotero.debug(url);
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
// Zotero.debug("Enter multiple.");
|
||||
// search page
|
||||
var items = new Array();
|
||||
|
||||
var xpath = '//iframe[@id="iframeResult"]';
|
||||
var iframe = doc.evaluate(xpath, doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if (iframe) {
|
||||
// fetch iframe's element
|
||||
// Zotero.debug(iframe.src);
|
||||
pages = Zotero.Utilities.retrieveSource(iframe.src);
|
||||
} else {
|
||||
// already in iframe
|
||||
// Zotero.debug("url:"+url);
|
||||
pages = Zotero.Utilities.retrieveSource(url);
|
||||
}
|
||||
|
||||
pattern = /<tr class=["']GTContentTitle["']>[\s\S]*?<\/tr>([\s\S]*?)<table class=["']pageBar_bottom["']/;
|
||||
var content;
|
||||
try {
|
||||
content = pattern.exec(pages)[1];
|
||||
// Zotero.debug(content);
|
||||
pattern = /<\/table>[\s\S]*?<a href=["'](.*?)["'][^>]*?><script[\s\S]*?(?:Replace[^\(]*?\()'(.*?)'\)/g;
|
||||
} catch (err) {
|
||||
content = pages;
|
||||
pattern = /<div class=["']GridTitleDiv["']>.*?<a href=["'](.*?)["'][^>]*?><script[\s\S]*?(?:Replace[^\(]*?\()'(.*?)'\)/g;
|
||||
}
|
||||
var res = pattern.exec(content);
|
||||
if (!res) {
|
||||
pattern = /<div class=["']GridTitleDiv["']>.*?<a href=["'](.*?)["'][^>]*?>(.*?)<\/a>/g;
|
||||
res = pattern.exec(content);
|
||||
if (!res) {
|
||||
pattern = /<\/table>[\s\S]*?<a href=["'](.*?)["'][^>]*?>(.*?)<\/a>/g;
|
||||
res = pattern.exec(content);
|
||||
}
|
||||
}
|
||||
var link;
|
||||
var title;
|
||||
while (res) {
|
||||
|
||||
title = Zotero.Utilities.cleanTags(res[2]);
|
||||
link = res[1];
|
||||
|
||||
patt = /^(http:\/\/.*?)\//;
|
||||
link = patt.exec(url)[1] + link;
|
||||
items[link] = trimTags(title);
|
||||
// Zotero.debug("title:"+title);
|
||||
// Zotero.debug("link:"+link);
|
||||
|
||||
res = pattern.exec(content);
|
||||
}
|
||||
// Zotero.debug(items);
|
||||
if (items.__count__) {
|
||||
// 让用户选择要保存哪些文献
|
||||
items = Zotero.selectItems(items);
|
||||
if (!items) return true;
|
||||
|
||||
urls = new Array();
|
||||
for (var url in items) {
|
||||
urls.push(url);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
urls = [url];
|
||||
}
|
||||
|
||||
if (urls) {
|
||||
// Zotero.debug(urls);
|
||||
|
||||
for (var i=0; i<urls.length; i++) {
|
||||
var type = detectWeb(null, urls[i]);
|
||||
// Zotero.debug(type);
|
||||
if (type == "journalArticle") {
|
||||
scrapeAndParse1(urls[i]);
|
||||
} else if (type == "thesis") {
|
||||
scrapeAndParse2(urls[i]);
|
||||
} else if (type == "conferencePaper") {
|
||||
scrapeAndParse3(urls[i]);
|
||||
} else if (type == "newspaperArticle") {
|
||||
scrapeAndParse4(urls[i]);
|
||||
} else {
|
||||
Zotero.debug("Not supported type.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
{
|
||||
"translatorID": "05d07af9-105a-4572-99f6-a8e231c0daef",
|
||||
"label": "COinS",
|
||||
"creator": "Simon Kornblith",
|
||||
"target": "",
|
||||
"minVersion": "2.1",
|
||||
"maxVersion": "",
|
||||
"priority": 300,
|
||||
"inRepository": true,
|
||||
"translatorType": 6,
|
||||
"browserSupport": "gcs",
|
||||
"lastUpdated": "2011-08-25 23:46:18"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var spanTags = doc.getElementsByTagName("span");
|
||||
|
||||
var encounteredType = false;
|
||||
|
||||
// This and the x: prefix in the XPath are to work around an issue with pages
|
||||
// served as application/xhtml+xml
|
||||
//
|
||||
// https://developer.mozilla.org/en/Introduction_to_using_XPath_in_JavaScript#Implementing_a_default_namespace_for_XML_documents
|
||||
function nsResolver() {
|
||||
return 'http://www.w3.org/1999/xhtml';
|
||||
}
|
||||
|
||||
var spans = doc.evaluate('//x:span[contains(@class, " Z3988") or contains(@class, "Z3988 ") or @class="Z3988"][@title]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var span;
|
||||
while(span = spans.iterateNext()) {
|
||||
// determine if it's a valid type
|
||||
var item = new Zotero.Item;
|
||||
var success = Zotero.Utilities.parseContextObject(span.title, item);
|
||||
|
||||
if(item.itemType) {
|
||||
if(encounteredType) {
|
||||
return "multiple";
|
||||
} else {
|
||||
encounteredType = item.itemType;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return encounteredType;
|
||||
}
|
||||
|
||||
// used to retrieve next COinS object when asynchronously parsing COinS objects
|
||||
// on a page
|
||||
function retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc) {
|
||||
if(needFullItems.length) {
|
||||
var item = needFullItems.shift();
|
||||
|
||||
Zotero.debug("looking up contextObject");
|
||||
var search = Zotero.loadTranslator("search");
|
||||
search.setHandler("itemDone", function(obj, item) {
|
||||
newItems.push(item);
|
||||
});
|
||||
search.setHandler("done", function() {
|
||||
retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc);
|
||||
});
|
||||
// look for translators
|
||||
search.setHandler("translators", function(obj, translators) {
|
||||
if(translators.length) {
|
||||
search.setTranslator(translators);
|
||||
search.translate();
|
||||
} else {
|
||||
retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc);
|
||||
}
|
||||
});
|
||||
|
||||
search.setSearch(item);
|
||||
search.getTranslators();
|
||||
} else {
|
||||
completeCOinS(newItems, couldUseFullItems, doc);
|
||||
Zotero.done();
|
||||
}
|
||||
}
|
||||
|
||||
// saves all COinS objects
|
||||
function completeCOinS(newItems, couldUseFullItems, doc) {
|
||||
if(newItems.length > 1) {
|
||||
var selectArray = new Array(newItems.length);
|
||||
for(var i in newItems) {
|
||||
selectArray[i] = newItems[i].title;
|
||||
}
|
||||
|
||||
Zotero.selectItems(selectArray, function (selectArray) {
|
||||
var useIndices = new Array();
|
||||
for(var i in selectArray) {
|
||||
useIndices.push(i);
|
||||
}
|
||||
completeItems(newItems, useIndices, couldUseFullItems);
|
||||
});
|
||||
} else if(newItems.length) {
|
||||
completeItems(newItems, [0], couldUseFullItems);
|
||||
}
|
||||
}
|
||||
|
||||
function completeItems(newItems, useIndices, couldUseFullItems, doc) {
|
||||
if(!useIndices.length) {
|
||||
return;
|
||||
}
|
||||
var i = useIndices.shift();
|
||||
|
||||
// grab full item if the COinS was missing an author
|
||||
if(couldUseFullItems[i]) {
|
||||
Zotero.debug("looking up contextObject");
|
||||
var search = Zotero.loadTranslator("search");
|
||||
|
||||
var firstItem = false;
|
||||
search.setHandler("itemDone", function(obj, newItem) {
|
||||
if(!firstItem) {
|
||||
// add doc as attachment
|
||||
newItem.attachments.push({document:doc});
|
||||
newItem.complete();
|
||||
firstItem = true;
|
||||
}
|
||||
});
|
||||
search.setHandler("done", function(obj) {
|
||||
// if we didn't find anything, use what we had before (even if it
|
||||
// lacks the creator)
|
||||
if(!firstItem) {
|
||||
newItems[i].complete();
|
||||
}
|
||||
// call next
|
||||
completeItems(newItems, useIndices, couldUseFullItems);
|
||||
});
|
||||
search.setHandler("translators", function(obj, translators) {
|
||||
if(translators.length) {
|
||||
search.setTranslator(translators);
|
||||
search.translate();
|
||||
} else {
|
||||
// add doc as attachment
|
||||
newItems[i].attachments.push({document:doc});
|
||||
newItems[i].complete();
|
||||
// call next
|
||||
completeItems(newItems, useIndices, couldUseFullItems);
|
||||
}
|
||||
});
|
||||
|
||||
search.setSearch(newItems[i]);
|
||||
search.getTranslators();
|
||||
} else {
|
||||
// add doc as attachment
|
||||
newItems[i].attachments.push({document:doc});
|
||||
newItems[i].complete();
|
||||
// call next
|
||||
completeItems(newItems, useIndices, couldUseFullItems);
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var newItems = new Array();
|
||||
var needFullItems = new Array();
|
||||
var couldUseFullItems = new Array();
|
||||
|
||||
|
||||
// See note in detectWeb()
|
||||
function nsResolver() {
|
||||
return 'http://www.w3.org/1999/xhtml';
|
||||
}
|
||||
|
||||
var spans = doc.evaluate('//x:span[contains(@class, " Z3988") or contains(@class, "Z3988 ") or @class="Z3988"][@title]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var span;
|
||||
while(span = spans.iterateNext()) {
|
||||
var spanTitle = span.title;
|
||||
var newItem = new Zotero.Item();
|
||||
newItem.repository = false; // do not save repository
|
||||
if(Zotero.Utilities.parseContextObject(spanTitle, newItem)) {
|
||||
if(newItem.title) {
|
||||
if(!newItem.creators.length) {
|
||||
// if we have a title but little other identifying
|
||||
// information, say we'll get full item later
|
||||
newItem.contextObject = spanTitle;
|
||||
couldUseFullItems[newItems.length] = true;
|
||||
}
|
||||
|
||||
// title and creators are minimum data to avoid looking up
|
||||
newItems.push(newItem);
|
||||
} else {
|
||||
// retrieve full item
|
||||
newItem.contextObject = spanTitle;
|
||||
needFullItems.push(newItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Zotero.debug(needFullItems);
|
||||
if(needFullItems.length) {
|
||||
// retrieve full items asynchronously
|
||||
Zotero.wait();
|
||||
retrieveNextCOinS(needFullItems, newItems, couldUseFullItems, doc);
|
||||
} else {
|
||||
completeCOinS(newItems, couldUseFullItems, doc);
|
||||
}
|
||||
}
|
||||
|
||||
function doExport() {
|
||||
var item;
|
||||
var co;
|
||||
|
||||
while (item = Zotero.nextItem()) {
|
||||
co = Zotero.Utilities.createContextObject(item, "1.0");
|
||||
Zotero.write("<span class='Z3988' title='"+ Zotero.Utilities.htmlSpecialChars(co) +"'></span>\n");
|
||||
}
|
||||
}
|
||||
/** BEGIN TEST CASES **/
|
||||
var testCases = [
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.husdal.com/2011/06/19/disruptions-in-supply-networks/",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "journalArticle",
|
||||
"creators": [
|
||||
{
|
||||
"firstName": "Phil",
|
||||
"lastName": "Greening",
|
||||
"creatorType": "author"
|
||||
},
|
||||
{
|
||||
"firstName": "Christine",
|
||||
"lastName": "Rutherford",
|
||||
"creatorType": "author"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{}
|
||||
],
|
||||
"publicationTitle": "International Journal of Logistics Management",
|
||||
"title": "Disruptions and supply networks: a multi-level, multi-theoretical relational perspective",
|
||||
"date": "2011",
|
||||
"volume": "22",
|
||||
"issue": "1",
|
||||
"pages": "104-126",
|
||||
"libraryCatalog": false,
|
||||
"shortTitle": "Disruptions and supply networks"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://gamblershouse.wordpress.com/2011/06/19/the-view-from-dolores/",
|
||||
"items": "multiple"
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.hubmed.org/display.cgi?uids=21665052",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "journalArticle",
|
||||
"creators": [
|
||||
{
|
||||
"creatorType": "author",
|
||||
"firstName": "Hui-Wen Vivian",
|
||||
"lastName": "Tang"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{}
|
||||
],
|
||||
"publicationTitle": "Evaluation and Program Planning",
|
||||
"volume": "34",
|
||||
"ISSN": "01497189",
|
||||
"date": "11/2011",
|
||||
"pages": "343-352",
|
||||
"DOI": "10.1016/j.evalprogplan.2011.04.002",
|
||||
"url": "http://linkinghub.elsevier.com/retrieve/pii/S0149718911000449",
|
||||
"title": "Optimizing an immersion ESL curriculum using analytic hierarchy process",
|
||||
"libraryCatalog": "CrossRef"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
/** END TEST CASES **/
|
|
@ -1,71 +0,0 @@
|
|||
{
|
||||
"translatorID":"303c2744-ea37-4806-853d-e1ca67be6818",
|
||||
"translatorType":4,
|
||||
"label":"CSIRO Publishing",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://(www.)?publish.csiro.au/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-04-23 09:45:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//a[@class="searchBoldBlue"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//a[@class="linkjournal"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (url.indexOf("/view/journals/") != -1 || url.indexOf("paper") != -1) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var links = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
if (doc.evaluate('//a[@class="searchBoldBlue"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var arts = doc.evaluate('//a[@class="searchBoldBlue"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var art = arts.iterateNext();
|
||||
while (art) {
|
||||
items[art.href] = art.textContent;
|
||||
art = arts.iterateNext();
|
||||
}
|
||||
} else if (doc.evaluate('//a[@class="linkjournal"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var arts = doc.evaluate('//a[@class="linkjournal"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var titles = doc.evaluate('//td[3]//td[1]/table/tbody/tr/td/b', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var art;
|
||||
var title;
|
||||
while ((art = arts.iterateNext()) && (title = titles.iterateNext())) {
|
||||
items[art.href] = title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
links.push(i.match(/([^/=.htm]*)(.htm)?$/)[1]);
|
||||
}
|
||||
} else {
|
||||
links.push(url.match(/([^/=.htm]*)(.htm)?$/)[1]);
|
||||
}
|
||||
for (var i in links) {
|
||||
var newURL = 'http://www.publish.csiro.au/view/journals/dsp_journal_retrieve_citation.cfm?ct=' + links[i] + '.ris';
|
||||
var pdfURL = 'http://www.publish.csiro.au/?act=view_file&file_id=' + links[i] + '.pdf';
|
||||
Zotero.Utilities.HTTP.doGet(newURL, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.itemType = "journalArticle";
|
||||
if (item.notes[0]) {
|
||||
item.abstractNote = item.notes[0].note;
|
||||
}
|
||||
item.attachments = [
|
||||
{url:pdfURL, title:"CSIRO Publishing PDF", mimeType:"application/pdf"},
|
||||
{url:newURL, title:"CSIRO Publishing Snaphost", mimeType:"text/html"}
|
||||
];
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
}
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,268 +0,0 @@
|
|||
{
|
||||
"translatorID":"24d9f058-3eb3-4d70-b78f-1ba1aef2128d",
|
||||
"translatorType":5,
|
||||
"label":"CTX",
|
||||
"creator":"Avram Lyon and Simon Kornblith",
|
||||
"target":"^http://freecite\\.library\\.brown\\.edu",
|
||||
"minVersion":"2.0",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"configOptions":{"dataMode":"line"},
|
||||
"inRepository":false,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
/*
|
||||
ContextObjects in XML Translator
|
||||
Copyright (C) 2010 Avram Lyon, ajlyon@gmail.com
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/*This translator imports OpenURL ContextObjects encapsulated in XML
|
||||
* documents, as described at:
|
||||
* http://alcme.oclc.org/openurl/servlet/OAIHandler?verb=GetRecord&metadataPrefix=oai_dc&identifier=info:ofi/fmt:xml:xsd:ctx
|
||||
* The schema for such XML documents is at:
|
||||
* http://www.openurl.info/registry/docs/xsd/info:ofi/fmt:xml:xsd:ctx
|
||||
*
|
||||
* This format is used in several places online, including Brown University's FreeCite
|
||||
* Citation parser (http://freecite.library.brown.edu/welcome) and Oslo University's
|
||||
* X-Port (http://www.ub.uio.no/portal/gs.htm or http://x-port.uio.no/).
|
||||
|
||||
* Our input looks like this:
|
||||
<ctx:context-objects xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='info:ofi/fmt:xml:xsd:ctx http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:ctx' xmlns:ctx='info:ofi/fmt:xml:xsd:ctx'>
|
||||
<ctx:context-object timestamp='2010-01-02T16:55:48-05:00' encoding='info:ofi/enc:UTF-8' version='Z39.88-2004' identifier=''>
|
||||
<ctx:referent>
|
||||
<ctx:metadata-by-val>
|
||||
<ctx:format>info:ofi/fmt:xml:xsd:journal</ctx:format>
|
||||
<ctx:metadata>
|
||||
<journal xmlns:rft='info:ofi/fmt:xml:xsd:journal' xsi:schemaLocation='info:ofi/fmt:xml:xsd:journal http://www.openurl.info/registry/docs/info:ofi/fmt:xml:xsd:journal'>
|
||||
<rft:atitle>Acute Myocardial Infarction in the Medicare population: process of care and clinical outcomes</rft:atitle>
|
||||
<rft:spage>2530</rft:spage>
|
||||
<rft:date>1992</rft:date>
|
||||
<rft:stitle>Journal of the American Medical Association</rft:stitle>
|
||||
<rft:genre>article</rft:genre>
|
||||
<rft:volume>18</rft:volume>
|
||||
<rft:epage>2536</rft:epage>
|
||||
<rft:au>I S Udvarhelyi</rft:au>
|
||||
<rft:au>C A Gatsonis</rft:au>
|
||||
<rft:au>A M Epstein</rft:au>
|
||||
<rft:au>C L Pashos</rft:au>
|
||||
<rft:au>J P Newhouse</rft:au>
|
||||
<rft:au>B J McNeil</rft:au>
|
||||
</journal>
|
||||
</ctx:metadata>
|
||||
</ctx:metadata-by-val>
|
||||
</ctx:referent>
|
||||
</ctx:context-object>
|
||||
</ctx:context-objects>
|
||||
*
|
||||
* The approach we will take is to convert this into COinS, so that we can
|
||||
* piggy-back off of the perhaps more robust support in the core Zotero code.
|
||||
*/
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var texts = [], text = "";
|
||||
var codes = doc.getElementsByTagName("code");
|
||||
for(var i = 0; i < codes.length; i++) {
|
||||
text = codes[i].textContent;
|
||||
text.replace(/</g,"<").replace(/>/g,">");
|
||||
texts.push(text);
|
||||
}
|
||||
return detectInString(texts);
|
||||
};
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var texts = [], text = "";
|
||||
var codes = doc.getElementsByTagName("code");
|
||||
for(var i = 0; i < codes.length; i++) {
|
||||
text = codes[i].textContent;
|
||||
text.replace(/</g,"<").replace(/>/g,">");
|
||||
texts.push(text);
|
||||
}
|
||||
doImportFromText(texts, true);
|
||||
};
|
||||
|
||||
function doImport() {
|
||||
var text = "";
|
||||
var line;
|
||||
while(line = Zotero.read()) {
|
||||
text += line;
|
||||
}
|
||||
return doImportFromText(text, false);
|
||||
}
|
||||
|
||||
function detectImport() {
|
||||
var text = "";
|
||||
var line;
|
||||
while(line = Zotero.read()) {
|
||||
text += line;
|
||||
}
|
||||
return detectInString(text) != false;
|
||||
}
|
||||
|
||||
function detectInString(text) {
|
||||
var detectedType = false;
|
||||
|
||||
var spans = [];
|
||||
|
||||
// This is because we want to be able to read multiple such CTX elements in a single page
|
||||
if (typeof text != "string" && text.length >= 1) {
|
||||
spans = text.map(contextObjectXMLToCOinS).reduce(function(a,b){return a.concat(b);});
|
||||
} else {
|
||||
spans = contextObjectXMLToCOinS(text);
|
||||
}
|
||||
|
||||
for (var i = 0 ; i < spans.length ; i++) {
|
||||
var item = new Zotero.Item;
|
||||
var success = Zotero.Utilities.parseContextObject(spans[i], item);
|
||||
if(item.itemType) {
|
||||
Zotero.debug("Found " + item.itemType);
|
||||
if (detectedType) {
|
||||
return "multiple";
|
||||
}
|
||||
detectedType = item.itemType;
|
||||
} else {
|
||||
Zotero.debug("Type not found");
|
||||
}
|
||||
}
|
||||
return detectedType;
|
||||
};
|
||||
|
||||
/* Takes the string of the ContextObject XML format
|
||||
* and returns an array of COinS titles of the same, per the COinS
|
||||
* specification.
|
||||
*/
|
||||
function contextObjectXMLToCOinS (text) {
|
||||
try {
|
||||
var doc = new XML(text);
|
||||
}
|
||||
catch (e) {
|
||||
return [];
|
||||
}
|
||||
|
||||
/* Here and elsewhere, we are using the E4X syntax for XML */
|
||||
var objects = doc..*::["context-object"];
|
||||
|
||||
/* Bail out if no object */
|
||||
if (objects.length() == 0) {
|
||||
Zotero.debug("No context object");
|
||||
return [];
|
||||
}
|
||||
|
||||
var titles = [];
|
||||
|
||||
for (var i = 0; i < objects.length(); i++) {
|
||||
Zotero.debug("Processing object: " + objects[i].text());
|
||||
var pieces = [];
|
||||
|
||||
|
||||
var version = objects[i].@version;
|
||||
pieces.push("ctx_ver="+encodeURIComponent(version));
|
||||
|
||||
var format = objects[i]..*::format;
|
||||
// Now convert this to the corresponding Key/Encoded-Value format; see note below.
|
||||
// Check if this is unknown; if it is, skip
|
||||
if (format.text() == "info:ofi/fmt:xml:xsd:unknown") {
|
||||
Zotero.debug("Skipping object of type 'unknown'");
|
||||
continue;
|
||||
}
|
||||
format = mapXMLtoKEV[format.text()];
|
||||
|
||||
pieces.push("rft_val_fmt=" + encodeURIComponent(format));
|
||||
|
||||
// Here we disregard the namespaces
|
||||
var fields = objects[i]..*::metadata.children()[0].*::*;
|
||||
var field;
|
||||
|
||||
for each (field in fields) {
|
||||
var name = field.localName();
|
||||
// We can hardcode the 'rft' namespace to keep COinS valid
|
||||
name = "rft."+name;
|
||||
var value = encodeURIComponent(field.text());
|
||||
pieces.push(name + "=" + value);
|
||||
}
|
||||
|
||||
var title = pieces.join("&");
|
||||
var span = "<span title='" + title + "' class='Z3988'></span>\n";
|
||||
Zotero.debug("Made span: " + span);
|
||||
titles.push(title);
|
||||
}
|
||||
return titles;
|
||||
};
|
||||
|
||||
function doImportFromText(text, showPrompt) {
|
||||
var spans = [], items = [], zoteroItems = [];
|
||||
|
||||
// This is because we want to be able to read multiple such CTX elements in a single page
|
||||
if (typeof text != "string" && text.length >= 1) {
|
||||
spans = text.map(contextObjectXMLToCOinS).reduce(function(a,b){return a.concat(b);});
|
||||
} else {
|
||||
spans = contextObjectXMLToCOinS(text);
|
||||
}
|
||||
|
||||
for (var i = 0 ; i < spans.length ; i++) {
|
||||
Zotero.debug("Processing span: "+spans[i]);
|
||||
var item = new Zotero.Item;
|
||||
Zotero.Utilities.parseContextObject(spans[i], item);
|
||||
if(item.itemType) {
|
||||
Zotero.debug("Found " + item.itemType);
|
||||
items.push(item.title);
|
||||
zoteroItems.push(item);
|
||||
// Set publicationTitle to the short title if only the latter is specified
|
||||
if (item.journalAbbreviation && !item.publicationTitle) {
|
||||
item.publicationTitle = item.journalAbbreviation;
|
||||
}
|
||||
// If we're in non-prompting mode, save right away
|
||||
if (showPrompt === false) {
|
||||
item.complete();
|
||||
}
|
||||
} else {
|
||||
Zotero.debug("Type not found");
|
||||
}
|
||||
}
|
||||
// Since we want to prompt, we have to parse twice.
|
||||
if(showPrompt === true) {
|
||||
if(items.length == 1) {
|
||||
item.complete();
|
||||
} else {
|
||||
items = Zotero.selectItems(items);
|
||||
if(!items) return true;
|
||||
for(var i in items) {
|
||||
zoteroItems[i].complete();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* These two arrays are needed because COinS uses Key/Escaped-Value, which has a different
|
||||
* set of format codes. Codes from "Registry for the OpenURL Framework - ANSI/NISO Z39.88-2004":
|
||||
* http://alcme.oclc.org/openurl/servlet/OAIHandler?verb=ListRecords&metadataPrefix=oai_dc&set=Core:Metadata+Formats
|
||||
*/
|
||||
var mapKEVtoXML = {
|
||||
'info:ofi/fmt:kev:mtx:book' : 'info:ofi/fmt:xml:xsd:book', // Books
|
||||
'info:ofi/fmt:kev:mtx:dc' : 'info:ofi/fmt:xml:xsd:oai_dc', // Dublin Core
|
||||
'info:ofi/fmt:kev:mtx:dissertation' : 'info:ofi/fmt:xml:xsd:dissertation', // Dissertations
|
||||
'info:ofi/fmt:kev:mtx:journal' : 'info:ofi/fmt:xml:xsd:journal', // Journals
|
||||
'info:ofi/fmt:kev:mtx:patent' : 'info:ofi/fmt:xml:xsd:patent', // Patents
|
||||
'info:ofi/fmt:kev:mtx:sch_svc' : 'info:ofi/fmt:xml:xsd:sch_svc' // Scholarly ServiceTypes
|
||||
};
|
||||
|
||||
var mapXMLtoKEV = {
|
||||
'info:ofi/fmt:xml:xsd:book' : 'info:ofi/fmt:kev:mtx:book', // Books
|
||||
'info:ofi/fmt:xml:xsd:oai_dc' : 'info:ofi/fmt:kev:mtx:dc', // Dublin Core
|
||||
'info:ofi/fmt:xml:xsd:dissertation' : 'info:ofi/fmt:kev:mtx:dissertation', // Dissertations
|
||||
'info:ofi/fmt:xml:xsd:journal' : 'info:ofi/fmt:kev:mtx:journal', // Journals
|
||||
'info:ofi/fmt:xml:xsd:patent' : 'info:ofi/fmt:kev:mtx:patent', // Patents
|
||||
'info:ofi/fmt:xml:xsd:sch_svc' : 'info:ofi/fmt:kev:mtx:sch_svc' // Scholarly ServiceTypes
|
||||
};
|
|
@ -1,184 +0,0 @@
|
|||
{
|
||||
"translatorID": "850f4c5f-71fb-4669-b7da-7fb7a95500ef",
|
||||
"label": "Cambridge Journals Online",
|
||||
"creator": "Sean Takats, Michael Berkowitz and Avram Lyon",
|
||||
"target": "^https?://[^/]*journals.cambridge.org[^/]*//?action/(quickSearch|search|displayAbstract|displayFulltext|displayIssue)",
|
||||
"minVersion": "2.1",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"browserSupport": "gcs",
|
||||
"inRepository": true,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-08-22 22:29:49"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace=doc.documentElement.namespaceURI;
|
||||
var nsResolver=namespace?function(prefix) {
|
||||
return (prefix=="x")?namespace:null;
|
||||
}:null;
|
||||
var xpath = '//div[@class="tableofcontents-row"][div/input[@type="checkbox"][@name="toView"]]';
|
||||
if ((url.indexOf("/action/displayAbstract") != -1) || (url.indexOf("action/displayFulltext") != -1)){
|
||||
return "journalArticle";
|
||||
} else if (doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()){
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url){
|
||||
var namespace=doc.documentElement.namespaceURI;
|
||||
var nsResolver=namespace?function(prefix) {
|
||||
return (prefix=="x")?namespace:null;
|
||||
}:null;
|
||||
var host = doc.location.host;
|
||||
var urlstring="http://" + host + "/action/exportCitation";
|
||||
var datastring="format=RIS&emailId=&Download=Download&componentIds=";
|
||||
var links = new Array();
|
||||
if(detectWeb(doc, url) == "multiple"){
|
||||
var xpath = '//div[@class="tableofcontents-row"][div/input[@type="checkbox"][@name="toView"]]';
|
||||
var tableRows = doc.evaluate(xpath, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var tableRow;
|
||||
var items=new Array();
|
||||
while (tableRow = tableRows.iterateNext()){
|
||||
var id = doc.evaluate('./div/input[@type="checkbox"][@name="toView"]/@value', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
var title = doc.evaluate('.//h3', tableRow, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
items['http://' + host + '/action/displayAbstract?aid=' + id.nodeValue] = Zotero.Utilities.capitalizeTitle(title.textContent);
|
||||
}
|
||||
Zotero.selectItems(items, function(items) {
|
||||
for (var i in items) {
|
||||
links.push(i);
|
||||
}
|
||||
Zotero.Utilities.processDocuments(links, scrape,
|
||||
function() {Zotero.done();});
|
||||
});
|
||||
} else {
|
||||
scrape(doc);
|
||||
}
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
function scrape (doc) {
|
||||
var namespace=doc.documentElement.namespaceURI;
|
||||
var nsResolver=namespace?function(prefix) {
|
||||
return (prefix=="x")?namespace:null;
|
||||
}:null;
|
||||
|
||||
var host = doc.location.host;
|
||||
var urlstring="http://" + host + "/action/exportCitation";
|
||||
var datastring="format=RIS&emailId=&Download=Download&componentIds=";
|
||||
|
||||
var locURL = doc.location.href;
|
||||
var abs;
|
||||
if (abs = doc.evaluate('//p[@class="section-title" and contains(text(),"Abstract")]/following-sibling::p[not(@class) and text() != ""]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
abs = abs.textContent;
|
||||
}
|
||||
if (doc.evaluate('//p[@class="KeyWords"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var kws = doc.evaluate('//p[@class="KeyWords"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.substr(11).split('; ');
|
||||
}
|
||||
var pdfpath='//div/ul/li/a[contains(text(), "PDF")]';
|
||||
if (doc.evaluate(pdfpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var pdflink = doc.evaluate(pdfpath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
}
|
||||
idRe = /aid=([0-9]+)/
|
||||
var m = idRe.exec(locURL);
|
||||
var id = m[1];
|
||||
Zotero.Utilities.doGet(urlstring + "?" + datastring+id, function(text) {
|
||||
text = text.replace(/(^|\n)?([A-Z\d]{2})\s+\-\s+(\n)?/g, "\n$2 - $3");
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
// Use RIS importer
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.attachments = [{url:locURL,
|
||||
title:"Cambridge Journals Snapshot",
|
||||
mimeType:"text/html"}];
|
||||
item.title = Zotero.Utilities.capitalizeTitle(item.title);
|
||||
var authors = item.creators;
|
||||
item.creators = new Array();
|
||||
for each (var aut in authors) {
|
||||
// correct all-caps, if present
|
||||
if (aut.firstName && aut.firstName.toUpperCase() == aut.firstName)
|
||||
aut.firstName=Zotero.Utilities.capitalizeTitle(aut.firstName.toLowerCase(),true);
|
||||
if (aut.lastName && aut.lastName.toUpperCase() == aut.lastName)
|
||||
aut.lastName=Zotero.Utilities.capitalizeTitle(aut.lastName.toLowerCase(),true);
|
||||
item.creators.push({firstName:aut.firstName,
|
||||
lastName:aut.lastName,
|
||||
creatorType:"author"});
|
||||
}
|
||||
if (item.tags.length === 1) item.tags = item.tags[0].split(",");
|
||||
if (abs) item.abstractNote = Zotero.Utilities.trimInternal(abs);
|
||||
if (pdflink) {
|
||||
// Some PDFs aren't paywalled, so they don't need the 2nd request
|
||||
item.attachments.push({
|
||||
url: pdflink,
|
||||
title: "Cambridge Journals PDF",
|
||||
mimeType:"application/pdf"
|
||||
});
|
||||
Zotero.Utilities.doGet(pdflink, function(text) {
|
||||
var domain = pdflink.match(/^https?:\/\/[^\/]+\//);
|
||||
var realpdf = text.match(/<iframe src="\/(action\/displayFulltext[^"]+)"/);
|
||||
if (realpdf && domain) {
|
||||
// If we matched the IFRAME, the first attachment must be bad
|
||||
for (var i in item.attachments) {
|
||||
if (item.attachments[i].mimeType.indexOf("pdf") !== -1)
|
||||
item.attachments[i].url = (domain[0]+realpdf[1]).replace(/&/g,"&");
|
||||
};
|
||||
}
|
||||
}, function () {
|
||||
item.complete();
|
||||
});
|
||||
} else {
|
||||
item.complete();
|
||||
}
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
}
|
||||
|
||||
/** BEGIN TEST CASES **/
|
||||
var testCases = [
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://journals.cambridge.org/action/quickSearch?quickSearchType=search_combined&inputField1=tatar&fieldStartMonth=01&fieldStartYear=1800&fieldEndMonth=12&fieldEndYear=2011&searchType=ADVANCESEARCH&searchTypeFrom=quickSearch&fieldScjrnl=All&fieldSccats=All&selectField1=%23&jnlId=AMS&issId=02&volId=45&journalSearchType=all",
|
||||
"items": "multiple"
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://journals.cambridge.org/action/displayAbstract?fromPage=online&aid=8267699&fulltextType=RA&fileId=S0021875810001738",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "journalArticle",
|
||||
"creators": [
|
||||
{
|
||||
"firstName": "Laurie A.",
|
||||
"lastName": "Rodrigues",
|
||||
"creatorType": "author"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [
|
||||
""
|
||||
],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{
|
||||
"url": false,
|
||||
"title": "Cambridge Journals Snapshot",
|
||||
"mimeType": "text/html"
|
||||
}
|
||||
],
|
||||
"date": "2011",
|
||||
"title": "“SAMO© as an Escape Clause”: Jean-Michel Basquiat's Engagement with a Commodified American Africanism",
|
||||
"publicationTitle": "Journal of American Studies",
|
||||
"pages": "227-243",
|
||||
"volume": "45",
|
||||
"issue": "02",
|
||||
"DOI": "10.1017/S0021875810001738",
|
||||
"abstractNote": "Heir to the racist configuration of the American art exchange and the delimiting appraisals of blackness in the American mainstream media, Jean-Michel Basquiat appeared on the late 1970s New York City street art scene – then he called himself “SAMO.” Not long thereafter, Basquiat grew into one of the most influential artists of an international movement that began around 1980, marked by a return to figurative painting. Given its rough, seemingly untrained and extreme, conceptual nature, Basquiat's high-art oeuvre might not look so sophisticated to the uninformed viewer. However, Basquiat's work reveals a powerful poetic and visual gift, “heady enough to confound academics and hip enough to capture the attention span of the hip hop nation,” as Greg Tate has remarked. As noted by Richard Marshall, Basquiat's aesthetic strength actually comes from his striving “to achieve a balance between the visual and intellectual attributes” of his artwork. Like Marshall, Tate, and others, I will connect with Basquiat's unique, self-reflexively experimental visual practices of signifying and examine anew Basquiat's active contribution to his self-alienation, as Hebdige has called it. Basquiat's aesthetic makes of his paintings economies of accumulation, building a productive play of contingency from the mainstream's constructions of race. This aesthetic move speaks to a need for escape from the perceived epistemic necessities of blackness. Through these economies of accumulation we see, as Tate has pointed out, Basquiat's “intellectual obsession” with issues such as ancestry/modernity, personhood/property and originality/origins of knowledge, driven by his tireless need to problematize mainstream media's discourses surrounding race – in other words, a commodified American Africanism.",
|
||||
"libraryCatalog": "Cambridge Journals Online",
|
||||
"shortTitle": "“SAMO© as an Escape Clause”"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
/** END TEST CASES **/
|
|
@ -1,208 +0,0 @@
|
|||
{
|
||||
"translatorID":"82174f4f-8c13-403b-99b2-affc7bc7769b",
|
||||
"translatorType":4,
|
||||
"label":"Cambridge Scientific Abstracts",
|
||||
"creator":"Simon Kornblith and Michael Berkowitz",
|
||||
"target":"https?://[^/]+/ids70/(?:results.php|view_record.php)",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-06-14 04:31:00"
|
||||
}
|
||||
|
||||
/* Provides support for databases of Cambridge Scientific Abstracts
|
||||
Tested with CSA Illumina, http://www.csa.com/
|
||||
CSA does not provide stable URLs
|
||||
*/
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
if(url.indexOf("/results.php") != -1) {
|
||||
var type = doc.evaluate('//td[@class="rt_tab_on"]', doc, nsResolver, XPathResult.ANY_TYPE,
|
||||
null).iterateNext().textContent;
|
||||
|
||||
if(type.substr(0, 15) == "Published Works") {
|
||||
return "multiple";
|
||||
}
|
||||
} else {
|
||||
// default to journal
|
||||
var itemType = "journalArticle";
|
||||
|
||||
var type = doc.evaluate('//tr[td[1][@class="data_heading"]/text() = "Publication Type"]/td[3]',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(type) {
|
||||
type = Zotero.Utilities.trimInternal(type.textContent);
|
||||
if(type == "Book Chapter") {
|
||||
return "bookSection";
|
||||
} else if(type.substr(0, 4) == "Book") {
|
||||
return "book";
|
||||
} else if(type.substr(0, 12) == "Dissertation") {
|
||||
return "thesis";
|
||||
} else if(type == "Catalog") {
|
||||
return "magazineArticle";
|
||||
}
|
||||
}
|
||||
return "journalArticle";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function scrape(doc) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var itemType = "journalArticle";
|
||||
|
||||
var type = doc.evaluate('//tr[td[1][@class="data_heading"]/text() = "Publication Type"]/td[3]',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(type) {
|
||||
type = Zotero.Utilities.trimInternal(type.textContent);
|
||||
if(type == "Book Chapter") {
|
||||
itemType = "bookSection";
|
||||
} else if(type.substr(0, 4) == "Book") {
|
||||
itemType = "book";
|
||||
} else if(type.substr(0, 12) == "Dissertation") {
|
||||
itemType = "thesis";
|
||||
} else if(type == "Catalog") {
|
||||
itemType = "magazineArticle";
|
||||
}
|
||||
}
|
||||
|
||||
var newItem = new Zotero.Item(itemType);
|
||||
|
||||
newItem.attachments = [{document:doc, title:"Cambridge Scientific Abstracts Snapshot"}];
|
||||
newItem.title = Zotero.Utilities.trimInternal(doc.evaluate('//tr/td[3][@class="data_emphasis"]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
|
||||
var dataRows = doc.evaluate('//tr[td[3][@class="data_content"]]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null);
|
||||
var dataRow;
|
||||
while(dataRow = dataRows.iterateNext()) {
|
||||
var tds = dataRow.getElementsByTagName("td");
|
||||
var heading = Zotero.Utilities.trimInternal(tds[0].textContent).toLowerCase();
|
||||
var content = Zotero.Utilities.trimInternal(tds[2].textContent);
|
||||
if(heading == "database") {
|
||||
newItem.repository = "Cambridge Scientific Abstracts ("+content+")";
|
||||
} else if(heading == "author") {
|
||||
var authors = content.split("; ");
|
||||
for each(var author in authors) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author.replace(/\d+/g, ""), "author", true));
|
||||
}
|
||||
} else if(heading == "source") {
|
||||
if(itemType == "journalArticle") {
|
||||
var parts = content.split(/(,|;)/);
|
||||
newItem.publicationTitle = parts.shift();
|
||||
for each (var i in parts) {
|
||||
if (i.match(/\d+/)) {
|
||||
if (i.match(/v(ol)?/)) {
|
||||
newItem.volume = i.match(/\d+/)[0];
|
||||
} else if (i.match(/pp/)) {
|
||||
newItem.pages = i.match(/[\d\-]+/)[0];
|
||||
} else if (i.match(/no?/)) {
|
||||
newItem.issue = i.match(/\d+/)[0];
|
||||
} else if (i.match(/\d{4}/)) {
|
||||
newItem.date = Zotero.Utilities.trimInternal(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(itemType == "book") {
|
||||
var m = content.match(/^([^:]+): ([^,0-9]+)/);
|
||||
if(m) {
|
||||
newItem.place = m[1];
|
||||
newItem.publisher = m[2];
|
||||
}
|
||||
} else if(itemType == "bookSection") {
|
||||
var untitled = !newItem.publicationTitle;
|
||||
if(untitled || (content.length > newItem.publicationTitle.length
|
||||
&& content.substr(0, newItem.publicationTitle.length) == newItem.publicationTitle)
|
||||
|| content.indexOf(newItem.publicationTitle)) {
|
||||
if (content.indexOf(newItem.publicationTitle) > 4) {
|
||||
// This means we probably have a book author or editor first
|
||||
var m = content.match(/^([^\.]+)\./);
|
||||
if (m) newItem.creators.push(
|
||||
Zotero.Utilities.cleanAuthor(m[1], "bookAuthor", true));
|
||||
}
|
||||
var m = content.match(/\)\. ([^:()]+): ([^,0-9]+)/);
|
||||
if(m) {
|
||||
if (untitled) {
|
||||
var n = content.match(/\([0-9]{4}\)([^(]*)/);
|
||||
if (n) newItem.publicationTitle = n[1];
|
||||
}
|
||||
newItem.place = m[1];
|
||||
newItem.publisher = m[2];
|
||||
}
|
||||
m = content.match(/\(pp. ([\-0-9]+)\)/);
|
||||
if(m) newItem.pages = m[1];
|
||||
}
|
||||
}
|
||||
} else if(heading == "monograph title") {
|
||||
newItem.publicationTitle = content;
|
||||
} else if(heading == "series title") {
|
||||
newItem.series = content;
|
||||
} else if(heading == "issn") {
|
||||
newItem.ISSN = content;
|
||||
} else if(heading == "isbn") {
|
||||
newItem.ISBN = content;
|
||||
} else if(heading == "abstract") {
|
||||
newItem.abstractNote = content;
|
||||
} else if(heading == "notes") {
|
||||
newItem.extra = content;
|
||||
} else if(heading == "publication year") {
|
||||
if(!newItem.date) newItem.date = content;
|
||||
} else if(heading == "information provider") {
|
||||
if(content.substr(0, 19) == "http://dx.doi.org/") {
|
||||
newItem.DOI = content.substr(19);
|
||||
}
|
||||
} else if(heading == "journal volume") {
|
||||
newItem.volume = content;
|
||||
} else if(heading == "journal pages") {
|
||||
newItem.pages = content;
|
||||
} else if(heading == "journal issue") {
|
||||
newItem.issue = content;
|
||||
} else if(heading == "affiliation") {
|
||||
if(newItem.itemType == "thesis") {
|
||||
newItem.publisher = content;
|
||||
}
|
||||
} else if(heading == "pages") { // This is for book sections
|
||||
newItem.pages = content;
|
||||
} else if(heading == "language") {
|
||||
newItem.language = content;
|
||||
}
|
||||
}
|
||||
|
||||
var terms = doc.evaluate('//input[substring(@name, 1, 4) = "term"]', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null);
|
||||
var term;
|
||||
while(term = terms.iterateNext()) {
|
||||
newItem.tags.push(term.value.replace(/ [0-9]{3,}$/, ""));
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
if(url.indexOf("/results.php") != -1) {
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, '/view_record\.php\?', '^(?:View Record|More\.{3})$');
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
if(!items) return true;
|
||||
|
||||
var urls = new Array();
|
||||
for(var url in items) {
|
||||
urls.push(url);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done() })
|
||||
Zotero.wait();
|
||||
} else {
|
||||
scrape(doc);
|
||||
}
|
||||
}
|
|
@ -1,112 +0,0 @@
|
|||
{
|
||||
"translatorID":"84799379-7bc5-4e55-9817-baf297d129fe",
|
||||
"translatorType":4,
|
||||
"label":"CanLII",
|
||||
"creator":"Bill McKinney",
|
||||
"target":"http:\\/\\/www\\.canlii\\.org\\/en\\/[^\\/]+\\/[^\\/]+\\/doc\\/.+",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2007-06-18 18:15:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var canLiiRegexp = /http:\/\/www\.canlii\.org\/en\/[^\/]+\/[^\/]+\/doc\/.+/
|
||||
if(canLiiRegexp .test(url)) {
|
||||
return "book";
|
||||
} else {
|
||||
var aTags = doc.getElementsByTagName("a");
|
||||
for(var i=0; i<aTags.length; i++) {
|
||||
if(articleRegexp.test(aTags[i].href)) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function associateMeta(newItem, metaTags, field, zoteroField) {
|
||||
var field = metaTags.namedItem(field);
|
||||
if(field) {
|
||||
newItem[zoteroField] = field.getAttribute("content");
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("case");
|
||||
|
||||
var metaTags = doc.getElementsByTagName("meta");
|
||||
associateMeta(newItem, metaTags, "DC.Title", "title");
|
||||
associateMeta(newItem, metaTags, "DC.Date", "dateDecided");
|
||||
associateMeta(newItem, metaTags, "DC.Language", "language");
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
var field = metaTags.namedItem("DC.Title");
|
||||
var tmpText = "";
|
||||
if(field) {
|
||||
tmpText = field.getAttribute("content");
|
||||
var capRe = /^(.+),\s+(\d{4})\s+(\w+)\s+(\d+)\s+\(([^\)]+)\)/;
|
||||
var m = capRe.exec(tmpText);
|
||||
if(m) {
|
||||
|
||||
newItem.caseName = m[1]+", "+m[2]+" "+m[3]+" "+m[4];
|
||||
if (m[3] == 'CanLII') {
|
||||
newItem.court = m[5];
|
||||
} else {
|
||||
newItem.court = m[3];
|
||||
}
|
||||
|
||||
} else {
|
||||
newItem.caseName = tmpText;
|
||||
newItem.court = "not found";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// attach link to pdf version
|
||||
// NOTE: not working - don't know why
|
||||
var pdfRe = /^(.+)\.html$/;
|
||||
var pdfMatch = pdfRe.exec(doc.location.href);
|
||||
if (pdfMatch) {
|
||||
var pdfUrl = pdfMatch[1]+".pdf";
|
||||
newItem.attachments = [{url:pdfUrl, title:"PDF version", mimeType:"application/pdf"}];
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var canLiiRegexp= /http:\/\/www\.canlii\.org\/en\/[^\/]+\/[^\/]+\/doc\/.+/
|
||||
if(canLiiRegexp.test(url)) {
|
||||
scrape(doc);
|
||||
} else {
|
||||
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, canLiiRegexp);
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); });
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,153 +0,0 @@
|
|||
{
|
||||
"translatorID":"4da40f07-904b-4472-93b6-9bea1fe7d4df",
|
||||
"translatorType":4,
|
||||
"label":"Canada.com",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://www.canada.com",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-24 05:30:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.location.href.match("story")) {
|
||||
return "newspaperArticle";
|
||||
} else if (doc.location.href.match("search")) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var fieldTitle;
|
||||
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
|
||||
newItem.title = doc.title;
|
||||
|
||||
if (doc.evaluate('//div[@class="storyheader"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.abstractNote = doc.evaluate('//div[@class="storyheader"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
} else if (doc.evaluate('//div[@class="storyheader"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.abstracteNote = doc.evaluate('//div[@class="storyheader"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
if (doc.evaluate('//div[@class="feed_details"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var author = doc.evaluate('//div[@class="feed_details"]/h4', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
if (author.match(/\n/)) {
|
||||
author1 = author.split(/\n/);
|
||||
if (author1[0].match(/ and /)) {
|
||||
author2 = author1[0].split(/ and /);
|
||||
for (var i in author2) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author2[i], "author"));
|
||||
}
|
||||
} else {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author1[0], "author"));
|
||||
}
|
||||
} else {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.evaluate('//div[@class="feed_details"]/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var date1 = doc.evaluate('//div[@class="feed_details"]/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(/^\s*|\s*$/g, '');
|
||||
if (date1.match("Published:")) {
|
||||
date1 = date1.substr(11);
|
||||
newItem.date = date1;
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.evaluate('//ul[@class="home"]/li/a/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var pubTitle = doc.evaluate('//ul[@class="home"]/li/a/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
if (pubTitle.match("Home")) {
|
||||
newItem.publicationTitle = pubTitle.substr(0, pubTitle.length-5);
|
||||
} else {
|
||||
newItem.publicationTitle = pubTitle;
|
||||
}
|
||||
} else {
|
||||
newItem.publicationTitle = "Canada.com";
|
||||
}
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var next_title;
|
||||
|
||||
if (doc.evaluate('//div[@class="even"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
Zotero.debug("AAAAAA");
|
||||
var titles0 = doc.evaluate('//div[@class="even"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
while (next_title = titles0.iterateNext()) {
|
||||
if (next_title.href.match("story") && next_title.href.match("canada.com")) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.evaluate('//div[@class="odd"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
Zotero.debug("BBBBB");
|
||||
var titles1 = doc.evaluate('//div[@class="odd"]/p/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
while (next_title = titles1.iterateNext()) {
|
||||
if (next_title.href.match("story") && next_title.href.match("canada.com")) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.evaluate('//p/b/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
Zotero.debug("CCCCC");
|
||||
var titles2 = doc.evaluate('//p/b/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
while (next_title = titles2.iterateNext()) {
|
||||
if (next_title.href.match("story") && next_title.href.match("canada.com")) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (doc.evaluate('//div[@class="name"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
|
||||
Zotero.debug("DDDD");
|
||||
var titles3 = doc.evaluate('//div[@class="name"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
while (next_title = titles3.iterateNext()) {
|
||||
if (next_title.href.match("story") && next_title.href.match("canada.com")) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,124 +0,0 @@
|
|||
{
|
||||
"translatorID":"a7c8b759-6f8a-4875-9d6e-cc0a99fe8f43",
|
||||
"translatorType":4,
|
||||
"label":"Canadian Letters and Images",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://(www.)?canadianletters.ca/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-20 20:45:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.location.href.match("results")) {
|
||||
return "multiple";
|
||||
} else if (doc.location.href.match("letters.php")) {
|
||||
return "document";
|
||||
} else if (doc.location.href.match("template")) {
|
||||
return "artwork";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Translator for Canadian Letters and Images. Code by Adam Crymble
|
||||
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
|
||||
var mediaType = (detectWeb(doc, url));
|
||||
if (mediaType == "document") {
|
||||
var newItem = new Zotero.Item("letter");
|
||||
var title2;
|
||||
|
||||
//title
|
||||
if (doc.evaluate('//h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.title = doc.evaluate('//h3', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
} else {
|
||||
newItem.title = doc.title;
|
||||
}
|
||||
|
||||
//letter, diary, memoir, personal item
|
||||
if (doc.evaluate('//div[@id="collectionCategory_letters"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
|
||||
var xPathType = doc.evaluate('//div[@id="collectionCategory_letters"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.type = xPathType;
|
||||
}
|
||||
|
||||
//gets date, to and from
|
||||
if (doc.evaluate('//div[@class="letterInfo_label"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var xPathHeaders = doc.evaluate('//div[@class="letterInfo_label"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathContent = doc.evaluate('//div[@class="letterInfo_title"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//div[@class="letterInfo_label"])', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (i=0; i<xPathCount.numberValue; i++) {
|
||||
fieldTitle=xPathHeaders.iterateNext().textContent.replace(/\s+/g, '');
|
||||
dataTags[fieldTitle] = xPathContent.iterateNext().textContent.replace(/^\s*|\s*$/g, '');
|
||||
|
||||
if (fieldTitle == "To:") {
|
||||
|
||||
newItem.abstractNote = ("To: " + dataTags[fieldTitle]);
|
||||
|
||||
} else if (fieldTitle == "From:") {
|
||||
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags[fieldTitle], "author"));
|
||||
|
||||
} else if (fieldTitle == "Date:") {
|
||||
|
||||
newItem.date = dataTags[fieldTitle];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (mediaType == "artwork") {
|
||||
|
||||
newItem = new Zotero.Item("artwork");
|
||||
|
||||
if (doc.evaluate('//div[@class="pictureDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.title = doc.evaluate('//div[@class="pictureDisplay"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
} else {
|
||||
newItem.title = doc.title;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//div[@class="searchResultsDisplay"]/div/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
{
|
||||
"translatorID":"2d174277-7651-458f-86dd-20e168d2f1f3",
|
||||
"translatorType":4,
|
||||
"label":"Canadiana.org",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://(www.)?canadiana.org",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-12 19:30:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
//checks the title of the webpage. If it matches, then the little blue book symbol appears in the address bar.
|
||||
//works for English and French versions of the page.
|
||||
|
||||
if(doc.title == "Early Canadiana Online - Item Record"|doc.title == "Notre mémoire en ligne - Notice") {
|
||||
return "book";
|
||||
} else if (doc.evaluate('//div[@id="Content"]/div[@class="NormalRecord"]/h3/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Canadiana Translator Coding by Adam Crymble
|
||||
//because the site uses so many random formats for the "Imprint" field, it's not always perfect. But it works for MOST entries
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == "x" ) return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
//declaring variables to be used later.
|
||||
var newItem = new Zotero.Item("book");
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
var dataTags = new Object();
|
||||
var fieldTitle;
|
||||
var tagsContent= new Array();
|
||||
|
||||
//these variables tell the program where to find the data we want in the HTML file we're looking at.
|
||||
//in this case, the data is found in a table.
|
||||
var xPath1 = '//tr/td[1][@class="Label"]';
|
||||
var xPath2 = '//tr/td[2]';
|
||||
|
||||
|
||||
//at this point, all the data we want has been saved into the following 2 Objects: one for the headings, one for the content.
|
||||
// The 3rd object tells us how many items we've found.
|
||||
if (doc.evaluate('//tr/td[1][@class="Label"]', doc, nsResolver, XPathResult.ANY_TYPE, null)) {
|
||||
var xPath1Results = doc.evaluate(xPath1, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPath2Results = doc.evaluate(xPath2, doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate( 'count (//tr/td[1][@class="Label"])', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
}
|
||||
|
||||
//At this point we have two lists (xPath1Results and xPath2Results). this loop matches the first item in the first list
|
||||
//with the first item in the second list, and on until the end.
|
||||
//If we then ask for the "Principal Author" the program returns "J.K. Rowling" instead of "Principal Author"
|
||||
if (doc.evaluate('//tr/td[1][@class="Label"]', doc, nsResolver, XPathResult.ANY_TYPE, null)) {
|
||||
for (i=0; i<xPathCount.numberValue; i++) {
|
||||
|
||||
fieldTitle=xPath1Results.iterateNext().textContent.replace(/\s+/g, '');
|
||||
|
||||
//gets the author's name without cleaning it away using cleanTags.
|
||||
if (fieldTitle =="PrincipalAuthor:" || fieldTitle == "Auteurprincipal:") {
|
||||
|
||||
fieldTitle="PrincipalAuthor:";
|
||||
dataTags[fieldTitle]=(xPath2Results.iterateNext().textContent);
|
||||
var authorName =dataTags["PrincipalAuthor:"].split(",");
|
||||
authorName[0]=authorName[0].replace(/\s+/g, '');
|
||||
dataTags["PrincipalAuthor:"]= (authorName[1] + (" ") + authorName[0]);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(dataTags["PrincipalAuthor:"], "author"));
|
||||
|
||||
//Splits Adressebibliographique or Imprint into 3 fields and cleans away any extra whitespace or unwanted characters.
|
||||
} else if (fieldTitle =="Adressebibliographique:" || fieldTitle == "Imprint:") {
|
||||
|
||||
fieldTitle = "Imprint:";
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent);
|
||||
|
||||
var separateImprint = dataTags["Imprint:"].split(":");
|
||||
separateImprint[0]= separateImprint[0].replace(/^\s*|\[|\]/g,'');
|
||||
dataTags["Place:"]=separateImprint[0];
|
||||
|
||||
var justDate = separateImprint[1].replace(/\D/g, '');
|
||||
dataTags["Date:"]= justDate;
|
||||
|
||||
separateImprint[1] = separateImprint[1].replace(/\d|\[|\]|\./g, '');
|
||||
separateImprint[1] = separateImprint[1].replace(/^\s*|\s*$/g, '');
|
||||
dataTags["Publisher:"]= separateImprint[1];
|
||||
|
||||
// determines how many tags there will be, pushes them into an array and clears away whitespace.
|
||||
} else if (fieldTitle == "Subject:" || fieldTitle == "Sujet:") {
|
||||
|
||||
tagsContent.push(Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent.replace(/^\s*|\s*$/g, '')));
|
||||
while (fieldTitle != "Collection:") {
|
||||
i=i+1;
|
||||
tagsContent.push(Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent.replace(/^\s*|\s*$/g, '')));
|
||||
fieldTitle=xPath1Results.iterateNext().textContent.replace(/\s+/g, '');
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(xPath2Results.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
//Adds a string to CIHM no: and ICMH no: so that the resulting number makes sense to the reader.
|
||||
if (dataTags["CIHMno.:"]) {
|
||||
|
||||
dataTags["CIHMno.:"]=("CIHM Number: " + dataTags["CIHMno.:"]);
|
||||
}
|
||||
|
||||
if (dataTags["ICMHno:"]) {
|
||||
|
||||
dataTags["ICMHno:"]=("ICMH nombre: " + dataTags["ICMHno:"]);
|
||||
}
|
||||
|
||||
//makes tags of the items in the "tagsContent" array.
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
|
||||
//calls the associateData function to put the data in the correct Zotero field.
|
||||
associateData (newItem, dataTags, "Title:", "title");
|
||||
associateData (newItem, dataTags, "Place:", "place");
|
||||
associateData (newItem, dataTags, "Publisher:", "publisher");
|
||||
associateData (newItem, dataTags, "Date:", "date");
|
||||
associateData (newItem, dataTags, "PageCount:", "pages");
|
||||
associateData (newItem, dataTags, "CIHMno.:", "extra");
|
||||
associateData (newItem, dataTags, "DocumentSource:", "rights");
|
||||
|
||||
associateData (newItem, dataTags, "Titre:", "title" );
|
||||
associateData (newItem, dataTags, "Nombredepages:", "pages");
|
||||
associateData (newItem, dataTags, "ICMHno:", "extra");
|
||||
associateData (newItem, dataTags, "Documentoriginal:", "rights");
|
||||
|
||||
//Saves everything to Zotero.
|
||||
newItem.complete();
|
||||
|
||||
}
|
||||
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//div[@id="Content"]/div[@class="NormalRecord"]/h3/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
{
|
||||
"translatorID":"f26cfb71-efd7-47ae-a28c-d4d8852096bd",
|
||||
"translatorType":4,
|
||||
"label":"Cell Press",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.(cancercell|cell|cellhostandmicrobe|cellmetabolism|cellstemcell|chembiol|current-biology|developmentalcell|immunity|molecule|neuron|structure).(org|com)",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":99,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-07-07 14:50:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
if (url.indexOf("search/results") != -1) {
|
||||
return "multiple";
|
||||
} else if (url.indexOf("content/article") != -1) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var fieldTitle;
|
||||
var commaSplit = new Array();
|
||||
|
||||
var newItem = new Zotero.Item("journalArticle");
|
||||
|
||||
//title
|
||||
newItem.title = doc.evaluate('//h1[@class="article_title"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
//publication, volume, pages, date.
|
||||
var voliss = doc.evaluate('//div[contains(@class, "article_citation")]/p[1]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
var volissSplit = voliss.split(".");
|
||||
|
||||
for (var i = 0; i < volissSplit.length; i++) {
|
||||
if (volissSplit[i].match(", ")) {
|
||||
commaSplit = volissSplit[i].split(", ");
|
||||
}
|
||||
}
|
||||
if (commaSplit[0] != '') {
|
||||
newItem.publicationTitle = commaSplit[0];
|
||||
}
|
||||
if (commaSplit[1] != '') {
|
||||
newItem.volume = commaSplit[1];
|
||||
}
|
||||
if (commaSplit[2] != '') {
|
||||
newItem.pages= commaSplit[2];
|
||||
}
|
||||
if (commaSplit[3] != '') {
|
||||
newItem.date= commaSplit[3];
|
||||
}
|
||||
|
||||
//abstract
|
||||
|
||||
var abstractXPath2 = '//div[@class="min_fulltext"][@id="main_content"]/p';
|
||||
if (doc.evaluate(abstractXPath2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.abstractNote = doc.evaluate(abstractXPath2, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
var abstractXPath = '//div[@class="panelcontent article_summary"]/p[contains(text(), " ")]';
|
||||
if (doc.evaluate(abstractXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.abstractNote = doc.evaluate(abstractXPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
//authors
|
||||
var authors = doc.evaluate('//p[@class="authors"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(",");
|
||||
for (var i in authors) {
|
||||
var next_author = authors[i];
|
||||
if (next_author.match(/[a-z]/)) {
|
||||
next_author = Zotero.Utilities.trimInternal(next_author.replace(/\d/g, ""));
|
||||
if (next_author.substr(0, 3) == "and") {
|
||||
next_author = next_author.substr(4);
|
||||
}
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(next_author, "author"));
|
||||
}
|
||||
}
|
||||
|
||||
//url
|
||||
var newurl = doc.location.href;
|
||||
if (newurl.indexOf("abstract") != -1) {
|
||||
newurl = newurl.replace("abstract", "fulltext");
|
||||
}
|
||||
|
||||
//attachments
|
||||
var uid = newurl.match(/uid=([^&]+)/)[1];
|
||||
var pdfx = '//a[contains(text(), "PDF")][contains(@href, "' + uid + '")]';
|
||||
var pdfurl = doc.evaluate(pdfx, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
newItem.attachments = [
|
||||
{url:newurl, title:"Cell Press Snapshot", mimeType:"text/html"},
|
||||
{url:pdfurl, title:"Cell Press Full Text PDF", mimeType:"application/pdf"}
|
||||
];
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//dd/strong', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var link = doc.evaluate('//nobr/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
var next_lilnk;
|
||||
|
||||
while (next_title = titles.iterateNext()) {
|
||||
next_link = link.iterateNext();
|
||||
if (next_link.textContent.match("Summary")) {
|
||||
items[next_link.href] = next_title.textContent;
|
||||
} else {
|
||||
next_link = link.iterateNext();
|
||||
items[next_link.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
{
|
||||
"translatorID":"50d3ca81-3c4c-406b-afb2-0fe8105b9b38",
|
||||
"translatorType":4,
|
||||
"label":"Champlain Society - Collection",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://link.library.utoronto.ca",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-09-02 13:40:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.location.href.match("search_results")) {
|
||||
return "multiple";
|
||||
} else if (doc.location.href.match("item_record")) {
|
||||
return "book";
|
||||
}
|
||||
}
|
||||
|
||||
//Champlain Collection translator. Code by Adam Crymble
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var fieldTitle;
|
||||
|
||||
var newItem = new Zotero.Item("book");
|
||||
|
||||
var headers = doc.evaluate('//table[1]/tbody/tr/td[1]/b/font', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var contents = doc.evaluate('//td/table[1]/tbody/tr/td[2]/font', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//table[1]/tbody/tr/td[1]/b/font)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
for (i=0; i<xPathCount.numberValue; i++) {
|
||||
fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, '');
|
||||
if (fieldTitle == "Auteur:" ) {
|
||||
fieldTitle = "Author:";
|
||||
} else if (fieldTitle == "Titre:") {
|
||||
fieldTitle = "Title:";
|
||||
} else if (fieldTitle == "Description:") {
|
||||
fieldTitle = "Extent:";
|
||||
} else if (fieldTitle == "Éditeur:") {
|
||||
fieldTitle = "Published:";
|
||||
} else if (fieldTitle == "Sujet:") {
|
||||
fieldTitle = "Subjects:";
|
||||
}
|
||||
|
||||
dataTags[fieldTitle] = (contents.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
}
|
||||
|
||||
//author
|
||||
var multiAuthors = 0;
|
||||
if (dataTags["Author:"]) {
|
||||
var author = dataTags["Author:"];
|
||||
if (author.match("; ")) {
|
||||
var authors = author.split("; ");
|
||||
multiAuthors = 1;
|
||||
}
|
||||
|
||||
if (multiAuthors == 1) {
|
||||
for (var i = 0; i < authors.length; i++) {
|
||||
if (authors[i].match(", ")) {
|
||||
var author1 = authors[i].split(", ");
|
||||
author = author1[1] + " " + author1[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: author, creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (author.match(", ")) {
|
||||
var author1 = author.split(", ");
|
||||
author = author1[1] + " " + author1[0];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
} else {
|
||||
newItem.creators.push({lastName: author, creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["Published:"]) {
|
||||
if (dataTags["Published:"].match(": ")) {
|
||||
var place1 = dataTags["Published:"].indexOf(": ");
|
||||
newItem.place = dataTags["Published:"].substr(0, place1);
|
||||
var publisher1 = dataTags["Published:"].substr(place1 + 2);
|
||||
|
||||
if (publisher1.match(", ")) {
|
||||
var date1 = publisher1.lastIndexOf(", ");
|
||||
newItem.date = publisher1.substr(date1 +2);
|
||||
newItem.publisher = publisher1.substr(0, date1);
|
||||
} else {
|
||||
newItem.publisher = publisher1;
|
||||
}
|
||||
} else {
|
||||
newItem.publisher = publisher1;
|
||||
}
|
||||
}
|
||||
|
||||
//for Tags
|
||||
if (dataTags["Subjects:"]) {
|
||||
tagsContent = dataTags["Subjects:"].split(/\n/);
|
||||
}
|
||||
|
||||
var j = 0;
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
if (tagsContent[i].match(/\w/)) {
|
||||
newItem.tags[j] = tagsContent[i].replace(/^\s*|\s+$/g, '');
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "Extent:", "pages");
|
||||
associateData (newItem, dataTags, "ID:", "callNumber");
|
||||
associateData (newItem, dataTags, "Notes:", "abstractNote");
|
||||
|
||||
newItem.title = doc.title;
|
||||
if (dataTags["Title:"]) {
|
||||
associateData (newItem, dataTags, "Title:", "title");
|
||||
} else {
|
||||
newItem.title = "No Title Found: Champlain Collection";
|
||||
}
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//tr[1]/td[2]/font/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
{
|
||||
"translatorID":"04c0db88-a7fc-4d1a-9cf7-471d0990acb1",
|
||||
"translatorType":4,
|
||||
"label":"Christian Science Monitor",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://(features.csmonitor|www.csmonitor).com",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-08-06 17:00:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.location.href.match("search")) {
|
||||
return "multiple";
|
||||
} else if (doc.location.href.match("features")) {
|
||||
return "newspaperArticle";
|
||||
} else if (doc.evaluate('//div[@id="storyContent"]/h1', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "newspaperArticle";
|
||||
}
|
||||
}
|
||||
|
||||
//Christian Science Monitor translator. Code by Adam Crymble.
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
|
||||
|
||||
if (doc.location.href.match("features.csmonitor")) {
|
||||
|
||||
newItem.title = doc.title;
|
||||
|
||||
|
||||
if (doc.evaluate('//div[@class="story"][@id="main"]/p/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.abstractNote = doc.evaluate('//div[@class="story"][@id="main"]/p/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
if (doc.evaluate('//h3/span[@class="time-date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.date = doc.evaluate('//h3/span[@class="time-date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent.replace(" edition", '');
|
||||
}
|
||||
|
||||
if (doc.evaluate('//h3/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
|
||||
var author = doc.evaluate('//h3/span', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
if (author.match("By ")) {
|
||||
author = author.substr(3);
|
||||
}
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
|
||||
var title1 = doc.title;
|
||||
|
||||
//Some entries do not work for some reason unbeknownst to me; this flag catches the problem and prevents an error, but doesn't save the data properly.
|
||||
if (title1.match("csmonitor")) {
|
||||
newItem.title = title1.substr(0, title1.length-15);
|
||||
} else {
|
||||
newItem.title = "This Entry Cannot Be Saved";
|
||||
newItem.abstractNote = "Entry must be entered manually";
|
||||
}
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
|
||||
//title
|
||||
if (doc.evaluate('//div[@id="storyContent"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
|
||||
var title1 = doc.evaluate('//div[@id="storyContent"]/h1', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
var words = title1.split(" ");
|
||||
for (var i in words) {
|
||||
words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase();
|
||||
}
|
||||
title1 = words.join(" ");
|
||||
newItem.title = title1;
|
||||
} else {
|
||||
newItem.title = "no title found";
|
||||
}
|
||||
|
||||
//abstract note
|
||||
if (doc.evaluate('//div[@id="storyContent"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.abstractNote = doc.evaluate('//div[@id="storyContent"]/h2', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
//date
|
||||
if (doc.evaluate('//div[@id="storyContent"]/p[@class="postdate"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var date1 = doc.evaluate('//div[@id="storyContent"]/p[@class="postdate"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
date1 = date1.replace(/from the /g, '');
|
||||
date1 = date1.replace(/ edition/g, '');
|
||||
newItem.date = date1;
|
||||
}
|
||||
|
||||
//author
|
||||
if (doc.evaluate('//address[@class="byline"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var author = doc.evaluate('//address[@class="byline"]/strong', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
|
||||
if (author.match("By ")) {
|
||||
author = author.substr(3);
|
||||
}
|
||||
var words = author.split(" ");
|
||||
for (var i in words) {
|
||||
words[i] = words[i][0].toUpperCase() + words[i].substr(1).toLowerCase();
|
||||
}
|
||||
author = words.join(" ");
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newItem.publicationTitle = "Christian Science Monitor";
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//p[@id="searchResultRow"]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
if (!next_title.href.match("features")) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
{
|
||||
"translatorID":"46291dc3-5cbd-47b7-8af4-d009078186f6",
|
||||
"translatorType":4,
|
||||
"label":"CiNii",
|
||||
"creator":"Michael Berkowitz and Mitsuo Yoshida",
|
||||
"target":"http://ci.nii.ac.jp/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2010-05-20 04:00:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/naid/)) {
|
||||
return "journalArticle";
|
||||
} else if (doc.evaluate('//a[contains(@href, "/naid/")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var n = doc.documentElement.namespaceURI;
|
||||
var ns = n ? function(prefix) {
|
||||
if (prefix == 'x') return n; else return null;
|
||||
} : null;
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var links = doc.evaluate('//a[contains(@href, "/naid/")]', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var link;
|
||||
while (link = links.iterateNext()) {
|
||||
items[link.href] = Zotero.Utilities.trimInternal(link.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
arts.push(i);
|
||||
}
|
||||
} else {
|
||||
arts = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(arts, function(doc) {
|
||||
var biblink = 'http://ci.nii.ac.jp/export?fileType=2&docSelect=' + doc.evaluate('//input[@name="docSelect"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().value;
|
||||
var newurl = doc.location.href;
|
||||
var tags = new Array();
|
||||
if (doc.evaluate('//a[@rel="tag"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var kws = doc.evaluate('//a[@rel="tag"]', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var kw;
|
||||
while (kw = kws.iterateNext()) {
|
||||
tags.push(Zotero.Utilities.trimInternal(kw.textContent));
|
||||
}
|
||||
}
|
||||
var abstractNote;
|
||||
if (doc.evaluate('//div[@class="abstract"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
abstractNote = doc.evaluate('//div[@class="abstract"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
Zotero.Utilities.HTTP.doGet(biblink, function(text) {
|
||||
var trans = Zotero.loadTranslator("import");
|
||||
trans.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||
trans.setString(text);
|
||||
trans.setHandler("itemDone", function(obj, item) {
|
||||
item.url = newurl;
|
||||
item.attachments = [{url:item.url, title:item.title + " Snapshot", mimeType:"text/html"}];
|
||||
item.tags = tags;
|
||||
item.abstractNote = abstractNote;
|
||||
item.complete();
|
||||
});
|
||||
trans.translate();
|
||||
});
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,111 +0,0 @@
|
|||
{
|
||||
"translatorID":"fa396dd4-7d04-4f99-95e1-93d6f355441d",
|
||||
"translatorType":4,
|
||||
"label":"CiteSeer",
|
||||
"creator":"Simon Kornblith",
|
||||
"target":"^http://(?:citeseer\\.ist\\.psu\\.edu/|citeseer\\.csail\\.mit\\.edu/|citeseer\\.ifi\\.unizh\\.ch/|citeseer\\.comp\\.nus\\.edu\\.sg/)",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-02-06 21:00:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var searchRe = /http:\/\/[^\/]+\/ci?s/;
|
||||
if(searchRe.test(url)) {
|
||||
return "multiple";
|
||||
} else {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
if(doc.evaluate('/html/body/span[@class="m"]/pre', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
// figure out what attachments to add
|
||||
var attachments = new Array();
|
||||
var results = doc.evaluate('/html/body/span[@class="m"]/table[@class="h"]/tbody/tr/td[4]/center/font/a',
|
||||
doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var elmt;
|
||||
|
||||
var acceptableTypes = ["PDF", "PS", "PS.gz"];
|
||||
var mimeTypes = ["application/pdf", "application/postscript", "application/gzip"];
|
||||
var resultsArray = [];
|
||||
while (elmt = results.iterateNext()) {
|
||||
resultsArray.push(elmt);
|
||||
}
|
||||
resultsArray = resultsArray.filter(function (element, index, array) {
|
||||
return (acceptableTypes.indexOf(element.textContent.toString()) != -1);
|
||||
});
|
||||
resultsArray = resultsArray.sort(function (a,b) {
|
||||
return (acceptableTypes.indexOf(a.textContent.toString()) -
|
||||
acceptableTypes.indexOf(b.textContent.toString()));
|
||||
});
|
||||
if (resultsArray.length > 0) {
|
||||
var elmt = resultsArray[0];
|
||||
var kind = elmt.textContent.toString();
|
||||
var index = acceptableTypes.indexOf(kind);
|
||||
var attachment = {url:elmt.href, mimeType:mimeTypes[index],
|
||||
title:"CiteSeer Full Text "+kind};
|
||||
attachments.push(attachment);
|
||||
}
|
||||
|
||||
var bibtex = doc.evaluate('/html/body/span[@class="m"]/pre/text()', doc, nsResolver,
|
||||
XPathResult.ANY_TYPE, null).iterateNext();
|
||||
if(bibtex) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||
translator.setString(bibtex.nodeValue.toString());
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
if(item.url) { // add http to url
|
||||
item.url = "http://"+item.url;
|
||||
}
|
||||
item.attachments = attachments;
|
||||
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
} else {
|
||||
throw "No BibTeX found!";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var searchRe = /http:\/\/([^\/]+)\/ci?s/;
|
||||
var m = searchRe.exec(doc.location.href);
|
||||
if(m) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, "^http://"+m[1]+"/[^/]+.html");
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); });
|
||||
Zotero.wait();
|
||||
} else {
|
||||
scrape(doc);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
{
|
||||
"translatorID":"8917b41c-8527-4ee7-b2dd-bcbc3fa5eabd",
|
||||
"translatorType":4,
|
||||
"label":"CiteULike",
|
||||
"creator":"Sean Takats",
|
||||
"target":"https?://(?:www\\.)?citeulike.org(?:.*/tag/[^/]*$|/search/|/journal/|/user/|/group/[0-9]+/library$|/\\?page=[0-9]+$|/.*article/[0-9]+$|/$)",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-06-13 19:30:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url){
|
||||
var articleRe = /\/article\/[0-9]+$/;
|
||||
var m = url.match(articleRe);
|
||||
var newUris = new Array();
|
||||
|
||||
if (m){
|
||||
return "journalArticle";
|
||||
} else {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url){
|
||||
var articleRe = /\/article\/[0-9]+$/;
|
||||
var m = url.match(articleRe);
|
||||
var newUris = new Array();
|
||||
|
||||
if (m){
|
||||
newUris.push(url.replace(/citeulike\.org\//, "citeulike.org/endnote/"));
|
||||
} else {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var elmt;
|
||||
var elmts = doc.evaluate('//a[@class="title"]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var items = new Object();
|
||||
while(elmt = elmts.iterateNext()) {
|
||||
items[elmt.href] = Zotero.Utilities.trimInternal(elmt.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
if(!items) return true;
|
||||
for(var uri in items) {
|
||||
newUris.push(uri.replace(/citeulike\.org\//, "citeulike.org/endnote/"));
|
||||
}
|
||||
}
|
||||
Zotero.Utilities.HTTP.doGet(newUris, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.translate();
|
||||
Zotero.done();
|
||||
});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
{
|
||||
"translatorID":"daa26181-71d4-48ef-8cac-54c06ff4c20e",
|
||||
"translatorType":12,
|
||||
"label":"Citebase",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"^http://www\\.citebase\\.org/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/\/search/)) {
|
||||
return "multiple";
|
||||
} else if (url.match(/\/abstract/)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function detectSearch(item) {
|
||||
if(item.itemType == "journalArticle") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var articles = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var links = doc.evaluate('//div[@class="rs_match"]/div/a[@class="abs_title"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var items = new Object();
|
||||
var link;
|
||||
while (link = links.iterateNext()) {
|
||||
items[link.href] = link.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(articles, function(doc) {
|
||||
var biburl = doc.evaluate('//a[contains(text(), "BibTeX")]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
if (doc.evaluate('/html/body/div[@class="body"]/div[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) var abs = Zotero.Utilities.trimInternal(doc.evaluate('/html/body/div[@class="body"]/div[@class="abstract"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||
Zotero.Utilities.HTTP.doGet(biburl, function(text) {
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
if (abs) {
|
||||
if (abs.match(/^Abstract/)) {
|
||||
item.abstractNote = abs.substr(9);
|
||||
} else {
|
||||
item.abstractNote = abs;
|
||||
}
|
||||
}
|
||||
item.attachments = [{url:item.url, title:"Citebase Snapshot", mimeType:"text/html"}];
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
function doSearch(item) {
|
||||
if(item.contextObject) {
|
||||
var co = item.contextObject;
|
||||
if(co.indexOf("url_ver=") == -1) {
|
||||
co = "url_ver=Z39.88-2004&"+co;
|
||||
}
|
||||
co = co.replace(/(?:&|^)svc_id=[^&]*/, "");
|
||||
} else {
|
||||
var co = Zotero.Utilities.createContextObject(item);
|
||||
}
|
||||
|
||||
Zotero.Utilities.HTTP.doGet("http://www.citebase.org/openurl?"+co+"&svc_id=bibtex", function(responseText, request) {
|
||||
if(responseText.substr(0, 6) != "<?xml ") {
|
||||
// read BibTeX
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("9cb70025-a888-4a29-a210-93ec52da40d4");
|
||||
translator.setString(responseText);
|
||||
translator.translate();
|
||||
}
|
||||
|
||||
Zotero.done();
|
||||
});
|
||||
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,132 +0,0 @@
|
|||
{
|
||||
"translatorID":"8451431a-895f-4732-8339-79eb6756d2f9",
|
||||
"translatorType":4,
|
||||
"label":"Civilization.ca",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://collections.civilization.ca",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-09-02 13:40:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//tr/td[2]/a/font', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.location.href.match("Display.php")) {
|
||||
return "artwork";
|
||||
}
|
||||
}
|
||||
|
||||
//Civilization.ca translator. Code by Adam Crymble.
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var fieldTitle;
|
||||
|
||||
var newItem = new Zotero.Item("artwork");
|
||||
|
||||
var headers = doc.evaluate('//table[2]/tbody/tr/td[1]/span[@class="textb"]/b', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var contents = doc.evaluate('//tr[2]/td/table[2]/tbody/tr/td[2]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var xPathCount = doc.evaluate('count (//table[2]/tbody/tr/td[1]/span[@class="textb"]/b)', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
newItem.title = contents.iterateNext().textContent.replace(/^\s*|\s+$/g, '');
|
||||
var dump = contents.iterateNext();
|
||||
|
||||
for (i=0; i<xPathCount.numberValue; i++) {
|
||||
|
||||
fieldTitle = headers.iterateNext().textContent.replace(/\s+/g, '');
|
||||
if (fieldTitle == "Artist/Maker/Manufacturer") {
|
||||
fieldTitle = " Artiste/Artisan/Fabricant";
|
||||
} else if (fieldTitle == "Autreaffiliationculturelle") {
|
||||
fieldTitle = "OtherCulturalAffiliation";
|
||||
}
|
||||
|
||||
dataTags[fieldTitle] = Zotero.Utilities.cleanTags(contents.iterateNext().textContent.replace(/^\s*|\s*$/g, ''));
|
||||
}
|
||||
|
||||
if (dataTags["Artist/Maker/Manufacturer"]) {
|
||||
var author = dataTags["Artist/Maker/Manufacturer"];
|
||||
if (author.match(" and ")) {
|
||||
var authors = author.split(" and ");
|
||||
for (var i in authors) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[i], "author"));
|
||||
}
|
||||
} else {
|
||||
newItem.creators.push({lastName: author, creatorType: "creator"});
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["OtherCulturalAffiliation"]) {
|
||||
tagsContent = dataTags["OtherCulturalAffiliation"].split(/\n/);
|
||||
|
||||
for (var i = 0; i < tagsContent.length; i++) {
|
||||
newItem.tags[i] = tagsContent[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (dataTags["Collection"]) {
|
||||
newItem.extra = "Collection: " + dataTags['Collection'];
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "ArtifactNumber", "callNumber");
|
||||
associateData (newItem, dataTags, "Museum", "repository");
|
||||
associateData (newItem, dataTags, "Measurements", "artworkSize");
|
||||
associateData (newItem, dataTags, "BeginDate", "date");
|
||||
associateData (newItem, dataTags, "EndDate", "date");
|
||||
associateData (newItem, dataTags, "AdditionalInformation", "abstractNote");
|
||||
|
||||
associateData (newItem, dataTags, "Numérod'artefact", "callNumber");
|
||||
associateData (newItem, dataTags, "Musée", "repository");
|
||||
associateData (newItem, dataTags, "Mesures", "artworkSize");
|
||||
associateData (newItem, dataTags, "Datededébut", "date");
|
||||
associateData (newItem, dataTags, "Datedefin", "date");
|
||||
associateData (newItem, dataTags, "Informationsupplémentaire", "abstractNote");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate('//tr/td[2]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
if (next_title.textContent.match(/\w/)) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
{
|
||||
"translatorID":"a326fc49-60c2-405b-8f44-607e5d18b9ad",
|
||||
"translatorType":4,
|
||||
"label":"Code4Lib Journal",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://journal.code4lib.org/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//h2[@class="articletitle"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.evaluate('//h1[@class="articletitle"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var items = new Object();
|
||||
var articles = new Array();
|
||||
var xpath = '//div[@class="article"]/h2[@class="articletitle"]/a';
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var xpath = '//div[@class="article"]/h2[@class="articletitle"]/a';
|
||||
var titles = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var next_title = titles.iterateNext();
|
||||
while (next_title) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
next_title = titles.iterateNext();
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
} else {
|
||||
articles.push(url);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(articles, function(newDoc, url) {
|
||||
var newItem = new Zotero.Item("journalArticle");
|
||||
newItem.repository = "Code4Lib Journal";
|
||||
newItem.publicationTitle = "The Code4Lib Journal";
|
||||
newItem.ISSN = "1940-5758";
|
||||
newItem.url = newDoc.location.href;
|
||||
newItem.title = newDoc.evaluate('//div[@class="article"]/h1[@class="articletitle"]/a', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.abstractNote = newDoc.evaluate('//div[@class="article"]/div[@class="abstract"]/p', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
var issdate = newDoc.evaluate('//p[@id="issueDesignation"]', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.issue = issdate.match(/([^,]*)/)[0].match(/\d+/)[0];
|
||||
newItem.date = issdate.match(/,\s+(.*)$/)[1];
|
||||
|
||||
|
||||
var axpath = '//div[@class="article"]/div[@class="entry"]/p[1]/a';
|
||||
var authors = newDoc.evaluate(axpath, newDoc, null, XPathResult.ANY_TYPE, null);
|
||||
var next_author = authors.iterateNext();
|
||||
while (next_author) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(next_author.textContent, "author"));
|
||||
next_author = authors.iterateNext();
|
||||
}
|
||||
|
||||
newItem.attachments.push({url:newDoc.location.href, title:"Code4Lib Journal Snapshot", mimeType:"text/html"});
|
||||
newItem.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
{
|
||||
"translatorID":"a75e0594-a9e8-466e-9ce8-c10560ea59fd",
|
||||
"translatorType":4,
|
||||
"label":"Columbia University Press",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.cup.columbia.edu/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match(/book\//)) {
|
||||
return "book";
|
||||
} else if (doc.evaluate('//p[@class="header"]/a/span[@class="_booktitle"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function addTag(item, tag, xpath) {
|
||||
item[tag] = Zotero.Utilities.trimInternal(doc.evaluate(xpath, doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var n = doc.documentElement.namespaceURI;
|
||||
var ns = n ? function(prefix) {
|
||||
if (prefix == 'x') return n; else return null;
|
||||
} : null;
|
||||
|
||||
var books = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//p[@class="header"]/a', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
while (title = titles.iterateNext()) {
|
||||
items[title.href] = title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
books.push(i);
|
||||
}
|
||||
} else {
|
||||
books = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(books, function(doc) {
|
||||
var item = new Zotero.Item("book");
|
||||
item.title = Zotero.Utilities.trimInternal(doc.evaluate('//h1[@id="_booktitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var authors = Zotero.Utilities.trimInternal(doc.evaluate('//p[@id="_authors"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
if (authors.match(/Edited/)) {
|
||||
authors = Zotero.Utilities.trimInternal(authors.replace("Edited by", ""));
|
||||
var autType = "editor";
|
||||
} else {
|
||||
var autType = "author";
|
||||
}
|
||||
var auts = authors.split(/,|\band\b/);
|
||||
for each (var aut in auts) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, autType));
|
||||
}
|
||||
item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//p[@id="_desc"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.date = Zotero.Utilities.trimInternal(doc.evaluate('//span[@id="_publishDate"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.ISBN = Zotero.Utilities.trimInternal(doc.evaluate('//span[@id="_isbn"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.publisher = Zotero.Utilities.trimInternal(doc.evaluate('//span[@id="_publisher"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
{
|
||||
"translatorID":"c3edb423-f267-47a1-a8c2-158c247f87c2",
|
||||
"translatorType":4,
|
||||
"label":"Common-Place",
|
||||
"creator":"Frederick Gibbs",
|
||||
"target":"http://www.common-place\\.|historycooperative\\.org/journals/cp",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-06-12 19:30:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if(doc.title.indexOf("Previous Issues") != -1 || doc.title.indexOf("Search Site") != -1 ) {
|
||||
return "multiple";
|
||||
} else {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("journalArticle");
|
||||
newItem.publicationTitle = "Common-Place";
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
|
||||
//get issue year and month
|
||||
//these will determine what xpaths we use for title and author
|
||||
var pubDate;
|
||||
var dateRe = /<a href="\/vol-[0-9]{2}\/no-[0-9]{2}\/">(.*)<\/a><\/b>/;
|
||||
var m = dateRe.exec(Zotero.Utilities.trimInternal(doc.getElementsByTagName("body")[0].innerHTML));
|
||||
|
||||
if(m) {
|
||||
//newItem.title = Zotero.Utilities.trimInternal(Zotero.Utilities.unescapeHTML(m[1]));
|
||||
pubDate = m[1];
|
||||
} else {
|
||||
pubDate = doc.evaluate('//div[@id="container"]/div[@id="top"]/p/b/a[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
var d;
|
||||
//Zotero.debug(pubDate);
|
||||
pubDateVolRE = /vol. (.*) · no. /;
|
||||
d = pubDateVolRE.exec(pubDate);
|
||||
newItem.volume = d[1];
|
||||
|
||||
pubDateVolRE = /no. (.*) ·/;
|
||||
d = pubDateVolRE.exec(pubDate);
|
||||
newItem.issue = d[1];
|
||||
|
||||
pubDateVolRE = /no. [0-9] · (.*)/;
|
||||
d = pubDateVolRE.exec(pubDate);
|
||||
newItem.date = d[1];
|
||||
|
||||
//usually the page begins with the article title or book title (of reviewed book)
|
||||
//some pages have an image just before them, so we need to skip it if it's there.
|
||||
var pLevel;
|
||||
var m=doc.evaluate('//div[@id="content"]/p[1]/img', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
|
||||
//if there is an image here, offset the xpath
|
||||
if (m == null) {
|
||||
pLevel = '//div[@id="content"]/p[1]';
|
||||
} else {
|
||||
pLevel = '//div[@id="content"]/p[2]';
|
||||
}
|
||||
|
||||
//issues before 2004 have a table based layout, so a totally different xpath.
|
||||
//check to see if we have anything, then try again if we don't.
|
||||
var author;
|
||||
var title;
|
||||
|
||||
author = doc.evaluate(pLevel+'/span[1]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
author = author.iterateNext();
|
||||
|
||||
if (author != null) {
|
||||
//Zotero.debug("au"+author+"au");
|
||||
var title = doc.evaluate(pLevel+'/span[2]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
//Zotero.debug("ti"+title+"ti");
|
||||
title = title.iterateNext().textContent;
|
||||
|
||||
//determine if we have a book review
|
||||
// if so, get the publication information
|
||||
if (author.textContent.indexOf("Review by") != -1 ) {
|
||||
newItem.title = String.concat("Review of ", title);
|
||||
newItem.author = author.textContent.substring(10);
|
||||
} else {
|
||||
newItem.author = author.textContent;
|
||||
newItem.title = title;
|
||||
}
|
||||
|
||||
}
|
||||
else { //we have older issue
|
||||
|
||||
//check if we are on a review
|
||||
var review = doc.evaluate('/html/body/table/tbody/tr/td[2]/p[2]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext();
|
||||
var temp = review.textContent;
|
||||
if (temp.indexOf("Review") != -1) {
|
||||
title = doc.evaluate('/html/body/table/tbody/tr/td[2]/p/i', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
title = "Review of " + title;
|
||||
author = review.textContent.substring(10);
|
||||
} else { //for articles
|
||||
title = doc.evaluate('/html/body/table/tbody/tr/td[2]/p/b', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
author = doc.evaluate('/html/body/table/tbody/tr/td[2]/p[1]', doc, null, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/\n/)[1];
|
||||
//Zotero.debug(author);
|
||||
}
|
||||
newItem.author = author;
|
||||
newItem.title = title;
|
||||
}
|
||||
|
||||
newItem.attachments.push({document:doc, title:doc.title});
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var type = detectWeb(doc, url);
|
||||
if (type == "multiple") {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
//create list of items
|
||||
//what about home page (current issue table of contents?)
|
||||
//for search result links: /html/body/table[2]/tbody/tr/td[2]/li[3]/a
|
||||
//for previous issues: //tr/td/p/a/b (but we need to strip out volume links (starts with 'Volume')
|
||||
|
||||
var link;
|
||||
var title;
|
||||
var items = new Object();
|
||||
var searchLinks = doc.evaluate('/html/body/table[2]/tbody/tr/td[2]/li/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
while (elmt = searchLinks.iterateNext()) {
|
||||
Zotero.debug(elmt.textContent);
|
||||
title = elmt.textContent;
|
||||
link = elmt.href;
|
||||
if (title && link){
|
||||
items[link] = title;
|
||||
}
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var uris = new Array();
|
||||
for(var i in items) {
|
||||
uris.push(i);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(uris, function(doc) { scrape(doc) },
|
||||
function() { Zotero.done(); }, null);
|
||||
|
||||
Zotero.wait();
|
||||
} else {
|
||||
scrape(doc);
|
||||
}
|
||||
}
|
|
@ -1,187 +0,0 @@
|
|||
{
|
||||
"translatorID": "8082115d-5bc6-4517-a4e8-abed1b2a784a",
|
||||
"label": "Copernicus",
|
||||
"creator": "Michael Berkowitz",
|
||||
"target": "http://www.(adv-sci-res|adv-geosci|adv-radio-sci|ann-geophys|astrophys-space-sci-trans|atmos-chem-phys|biogeosciences(-discuss)?|clim-past|electronic-earth|hydrol-earth-syst-sci|nat-hazards-earth-syst-sci|nonlin-processes-geophys|ocean-sci|soc-geogr|surv-perspect-integr-environ-soc|the-cryosphere).net/",
|
||||
"minVersion": "2.1",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"browserSupport": "gcs",
|
||||
"inRepository": true,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-07-01 07:40:29"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//div[@id="publisher"]/iframe', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//td[*[a[contains(text(), "Abstract")]]]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
} else if (doc.title.match(/Abstract/)) {
|
||||
return "journalArticle";
|
||||
}
|
||||
}
|
||||
|
||||
function getRIS(link) {
|
||||
Zotero.Utilities.HTTP.doGet(link, function(text) {
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("32d59d2d-b65a-4da4-b0a3-bdd3cfb979e7");
|
||||
translator.setString(text);
|
||||
translator.setHandler("itemDone", function(obj, item) {
|
||||
item.repository = "Copernicus Online Journals";
|
||||
item.attachments[0].title = item.publicationTitle + " Snapshot";
|
||||
item.attachments[0].mimeType = "text/html";
|
||||
item.attachments[1].title = item.publicationTitle + " PDF";
|
||||
item.complete();
|
||||
});
|
||||
translator.translate();
|
||||
});
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var arts = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
if (doc.evaluate('//div[@id="publisher"]/iframe', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var link = doc.evaluate('//div[@id="publisher"]/iframe', doc, null, XPathResult.ANY_TYPE, null).iterateNext().src;
|
||||
Zotero.Utilities.HTTP.doGet(link, function(text) {
|
||||
var links = text.match(/<a\s+target=\"_top\"\s+href=\"[^"]+\">[^<]+/g);
|
||||
for each (var link in links) {
|
||||
link = link.match(/href=\"([^"]+)\">(.*)/);
|
||||
items[link[1].replace(/\.[^\.]+$/, ".ris")] = Zotero.Utilities.trimInternal(link[2]) + "...";
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
getRIS(i);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var titles = doc.evaluate('//td[*[a[contains(text(), "Abstract")]]]/span[@class="pb_toc_article_title"]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//td[*[a[contains(text(), "Abstract")]]]//a[1]', doc, null, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
var link;
|
||||
while ((title = titles.iterateNext()) && (link = links.iterateNext())) {
|
||||
items[link.href] = title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
getRIS(i.replace(".html", ".ris"));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
getRIS(url.replace('.html', '.ris'));
|
||||
}
|
||||
Zotero.wait();
|
||||
}
|
||||
|
||||
/** BEGIN TEST CASES **/
|
||||
var testCases = [
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.adv-geosci.net/30/1/2011/adgeo-30-1-2011.html",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "journalArticle",
|
||||
"creators": [
|
||||
{
|
||||
"lastName": "Michaelides",
|
||||
"firstName": "S.",
|
||||
"creatorType": "author"
|
||||
},
|
||||
{
|
||||
"lastName": "Athanasatos",
|
||||
"firstName": "S.",
|
||||
"creatorType": "author"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{
|
||||
"url": "http://www.adv-geosci.net/30/1/2011/",
|
||||
"title": "Adv. Geosci. Snapshot",
|
||||
"mimeType": "text/html"
|
||||
},
|
||||
{
|
||||
"url": "http://www.adv-geosci.net/30/1/2011/adgeo-30-1-2011.pdf",
|
||||
"mimeType": "application/pdf",
|
||||
"title": "Adv. Geosci. PDF",
|
||||
"downloadable": true
|
||||
}
|
||||
],
|
||||
"title": "Preface ''Precipitation: Measurement, Climatology, Remote Sensing, and Modeling (EGU 2010)''",
|
||||
"publicationTitle": "Adv. Geosci.",
|
||||
"volume": "30",
|
||||
"pages": "1-2",
|
||||
"date": "May 09, 2011",
|
||||
"publisher": "Copernicus Publications",
|
||||
"ISBN": "1680-7359",
|
||||
"ISSN": "1680-7359",
|
||||
"url": "http://www.adv-geosci.net/30/1/2011/",
|
||||
"DOI": "10.5194/adgeo-30-1-2011",
|
||||
"libraryCatalog": "Copernicus Online Journals",
|
||||
"accessDate": "CURRENT_TIMESTAMP",
|
||||
"shortTitle": "Preface ''Precipitation"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.adv-radio-sci.net/6/1/2008/ars-6-1-2008.html",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "journalArticle",
|
||||
"creators": [
|
||||
{
|
||||
"lastName": "Will",
|
||||
"firstName": "B.",
|
||||
"creatorType": "author"
|
||||
},
|
||||
{
|
||||
"lastName": "Gerding",
|
||||
"firstName": "M.",
|
||||
"creatorType": "author"
|
||||
},
|
||||
{
|
||||
"lastName": "Schultz",
|
||||
"firstName": "S.",
|
||||
"creatorType": "author"
|
||||
},
|
||||
{
|
||||
"lastName": "Schiek",
|
||||
"firstName": "B.",
|
||||
"creatorType": "author"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{
|
||||
"url": "http://www.adv-radio-sci.net/6/1/2008/",
|
||||
"title": "Adv. Radio Sci. Snapshot",
|
||||
"mimeType": "text/html"
|
||||
},
|
||||
{
|
||||
"url": "http://www.adv-radio-sci.net/6/1/2008/ars-6-1-2008.pdf",
|
||||
"mimeType": "application/pdf",
|
||||
"title": "Adv. Radio Sci. PDF",
|
||||
"downloadable": true
|
||||
}
|
||||
],
|
||||
"title": "Time domain reflectrometry measurements using a movable obstacle for the determination of dielectric profiles",
|
||||
"publicationTitle": "Adv. Radio Sci.",
|
||||
"volume": "6",
|
||||
"pages": "1-4",
|
||||
"date": "May 26, 2008",
|
||||
"publisher": "Copernicus Publications",
|
||||
"ISBN": "1684-9965",
|
||||
"ISSN": "1684-9965",
|
||||
"url": "http://www.adv-radio-sci.net/6/1/2008/",
|
||||
"DOI": "10.5194/ars-6-1-2008",
|
||||
"libraryCatalog": "Copernicus Online Journals",
|
||||
"accessDate": "CURRENT_TIMESTAMP"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
/** END TEST CASES **/
|
|
@ -1,209 +0,0 @@
|
|||
{
|
||||
"translatorID":"930d49bc-44a1-4c22-9dde-aa6f72fb11e5",
|
||||
"translatorType":4,
|
||||
"label":"Cornell LII",
|
||||
"creator":"Bill McKinney",
|
||||
"target":"^http://www\\.law\\.cornell\\.edu/supct/html/.+",
|
||||
"minVersion":"1.0.0b4.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-03-19 17:36:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var liiRegexp = /http:\/\/www\.law\.cornell\.edu\/supct\/html\/.+/
|
||||
if(liiRegexp.test(url)) {
|
||||
return "book";
|
||||
} else {
|
||||
var aTags = doc.getElementsByTagName("a");
|
||||
for(var i=0; i<aTags.length; i++) {
|
||||
if(articleRegexp.test(aTags[i].href)) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function associateMeta(newItem, metaTags, field, zoteroField) {
|
||||
var field = metaTags.namedItem(field);
|
||||
if(field) {
|
||||
newItem[zoteroField] = field.getAttribute("content");
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc) {
|
||||
|
||||
var caselawCourt = "U.S. Supreme Court";
|
||||
var caselawJurisdiction = "Federal";
|
||||
var caselawSourceReporter = "U.S.";
|
||||
var caselawSourceVolume = "___";
|
||||
var caselawSourceStartPage = "___";
|
||||
var caselawParallelSourceVolume = "___";
|
||||
var caselawParallelSourceStartPage = "___";
|
||||
var caselawParallelSourceReporter = "___";
|
||||
var caselawDecisionYear = "";
|
||||
|
||||
var newItem = new Zotero.Item("case");
|
||||
newItem.url = doc.location.href;
|
||||
newItem.language = "en-us";
|
||||
newItem.court = "U.S. Supreme Court";
|
||||
newItem.reporter = "U.S.";
|
||||
|
||||
// LII provides a bunch of meta tags to harvest
|
||||
var metaTags = doc.getElementsByTagName("meta");
|
||||
associateMeta(newItem, metaTags, "CASENAME", "title");
|
||||
associateMeta(newItem, metaTags, "CASENAME", "caseName");
|
||||
//associateMeta(newItem, metaTags, "DOCKET", "caselawDocket");
|
||||
//associateMeta(newItem, metaTags, "PARTY1", "caselawParty1");
|
||||
//associateMeta(newItem, metaTags, "PARTY2", "caselawParty2");
|
||||
//associateMeta(newItem, metaTags, "ARGDATE", "caselawArguedDate");
|
||||
//associateMeta(newItem, metaTags, "DECDATE", "dateDecided");
|
||||
associateMeta(newItem, metaTags, "COURTBELOW", "history");
|
||||
//associateMeta(newItem, metaTags, "ACTION", "caselawCourtAction");
|
||||
|
||||
|
||||
var tmpCasename = newItem.caseName;
|
||||
tmpCasename = Zotero.Utilities.capitalizeTitle(tmpCasename.toLowerCase());
|
||||
tmpCasename = tmpCasename.replace("V.", "v.");
|
||||
newItem.caseName = tmpCasename;
|
||||
newItem.shortTitle = tmpCasename;
|
||||
|
||||
// judge
|
||||
var j = metaTags.namedItem("AUTHOR");
|
||||
if(j) {
|
||||
// Some entries the AUTHOR meta tag content is empty, this makes zotero unhappy, adding a default
|
||||
newItem.creators.push({lastName:j.getAttribute("content") ? j.getAttribute("content") : "Author Not Provided", creatorType:"judge", fieldMode:true});
|
||||
}
|
||||
|
||||
// group meta tags
|
||||
for(var i=0; i<metaTags.length; i++) {
|
||||
var key = metaTags[i].getAttribute("name");
|
||||
var value = metaTags[i].getAttribute("content");
|
||||
if (key == "GROUP") {
|
||||
newItem.tags.push(value);
|
||||
}
|
||||
}
|
||||
|
||||
// parse year out of decision date
|
||||
var decdateField = metaTags.namedItem("DECDATE");
|
||||
if(decdateField ) {
|
||||
var decisionYearRegex = /(\w+)\s+(\d+),\s+(\d+)/
|
||||
var decisionDateMatch = decisionYearRegex.exec(decdateField.getAttribute("content"));
|
||||
var dy;
|
||||
var dm;
|
||||
var dd;
|
||||
if (decisionDateMatch ) {
|
||||
dm = decisionDateMatch[1];
|
||||
dd = decisionDateMatch[2];
|
||||
dy = decisionDateMatch [3];
|
||||
caselawDecisionYear = dy;
|
||||
newItem.dateDecided = dy + " " + dm + " " + dd;
|
||||
}
|
||||
}
|
||||
|
||||
// create attachment to pdf
|
||||
var dyRegex = /^(.+)\/html\/(.+)(\.Z\w+)\.html$/;
|
||||
var dyMatch = dyRegex.exec(newItem.url);
|
||||
if (dyMatch) {
|
||||
var pdfUrl = dyMatch[1]+"/pdf/"+dyMatch[2]+"P"+dyMatch[3];
|
||||
newItem.attachments.push({url:pdfUrl, title:"PDF version", mimeType:"application/pdf", downloadable:true});
|
||||
}
|
||||
|
||||
// parse disposition
|
||||
var dis = doc.getElementsByTagName("DISPOSITION");
|
||||
if (dis.length > 0) {
|
||||
var tmpDis = dis[0].innerHTML;
|
||||
tmpDis = tmpDis.replace(/\s+/g, " ");
|
||||
newItem.title = newItem.title + " (" + tmpDis + ")";
|
||||
newItem.caseName= newItem.caseName + " (" + tmpDis + ")";
|
||||
|
||||
}
|
||||
|
||||
|
||||
// parse citation into parts so that bluebook can be constructed
|
||||
var cite = doc.getElementsByTagName("CASENUMBER");
|
||||
if (cite.length > 0) {
|
||||
var citeRegex = /([0-9]+)\s+U\.S\.\s+([0-9]+)/;
|
||||
var citeMatch = citeRegex.exec(cite[0].innerHTML);
|
||||
if (citeMatch) {
|
||||
caselawSourceVolume = citeMatch[1];
|
||||
newItem.reporterVolume = citeMatch[1];
|
||||
caselawSourceStartPage = citeMatch[2];
|
||||
newItem.firstPage = citeMatch[2];
|
||||
}
|
||||
}
|
||||
|
||||
// look for offcite span element
|
||||
var spanTags = doc.getElementsByTagName("span");
|
||||
if (spanTags.length > 0) {
|
||||
for(var i=0; i<spanTags.length; i++) {
|
||||
if(spanTags[i].className == "offcite") {
|
||||
var citeRegex = /([0-9]+)\s+U\.S\.\s+([0-9]+)/;
|
||||
var citeMatch = citeRegex.exec(spanTags[i].innerHTML);
|
||||
if (citeMatch) {
|
||||
caselawSourceVolume = citeMatch[1];
|
||||
newItem.reporterVolume = citeMatch[1];
|
||||
caselawSourceStartPage = citeMatch[2];
|
||||
newItem.firstPage = citeMatch[2];
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bluebook citation
|
||||
var bbCite = newItem.shortTitle + ", " +
|
||||
caselawSourceVolume + " " +
|
||||
caselawSourceReporter + " " +
|
||||
caselawSourceStartPage;
|
||||
// paralell cite
|
||||
if (caselawParallelSourceVolume != "___") {
|
||||
bbCite = bbCite + ", " + caselawParallelSourceVolume +
|
||||
" " + caselawParallelSourceReporter + " " +
|
||||
caselawParallelSourceStartPage;
|
||||
}
|
||||
// jurisdiction and year
|
||||
bbCite = bbCite + " (" + caselawDecisionYear + ")";
|
||||
// closing period
|
||||
bbCite = "Bluebook citation: " + bbCite + ".";
|
||||
newItem.notes.push({note:bbCite});
|
||||
|
||||
// parse out publication notice
|
||||
var notice = doc.getElementsByTagName("NOTICE");
|
||||
if (notice .length > 0) {
|
||||
var tmpNotice= notice [0].innerHTML;
|
||||
tmpNotice= tmpNotice.replace(/\s+/g, " ");
|
||||
newItem.notes.push({note:tmpNotice});
|
||||
}
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var liiRegexp = /http:\/\/www\.law\.cornell\.edu\/supct\/html\/.+/
|
||||
if(liiRegexp.test(url)) {
|
||||
scrape(doc);
|
||||
} else {
|
||||
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, liiRegexp);
|
||||
items = Zotero.selectItems(items);
|
||||
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var urls = new Array();
|
||||
for(var i in items) {
|
||||
urls.push(i);
|
||||
}
|
||||
|
||||
Zotero.Utilities.processDocuments(urls, scrape, function() { Zotero.done(); });
|
||||
Zotero.wait();
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
{
|
||||
"translatorID":"4363275e-5cc5-4627-9a7f-951fb58a02c3",
|
||||
"translatorType":4,
|
||||
"label":"Cornell University Press",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.cornellpress.cornell.edu/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.match("detail.taf")) {
|
||||
return "book";
|
||||
} else if (url.match("list.taf") || url.match("listsearch.taf")) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var n = doc.documentElement.namespaceURI;
|
||||
var ns = n ? function (prefix) {
|
||||
if (prefix == 'x') return n; else return null;
|
||||
} : null;
|
||||
|
||||
var books = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
var titles = doc.evaluate('//tr/td[2]/a', doc, ns, XPathResult.ANY_TYPE, null);
|
||||
var title;
|
||||
while (title = titles.iterateNext()) {
|
||||
if (title.textContent.match(/\w+/)) items[title.href] = Zotero.Utilities.trimInternal(title.textContent);
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
books.push(i);
|
||||
}
|
||||
} else {
|
||||
books = [url];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(books, function(doc) {
|
||||
var item = new Zotero.Item("book");
|
||||
item.title = Zotero.Utilities.capitalizeTitle(doc.evaluate('//span[@class="bktitle"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
var authors = doc.evaluate('//div[@id="detail"]/table/tbody/tr/td/form/a', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent.split(/;/);
|
||||
Zotero.debug(authors);
|
||||
for each (var aut in authors) {
|
||||
if (aut.match(/Translator/)) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut.match(/^(.*)\s+\(/)[1], "translator"));
|
||||
} else if (aut.match(/Editor/)) {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut.match(/^(.*)\s+\(/)[1], "editor"));
|
||||
} else {
|
||||
item.creators.push(Zotero.Utilities.cleanAuthor(aut, "author"));
|
||||
}
|
||||
}
|
||||
var bits = doc.evaluate('//div[@id="detail"]/table/tbody/tr/td/form', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
item.ISBN = bits.match(/ISBN:\s+([\d\-]+)/)[1];
|
||||
item.date = bits.match(/\d{4}/)[0];
|
||||
item.abstractNote = Zotero.Utilities.trimInternal(doc.evaluate('//div[@id="description"]', doc, ns, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
item.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,282 +0,0 @@
|
|||
{
|
||||
"translatorID":"11645bd1-0420-45c1-badb-53fb41eeb753",
|
||||
"translatorType":8,
|
||||
"label":"CrossRef",
|
||||
"creator":"Simon Kornblith",
|
||||
"target":"^https?://partneraccess\\.oclc\\.org/",
|
||||
"minVersion":"2.1.9",
|
||||
"maxVersion":"",
|
||||
"priority":90,
|
||||
"browserSupport":"gcs",
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-07-29 18:13:47"
|
||||
}
|
||||
|
||||
/* CrossRef uses unixref; documentation at http://www.crossref.org/schema/documentation/unixref1.0/unixref.html */
|
||||
var ns;
|
||||
|
||||
function detectSearch(item) {
|
||||
// query: should we make this more forgiving?
|
||||
if(item.itemType === "journalArticle" || item.DOI) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function fixAuthorCapitalization(string) {
|
||||
if(typeof string === "string" && string.toUpperCase() === string) {
|
||||
string = string.toLowerCase().replace(/\b[a-z]/g, function(m) { return m[0].toUpperCase() });
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
function parseCreators(node, item, typeOverrideMap) {
|
||||
var contributors = ZU.xpath(node, 'c:contributors/c:organization | c:contributors/c:person_name', ns);
|
||||
for(var i in contributors) {
|
||||
var creatorXML = contributors[i];
|
||||
var creator = {};
|
||||
|
||||
var role = creatorXML.getAttribute("contributor_role");
|
||||
if(typeOverrideMap && typeOverrideMap[role]) {
|
||||
creator.creatorType = typeOverrideMap[role];
|
||||
} else if(role === "author" || role === "editor" || role === "translator") {
|
||||
creator.creatorType = role;
|
||||
} else {
|
||||
creator.creatorType = "contributor";
|
||||
}
|
||||
|
||||
if(creatorXML.nodeName === "organization") {
|
||||
creator.fieldMode = 1;
|
||||
creator.lastName = creatorXML.textContent;
|
||||
} else if(creatorXML.nodeName === "person_name") {
|
||||
creator.firstName = fixAuthorCapitalization(ZU.xpathText(creatorXML, 'c:given_name', ns));
|
||||
creator.lastName = fixAuthorCapitalization(ZU.xpathText(creatorXML, 'c:surname', ns));
|
||||
}
|
||||
item.creators.push(creator);
|
||||
}
|
||||
}
|
||||
|
||||
function processCrossRef(xmlOutput) {
|
||||
// XPath does not give us the ability to use the same XPaths regardless of whether or not
|
||||
// there is a namespace, so we add an element to make sure that there will always be a
|
||||
// namespace.
|
||||
xmlOutput = '<xml xmlns="http://www.example.com/">'+xmlOutput.replace(/<\?xml[^>]*\?>/, "")+"</xml>";
|
||||
|
||||
// parse XML with E4X
|
||||
try {
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(xmlOutput, "text/xml");
|
||||
} catch(e) {
|
||||
Zotero.debug(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
// determine appropriate namespace
|
||||
ns = {"c":"http://www.crossref.org/xschema/1.1", "x":"http://www.example.com/"};
|
||||
var doiRecords = ZU.xpath(doc, '/x:xml/c:doi_records/c:doi_record', ns);
|
||||
if(!doiRecords.length) {
|
||||
ns.c = "http://www.crossref.org/xschema/1.0";
|
||||
doiRecords = ZU.xpath(doc, '/x:xml/c:doi_records/c:doi_record', ns);
|
||||
if(!doiRecords.length) {
|
||||
// this means that the original document was un-namespaced
|
||||
ns.c = "http://www.example.com/";
|
||||
doiRecords = ZU.xpath(doc, '/c:xml/c:doi_records/c:doi_record', ns);
|
||||
if(!doiRecords.length) {
|
||||
throw new Error("No records found");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var doiRecord = doiRecords[0];
|
||||
|
||||
// ensure this isn't an error
|
||||
var errorString = ZU.xpathText(doiRecord, 'c:crossref/c:error', ns);
|
||||
if(errorString !== null) {
|
||||
throw errorString;
|
||||
return false;
|
||||
}
|
||||
|
||||
var itemXML, item, refXML, metadataXML, seriesXML;
|
||||
if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:journal', ns)).length) {
|
||||
item = new Zotero.Item("journalArticle");
|
||||
refXML = ZU.xpath(itemXML, 'c:journal_article', ns);
|
||||
metadataXML = ZU.xpath(itemXML, 'c:journal_metadata', ns);
|
||||
|
||||
item.publicationTitle = ZU.xpathText(metadataXML, 'c:full_title[1]', ns);
|
||||
item.journalAbbreviation = ZU.xpathText(refXML, 'c:abbrev_title[1]', ns);
|
||||
item.volume = ZU.xpathText(itemXML, 'c:journal_issue/c:journal_volume/c:volume', ns);
|
||||
item.issue = ZU.xpathText(itemXML, 'c:journal_issue/c:journal_volume/c:issue', ns);
|
||||
} else if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:report-paper', ns)).length) {
|
||||
// Report Paper
|
||||
// Example: doi: 10.4271/2010-01-0907
|
||||
// http://www.crossref.org/openurl/?pid=zter:zter321&url_ver=Z39.88-2004&rft_id=info:doi/10.4271/2010-01-0907&format=unixref&redirect=false
|
||||
item = new Zotero.Item("report");
|
||||
refXML = ZU.xpath(itemXML, 'c:report-paper_metadata', ns);
|
||||
metadataXML = refXML;
|
||||
|
||||
item.reportNumber = ZU.xpathText(refXML, 'c:publisher_item/c:item_number', ns);
|
||||
item.institution = ZU.xpathText(refXML, 'c:publisher/c:publisher_name', ns);
|
||||
item.place = ZU.xpathText(refXML, 'c:publisher/c:publisher_place', ns);
|
||||
} else if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:book', ns)).length) {
|
||||
// Book chapter
|
||||
// Example: doi: 10.1017/CCOL0521858429.016
|
||||
// http://www.crossref.org/openurl/?pid=zter:zter321&url_ver=Z39.88-2004&rft_id=info:doi/10.1017/CCOL0521858429.016&format=unixref&redirect=false
|
||||
// Reference book entry
|
||||
// Example: doi: 10.1002/14651858.CD002966.pub3
|
||||
// http://www.crossref.org/openurl/?pid=zter:zter321&url_ver=Z39.88-2004&rft_id=info:doi/10.1002/14651858.CD002966.pub3&format=unixref&redirect=false
|
||||
var bookType = itemXML[0].hasAttribute("book_type") ? itemXML[0].getAttribute("book_type") : null;
|
||||
var componentType = itemXML[0].hasAttribute("component_type") ? itemXML[0].getAttribute("component_type") : null;
|
||||
|
||||
var isReference = ["reference", "other"].indexOf(bookType) !== -1
|
||||
&& ["chapter", "reference_entry"].indexOf(componentType);
|
||||
|
||||
if(bookType === "edited_book" || isReference) {
|
||||
item = new Zotero.Item("bookSection");
|
||||
refXML = ZU.xpath(itemXML, 'c:content_item', ns);
|
||||
|
||||
if(isReference) {
|
||||
metadataXML = ZU.xpath(itemXML, 'c:book_metadata', ns);
|
||||
if(!metadataXML.length) metadataXML = ZU.xpath(itemXML, 'c:book_series_metadata', ns);
|
||||
|
||||
item.bookTitle = ZU.xpathText(metadataXML, 'c:titles[1]/c:title[1]', ns);
|
||||
} else {
|
||||
metadataXML = ZU.xpath(itemXML, 'c:book_series_metadata', ns);
|
||||
if(!metadataXML.length) metadataXML = ZU.xpath(itemXML, 'c:book_metadata', ns);
|
||||
|
||||
item.bookTitle = ZU.xpathText(metadataXML, 'c:series_metadata/c:titles[1]/c:title[1]', ns);
|
||||
if(!item.bookTitle) item.bookTitle = ZU.xpathText(metadataXML, 'c:titles[1]/c:title[1]', ns);
|
||||
}
|
||||
|
||||
// Handle book authors
|
||||
parseCreators(metadataXML, item, {"author":"bookAuthor"});
|
||||
// Book
|
||||
} else {
|
||||
item = new Zotero.Item("book");
|
||||
refXML = ZU.xpath(itemXML, 'c:book_metadata', ns);
|
||||
metadataXML = refXML;
|
||||
seriesXML = ZU.xpath(refXML, 'c:series_metadata', ns);
|
||||
}
|
||||
|
||||
item.place = ZU.xpathText(metadataXML, 'c:publisher/c:publisher_place', ns);
|
||||
} else if((itemXML = ZU.xpath(doiRecord, 'c:crossref/c:conference', ns)).length) {
|
||||
item = new Zotero.Item("conferencePaper");
|
||||
refXML = ZU.xpath(itemXML, 'c:conference_paper', ns);
|
||||
metadataXML = ZU.xpath(itemXML, 'c:proceedings_metadata', ns);
|
||||
seriesXML = ZU.xpath(metadataXML, 'c:proceedings_metadata', ns);
|
||||
|
||||
item.publicationTitle = ZU.xpathText(metadataXML, 'c:publisher/c:proceedings_title', ns);
|
||||
item.place = ZU.xpathText(metadataXML, 'c:event_metadata/c:conference_location', ns);
|
||||
item.conferenceName = ZU.xpathText(metadataXML, 'c:event_metadata/c:conference_name', ns);
|
||||
}
|
||||
|
||||
item.ISBN = ZU.xpathText(metadataXML, 'c:isbn', ns);
|
||||
item.ISSN = ZU.xpathText(metadataXML, 'c:issn', ns);
|
||||
item.publisher = ZU.xpathText(metadataXML, 'c:publisher/c:publisher_name', ns);
|
||||
item.edition = ZU.xpathText(metadataXML, 'c:edition_number', ns);
|
||||
if(!item.volume) item.volume = ZU.xpathText(metadataXML, 'c:volume', ns);
|
||||
|
||||
parseCreators(refXML, item, "author");
|
||||
|
||||
if(seriesXML && seriesXML.length) {
|
||||
parseCreators(refXML, item, {"editor":"seriesEditor"});
|
||||
item.seriesNumber = ZU.xpathText(seriesXML, 'c:series_number', ns);
|
||||
}
|
||||
|
||||
var pubDateNode = ZU.xpath(refXML, 'c:publication_date', ns);
|
||||
if(!pubDateNode) ZU.xpath(metadataXML, 'c:publication_date', ns);
|
||||
|
||||
if(pubDateNode.length) {
|
||||
var year = ZU.xpathText(pubDateNode[0], 'c:year', ns);
|
||||
var month = ZU.xpathText(pubDateNode[0], 'c:month', ns);
|
||||
var day = ZU.xpathText(pubDateNode[0], 'c:day', ns);
|
||||
|
||||
if(year) {
|
||||
if(month) {
|
||||
if(day) {
|
||||
item.date = year+"-"+month+"-"+day;
|
||||
} else {
|
||||
item.date = month+"/"+year
|
||||
}
|
||||
} else {
|
||||
item.date = year;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var pages = ZU.xpath(refXML, 'c:pages[1]', ns);
|
||||
if(pages.length) {
|
||||
item.pages = ZU.xpathText(pages, 'c:first_page[1]', ns);
|
||||
var lastPage = ZU.xpathText(pages, 'c:last_page[1]', ns);
|
||||
if(lastPage) item.pages += "-"+lastPage;
|
||||
}
|
||||
|
||||
item.DOI = ZU.xpathText(refXML, 'c:doi_data/c:doi', ns);
|
||||
item.url = ZU.xpathText(refXML, 'c:doi_data/c:resource', ns);
|
||||
item.title = ZU.xpathText(refXML, 'c:titles[1]/c:title[1]', ns);
|
||||
|
||||
//Zotero.debug(JSON.stringify(item, null, 4));
|
||||
|
||||
item.complete();
|
||||
return true;
|
||||
}
|
||||
|
||||
function doSearch(item) {
|
||||
if(item.contextObject) {
|
||||
var co = item.contextObject;
|
||||
if(co.indexOf("url_ver=") == -1) {
|
||||
co = "url_ver=Z39.88-2004&"+co;
|
||||
}
|
||||
} else if(item.DOI) {
|
||||
var co = "url_ver=Z39.88-2004&&rft_id=info:doi/"+ZU.cleanDOI(item.DOI.toString());
|
||||
} else {
|
||||
var co = Zotero.Utilities.createContextObject(item);
|
||||
}
|
||||
|
||||
Zotero.Utilities.HTTP.doGet("http://www.crossref.org/openurl/?pid=zter:zter321&"+co+"&noredirect=true&format=unixref", function(responseText) {
|
||||
processCrossRef(responseText);
|
||||
Zotero.done();
|
||||
});
|
||||
|
||||
Zotero.wait();
|
||||
}
|
||||
/** BEGIN TEST CASES **/
|
||||
var testCases = [
|
||||
{
|
||||
"type": "search",
|
||||
"input": {
|
||||
"DOI":"10.1017/CCOL0521858429.016"
|
||||
},
|
||||
"items": [
|
||||
{
|
||||
"itemType": "bookSection",
|
||||
"creators": [
|
||||
{
|
||||
"creatorType": "editor",
|
||||
"firstName": "John",
|
||||
"lastName": "Rodden"
|
||||
},
|
||||
{
|
||||
"creatorType": "author",
|
||||
"firstName": "Christopher",
|
||||
"lastName": "Hitchens"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [],
|
||||
"bookTitle": "The Cambridge Companion to George Orwell",
|
||||
"place": "Cambridge",
|
||||
"ISBN": "0521858429, 9780521858427, 0521675073, 9780521675079",
|
||||
"publisher": "Cambridge University Press",
|
||||
"pages": "201-207",
|
||||
"DOI": "10.1017/CCOL0521858429.016",
|
||||
"url": "http://cco.cambridge.org/extract?id=ccol0521858429_CCOL0521858429A016",
|
||||
"title": "Why Orwell still matters",
|
||||
"libraryCatalog": "CrossRef"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
/** END TEST CASES **/
|
|
@ -1,87 +0,0 @@
|
|||
{
|
||||
"translatorID":"dbfcaa3e-082a-45a4-9619-9892f49399c1",
|
||||
"translatorType":4,
|
||||
"label":"Cyberpresse",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://www.cyberpresse.ca",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-08-06 17:00:00"
|
||||
}
|
||||
|
||||
function detectWeb (doc, url) {
|
||||
if (doc.location.href.match("article")) {
|
||||
return "newspaperArticle";
|
||||
}
|
||||
}
|
||||
|
||||
//Cyberpresse translator. Code by Adam Crymble
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
var tagsContent = new Array();
|
||||
var fieldTitle;
|
||||
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
|
||||
if (doc.title.match("|")) {
|
||||
|
||||
var titleStuff = doc.title.split("|");
|
||||
if (titleStuff[0].match(":")) {
|
||||
var authorTitle = titleStuff[0].split(":");
|
||||
newItem.title = authorTitle[1];
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authorTitle[0], "author"));
|
||||
|
||||
} else {
|
||||
newItem.title = titleStuff[0];
|
||||
}
|
||||
|
||||
} else {
|
||||
newItem.title = doc.title;
|
||||
}
|
||||
|
||||
var dataTagHTML = doc.getElementsByTagName("meta");
|
||||
for (var i = 0 ; i < dataTagHTML.length ; i++) {
|
||||
dataTags[dataTagHTML[i].getAttribute("name")] = Zotero.Utilities.cleanTags(dataTagHTML[i].getAttribute("content"));
|
||||
}
|
||||
|
||||
if (doc.evaluate('//div[@id="nouvelle"]/p[@class="auteur"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var author = doc.evaluate('//div[@id="nouvelle"]/p[@class="auteur"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author, "author"));
|
||||
}
|
||||
|
||||
if (doc.evaluate('//div[@id="nouvelle"]/p[@class="date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
newItem.date = doc.evaluate('//div[@id="nouvelle"]/p[@class="date"]', doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
}
|
||||
|
||||
associateData (newItem, dataTags, "summary", "abstractNote");
|
||||
associateData (newItem, dataTags, "mediaarticle", "publicationTitle");
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
newItem.complete();
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
articles = [url];
|
||||
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,170 +0,0 @@
|
|||
{
|
||||
"translatorID":"625c6435-e235-4402-a48f-3095a9c1a09c",
|
||||
"translatorType":4,
|
||||
"label":"DBLP Computer Science Bibliography",
|
||||
"creator":"Adam Crymble",
|
||||
"target":"http://(search?|dblp?).mpi-inf",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2008-09-02 13:40:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.title.match("journals")) {
|
||||
return "journalArticle";
|
||||
} else if (doc.title.match("conf")) {
|
||||
return "conferencePaper";
|
||||
} else if (doc.title.match("DBLP entry")) {
|
||||
return "bookSection";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//DBLP Computer Science Database Translator. Code by Adam Crymble.
|
||||
//Doesn't work for multiple entries. Site uses a different URL for the search and single entry. Multiple code attached as comment.
|
||||
|
||||
function associateData (newItem, dataTags, field, zoteroField) {
|
||||
if (dataTags[field]) {
|
||||
newItem[zoteroField] = dataTags[field];
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
} : null;
|
||||
|
||||
var dataTags = new Object();
|
||||
|
||||
var mediaType = detectWeb(doc, url);
|
||||
|
||||
if (mediaType == "bookSection") {
|
||||
var newItem = new Zotero.Item("bookSection");
|
||||
} else if (mediaType == "conferencePaper") {
|
||||
var newItem = new Zotero.Item("conferencePaper");
|
||||
} else if (mediaType == "journalArticle") {
|
||||
var newItem = new Zotero.Item("journalArticle");
|
||||
}
|
||||
|
||||
var xPathAllData = doc.evaluate('//pre', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var allData = xPathAllData.iterateNext().textContent.split("},");
|
||||
|
||||
var cleanFirstEntry = allData[0].indexOf(",");
|
||||
allData[0] = allData[0].substr(cleanFirstEntry);
|
||||
|
||||
var headers = new Array();
|
||||
var content = new Array();
|
||||
var splitAllData;
|
||||
|
||||
for (var i = 0; i < allData.length-2; i++) {
|
||||
splitAllData = allData[i].split("=");
|
||||
headers.push(splitAllData[0].replace(/^\s*|\s*$|\W*/g, ''));
|
||||
content.push(splitAllData[1].replace(/^\s*|\s*$|\{*/g, ''));
|
||||
|
||||
fieldTitle = headers[i].replace(",", '');
|
||||
|
||||
if (fieldTitle == "author") {
|
||||
var authors = content[i].split("and");
|
||||
|
||||
for (var j =0; j<authors.length; j++) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j], "author"));
|
||||
}
|
||||
} else if (fieldTitle == "editor") {
|
||||
var editors = content[i].split("and");
|
||||
|
||||
for (var j =0; j<editors.length; j++) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(editors[j], "editor"));
|
||||
}
|
||||
} else {
|
||||
|
||||
dataTags[fieldTitle] = content[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (mediaType == "conferencePaper") {
|
||||
associateData (newItem, dataTags, "booktitle", "conferenceName");
|
||||
} else {
|
||||
associateData (newItem, dataTags, "booktitle", "bookTitle");
|
||||
}
|
||||
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
associateData (newItem, dataTags, "year", "date");
|
||||
associateData (newItem, dataTags, "pages", "pages");
|
||||
associateData (newItem, dataTags, "title", "title");
|
||||
associateData (newItem, dataTags, "publisher", "publisher");
|
||||
associateData (newItem, dataTags, "volume", "volume");
|
||||
associateData (newItem, dataTags, "isbn", "ISBN");
|
||||
associateData (newItem, dataTags, "series", "series");
|
||||
associateData (newItem, dataTags, "journal", "publicationTitle");
|
||||
associateData (newItem, dataTags, "number", "issue");
|
||||
|
||||
newItem.complete();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var articles = new Array();
|
||||
|
||||
/* Multiple code doesn't work due to Permission denied to get property HTMLDocument.documentElement error.
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
//newer interface xPaths
|
||||
if (doc.title.match("DEMO")) {
|
||||
|
||||
var titles = doc.evaluate('//a/font', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//dt/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[links.iterateNext().href] = next_title.textContent;
|
||||
}
|
||||
|
||||
//older interface xPaths
|
||||
} else {
|
||||
|
||||
var titles = doc.evaluate('//td[3]', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var links = doc.evaluate('//td[1]/a', doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
var split1;
|
||||
var split2;
|
||||
|
||||
while (next_title = titles.iterateNext()) {
|
||||
|
||||
split1 = next_title.textContent.indexOf(":");
|
||||
var title = next_title.textContent.substr(split1+2);
|
||||
split2 = title.indexOf(".");
|
||||
title = title.substr(0, split2);
|
||||
|
||||
items[links.iterateNext().href] = title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
*/
|
||||
|
||||
articles = [url];
|
||||
//}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,155 +0,0 @@
|
|||
{
|
||||
"translatorID":"c159dcfe-8a53-4301-a499-30f6549c340d",
|
||||
"translatorType":4,
|
||||
"label":"DOI",
|
||||
"creator":"Simon Kornblith",
|
||||
"target":null,
|
||||
"minVersion":"1.0.10",
|
||||
"maxVersion":"",
|
||||
"priority":300,
|
||||
"browserSupport":"gcs",
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-06-23 08:58:22"
|
||||
}
|
||||
|
||||
var items = {};
|
||||
var selectArray = {};
|
||||
|
||||
// builds a list of DOIs
|
||||
function getDOIs(doc) {
|
||||
// TODO Detect DOIs more correctly.
|
||||
// The actual rules for DOIs are very lax-- but we're more strict.
|
||||
// Specifically, we should allow space characters, and all Unicode
|
||||
// characters except for control characters. Here, we're cheating
|
||||
// by not allowing ampersands, to fix an issue with getting DOIs
|
||||
// out of URLs.
|
||||
// Description at: http://www.doi.org/handbook_2000/appendix_1.html#A1-4
|
||||
const DOIre = /\b(10\.[\w.]+\/[^\s&]+)\.?\b/igm;
|
||||
const DOIXPath = "//text()[contains(., '10.')]";
|
||||
|
||||
DOIre.lastMatch = 0;
|
||||
var DOIs = [];
|
||||
|
||||
var node, m;
|
||||
var results = doc.evaluate(DOIXPath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
while(node = results.iterateNext()) {
|
||||
while(m = DOIre.exec(node.nodeValue)) {
|
||||
var DOI = m[1];
|
||||
if(DOI.substr(-1) == ")" && DOI.indexOf("(") == -1) {
|
||||
DOI = DOI.substr(0, DOI.length-1);
|
||||
}
|
||||
// only add new DOIs
|
||||
if(DOIs.indexOf(DOI) == -1) {
|
||||
DOIs.push(DOI);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return DOIs;
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
const blacklistRe = /^https?:\/\/[^/]*google\.com/i;
|
||||
|
||||
if(!blacklistRe.test(url)) {
|
||||
var DOIs = getDOIs(doc);
|
||||
if(DOIs.length) {
|
||||
return DOIs.length == 1 ? "journalArticle" : "multiple";
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function retrieveNextDOI(DOIs, doc) {
|
||||
if(DOIs.length) {
|
||||
// retrieve DOI
|
||||
var DOI = DOIs.shift();
|
||||
var translate = Zotero.loadTranslator("search");
|
||||
translate.setTranslator("11645bd1-0420-45c1-badb-53fb41eeb753");
|
||||
var item = {"itemType":"journalArticle", "DOI":DOI};
|
||||
translate.setSearch(item);
|
||||
// don't save when item is done
|
||||
translate.setHandler("itemDone", function(translate, item) {
|
||||
item.repository = "CrossRef";
|
||||
items[DOI] = item;
|
||||
selectArray[DOI] = item.title;
|
||||
});
|
||||
translate.setHandler("done", function(translate) {
|
||||
retrieveNextDOI(DOIs, doc);
|
||||
});
|
||||
translate.translate();
|
||||
} else {
|
||||
// all DOIs retrieved now
|
||||
// check to see if there is more than one DOI
|
||||
var numDOIs = 0;
|
||||
for(var DOI in selectArray) {
|
||||
numDOIs++;
|
||||
if(numDOIs == 2) break;
|
||||
}
|
||||
if(numDOIs == 0) {
|
||||
throw "DOI Translator: could not find DOI";
|
||||
} else if(numDOIs == 1) {
|
||||
// do we want to add URL of the page?
|
||||
items[DOI].url = doc.location.href;
|
||||
items[DOI].attachments = [{document:doc}];
|
||||
items[DOI].complete();
|
||||
} else {
|
||||
selectArray = Zotero.selectItems(selectArray);
|
||||
for(var DOI in selectArray) {
|
||||
items[DOI].complete();
|
||||
}
|
||||
}
|
||||
Zotero.done();
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var DOIs = getDOIs(doc);
|
||||
// retrieve full items asynchronously
|
||||
Zotero.wait();
|
||||
retrieveNextDOI(DOIs, doc);
|
||||
}
|
||||
|
||||
|
||||
/** BEGIN TEST CASES **/
|
||||
var testCases = [
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://www.crossref.org/help/Content/01_About_DOIs/What_is_a_DOI.htm",
|
||||
"items": [
|
||||
{
|
||||
"itemType": "journalArticle",
|
||||
"creators": [
|
||||
{
|
||||
"creatorType": "author",
|
||||
"firstName": "J",
|
||||
"lastName": "Mou"
|
||||
}
|
||||
],
|
||||
"notes": [],
|
||||
"tags": [],
|
||||
"seeAlso": [],
|
||||
"attachments": [
|
||||
{
|
||||
"document": false
|
||||
}
|
||||
],
|
||||
"publicationTitle": "Journal of Molecular Biology",
|
||||
"volume": "248",
|
||||
"ISSN": "00222836",
|
||||
"date": "1995-5-5",
|
||||
"pages": "507-512",
|
||||
"DOI": "10.1006/jmbi.1995.0238",
|
||||
"url": "http://www.crossref.org/help/Content/01_About_DOIs/What_is_a_DOI.htm",
|
||||
"title": "Atomic Force Microscopy of Cholera Toxin B-oligomers Bound to Bilayers of Biologically Relevant Lipids",
|
||||
"libraryCatalog": "CrossRef"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "web",
|
||||
"url": "http://blog.apastyle.org/apastyle/digital-object-identifier-doi/",
|
||||
"items": "multiple"
|
||||
}
|
||||
]
|
||||
/** END TEST CASES **/
|
|
@ -1,101 +0,0 @@
|
|||
{
|
||||
"translatorID":"0abd577b-ec45-4e9f-9081-448737e2fd34",
|
||||
"translatorType":4,
|
||||
"label":"DSpace",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"(dspace|upcommons.upc.edu)",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (doc.evaluate('//table[@class="itemDisplayTable"]', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "document";
|
||||
} else if (doc.evaluate('//table[@class="miscTable"]//td[2]', doc, null, XPathResult.ANY_TYPE, null).iterateNext() || doc.evaluate('//div[@id="main"]/ul[@class="browselist"]/li/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
var itemTypes = {
|
||||
"Article":"journalArticle",
|
||||
"Book":"book",
|
||||
"Thesis":"thesis",
|
||||
"Working Paper":"report",
|
||||
"Technical Report":"report"
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var records = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
if (doc.evaluate('//div[@id="main"]/ul[@class="browselist"]/li/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var xpath = '//div[@id="main"]/ul[@class="browselist"]/li/a';
|
||||
} else {
|
||||
var xpath = '//table[@class="miscTable"]//td[2]//a';
|
||||
}
|
||||
var rows = doc.evaluate(xpath, doc, null, XPathResult.ANY_TYPE, null);
|
||||
var row;
|
||||
while (row = rows.iterateNext()) {
|
||||
items[row.href] = row.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
records.push(i + '?mode=full');
|
||||
}
|
||||
} else {
|
||||
records = [url.match(/^([^?]+)\??/)[1] + "?mode=full"];
|
||||
}
|
||||
Zotero.Utilities.processDocuments(records, function(newDoc) {
|
||||
var values = new Object();
|
||||
var fields = newDoc.evaluate('//table[@class="itemDisplayTable"]/tbody/tr/td[1]', newDoc, null, XPathResult.ANY_TYPE, null);
|
||||
var data = newDoc.evaluate('//table[@class="itemDisplayTable"]/tbody/tr/td[2]', newDoc, null, XPathResult.ANY_TYPE, null);
|
||||
var field2;
|
||||
var datum2;
|
||||
var newItem = new Zotero.Item();
|
||||
while ((field2 = fields.iterateNext()) && (datum2 = data.iterateNext())) {
|
||||
var field = field2.textContent.replace(/^dc\./, "");
|
||||
var datum = datum2.textContent;
|
||||
if (field == "contributor.author") {
|
||||
var name = datum.split(",");
|
||||
newItem.creators.push({firstName:name[1], lastName:name[0], creatorType:"author"});
|
||||
} else if (field == "dentifier.uri") {
|
||||
newItem.url = datum;
|
||||
} else if (field == "title") {
|
||||
newItem.title = datum;
|
||||
} else if (field == "type") {
|
||||
if (itemTypes[datum]) {
|
||||
newItem.itemType = itemTypes[datum];
|
||||
} else {
|
||||
newItem.itemType = "document";
|
||||
}
|
||||
} else if (field == "description.abstract") {
|
||||
newItem.abstractNote = datum;
|
||||
} else if (field == "date.available") {
|
||||
newItem.date = datum.replace(/T.*$/, "");
|
||||
} else if (field == "subject") {
|
||||
newItem.tags.push(datum);
|
||||
} else if (field == "publisher") {
|
||||
newItem.publisher = datum;
|
||||
} else if (field == "identifier.issn") {
|
||||
newItem.ISSN = datum;
|
||||
} else if (field == "relation.ispartofseries") {
|
||||
if (datum.match(/Vol/)) {
|
||||
newItem.volume = datum.match(/\d+/)[0];
|
||||
} else if (datum.match(/No/)) {
|
||||
newItem.issue = datum.match(/\d+/)[0];
|
||||
}
|
||||
} else if (field == "rights") {
|
||||
newItem.rights = datum;
|
||||
}
|
||||
}
|
||||
if (newDoc.evaluate('//td[@class="standard"]/a', doc, null, XPathResult.ANY_TYPE, null).iterateNext()) var pdf = newDoc.evaluate('//td[@class="standard"]/a', newDoc, null, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
newItem.attachments = [{url:newDoc.location.href, title:"DSpace Snapshot", mimeType:"text/html"}];
|
||||
if (pdf) {
|
||||
newItem.attachments.push({url:pdf, title:"DSpace PDF", mimeType:"application/pdf"});
|
||||
}
|
||||
newItem.complete();
|
||||
}, function() {Zotero.done();});
|
||||
}
|
|
@ -1,126 +0,0 @@
|
|||
{
|
||||
"translatorID":"99be9976-2ff9-40df-96e8-82edfa79d9f3",
|
||||
"translatorType":4,
|
||||
"label":"Defense Technical Information Center",
|
||||
"creator":"Matt Burton",
|
||||
"target":"http://oai\\.dtic\\.mil/oai/",
|
||||
"minVersion":"1.0.0b3.r1",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2011-01-11 04:31:00"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if(doc.title.indexOf("DTIC OAI Index for") != -1) {
|
||||
return "multiple";
|
||||
} else if (url.indexOf("verb=getRecord") != -1){
|
||||
return "report";
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newURIs = new Array();
|
||||
|
||||
if(detectWeb(doc,url) == "multiple"){
|
||||
var links = doc.evaluate("//a/@href", doc, nsResolver, XPathResult.Abstract, null);
|
||||
var titles = doc.evaluate("//a/preceding::text()[1]", doc, nsResolver, XPathResult.Abstract, null);
|
||||
var items = new Object();
|
||||
var link, title;
|
||||
while( link = links.iterateNext(), title = titles.iterateNext()){
|
||||
items[link.textContent.replace(/&metadataPrefix=html/, "&metadataPrefix=oai_dc")] = title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
if(!items) {
|
||||
return true;
|
||||
}
|
||||
for (url in items) {
|
||||
newURIs.push(url);
|
||||
Zotero.debug(url);
|
||||
}
|
||||
} else {
|
||||
newURIs.push(url.replace(/&metadataPrefix=html/, "&metadataPrefix=oai_dc"))
|
||||
}
|
||||
|
||||
// ripped the arXiv.org code, hence the funny var names.
|
||||
Zotero.Utilities.HTTP.doGet(newURIs, function(text) {
|
||||
var newItem = new Zotero.Item("report");
|
||||
// remove header
|
||||
text = text.replace(/<!DOCTYPE[^>]*>/, "").replace(/<\?xml[^>]*\?>/, "");
|
||||
// fix non-compliant XML tags (colons)
|
||||
text = text.replace(/<dc:/g, "<dc_").replace(/<\/dc:/g, "</dc_");
|
||||
text = text.replace(/<oai_dc:dc/g, "<oai_dc_dc").replace(/<\/oai_dc:dc/g, "</oai_dc_dc");
|
||||
text = text.replace(/<OAI-PMH[^>]*>/, "").replace(/<\/OAI-PMH[^>]*>/, "");
|
||||
text = "<zotero>" + text + "</zotero>";
|
||||
var xml = new XML(text);
|
||||
var title;
|
||||
var citation = xml.GetRecord.record.metadata.oai_dc_dc;
|
||||
var test = xml..responseDate.text().toString();
|
||||
|
||||
if (citation.dc_title.length()){
|
||||
title = Zotero.Utilities.trimInternal(citation.dc_title.text().toString());
|
||||
newItem.title = title;
|
||||
}
|
||||
Zotero.debug("article title: " + title);
|
||||
var type = "";
|
||||
if(citation.dc_creator.length()) {
|
||||
var authors = citation.dc_creator;
|
||||
for(var j=0; j<authors.length(); j++) {
|
||||
Zotero.debug("author: " + authors[j]);
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(authors[j].text().toString(),type,true));
|
||||
}
|
||||
}
|
||||
if (citation.dc_date.length()) {
|
||||
var dates = citation.dc_date;
|
||||
newItem.date = Zotero.Utilities.trimInternal(dates[0].text().toString());
|
||||
}
|
||||
if (citation.dc_description.length()) {
|
||||
var descriptions = citation.dc_description;
|
||||
for (var j=0; j<descriptions.length(); j++) {
|
||||
var noteStr = Zotero.Utilities.trimInternal(descriptions[j].text().toString());
|
||||
newItem.notes.push({note:noteStr});
|
||||
}
|
||||
}
|
||||
if (citation.dc_subject.length()) {
|
||||
var subjects = citation.dc_subject;
|
||||
for (var j=0; j<subjects.length(); j++) {
|
||||
var subjectValue = Zotero.Utilities.trimInternal(subjects[j].text().toString());
|
||||
newItem.tags.push(subjectValue);
|
||||
}
|
||||
}
|
||||
if (citation.dc_identifier.length()) {
|
||||
var identifiers = citation.dc_identifier;
|
||||
for (var j=0; j<identifiers.length(); j++) {
|
||||
var identifier = Zotero.Utilities.trimInternal(identifiers[j].text().toString());
|
||||
if (identifier.substr(0, 4) == "doi:") {
|
||||
newItem.DOI = identifier;
|
||||
}
|
||||
else if (identifier.substr(0, 7) == "http://") {
|
||||
newItem.url = identifier;
|
||||
}
|
||||
else {
|
||||
newItem.extra = identifier;
|
||||
}
|
||||
}
|
||||
}
|
||||
var articleID = "";
|
||||
if (xml.GetRecord.record.header.identifier.length()) {
|
||||
articleID = xml.GetRecord.record.header.identifier.text().toString();
|
||||
articleID = articleID.substr(14);
|
||||
newItem.publicationTitle = articleID;
|
||||
}
|
||||
// TODO add "arXiv.org" to bib data?
|
||||
newItem.attachments.push({url:newItem.url, title:"DTIC Snapshot", mimeType:"text/html"});
|
||||
if (newItem.notes[0]['note']) {
|
||||
newItem.abstractNote = newItem.notes[0]['note'];
|
||||
newItem.notes = new Array();
|
||||
}
|
||||
newItem.complete();
|
||||
}, function() {Zotero.done();}, null);
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,81 +0,0 @@
|
|||
{
|
||||
"translatorID":"8b35ab14-f18a-4f69-8472-b2df18c984da",
|
||||
"translatorType":4,
|
||||
"label":"Davidson College Library",
|
||||
"creator":"Michael Berkowitz",
|
||||
"target":"http://www.lib.davidson.edu/",
|
||||
"minVersion":"1.0.0b4.r5",
|
||||
"maxVersion":"",
|
||||
"priority":100,
|
||||
"inRepository":true,
|
||||
"lastUpdated":"2009-01-08 08:19:07"
|
||||
}
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
if (url.indexOf("log_in") == -1) {
|
||||
if (url.indexOf("screen=Record") != -1) {
|
||||
return "book";
|
||||
} else {
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var books = new Array();
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = Zotero.Utilities.getItemArray(doc, doc, 'screen=Record.html');
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
books.push(i.replace("Record.html", "MARCRecord.html"));
|
||||
}
|
||||
} else {
|
||||
books = [url.replace("Record.html", "MARCRecord.html")];
|
||||
}
|
||||
|
||||
var translator = Zotero.loadTranslator("import");
|
||||
translator.setTranslator("a6ee60df-1ddc-4aae-bb25-45e0537be973");
|
||||
var marc = translator.getTranslatorObject();
|
||||
Zotero.Utilities.processDocuments(books, function(newDoc) {
|
||||
var uri = newDoc.location.href;
|
||||
var namespace = newDoc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var nonstandard = false;
|
||||
var xpath;
|
||||
var xpath = '//td[@class="body"]/p/table/tbody/tr[td[3]]';
|
||||
var elmts = newDoc.evaluate(xpath, newDoc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
var elmt;
|
||||
var record = new marc.record();
|
||||
while(elmt = elmts.iterateNext()) {
|
||||
var field = Zotero.Utilities.trimInternal(newDoc.evaluate('./td[1]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent);
|
||||
if(field) {
|
||||
var value = newDoc.evaluate('./td[3]', elmt, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
if(field == "LDR") {
|
||||
record.leader = value;
|
||||
} else if(field != "FMT") {
|
||||
value = value.replace(/\$([a-z]) /g, marc.subfieldDelimiter+"$1");
|
||||
var code = field.substring(0, 3);
|
||||
var ind = "";
|
||||
if(field.length > 3) {
|
||||
ind = field[3];
|
||||
if(field.length > 4) {
|
||||
ind += field[4];
|
||||
}
|
||||
}
|
||||
|
||||
record.addField(code, ind, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var newItem = new Zotero.Item();
|
||||
record.translate(newItem);
|
||||
|
||||
var domain = url.match(/https?:\/\/([^/]+)/);
|
||||
newItem.repository = "Davidson College Library Catalog";
|
||||
newItem.complete();
|
||||
}, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
}
|
|
@ -1,146 +0,0 @@
|
|||
{
|
||||
"translatorID": "1ab8b9a4-72b5-4ef4-adc8-4956a50718f7",
|
||||
"label": "Der Freitag",
|
||||
"creator": "Martin Meyerhoff",
|
||||
"target": "^http://www\\.freitag\\.de",
|
||||
"minVersion": "1.0",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": false,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-04-21 01:51:03"
|
||||
}
|
||||
|
||||
/*
|
||||
Der Freitag Translator
|
||||
Copyright (C) 2011 Martin Meyerhoff
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
This site is good, but very, very slow. So when importing multiple Items, be patient!
|
||||
http://www.freitag.de/search?modus=articles&SearchableText=Gaddafi*
|
||||
http://www.freitag.de
|
||||
http://www.freitag.de/guardian-world
|
||||
*/
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
// I use XPaths. Therefore, I need the following block.
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var Freitag_Artikel_XPath = '//div[contains(@class, "artikel_content")]/h2';
|
||||
var Freitag_multiple_XPath = ".//h3[contains(@class, 'listing')]/a";
|
||||
|
||||
if (doc.evaluate(Freitag_Artikel_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ // Diese Zeile verhindert die aus dem Tagesspiegel übernommenen Artikel!
|
||||
Zotero.debug("newspaperArticle");
|
||||
return "newspaperArticle";
|
||||
} else if (doc.evaluate(Freitag_multiple_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){ // Diese Zeile verhindert die aus dem Tagesspiegel übernommenen Artikel!
|
||||
Zotero.debug("multiple");
|
||||
return "multiple";
|
||||
}
|
||||
}
|
||||
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
|
||||
// This is for the author and date
|
||||
|
||||
var meta_XPath = "//div[contains(@class, 'article-heading-meta-left')]"
|
||||
var meta = doc.evaluate(meta_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
meta = meta.split("|");
|
||||
for (var i in meta) {
|
||||
meta[i] = meta[i].replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
|
||||
newItem.date = meta[1].split(/\s/)[0];
|
||||
|
||||
// author
|
||||
var author = meta[2].split(/\sund\s|\su\.\s|\,\s|\//);
|
||||
for (var i in author) {
|
||||
if (author[i].match(/\s/)) { // only names that contain a space!
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author"));
|
||||
}
|
||||
}
|
||||
|
||||
// title
|
||||
var title_XPath = '//title';
|
||||
var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
title = title.split(/\:|\—/);
|
||||
for (var i in title) {
|
||||
title[i] = title[i].replace(/^\s*|\s*$/g, '');
|
||||
}
|
||||
newItem.title = ""
|
||||
newItem.title = newItem.title.concat(title[0], ": ", title[1]);
|
||||
newItem.publicationTitle = "Der Freitag";
|
||||
|
||||
// Summary
|
||||
var summary_XPath = "//div[@class='artikel_content']/h3";
|
||||
var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.abstractNote = Zotero.Utilities.trim(summary);
|
||||
|
||||
// no Tags, because Der Freitag doesn't supply any.
|
||||
// Section
|
||||
var section_XPath = "//h1";
|
||||
var section= doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.section= section;
|
||||
|
||||
|
||||
// Snapshot
|
||||
var printurl_XPath = ".//a[@id='article-drucken']"
|
||||
var printurl= doc.evaluate(printurl_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().href;
|
||||
newItem.attachments.push({url:printurl, title:doc.title, mimeType:"text/html"});
|
||||
newItem.complete()
|
||||
|
||||
}
|
||||
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate(".//h3[contains(@class, 'listing')]/a", doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
articles.push(i);
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
} else {
|
||||
scrape(doc, url);
|
||||
}
|
||||
}
|
|
@ -1,183 +0,0 @@
|
|||
{
|
||||
"translatorID": "312bbb0e-bfb6-4563-a33c-085445d391ed",
|
||||
"label": "Die Zeit",
|
||||
"creator": "Martin Meyerhoff",
|
||||
"target": "^http://www\\.zeit\\.de/",
|
||||
"minVersion": "1.0",
|
||||
"maxVersion": "",
|
||||
"priority": 100,
|
||||
"inRepository": true,
|
||||
"translatorType": 4,
|
||||
"lastUpdated": "2011-04-21 02:25:21"
|
||||
}
|
||||
|
||||
/*
|
||||
Die Zeit Translator
|
||||
Copyright (C) 2011 Martin Meyerhoff
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
This translator works only partially, because zeit.de uses some strange javascript that makes
|
||||
processDocuments return an error. If I just call scrape(doc, url) on a single document, it works.
|
||||
The way the translator is programmed now, it only works if JavaScript is turned off in the browser.
|
||||
|
||||
Try it out here:
|
||||
http://www.zeit.de/wirtschaft/2011-03/schnappauf-ruecktritt-stuttgart
|
||||
http://www.zeit.de/online/2009/12/arbeitsrecht-urlaub
|
||||
http://www.zeit.de/suche/index?q=Krise
|
||||
http://www.zeit.de/2009/11/
|
||||
*/
|
||||
|
||||
function detectWeb(doc, url) {
|
||||
|
||||
// I use XPaths. Therefore, I need the following block.
|
||||
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var Zeit_ArticleTools_XPath = ".//*[@id='informatives']/ul[@class='tools']/li";
|
||||
var Zeit_Archive_XPath = "//h4/a|//h2/a";
|
||||
|
||||
if (doc.evaluate(Zeit_ArticleTools_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
Zotero.debug("newspaperArticle");
|
||||
return "newspaperArticle";
|
||||
} else if (doc.evaluate(Zeit_Archive_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
Zotero.debug("multiple");
|
||||
//return "multiple";
|
||||
return false; // TODO Make this not throw javascript errors when using processDocuments
|
||||
}
|
||||
}
|
||||
function scrape(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
|
||||
var newItem = new Zotero.Item("newspaperArticle");
|
||||
newItem.url = doc.location.href;
|
||||
|
||||
|
||||
// This is for the title!
|
||||
|
||||
var title_XPath = '//title'
|
||||
var title = doc.evaluate(title_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.title = Zotero.Utilities.trim(title.split("|")[0]);
|
||||
|
||||
|
||||
// Now for the Author
|
||||
|
||||
var author_XPath = '//li[contains(@class, "author first")]'; // I can't get the span selection to work. Help is appreciated.
|
||||
if (doc.evaluate(author_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var author = doc.evaluate(author_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
author = author.replace(/^\s*Von\s|\s*$/g, ''); // remove whitespace around the author and the "Von "at the beginning
|
||||
} else {
|
||||
var author = "";
|
||||
}
|
||||
var author = author.split(" | "); // this seems to work even if there's no |
|
||||
for (var i in author) {
|
||||
newItem.creators.push(Zotero.Utilities.cleanAuthor(author[i], "author"));
|
||||
}
|
||||
|
||||
// Now for the Tags
|
||||
|
||||
var tags_XPath = '//li[contains(@class, "tags")]'; // I can't get the span selection to work. Help is appreciated.
|
||||
if (doc.evaluate(tags_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var tags = doc.evaluate(tags_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
tags = tags.replace(/^\s*Schlagworte\s|\s*$/g, ''); // remove whitespace around the author and the "Von "at the beginning
|
||||
} else {
|
||||
var tags = "";
|
||||
}
|
||||
var tags= tags.split("|"); // this seems to work even if there's no |
|
||||
for (var i in tags) {
|
||||
tags[i] = tags[i].replace(/^\s*|\s*$/g, '') // remove whitespace around the tags
|
||||
newItem.tags.push(tags[i]);
|
||||
}
|
||||
|
||||
// Date
|
||||
var date_XPath = '//meta[contains(@name, "date_first_released")]';
|
||||
var date2_XPath = ".//li[@class='date']";
|
||||
if (doc.evaluate(date_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
var date = doc.evaluate(date_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content;
|
||||
date = date.split("T")[0];
|
||||
newItem.date = date;
|
||||
} else if (doc.evaluate(date2_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
var date = doc.evaluate(date2_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
date = Zotero.Utilities.trim(date.split(/\n/)[1]);
|
||||
date = date.replace(/Datum\s(\d\d?\.\d\d?\.\d\d\d\d).*/g, '$1');
|
||||
newItem.date = date;
|
||||
}
|
||||
|
||||
|
||||
// Summary
|
||||
|
||||
var summary_XPath = ".//p[@class='excerpt']"
|
||||
if (doc.evaluate(summary_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext() ){
|
||||
var summary = doc.evaluate(summary_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().textContent;
|
||||
newItem.abstractNote = Zotero.Utilities.trim(summary);
|
||||
}
|
||||
// Produkt (Zeit, Zeit online etc.)
|
||||
product_XPath = '//meta[contains(@name, "zeit::product-name")]'
|
||||
if (doc.evaluate(product_XPath, doc, null, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||
var product = doc.evaluate(product_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content;
|
||||
newItem.publicationTitle = product;
|
||||
} else {
|
||||
var product = "Die Zeit";
|
||||
newItem.publicationTitle = product;
|
||||
}
|
||||
|
||||
|
||||
// Section
|
||||
var section_XPath = '//meta[contains(@name, "zeit::ressort")]'
|
||||
var section = doc.evaluate(section_XPath, doc, nsResolver, XPathResult.ANY_TYPE, null).iterateNext().content;
|
||||
newItem.section= section;
|
||||
|
||||
newItem.attachments.push({url:doc.location.href+"?page=all&print=true", title:doc.title, mimeType:"text/html"});
|
||||
newItem.complete()
|
||||
|
||||
|
||||
}
|
||||
|
||||
function doWeb(doc, url) {
|
||||
var namespace = doc.documentElement.namespaceURI;
|
||||
var nsResolver = namespace ? function(prefix) {
|
||||
if (prefix == 'x') return namespace; else return null;
|
||||
} : null;
|
||||
var articles = new Array();
|
||||
|
||||
if (detectWeb(doc, url) == "multiple") {
|
||||
var items = new Object();
|
||||
|
||||
var titles = doc.evaluate("//h4/a|//h2/a", doc, nsResolver, XPathResult.ANY_TYPE, null);
|
||||
|
||||
var next_title;
|
||||
while (next_title = titles.iterateNext()) {
|
||||
if (next_title.textContent != '') {
|
||||
items[next_title.href] = next_title.textContent;
|
||||
}
|
||||
}
|
||||
items = Zotero.selectItems(items);
|
||||
for (var i in items) {
|
||||
Zotero.debug(i);
|
||||
articles.push(i);
|
||||
}
|
||||
Zotero.Utilities.processDocuments(articles, scrape, function() {Zotero.done();});
|
||||
Zotero.wait();
|
||||
} else {
|
||||
scrape(doc, url);
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue