add support for pushing configOptions and displayOptions, once Dan adds it to the repo

This commit is contained in:
Simon Kornblith 2011-03-23 01:42:17 +00:00
parent 74395a3024
commit e5cb2875e6
2 changed files with 14 additions and 9 deletions

View file

@ -1433,9 +1433,19 @@ Zotero.Schema = new function(){
xmlnode.getElementsByTagName('priority')[0].firstChild.nodeValue
),
inRepository: true,
lastUpdated: xmlnode.getAttribute('lastUpdated')
};
for each(var attr in ["configOptions", "displayOptions"]) {
try {
metadata[attr] = JSON.parse(xmlnode.getAttribute(attr));
} catch(e) {
Zotero.logError("Invalid JSON for "+attr+" in new version of "+metadata.label+" ("+translatorID+") from repository");
return;
}
}
metadata.lastUpdated = xmlnode.getAttribute('lastUpdated');
// detectCode can not exist or be empty
var detectCode = (xmlnode.getElementsByTagName('detectCode').item(0) &&
xmlnode.getElementsByTagName('detectCode')[0].firstChild)

View file

@ -181,6 +181,8 @@ Zotero.Translators = new function() {
* @param {String|Null} metadata.target Target regexp
* @param {String|Null} metadata.minVersion
* @param {String} metadata.maxVersion
* @param {String|undefined} metadata.configOptions
* @param {String|undefined} metadata.displayOptions
* @param {Integer} metadata.priority
* @param {Boolean} metadata.inRepository
* @param {String} metadata.lastUpdated SQL date
@ -225,15 +227,8 @@ Zotero.Translators = new function() {
var destFile = Zotero.getTranslatorsDirectory();
destFile.append(fileName);
var metadataJSON;
// JSON.stringify (FF 3.5.4 and up) has the benefit of indenting JSON
if (typeof JSON != "undefined" && 'function' == typeof JSON.stringify) {
metadataJSON = JSON.stringify(metadata,null,8);
} else {
var nsIJSON = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
metadataJSON = nsIJSON.encode(metadata);
}
var metadataJSON = JSON.stringify(metadata,null,8);
var str = metadataJSON + "\n\n" + code;