From 5ddd30eed8b38ef7143667d190ff722479abf54a Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 20 Dec 2006 05:01:13 +0000 Subject: [PATCH] - closes #458, chicago manual of style bibliography style. Sean and others, please test this if you have the time. - fixes conditional bugs in cite.js. i haven't had to use the conditionals until now, but Chicago has some bizarre formatting rules (especially 17.169) - removes extraneous debug code --- chrome/content/zotero/xpcom/cite.js | 21 ++-- chrome/content/zotero/xpcom/zotero.js | 7 -- chrome/locale/en-US/zotero/locales.xml | 4 + scrapers.sql | 165 ++++++++++++++++++++++++- 4 files changed, 174 insertions(+), 23 deletions(-) diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js index e55bb0fbfc..a00171ccf3 100644 --- a/chrome/content/zotero/xpcom/cite.js +++ b/chrome/content/zotero/xpcom/cite.js @@ -652,7 +652,9 @@ Zotero.CSL.prototype._parseFields = function(ref, position, type, bibCitElement, } // parse group children - if(itemDesc.name == "group") { + if(itemDesc.name == "group" || itemDesc.name == "conditional" || + itemDesc.name == "if" || itemDesc.name == "else-if" || + itemDesc.name == "else") { // parse attributes on this field, but ignore children this._parseFieldAttrChildren(element, itemDesc, true); @@ -1276,9 +1278,9 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr status = true; } } else if(condition.field) { - var formattedString = new Zotero.CSL.FormattedString(this, "Text"); + var testString = new Zotero.CSL.FormattedString(this, "Text"); status = this._getFieldValue(condition.field, this._getFieldDefaults(condition.field), item, - formattedString, bibCitElement); + testString, bibCitElement); } } else if(condition.name == "else") { status = true; @@ -1293,7 +1295,7 @@ Zotero.CSL.prototype._getFieldValue = function(name, element, item, formattedStr this._getFieldValue(child.name, child, item, data, bibCitElement, position, typeName); } - dataAppended = formattedString.concat(data, element); + dataAppended = formattedString.concat(data, condition); break; } } @@ -1407,8 +1409,6 @@ Zotero.CSL.FormattedString.prototype.concat = function(formattedString, element) * appends a string (with format parameters) to the current one */ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDelimit, dontEscape) { - Zotero.debug("CSL: ordered to append "+string); - if(!string) return false; if(typeof(string) != "string") { string = string.toString(); @@ -1444,7 +1444,7 @@ Zotero.CSL.FormattedString.prototype.append = function(string, element, dontDeli string = string.toUpperCase(); } else if(element["text-transform"] == "capitalize") { // capitalize first - string = string[0].toUpperCase()+string.substr(1).toLowerCase(); + string = string[0].toUpperCase()+string.substr(1); } } } @@ -1742,11 +1742,7 @@ Zotero.CSL.prototype._separateItemCreators = function(item) { var translatorID = Zotero.CreatorTypes.getID("translator"); var creators = item.getCreators(); - Zotero.debug("here come the creators"); - Zotero.debug(creators); for each(var creator in creators) { - Zotero.debug(creator); - if(creator.creatorTypeID == editorID) { editors.push(creator); } else if(creator.creatorTypeID == translatorID) { @@ -1757,9 +1753,6 @@ Zotero.CSL.prototype._separateItemCreators = function(item) { } } - Zotero.debug(authorID+", "+editorID+", "+translatorID); - Zotero.debug(creators); - return [authors, editors, translators]; } diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index e9ae5b5085..1797cbfe27 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -933,7 +933,6 @@ Zotero.Date = new function(){ date.day = m[2]; } } - Zotero.debug(date); if(date.year) date.year = parseInt(date.year, 10); if(date.day) date.day = parseInt(date.day, 10); @@ -948,8 +947,6 @@ Zotero.Date = new function(){ } } - Zotero.debug(date); - if(!date.month || date.month <= 12) { if(date.year && date.year < 100) { // for two digit years, determine proper // four digit year @@ -976,8 +973,6 @@ Zotero.Date = new function(){ Zotero.debug("DATE: algorithms failed sanity check"); date = {"part":string}; } - - Zotero.debug(date); } else { Zotero.debug("DATE: could not apply algorithms"); date.part = string; @@ -1043,8 +1038,6 @@ Zotero.Date = new function(){ } } - Zotero.debug(date); - return date; } diff --git a/chrome/locale/en-US/zotero/locales.xml b/chrome/locale/en-US/zotero/locales.xml index f126ce9400..a3c9126f14 100644 --- a/chrome/locale/en-US/zotero/locales.xml +++ b/chrome/locale/en-US/zotero/locales.xml @@ -68,6 +68,10 @@ edited by translated by + + ed + trans + January February diff --git a/scrapers.sql b/scrapers.sql index 07ef10168c..c2706e3618 100644 --- a/scrapers.sql +++ b/scrapers.sql @@ -1,4 +1,4 @@ --- 149 +-- 150 -- ***** BEGIN LICENSE BLOCK ***** -- @@ -22,7 +22,7 @@ -- Set the following timestamp to the most recent scraper update date -REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-12-19 21:25:46')); +REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-12-19 23:51:00')); REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b3.r1', '', '2006-12-15 03:40:00', 1, 100, 4, 'Amazon.com', 'Sean Takats', '^https?://(?:www\.)?amazon', 'function detectWeb(doc, url) { @@ -9677,6 +9677,167 @@ REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/apa.csl', '200 '); +REPLACE INTO "csl" VALUES('http://www.zotero.org/namespaces/CSL/chicago-author-date.csl', '2006-12-19 23:51:00', 'Chicago Manual of Style (Author-Date)', +' +'); + REPLACE INTO "csl" VALUES('http://purl.org/net/xbiblio/csl/styles/chicago-note.csl', '2006-10-02 17:00:00', 'Chicago Manual of Style (Note)', '