Tweaks to getHiddenPref()
- Remove references to configOptions, displayOptions, and hiddenPrefs from connector/translator.js. We can't rely on them to be set in Zotero.Translator since https://repo.zotero.org/repo/metadata doesn't provide them, but we shouldn't need them until we get the translator code anyway. - Don't serve configOptions, displayOptions, and hiddenPrefs from Zotero Standalone server. There's no point in serving anything that https://repo.zotero.org/repo/metadata doesn't. - Alias the translator metadata loaded into the sandbox as Zotero.Translate._translatorInfo. Use this to get configOptions and hiddenPrefs. - "v" browserSupport indicates that a translator can be run through translation-server, not that translation-server is required. This obviates the need for zotero/zotero-connectors#4.
This commit is contained in:
parent
0c38ce03ac
commit
5465c885e5
|
@ -366,8 +366,7 @@ Zotero.Translators.CodeGetter.prototype.getCodeFor = function(i) {
|
|||
|
||||
const TRANSLATOR_REQUIRED_PROPERTIES = ["translatorID", "translatorType", "label", "creator", "target",
|
||||
"priority", "lastUpdated"];
|
||||
var TRANSLATOR_PASSING_PROPERTIES = TRANSLATOR_REQUIRED_PROPERTIES.concat(["displayOptions", "configOptions",
|
||||
"hiddenPrefs", "browserSupport", "code", "runMode"]);
|
||||
var TRANSLATOR_PASSING_PROPERTIES = TRANSLATOR_REQUIRED_PROPERTIES.concat(["browserSupport", "code", "runMode"]);
|
||||
var TRANSLATOR_SAVE_PROPERTIES = TRANSLATOR_REQUIRED_PROPERTIES.concat(["browserSupport"]);
|
||||
/**
|
||||
* @class Represents an individual translator
|
||||
|
@ -386,7 +385,7 @@ var TRANSLATOR_SAVE_PROPERTIES = TRANSLATOR_REQUIRED_PROPERTIES.concat(["browser
|
|||
* s = Safari (WebKit & Nitro/Squirrelfish Extreme)
|
||||
* i = Internet Explorer
|
||||
* b = Bookmarklet
|
||||
* v = Server (requires server translation when using a bookmarklet)
|
||||
* v = Server
|
||||
* @property {Object} configOptions Configuration options for import/export
|
||||
* @property {Object} displayOptions Display options for export
|
||||
* @property {Object} hiddenPrefs Hidden preferences configurable through about:config
|
||||
|
@ -422,10 +421,6 @@ Zotero.Translator.prototype.init = function(info) {
|
|||
this.runMode = Zotero.Translator.RUN_MODE_ZOTERO_STANDALONE;
|
||||
}
|
||||
|
||||
this._configOptions = info["configOptions"] ? info["configOptions"] : {};
|
||||
this._displayOptions = info["displayOptions"] ? info["displayOptions"] : {};
|
||||
this._hiddenPrefs = info["hiddenPrefs"] ? info["hiddenPrefs"] : {};
|
||||
|
||||
if(this.translatorType & TRANSLATOR_TYPES["import"]) {
|
||||
// compile import regexp to match only file extension
|
||||
this.importRegexp = this.target ? new RegExp("\\."+this.target+"$", "i") : null;
|
||||
|
@ -466,16 +461,6 @@ Zotero.Translator.prototype.getCode = function(callback) {
|
|||
);
|
||||
}
|
||||
|
||||
Zotero.Translator.prototype.__defineGetter__("displayOptions", function() {
|
||||
return Zotero.Utilities.deepCopy(this._displayOptions);
|
||||
});
|
||||
Zotero.Translator.prototype.__defineGetter__("configOptions", function() {
|
||||
return Zotero.Utilities.deepCopy(this._configOptions);
|
||||
});
|
||||
Zotero.Translator.prototype.__defineGetter__("hiddenPrefs", function() {
|
||||
return Zotero.Utilities.deepCopy(this._hiddenPrefs);
|
||||
});
|
||||
|
||||
/**
|
||||
* Log a translator-related error
|
||||
* @param {String} message The error message
|
||||
|
|
|
@ -66,8 +66,7 @@ Zotero.Server.Connector.GetTranslators.prototype = {
|
|||
for each(var translator in translators) {
|
||||
let serializableTranslator = {};
|
||||
for each(var key in ["translatorID", "translatorType", "label", "creator", "target",
|
||||
"minVersion", "maxVersion", "configOptions", "displayOptions", "hiddenPrefs", "priority",
|
||||
"browserSupport", "inRepository", "lastUpdated"]) {
|
||||
"minVersion", "maxVersion", "priority", "browserSupport", "inRepository", "lastUpdated"]) {
|
||||
serializableTranslator[key] = translator[key];
|
||||
}
|
||||
responseData.push(serializableTranslator);
|
||||
|
|
|
@ -181,7 +181,7 @@ Zotero.Translate.Sandbox = {
|
|||
throw(new Error("getPref: preference must be a string"));
|
||||
}
|
||||
|
||||
var hp = translate._hiddenPrefs || {}; //_hiddenPrefs should already be {} if undefined
|
||||
var hp = translate._translatorInfo.hiddenPrefs || {};
|
||||
|
||||
var value;
|
||||
try {
|
||||
|
@ -757,6 +757,7 @@ Zotero.Translate.Base.prototype = {
|
|||
"init":function() {
|
||||
this._handlers = [];
|
||||
this._currentState = null;
|
||||
this._translatorInfo = null;
|
||||
this.document = null;
|
||||
this.location = null;
|
||||
},
|
||||
|
@ -786,7 +787,6 @@ Zotero.Translate.Base.prototype = {
|
|||
}
|
||||
|
||||
this.translator = null;
|
||||
this._setDisplayOptions = null;
|
||||
|
||||
if(typeof(translator) == "object") { // passed an object and not an ID
|
||||
if(translator.translatorID) {
|
||||
|
@ -1352,7 +1352,6 @@ Zotero.Translate.Base.prototype = {
|
|||
this._runningAsyncProcesses = 0;
|
||||
this._returnValue = undefined;
|
||||
this._aborted = false;
|
||||
this._hiddenPrefs = translator.hiddenPrefs;
|
||||
this.saveQueue = [];
|
||||
|
||||
Zotero.debug("Translate: Parsing code for "+translator.label, 4);
|
||||
|
@ -1366,6 +1365,7 @@ Zotero.Translate.Base.prototype = {
|
|||
this.complete(false, e);
|
||||
return;
|
||||
}
|
||||
this._translatorInfo = this._sandboxManager.sandbox.ZOTERO_TRANSLATOR_INFO;
|
||||
|
||||
if(callback) callback();
|
||||
},
|
||||
|
@ -1848,7 +1848,7 @@ Zotero.Translate.Import.prototype._loadTranslator = function(translator, callbac
|
|||
* Prepare translator IO
|
||||
*/
|
||||
Zotero.Translate.Import.prototype._loadTranslatorPrepareIO = function(translator, callback) {
|
||||
var configOptions = this._sandboxManager.sandbox.ZOTERO_TRANSLATOR_INFO.configOptions;
|
||||
var configOptions = this._translatorInfo.configOptions;
|
||||
var dataMode = configOptions ? configOptions["dataMode"] : "";
|
||||
|
||||
var me = this;
|
||||
|
|
|
@ -426,7 +426,7 @@ Zotero.Translators = new function() {
|
|||
* s = Safari (WebKit & Nitro/Squirrelfish Extreme)
|
||||
* i = Internet Explorer
|
||||
* b = Bookmarklet
|
||||
* v = Server (requires server translation when using a bookmarklet)
|
||||
* v = Server
|
||||
* @property {Object} configOptions Configuration options for import/export
|
||||
* @property {Object} displayOptions Display options for export
|
||||
* @property {Object} hiddenPrefs Hidden preferences configurable through about:config
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 2c33d5d461cab0749702529e26686738e7a0b411
|
||||
Subproject commit a14697a41dcb6d51dc93cdafcdafe8a1cd1a2213
|
Loading…
Reference in New Issue
Block a user