Use renamed-styles.json and flag from repo to replace renamed styles
Currently updating renamed-styles.json is a manual process.
This commit is contained in:
parent
6952f46986
commit
4f6fbf364d
4 changed files with 82 additions and 29 deletions
|
@ -31,8 +31,8 @@ Zotero.Schema = new function(){
|
|||
var _dbVersions = [];
|
||||
var _schemaVersions = [];
|
||||
var _repositoryTimer;
|
||||
var _remoteUpdateInProgress = false,
|
||||
_localUpdateInProgress = false;
|
||||
var _remoteUpdateInProgress = false, _localUpdateInProgress = false;
|
||||
var _renamedStylesByNew = null;
|
||||
|
||||
var self = this;
|
||||
|
||||
|
@ -597,6 +597,8 @@ Zotero.Schema = new function(){
|
|||
// Delete renamed/obsolete files
|
||||
case 'chicago-note.csl':
|
||||
case 'mhra_note_without_bibliography.csl':
|
||||
case 'mhra.csl':
|
||||
case 'mla.csl':
|
||||
toDelete.push(file);
|
||||
continue;
|
||||
|
||||
|
@ -1714,6 +1716,7 @@ Zotero.Schema = new function(){
|
|||
xmlnode.normalize();
|
||||
|
||||
var uri = xmlnode.getAttribute('id');
|
||||
var shortName = uri.replace("http://www.zotero.org/styles/", "");
|
||||
|
||||
// Delete local style if CSL code is empty
|
||||
if (!xmlnode.firstChild) {
|
||||
|
@ -1724,18 +1727,10 @@ Zotero.Schema = new function(){
|
|||
return;
|
||||
}
|
||||
|
||||
// Remove renamed styles
|
||||
if (uri == 'http://www.zotero.org/styles/american-medical-association') {
|
||||
var oldID = 'http://www.zotero.org/styles/ama';
|
||||
var style = Zotero.Styles.get(oldID);
|
||||
if (style && style.file.exists()) {
|
||||
Zotero.debug("Deleting renamed style '" + oldID + "'");
|
||||
style.file.remove(false);
|
||||
}
|
||||
}
|
||||
else if (uri == 'http://www.zotero.org/styles/national-library-of-medicine') {
|
||||
var oldID = 'http://www.zotero.org/styles/nlm';
|
||||
var style = Zotero.Styles.get(oldID);
|
||||
// Remove renamed styles, as instructed by the server
|
||||
var oldID = xmlnode.getAttribute('oldID');
|
||||
if (oldID) {
|
||||
var style = Zotero.Styles.get(oldID, true);
|
||||
if (style && style.file.exists()) {
|
||||
Zotero.debug("Deleting renamed style '" + oldID + "'");
|
||||
style.file.remove(false);
|
||||
|
|
|
@ -32,6 +32,8 @@ Zotero.Styles = new function() {
|
|||
var _initialized = false;
|
||||
var _styles, _visibleStyles, _cacheTranslatorData;
|
||||
|
||||
var _renamedStyles = null;
|
||||
|
||||
Components.utils.import("resource://zotero/q.js");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
|
@ -116,22 +118,26 @@ Zotero.Styles = new function() {
|
|||
/**
|
||||
* Gets a style with a given ID
|
||||
* @param {String} id
|
||||
* @param {Boolean} skipMappings Don't automatically return renamed style
|
||||
*/
|
||||
this.get = function(id) {
|
||||
// Map some obsolete styles to current ones
|
||||
const MAPPINGS = {
|
||||
"http://www.zotero.org/styles/chicago-note": "http://www.zotero.org/styles/chicago-note-bibliography",
|
||||
"http://www.zotero.org/styles/mhra_note_without_bibliography": "http://www.zotero.org/styles/mhra",
|
||||
"http://www.zotero.org/styles/aaa": "http://www.zotero.org/styles/american-anthropological-association",
|
||||
"http://www.zotero.org/styles/ama": "http://www.zotero.org/styles/american-medical-association",
|
||||
"http://www.zotero.org/styles/nlm": "http://www.zotero.org/styles/national-library-of-medicine"
|
||||
};
|
||||
|
||||
this.get = function(id, skipMappings) {
|
||||
if(!_initialized) this.init();
|
||||
|
||||
if(MAPPINGS.hasOwnProperty(id) && _styles[MAPPINGS[id]]) {
|
||||
Zotero.debug("Mapping " + id + " to " + MAPPINGS[id]);
|
||||
return _styles[MAPPINGS[id]];
|
||||
|
||||
// Map some obsolete styles to current ones
|
||||
if(!_renamedStyles) {
|
||||
_renamedStyles = JSON.parse(Zotero.File.getContentsFromURL(
|
||||
"resource://zotero/schema/renamed-styles.json"
|
||||
));
|
||||
}
|
||||
|
||||
if(!skipMappings) {
|
||||
var prefix = "http://www.zotero.org/styles/";
|
||||
var shortName = id.replace(prefix, "");
|
||||
if(_renamedStyles.hasOwnProperty(shortName) && _styles[prefix + _renamedStyles[shortName]]) {
|
||||
let newID = prefix + _renamedStyles[shortName];
|
||||
Zotero.debug("Mapping " + id + " to " + newID);
|
||||
return _styles[newID];
|
||||
}
|
||||
}
|
||||
|
||||
return _styles[id] || false;
|
||||
|
|
52
resource/schema/renamed-styles.json
Normal file
52
resource/schema/renamed-styles.json
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
"aaa": "american-anthropological-association",
|
||||
"ama": "american-medical-association",
|
||||
"american-journal-of-cardiology": "the-american-journal-of-cardiology",
|
||||
"american-journal-of-pathology": "the-american-journal-of-pathology",
|
||||
"amiens": "universite-de-picardie-jules-verne-ufr-de-medecine",
|
||||
"annalen-des-naturhistorischen-museums-wien": "annalen-des-naturhistorischen-museums-in-wien",
|
||||
"apa5th": "apa-5th-edition",
|
||||
"apsa": "american-political-science-association",
|
||||
"asa": "american-sociological-association",
|
||||
"chicago-note": "chicago-note-bibliography",
|
||||
"cuadernos-filologia-clasica": "cuadernos-de-filologia-clasica",
|
||||
"febs-journal": "the-febs-journal",
|
||||
"fems": "federation-of-european-microbiological-societies",
|
||||
"geological-society-of-america": "the-geological-society-of-america",
|
||||
"gost-r-7-0-5-2008-csl-1-0": "gost-r-7-0-5-2008",
|
||||
"graefes-archive-and-experimental-ophthalmology": "graefes-archive-for-clinical-and-experimental-ophthalmology",
|
||||
"harvard-anglia-ruskin": "harvard-anglia-ruskin-university",
|
||||
"harvard-sheffield": "harvard-the-university-of-sheffield-town-and-regional-planning",
|
||||
"harvard-sheffield1": "harvard-the-university-of-sheffield-school-of-east-asian-studies",
|
||||
"harvard-university-of-northampton": "harvard-the-university-of-northampton",
|
||||
"harvard-university-west-london": "harvard-university-of-west-london",
|
||||
"harvard1-unisa-gbfe": "harvard-gesellschaft-fur-bildung-und-forschung-in-europa",
|
||||
"harvard3": "harvard-swinburne-university-of-technology",
|
||||
"hwr-berlin": "hochschule-fur-wirtschaft-und-recht-berlin",
|
||||
"ieee-w-url": "ieee-with-url",
|
||||
"institute-of-electronics-information-and-communication-engineers": "the-institute-of-electronics-information-and-communication-engineers",
|
||||
"international-journal-of-psychoanalysis": "the-international-journal-of-psychoanalysis",
|
||||
"international-journal-of-tropical-biology-and-conservation": "revista-de-biologia-tropical",
|
||||
"journal-of-clinical-endocrinology-and-metabolism": "the-journal-of-clinical-endocrinology-and-metabolism",
|
||||
"journal-of-clinical-investigation": "the-journal-of-clinical-investigation",
|
||||
"journal-of-hellenic-studies": "the-journal-of-hellenic-studies",
|
||||
"journal-of-juristic-papyrology": "the-journal-of-juristic-papyrology",
|
||||
"journal-of-pharmacology-and-experimental-therapeutics": "the-journal-of-pharmacology-and-experimental-therapeutics",
|
||||
"journal-of-the-torrey-botanical-society": "the-journal-of-the-torrey-botanical-society",
|
||||
"journal-of-wildlife-management": "the-journal-of-wildlife-management",
|
||||
"juristische-zitierweise-deutsch": "juristische-zitierweise",
|
||||
"lancet": "the-lancet",
|
||||
"lichenologist": "the-lichenologist",
|
||||
"lncs": "springer-lecture-notes-in-computer-science",
|
||||
"lncs2": "springer-lecture-notes-in-computer-science-alphabetical",
|
||||
"methods-information-medicine": "methods-of-information-in-medicine",
|
||||
"mhra-author-date": "modern-humanities-research-association-author-date",
|
||||
"mhra": "modern-humanities-research-association",
|
||||
"mhra_note_without_bibliography": "modern-humanities-research-association",
|
||||
"mla-notes": "modern-language-association-note",
|
||||
"mla-underline": "modern-language-association-underline",
|
||||
"mla-url": "modern-language-association-with-url",
|
||||
"mla": "modern-language-association",
|
||||
"molecular-biochemical-parasitology": "molecular-and-biochemical-parasitology",
|
||||
"nlm": "national-library-of-medicine"
|
||||
}
|
2
styles
2
styles
|
@ -1 +1 @@
|
|||
Subproject commit b53019e1e601c6e843c58ad12c8149afc29ce4d6
|
||||
Subproject commit e136c9f0b4cd82fcd1bed4b4a35bb7139a40d9ea
|
Loading…
Reference in a new issue