closes #358, APA style doesn't properly handle references with editors and no authors
closes #348, OpenURL should use only relevant parts of dates closes #354, Error saving History Cooperative article closes #356, Embedded Dublin Core scraper incorrectly saves web pages as item type "book" closes #355, PubMed translator problem closes #368, RIS/Endnote export hijack doesn't go into active collection fixes an issue with quotation marks in bibliographies exported as RTF fixes an issue with bibliographies and non-English locales
This commit is contained in:
parent
e9e13bd38f
commit
666831748e
|
@ -183,7 +183,7 @@ Zotero.CSL.Global = new function() {
|
||||||
|
|
||||||
// get default terms
|
// get default terms
|
||||||
var locales = new XML(Zotero.CSL.Global.cleanXML(req.responseText));
|
var locales = new XML(Zotero.CSL.Global.cleanXML(req.responseText));
|
||||||
Zotero.CSL.Global._defaultTerms = Zotero.CSL.Global.parseLocales(locales);
|
Zotero.CSL.Global._defaultTerms = Zotero.CSL.Global.parseLocales(locales, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ Zotero.CSL.Global = new function() {
|
||||||
/*
|
/*
|
||||||
* parses locale strings into Zotero.CSL.Global._defaultTerms
|
* parses locale strings into Zotero.CSL.Global._defaultTerms
|
||||||
*/
|
*/
|
||||||
this.parseLocales = function(termXML) {
|
this.parseLocales = function(termXML, ignoreLang) {
|
||||||
// return defaults if there are no terms
|
// return defaults if there are no terms
|
||||||
if(!termXML.length()) {
|
if(!termXML.length()) {
|
||||||
return (Zotero.CSL.Global._defaultTerms ? Zotero.CSL.Global._defaultTerms : {});
|
return (Zotero.CSL.Global._defaultTerms ? Zotero.CSL.Global._defaultTerms : {});
|
||||||
|
@ -213,15 +213,20 @@ Zotero.CSL.Global = new function() {
|
||||||
|
|
||||||
var xml = new Namespace("http://www.w3.org/XML/1998/namespace");
|
var xml = new Namespace("http://www.w3.org/XML/1998/namespace");
|
||||||
|
|
||||||
// get proper locale
|
if(ignoreLang) {
|
||||||
var locale = termXML.locale.(@xml::lang == Zotero.CSL.Global._xmlLang);
|
// ignore lang if loaded from chrome
|
||||||
if(!locale.length()) {
|
locale = termXML.locale[0];
|
||||||
var xmlLang = Zotero.CSL.Global._xmlLang.substr(0, 2);
|
} else {
|
||||||
locale = termXML.locale.(@xml::lang == xmlLang);
|
// get proper locale
|
||||||
}
|
var locale = termXML.locale.(@xml::lang == Zotero.CSL.Global._xmlLang);
|
||||||
if(!locale.length()) {
|
if(!locale.length()) {
|
||||||
// return defaults if there are no locales
|
var xmlLang = Zotero.CSL.Global._xmlLang.substr(0, 2);
|
||||||
return (Zotero.CSL.Global._defaultTerms ? Zotero.CSL.Global._defaultTerms : {});
|
locale = termXML.locale.(@xml::lang == xmlLang);
|
||||||
|
}
|
||||||
|
if(!locale.length()) {
|
||||||
|
// return defaults if there are no locales
|
||||||
|
return (Zotero.CSL.Global._defaultTerms ? Zotero.CSL.Global._defaultTerms : {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var termArray = new Object();
|
var termArray = new Object();
|
||||||
|
@ -1114,9 +1119,11 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr
|
||||||
bibCitElement, position,
|
bibCitElement, position,
|
||||||
locatorType, locator, typeName) {
|
locatorType, locator, typeName) {
|
||||||
|
|
||||||
|
|
||||||
var dataAppended = false;
|
var dataAppended = false;
|
||||||
var itemID = item.getID();
|
var itemID = item.getID();
|
||||||
if(element._serialized && this._ignore && this._ignore[itemID] && this._ignore[itemID][element._serialized]) {
|
|
||||||
|
if(element._serialized && this._ignore && this._ignore[element._serialized]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1178,10 +1185,11 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr
|
||||||
dataAppended = formattedString.concat(data, element);
|
dataAppended = formattedString.concat(data, element);
|
||||||
} else if(name == "access") {
|
} else if(name == "access") {
|
||||||
var data = new Zotero.CSL.FormattedString(this, formattedString.format);
|
var data = new Zotero.CSL.FormattedString(this, formattedString.format);
|
||||||
var text;
|
var text = null;
|
||||||
var save = false;
|
var save = false;
|
||||||
|
|
||||||
for(var i in element.children) {
|
for(var i in element.children) {
|
||||||
|
text = null;
|
||||||
var child = element.children[i];
|
var child = element.children[i];
|
||||||
|
|
||||||
if(child.name == "url") {
|
if(child.name == "url") {
|
||||||
|
@ -1198,8 +1206,8 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr
|
||||||
text = this._getTerm(child["term-name"], false, child["form"]);
|
text = this._getTerm(child["term-name"], false, child["form"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(string) {
|
if(text) {
|
||||||
data.append(string, child);
|
data.append(text, child);
|
||||||
if(child.name != "text") {
|
if(child.name != "text") {
|
||||||
// only save if there's non-text data
|
// only save if there's non-text data
|
||||||
save = true;
|
save = true;
|
||||||
|
@ -1342,8 +1350,7 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr
|
||||||
|
|
||||||
// ignore elements with the same serialization
|
// ignore elements with the same serialization
|
||||||
if(this._ignore) { // array might not exist if doing disambiguation
|
if(this._ignore) { // array might not exist if doing disambiguation
|
||||||
if(!this._ignore[itemID]) this._ignore[itemID] = new Array();
|
this._ignore[serialization] = true;
|
||||||
this._ignore[itemID][substituteElement._serialized] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return field value, if there is one; otherwise, keep processing
|
// return field value, if there is one; otherwise, keep processing
|
||||||
|
@ -1365,6 +1372,14 @@ Zotero.CSL.FormattedString = function(CSL, format, delimiter) {
|
||||||
this.string = "";
|
this.string = "";
|
||||||
this.closePunctuation = false;
|
this.closePunctuation = false;
|
||||||
this.useBritishStyleQuotes = false;
|
this.useBritishStyleQuotes = false;
|
||||||
|
|
||||||
|
if(format == "RTF") {
|
||||||
|
this._openQuote = "\\uc0\\u8220 ";
|
||||||
|
this._closeQuote = "\\uc0\\u8221 ";
|
||||||
|
} else {
|
||||||
|
this._openQuote = "\u201c";
|
||||||
|
this._closeQuote = "\u201d";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.CSL.FormattedString._punctuation = ["!", ".", ",", "?"];
|
Zotero.CSL.FormattedString._punctuation = ["!", ".", ",", "?"];
|
||||||
|
@ -1377,7 +1392,6 @@ Zotero.CSL.FormattedString.prototype.concat = function(formattedString, element)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.debug("adding "+formattedString.string+" to "+this.string);
|
|
||||||
if(formattedString.format != this.format) {
|
if(formattedString.format != this.format) {
|
||||||
throw "CSL: cannot concatenate formatted strings: formats do not match";
|
throw "CSL: cannot concatenate formatted strings: formats do not match";
|
||||||
}
|
}
|
||||||
|
@ -1431,34 +1445,36 @@ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDeli
|
||||||
string = string[0].toUpperCase()+string.substr(1).toLowerCase();
|
string = string[0].toUpperCase()+string.substr(1).toLowerCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!dontEscape) {
|
if(!dontEscape) {
|
||||||
if(this.format == "HTML") {
|
if(this.format == "HTML") {
|
||||||
// replace HTML entities
|
// replace HTML entities
|
||||||
string = string.replace(/&/g, "&");
|
string = string.replace(/&/g, "&");
|
||||||
string = string.replace(/</g, "<");
|
string = string.replace(/</g, "<");
|
||||||
string = string.replace(/>/g, ">");
|
string = string.replace(/>/g, ">");
|
||||||
} else if(this.format == "RTF") {
|
} else if(this.format == "RTF") {
|
||||||
var newString = "";
|
var newString = "";
|
||||||
|
|
||||||
// go through and fix up unicode entities
|
// go through and fix up unicode entities
|
||||||
for(i=0; i<string.length; i++) {
|
for(i=0; i<string.length; i++) {
|
||||||
var charCode = string.charCodeAt(i);
|
var charCode = string.charCodeAt(i);
|
||||||
if(charCode > 127) { // encode unicode
|
if(charCode > 127) { // encode unicode
|
||||||
newString += "\\uc0\\u"+charCode.toString()+" ";
|
newString += "\\uc0\\u"+charCode.toString()+" ";
|
||||||
} else if(charCode == 92) { // double backslashes
|
} else if(charCode == 92) { // double backslashes
|
||||||
newString += "\\\\";
|
newString += "\\\\";
|
||||||
} else {
|
} else {
|
||||||
newString += string[i];
|
newString += string[i];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string = newString
|
|
||||||
} else if(this.format == "Integration") {
|
|
||||||
string = string.replace(/\\/g, "\\\\");
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
string = newString
|
||||||
|
} else if(this.format == "Integration") {
|
||||||
|
string = string.replace(/\\/g, "\\\\");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(element) {
|
||||||
if(this.format == "HTML") {
|
if(this.format == "HTML") {
|
||||||
var style = "";
|
var style = "";
|
||||||
|
|
||||||
|
@ -1487,12 +1503,12 @@ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDeli
|
||||||
|
|
||||||
// add quotes if necessary
|
// add quotes if necessary
|
||||||
if(element.quotes) {
|
if(element.quotes) {
|
||||||
this.string += "\u201c";
|
this.string += this._openQuote;
|
||||||
|
|
||||||
if(this.useBritishStyleQuotes) {
|
if(this.useBritishStyleQuotes) {
|
||||||
string += "\u201d";
|
string += this._closeQuote;
|
||||||
} else {
|
} else {
|
||||||
this.closePunctuation = "\u201d";
|
this.closePunctuation = this._closeQuote;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1512,7 +1528,6 @@ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDeli
|
||||||
suffix = suffix.substr(1);
|
suffix = suffix.substr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Zotero.debug("appending suffix");
|
|
||||||
this.append(suffix, null, true);
|
this.append(suffix, null, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -326,9 +326,19 @@ Zotero.OpenURL = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(item.date) {
|
if(item.date) {
|
||||||
co += _mapTag(item.date, "date", version);
|
var date = Zotero.Date.strToDate(item.date);
|
||||||
} else {
|
|
||||||
co += _mapTag(item.year, "date", version);
|
if(date.year) {
|
||||||
|
var dateString = Zotero.Utilities.prototype.lpad(date.year, "0", 4);
|
||||||
|
if(date.month) {
|
||||||
|
dateString += "-"+Zotero.Utilities.prototype.lpad(date.month, "0", 2);
|
||||||
|
if(date.day) {
|
||||||
|
dateString += "-"+Zotero.Utilities.prototype.lpad(date.day, "0", 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
co += _mapTag(dateString, "date", version);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
co += _mapTag(item.pages, "pages", version);
|
co += _mapTag(item.pages, "pages", version);
|
||||||
co += _mapTag(item.ISBN, "isbn", version);
|
co += _mapTag(item.ISBN, "isbn", version);
|
||||||
|
@ -643,8 +653,16 @@ Zotero.Ingester.MIMEHandler.StreamListener.prototype.onStopRequest = function(ch
|
||||||
var translation = new Zotero.Translate("import");
|
var translation = new Zotero.Translate("import");
|
||||||
translation.setLocation(this._request.name);
|
translation.setLocation(this._request.name);
|
||||||
translation.setString(this._readString);
|
translation.setString(this._readString);
|
||||||
translation.setHandler("itemDone", this._frontWindow.Zotero_Ingester_Interface._itemDone);
|
|
||||||
translation.setHandler("done", this._frontWindow.Zotero_Ingester_Interface._finishScraping);
|
// use front window's save functions and folder
|
||||||
|
var frontWindow = this._frontWindow;
|
||||||
|
|
||||||
|
var saveLocation = null;
|
||||||
|
try {
|
||||||
|
saveLocation = frontWindow.ZoteroPane.getSelectedCollection();
|
||||||
|
} catch(e) {}
|
||||||
|
translation.setHandler("itemDone", function(obj, item) { frontWindow.Zotero_Ingester_Interface._itemDone(obj, item, saveLocation) });
|
||||||
|
translation.setHandler("done", function(obj, item) { frontWindow.Zotero_Ingester_Interface._finishScraping(obj, item, saveLocation) });
|
||||||
|
|
||||||
// attempt to retrieve translators
|
// attempt to retrieve translators
|
||||||
var translators = translation.getTranslators();
|
var translators = translation.getTranslators();
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
<term name="in">in</term>
|
<term name="in">in</term>
|
||||||
<term name="ibid">ibid</term>
|
<term name="ibid">ibid</term>
|
||||||
<term name="accessed">accessed</term>
|
<term name="accessed">accessed</term>
|
||||||
|
<term name="retrieved">retrieved</term>
|
||||||
|
<term name="from">from</term>
|
||||||
<term name="forthcoming">forthcoming</term>
|
<term name="forthcoming">forthcoming</term>
|
||||||
<term name="references">References</term>
|
<term name="references">References</term>
|
||||||
<term name="no date">nd</term>
|
<term name="no date">nd</term>
|
||||||
|
|
34
scrapers.sql
34
scrapers.sql
|
@ -1,4 +1,4 @@
|
||||||
-- 100
|
-- 101
|
||||||
|
|
||||||
-- ***** BEGIN LICENSE BLOCK *****
|
-- ***** BEGIN LICENSE BLOCK *****
|
||||||
--
|
--
|
||||||
|
@ -687,7 +687,7 @@ function doWeb(doc, url) {
|
||||||
Zotero.wait();
|
Zotero.wait();
|
||||||
}');
|
}');
|
||||||
|
|
||||||
REPLACE INTO "translators" VALUES ('e85a3134-8c1a-8644-6926-584c8565f23e', '2006-10-02 17:00:00', 1, 100, 4, 'History Cooperative', 'Simon Kornblith', '^http://www\.historycooperative\.org/(?:journals/.+/.+/.+\.s?html$|cgi-bin/search.cgi)',
|
REPLACE INTO "translators" VALUES ('e85a3134-8c1a-8644-6926-584c8565f23e', '2006-10-23 00:23:00', 1, 100, 4, 'History Cooperative', 'Simon Kornblith', '^http://www\.historycooperative\.org/(?:journals/.+/.+/.+\.s?html$|cgi-bin/search.cgi)',
|
||||||
'function detectWeb(doc, url) {
|
'function detectWeb(doc, url) {
|
||||||
if(doc.title == "History Cooperative: Search Results") {
|
if(doc.title == "History Cooperative: Search Results") {
|
||||||
return "multiple";
|
return "multiple";
|
||||||
|
@ -708,7 +708,13 @@ function scrape(doc) {
|
||||||
|
|
||||||
var month, year;
|
var month, year;
|
||||||
var metaTags = doc.getElementsByTagName("meta");
|
var metaTags = doc.getElementsByTagName("meta");
|
||||||
associateMeta(newItem, metaTags, "Title", "title");
|
|
||||||
|
// grab title without using meta tag, since when titles have quotes History
|
||||||
|
// Cooperative can''t create a proper meta tag
|
||||||
|
var titleRe = /<!--_title_-->(.*)<!--_\/title_-->/;
|
||||||
|
var m = titleRe.exec(doc.getElementsByTagName("body")[0].innerHTML);
|
||||||
|
newItem.title = m[1];
|
||||||
|
|
||||||
associateMeta(newItem, metaTags, "Journal", "publicationTitle");
|
associateMeta(newItem, metaTags, "Journal", "publicationTitle");
|
||||||
associateMeta(newItem, metaTags, "Volume", "volume");
|
associateMeta(newItem, metaTags, "Volume", "volume");
|
||||||
associateMeta(newItem, metaTags, "Issue", "issue");
|
associateMeta(newItem, metaTags, "Issue", "issue");
|
||||||
|
@ -2572,11 +2578,17 @@ REPLACE INTO "translators" VALUES ('c54d1932-73ce-dfd4-a943-109380e06574', '2006
|
||||||
}
|
}
|
||||||
}');
|
}');
|
||||||
|
|
||||||
REPLACE INTO "translators" VALUES ('fcf41bed-0cbc-3704-85c7-8062a0068a7a', '2006-10-02 17:00:00', 1, 100, 12, 'PubMed', 'Simon Kornblith', '^http://www\.ncbi\.nlm\.nih\.gov/entrez/query\.fcgi\?(?:.*db=PubMed.*list_uids=[0-9]|.*list_uids=[0-9].*db=PubMed|.*db=PubMed.*CMD=search|.*CMD=search.*db=PubMed)',
|
REPLACE INTO "translators" VALUES ('fcf41bed-0cbc-3704-85c7-8062a0068a7a', '2006-10-23 00:23:00', 1, 100, 12, 'PubMed', 'Simon Kornblith', '^http://www\.ncbi\.nlm\.nih\.gov/entrez/query\.fcgi\?.*db=PubMed',
|
||||||
'function detectWeb(doc, url) {
|
'function detectWeb(doc, url) {
|
||||||
|
var namespace = doc.documentElement.namespaceURI;
|
||||||
|
var nsResolver = namespace ? function(prefix) {
|
||||||
|
if (prefix == ''x'') return namespace; else return null;
|
||||||
|
} : null;
|
||||||
|
|
||||||
if(doc.location.href.indexOf("list_uids=") >= 0) {
|
if(doc.location.href.indexOf("list_uids=") >= 0) {
|
||||||
return "journalArticle";
|
return "journalArticle";
|
||||||
} else {
|
} else if(doc.evaluate(''//div[@class="ResultSet"]/table/tbody'', doc,
|
||||||
|
nsResolver, XPathResult.ANY_TYPE, null).iterateNext()) {
|
||||||
return "multiple";
|
return "multiple";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2754,6 +2766,8 @@ REPLACE INTO "translators" VALUES ('951c027d-74ac-47d4-a107-9c3069ab7b48', '2006
|
||||||
var translator = Zotero.loadTranslator("import");
|
var translator = Zotero.loadTranslator("import");
|
||||||
translator.setTranslator("5e3ad958-ac79-463d-812b-a86a9235c28f");
|
translator.setTranslator("5e3ad958-ac79-463d-812b-a86a9235c28f");
|
||||||
translator.setHandler("itemDone", function(obj, newItem) {
|
translator.setHandler("itemDone", function(obj, newItem) {
|
||||||
|
newItem.itemType = "webpage";
|
||||||
|
|
||||||
// use document title if none given in dublin core
|
// use document title if none given in dublin core
|
||||||
if(!newItem.title) {
|
if(!newItem.title) {
|
||||||
newItem.title = doc.title;
|
newItem.title = doc.title;
|
||||||
|
@ -7336,13 +7350,13 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200
|
||||||
<name/>
|
<name/>
|
||||||
</publisher>
|
</publisher>
|
||||||
<access>
|
<access>
|
||||||
<text term-name="retrieved" text-transform="capitalize"/>
|
<text term-name="retrieved" text-transform="capitalize" suffix=" "/>
|
||||||
<date suffix=", ">
|
<date suffix=", ">
|
||||||
<month suffix=" "/>
|
<month suffix=" "/>
|
||||||
<day suffix=", "/>
|
<day suffix=", "/>
|
||||||
<year/>
|
<year/>
|
||||||
</date>
|
</date>
|
||||||
<text term-name="from"/>
|
<text term-name="from" suffix=" "/>
|
||||||
<url/>
|
<url/>
|
||||||
</access>
|
</access>
|
||||||
</defaults>
|
</defaults>
|
||||||
|
@ -7579,7 +7593,7 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.c
|
||||||
</citation>
|
</citation>
|
||||||
</style>');
|
</style>');
|
||||||
|
|
||||||
REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/mla.csl', '2006-10-02 17:00:00', 'Modern Language Association',
|
REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/mla.csl', '2006-10-23 00:21:00', 'Modern Language Association',
|
||||||
'<?xml version="1.0" encoding="UTF-8"?>
|
'<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?>
|
<?oxygen RNGSchema="../schema/trunk/csl.rnc" type="compact"?>
|
||||||
<style xmlns="http://purl.org/net/xbiblio/csl" class="author" xml:lang="en">
|
<style xmlns="http://purl.org/net/xbiblio/csl" class="author" xml:lang="en">
|
||||||
|
@ -7604,7 +7618,7 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/mla.csl', '200
|
||||||
<defaults>
|
<defaults>
|
||||||
<contributor name-as-sort-order="first">
|
<contributor name-as-sort-order="first">
|
||||||
<name and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
|
<name and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="always"/>
|
||||||
<label form="short" suffix="."/>
|
<label form="short" prefix=", " suffix="."/>
|
||||||
</contributor>
|
</contributor>
|
||||||
<author>
|
<author>
|
||||||
<substitute>
|
<substitute>
|
||||||
|
@ -7693,7 +7707,7 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/mla.csl', '200
|
||||||
</group>
|
</group>
|
||||||
<volume prefix=" "/>
|
<volume prefix=" "/>
|
||||||
<issue prefix="."/>
|
<issue prefix="."/>
|
||||||
<group prefix=" " suffix=".">
|
<group suffix=".">
|
||||||
<date prefix=" (" suffix=")"/>
|
<date prefix=" (" suffix=")"/>
|
||||||
<pages prefix=": "/>
|
<pages prefix=": "/>
|
||||||
</group>
|
</group>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user