adds scaffold, an extension to assist in translator development. scaffold is currently functional, but far from finished. to use, first install (the ID is scaffold@zotero.org), then write a translator in the "Code" tab and press the execute button. scaffold will execute the code in the last selected browser window, reporting any debug output or new items in the pane below. if an error occurs, the line at which the error took place is selected. besides that, the only other functionality implemented is the GUID generator.

This commit is contained in:
Simon Kornblith 2006-12-15 11:32:29 +00:00
parent 3982e1aabf
commit 1fe4cbac92

View File

@ -387,6 +387,12 @@ Zotero.Translate.prototype.setTranslator = function(translator) {
* called: when Zotero.debug() is called
* passed: string debug message
* returns: true if message should be logged to the console, false if not
*
* error
* valid: all
* called: when a fatal error occurs
* passed: error object (or string)
* returns: N/A
*/
Zotero.Translate.prototype.setHandler = function(type, handler) {
if(!this._handlers[type]) {
@ -620,11 +626,7 @@ Zotero.Translate.prototype._generateSandbox = function() {
this._sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult;
// for debug messages
this._sandbox.Zotero.debug = function(string) {
// if handler does not return anything explicitly false, show debug
// message in console
if(me._runHandler("debug", string) !== false) Zotero.debug(string, 4);
}
this._sandbox.Zotero.debug = function(string) {me._debug(string)};
// for asynchronous operation, use wait()
// done() is implemented after wait() is called
@ -941,20 +943,22 @@ Zotero.Translate.prototype._translationComplete = function(returnValue, error) {
}
}
// call handlers
this._runHandler("done", returnValue);
if(!returnValue) {
var errorString = this._generateErrorString(error);
Zotero.debug("translation using "+this.translator[0].label+" failed: \n"+errorString);
this._debug("Translation using "+this.translator[0].label+" failed: \n"+errorString);
if(this.type == "web") {
// report translation error for webpages
this._reportTranslationFailure(errorString);
}
this._runHandler("error", error);
} else {
Zotero.debug("translation successful");
this._debug("Translation successful");
}
// call handlers
this._runHandler("done", returnValue);
}
}
}
@ -1383,6 +1387,15 @@ Zotero.Translate.prototype._processCollection = function(collection, parentID) {
return newCollection;
}
/*
* logs a debugging message
*/
Zotero.Translate.prototype._debug = function(string) {
// if handler does not return anything explicitly false, show debug
// message in console
if(this._runHandler("debug", string) !== false) Zotero.debug(string, 4);
}
/*
* calls a handler (see setHandler above)
*/