From 8ad7367cff006c94affa450b67e8f5120a9342d4 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sun, 8 Jul 2012 22:01:52 -0400 Subject: [PATCH 1/7] CSL JSON improvements: - Fix export of literal names - Fix import of dates specified with date-parts --- chrome/content/zotero/xpcom/utilities.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/chrome/content/zotero/xpcom/utilities.js b/chrome/content/zotero/xpcom/utilities.js index 8850963233..f0d193e45d 100644 --- a/chrome/content/zotero/xpcom/utilities.js +++ b/chrome/content/zotero/xpcom/utilities.js @@ -1347,7 +1347,11 @@ Zotero.Utilities = { if(!creatorType) continue; - var nameObj = {'family':creator.lastName, 'given':creator.firstName}; + if(creator.fieldMode == 1) { + var nameObj = {'literal':creator.lastName}; + } else { + var nameObj = {'family':creator.lastName, 'given':creator.firstName}; + } if(cslItem[creatorType]) { cslItem[creatorType].push(nameObj); @@ -1490,11 +1494,14 @@ Zotero.Utilities = { date = cslDate.literal; } } else { - var newDate = Zotero.Utilities.deepCopy(cslDate);; - if(cslDate.dateParts && typeof cslDate.dateParts == "object") { - if(cslDate.dateParts[0]) newDate.year = cslDate.dateParts[0]; - if(cslDate.dateParts[1]) newDate.month = cslDate.dateParts[1]; - if(cslDate.dateParts[2]) newDate.day = cslDate.dateParts[2]; + var newDate = Zotero.Utilities.deepCopy(cslDate); + if(cslDate["date-parts"] && typeof cslDate["date-parts"] === "object" + && cslDate["date-parts"] !== null + && typeof cslDate["date-parts"][0] === "object" + && cslDate["date-parts"][0] !== null) { + if(cslDate["date-parts"][0][0]) newDate.year = cslDate["date-parts"][0][0]; + if(cslDate["date-parts"][0][1]) newDate.month = cslDate["date-parts"][0][1]; + if(cslDate["date-parts"][0][2]) newDate.day = cslDate["date-parts"][0][2]; } if(newDate.year) { @@ -1502,7 +1509,7 @@ Zotero.Utilities = { // Need to convert to SQL var date = Zotero.Utilities.lpad(newDate.year, "0", 4); if(newDate.month) { - date += "-"+Zotero.Utilities.lpad(newDate.month+1, "0", 2); + date += "-"+Zotero.Utilities.lpad(newDate.month, "0", 2); if(newDate.day) { date += "-"+Zotero.Utilities.lpad(newDate.day, "0", 2); } From b5e4334df557d62ee344b33d74130a03a021c9d9 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Wed, 11 Jul 2012 21:49:46 -0400 Subject: [PATCH 2/7] Ignore whitespace differences in test results, and provide more readable output upon data mismatch --- .../tools/testTranslators/translatorTester.js | 180 +++++++++++------- 1 file changed, 112 insertions(+), 68 deletions(-) diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index 8a76533409..1675b67e5f 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -506,6 +506,11 @@ Zotero_TranslatorTester.prototype._checkResult = function(test, translate, retur var translatedItem = Zotero_TranslatorTester._sanitizeItem(translate.newItems[i]); if(!this._compare(testItem, translatedItem)) { + // Show diff + this._debug(this, "Data mismatch detected:"); + this._debug(this, this._generateDiff(testItem, translatedItem)); + + // Save items. This makes it easier to correct tests automatically. var m = translate.newItems.length; test.itemsReturned = new Array(m); for(var j=0; j Date: Thu, 12 Jul 2012 10:01:59 -0400 Subject: [PATCH 3/7] Fix data mismatch false positives --- .../content/zotero/tools/testTranslators/translatorTester.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index 1675b67e5f..bc42d512c3 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -507,7 +507,7 @@ Zotero_TranslatorTester.prototype._checkResult = function(test, translate, retur if(!this._compare(testItem, translatedItem)) { // Show diff - this._debug(this, "Data mismatch detected:"); + this._debug(this, "TranslatorTester: Data mismatch detected:"); this._debug(this, this._generateDiff(testItem, translatedItem)); // Save items. This makes it easier to correct tests automatically. @@ -602,7 +602,7 @@ Zotero_TranslatorTester.prototype._compare = function(a, b) { } for(var key in a) { if(!a.hasOwnProperty(key)) continue; - if(!b.hasOwnProperty(key)) return false; + if(a[key] !== false && !b.hasOwnProperty(key)) return false; if(!this._compare(a[key], b[key])) return false; } for(var key in b) { From e0995a80324bed1f4edb8876d28b6f315d71752a Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 12 Jul 2012 12:03:06 -0400 Subject: [PATCH 4/7] Fix spacing --- chrome/content/zotero/locale/csl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/locale/csl b/chrome/content/zotero/locale/csl index 1e4594c2bf..0e599ae2a6 160000 --- a/chrome/content/zotero/locale/csl +++ b/chrome/content/zotero/locale/csl @@ -1 +1 @@ -Subproject commit 1e4594c2bf0af2b716d7279b8619de961ad832e1 +Subproject commit 0e599ae2a6625607673901749ff45b9d6f5f2157 From 28c19b54fbb4559b9c965b3160e49ac5dbbb2620 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 12 Jul 2012 12:09:03 -0400 Subject: [PATCH 5/7] Actually fix spacing --- .../content/zotero/tools/testTranslators/translatorTester.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index bc42d512c3..60be2262a5 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -669,7 +669,7 @@ Zotero_TranslatorTester.prototype._generateDiff = new function() { if(b.hasOwnProperty(key)) { changes += compare(a[key], b[key], keyPrefix, indent+" "); } else { - changes += show(a[key], "- ", keyPrefix, indent+" "); + changes += show(a[key], "-", keyPrefix, indent+" "); } } for(var key in b) { @@ -678,7 +678,7 @@ Zotero_TranslatorTester.prototype._generateDiff = new function() { haveKeys = true; if(!a.hasOwnProperty(key)) { var keyPrefix = aIsArray ? "" : JSON.stringify(key)+": "; - changes += show(b[key], "+ ", keyPrefix, indent+" "); + changes += show(b[key], "+", keyPrefix, indent+" "); } } From ec391d9346e4a389c9b4c037dc33295dbd953013 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 12 Jul 2012 12:09:19 -0400 Subject: [PATCH 6/7] Fix CSL checkout --- chrome/content/zotero/locale/csl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/locale/csl b/chrome/content/zotero/locale/csl index 0e599ae2a6..74ca6327aa 160000 --- a/chrome/content/zotero/locale/csl +++ b/chrome/content/zotero/locale/csl @@ -1 +1 @@ -Subproject commit 0e599ae2a6625607673901749ff45b9d6f5f2157 +Subproject commit 74ca6327aaa9bae30a5454ec49e406a1fd858e30 From d27b0654e85c23afd5b6176a0529194328ec4c4c Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 14 Jul 2012 16:42:14 -0400 Subject: [PATCH 7/7] Fix Zotero.ItemFields.getFieldIDFromTypeAndBase in connector --- chrome/content/zotero/xpcom/connector/cachedTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chrome/content/zotero/xpcom/connector/cachedTypes.js b/chrome/content/zotero/xpcom/connector/cachedTypes.js index 9c7333842e..bdc0751874 100644 --- a/chrome/content/zotero/xpcom/connector/cachedTypes.js +++ b/chrome/content/zotero/xpcom/connector/cachedTypes.js @@ -143,7 +143,7 @@ Zotero.Connector_Types = new function() { // loop through base fields for item type var baseFields = itemType[5]; - for(var i=0, n=baseFields.length; i