Export CSL JSON with title-short rather than shortTitle
This commit is contained in:
parent
9ed48f3837
commit
e618410eb2
3 changed files with 55 additions and 36 deletions
|
@ -82,7 +82,8 @@ var CSL_TEXT_MAPPINGS = {
|
||||||
"number":["number"],
|
"number":["number"],
|
||||||
"chapter-number":["session"],
|
"chapter-number":["session"],
|
||||||
"references":["history", "references"],
|
"references":["history", "references"],
|
||||||
"shortTitle":["shortTitle"],
|
"shortTitle":["shortTitle"], /* preserved to read legacy data */
|
||||||
|
"title-short":["shortTitle"],
|
||||||
"journalAbbreviation":["journalAbbreviation"],
|
"journalAbbreviation":["journalAbbreviation"],
|
||||||
"status":["legalStatus"],
|
"status":["legalStatus"],
|
||||||
"language":["language"]
|
"language":["language"]
|
||||||
|
@ -1588,6 +1589,7 @@ Zotero.Utilities = {
|
||||||
|
|
||||||
// get all text variables (there must be a better way)
|
// get all text variables (there must be a better way)
|
||||||
for(var variable in CSL_TEXT_MAPPINGS) {
|
for(var variable in CSL_TEXT_MAPPINGS) {
|
||||||
|
if (variable === "shortTitle") continue; // read both title-short and shortTitle, but write only title-short
|
||||||
var fields = CSL_TEXT_MAPPINGS[variable];
|
var fields = CSL_TEXT_MAPPINGS[variable];
|
||||||
for(var i=0, n=fields.length; i<n; i++) {
|
for(var i=0, n=fields.length; i<n; i++) {
|
||||||
var field = fields[i],
|
var field = fields[i],
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"medium": "Medium",
|
"medium": "Medium",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "graphic"
|
"type": "graphic"
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
"number-of-volumes": "7",
|
"number-of-volumes": "7",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "song",
|
"type": "song",
|
||||||
|
@ -138,7 +138,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"references": "History",
|
"references": "History",
|
||||||
"section": "Section",
|
"section": "Section",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "bill",
|
"type": "bill",
|
||||||
"volume": "6"
|
"volume": "6"
|
||||||
|
@ -178,7 +178,7 @@
|
||||||
},
|
},
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "post-weblog"
|
"type": "post-weblog"
|
||||||
},
|
},
|
||||||
|
@ -239,7 +239,7 @@
|
||||||
"number-of-volumes": "7",
|
"number-of-volumes": "7",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -315,7 +315,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -365,7 +365,7 @@
|
||||||
"number": "3",
|
"number": "3",
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"references": "History",
|
"references": "History",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "legal_case",
|
"type": "legal_case",
|
||||||
"volume": "6"
|
"volume": "6"
|
||||||
|
@ -412,7 +412,7 @@
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "book",
|
"type": "book",
|
||||||
|
@ -475,7 +475,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -545,7 +545,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -606,7 +606,7 @@
|
||||||
"given": "reviewedAuthorFirst"
|
"given": "reviewedAuthorFirst"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -656,7 +656,7 @@
|
||||||
"given": "recipientFirst"
|
"given": "recipientFirst"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "personal_communication"
|
"type": "personal_communication"
|
||||||
},
|
},
|
||||||
|
@ -718,7 +718,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -770,7 +770,7 @@
|
||||||
"medium": "Medium",
|
"medium": "Medium",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "motion_picture"
|
"type": "motion_picture"
|
||||||
|
@ -810,7 +810,7 @@
|
||||||
},
|
},
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "post"
|
"type": "post"
|
||||||
},
|
},
|
||||||
|
@ -857,7 +857,7 @@
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"references": "History",
|
"references": "History",
|
||||||
"section": "Committee",
|
"section": "Committee",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "bill"
|
"type": "bill"
|
||||||
},
|
},
|
||||||
|
@ -900,7 +900,7 @@
|
||||||
"given": "recipientFirst"
|
"given": "recipientFirst"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "personal_communication"
|
"type": "personal_communication"
|
||||||
},
|
},
|
||||||
|
@ -947,7 +947,7 @@
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"medium": "Medium",
|
"medium": "Medium",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -1013,7 +1013,7 @@
|
||||||
"given": "reviewedAuthorFirst"
|
"given": "reviewedAuthorFirst"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -1068,7 +1068,7 @@
|
||||||
"given": "recipientFirst"
|
"given": "recipientFirst"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "personal_communication"
|
"type": "personal_communication"
|
||||||
|
@ -1119,7 +1119,7 @@
|
||||||
"given": "reviewedAuthorFirst"
|
"given": "reviewedAuthorFirst"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -1171,7 +1171,7 @@
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"number-of-pages": "4",
|
"number-of-pages": "4",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -1232,7 +1232,7 @@
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"scale": "Scale",
|
"scale": "Scale",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "map"
|
"type": "map"
|
||||||
|
@ -1286,7 +1286,7 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"section": "Section",
|
"section": "Section",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -1338,7 +1338,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"references": "References",
|
"references": "References",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"status": "Legal status",
|
"status": "Legal status",
|
||||||
"submitted": {
|
"submitted": {
|
||||||
"date-parts": [
|
"date-parts": [
|
||||||
|
@ -1380,7 +1380,7 @@
|
||||||
"medium": "Medium",
|
"medium": "Medium",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"number": "3",
|
"number": "3",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "broadcast"
|
"type": "broadcast"
|
||||||
},
|
},
|
||||||
|
@ -1421,7 +1421,7 @@
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "speech"
|
"type": "speech"
|
||||||
},
|
},
|
||||||
|
@ -1468,7 +1468,7 @@
|
||||||
"number": "3",
|
"number": "3",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "broadcast"
|
"type": "broadcast"
|
||||||
|
@ -1522,7 +1522,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
|
@ -1572,7 +1572,7 @@
|
||||||
"page": "1-10",
|
"page": "1-10",
|
||||||
"references": "History",
|
"references": "History",
|
||||||
"section": "Section",
|
"section": "Section",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "legislation",
|
"type": "legislation",
|
||||||
"volume": "Code number"
|
"volume": "Code number"
|
||||||
|
@ -1618,7 +1618,7 @@
|
||||||
"number-of-pages": "4",
|
"number-of-pages": "4",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "thesis"
|
"type": "thesis"
|
||||||
|
@ -1666,7 +1666,7 @@
|
||||||
"number": "3",
|
"number": "3",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "broadcast"
|
"type": "broadcast"
|
||||||
|
@ -1715,7 +1715,7 @@
|
||||||
"number-of-volumes": "7",
|
"number-of-volumes": "7",
|
||||||
"publisher": "Publisher",
|
"publisher": "Publisher",
|
||||||
"publisher-place": "Place",
|
"publisher-place": "Place",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"source": "Library catalog",
|
"source": "Library catalog",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"type": "motion_picture",
|
"type": "motion_picture",
|
||||||
|
@ -1756,7 +1756,7 @@
|
||||||
},
|
},
|
||||||
"language": "en-US",
|
"language": "en-US",
|
||||||
"note": "Extra",
|
"note": "Extra",
|
||||||
"shortTitle": "Short title",
|
"title-short": "Short title",
|
||||||
"title": "Title",
|
"title": "Title",
|
||||||
"translator": [
|
"translator": [
|
||||||
{
|
{
|
||||||
|
@ -1766,4 +1766,4 @@
|
||||||
],
|
],
|
||||||
"type": "webpage"
|
"type": "webpage"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -418,6 +418,23 @@ describe("Zotero.Utilities", function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
it("should recognize the legacy shortTitle key", function* () {
|
||||||
|
this.timeout(20000);
|
||||||
|
|
||||||
|
let data = loadSampleData('citeProcJSExport');
|
||||||
|
|
||||||
|
var json = data.artwork;
|
||||||
|
var canonicalKeys = Object.keys(json);
|
||||||
|
json.shortTitle = json["title-short"];
|
||||||
|
delete json["title-short"];
|
||||||
|
|
||||||
|
let item = new Zotero.Item();
|
||||||
|
Zotero.Utilities.itemFromCSLJSON(item, json);
|
||||||
|
yield item.saveTx();
|
||||||
|
|
||||||
|
let newJSON = Zotero.Utilities.itemToCSLJSON(item);
|
||||||
|
assert.hasAllKeys(newJSON, canonicalKeys);
|
||||||
|
});
|
||||||
it("should import exported standalone note", function* () {
|
it("should import exported standalone note", function* () {
|
||||||
let note = new Zotero.Item('note');
|
let note = new Zotero.Item('note');
|
||||||
note.setNote('Some note longer than 50 characters, which will become the title.');
|
note.setNote('Some note longer than 50 characters, which will become the title.');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue