commit ec786bf15c3ef0831b381d49a3022555dd2d8b19
parent c84a16984b80b0a7d44f1ad835f47eab86f1f36d
Author: Aurimas Vinckevicius <aurimas.dev@gmail.com>
Date: Wed, 13 May 2015 21:17:30 -0500
For now, use Zotero item DB ids when passing items to citeproc
citeproc-js relies on this in several locations. Seems that Zotero passes these IDs to citeproc from the item picker. We also need to consider existing embedded items in Word/LO documents, but they do have embedded URIs, so it shouldn't be a problem.
CC @fbennett
Diffstat:
2 files changed, 8 insertions(+), 17 deletions(-)
diff --git a/chrome/content/zotero/xpcom/cite.js b/chrome/content/zotero/xpcom/cite.js
@@ -524,6 +524,9 @@ Zotero.Cite.System.prototype = {
var cslItem = Zotero.Utilities.itemToCSLJSON(zoteroItem);
+ // TEMP: citeproc-js currently expects the id property to be the item DB id
+ cslItem.id = zoteroItem.id;
+
if (!Zotero.Prefs.get("export.citePaperJournalArticleURL")) {
var itemType = Zotero.ItemTypes.getName(zoteroItem.itemTypeID);
// don't return URL or accessed information for journal articles if a
diff --git a/test/content/support.js b/test/content/support.js
@@ -419,25 +419,13 @@ function generateCiteProcJSExportData(currentData) {
let zItem = Zotero.Items.get(items[itemName].id);
cslExportData[itemName] = Zotero.Cite.System.prototype.retrieveItem(zItem);
- // Don't replace id as long as it follows expected format
if (!currentData || !currentData[itemName]) continue;
- // For simplicity, be more lenient than for item key
- let idRe = /^http:\/\/zotero\.org\/users\/local\/\w{8}\/items\/\w{8}$/;
- for (let field in cslExportData[itemName]) {
- let oldVal = currentData[itemName][field];
- if (!oldVal) continue;
-
- let val = cslExportData[itemName][field];
- switch (field) {
- case 'id':
- if (!idRe.test(oldVal) || !idRe.test(val)) continue;
- break;
- default:
- continue;
- }
-
- cslExportData[itemName][field] = oldVal;
+ // Don't replace id as long as it follows expected format
+ if (Number.isInteger(currentData[itemName].id)
+ && Number.isInteger(cslExportData[itemName].id)
+ ) {
+ cslExportData[itemName].id = currentData[itemName].id;
}
}