From d5bc6cbe4b676d2de248e0d183d3e4374748b33d Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Sat, 9 Sep 2006 22:45:03 +0000 Subject: [PATCH] - fixes a bug in capitalizeTitle - better feedback for search translator errors --- .../content/scholar/xpcom/translate.js | 41 +++++++++++-------- .../content/scholar/xpcom/utilities.js | 7 +++- scrapers.sql | 6 +-- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js index 6f0a4012e..ba2a6e179 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/translate.js +++ b/chrome/chromeFiles/content/scholar/xpcom/translate.js @@ -876,6 +876,8 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) if(this.type == "search" && !this._itemsFound && this.translator.length > 1) { // if we're performing a search and didn't get any results, go on // to the next translator + Scholar.debug("could not find a result using "+this.translator[0].label+": \n" + +this._generateErrorString(error)); this.translator.shift(); this.translate(); } else { @@ -897,23 +899,7 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) this._runHandler("done", returnValue); if(!returnValue) { - var errorString = ""; - if(typeof(error) == "string") { - errorString = "\nthrown exception => "+error; - } else { - for(var i in error) { - if(typeof(error[i]) != "object") { - errorString += "\n"+i+' => '+error[i]; - } - } - } - - errorString += "\nurl => "+this.path - + "\nextensions.zotero.cacheTranslatorData => "+Scholar.Prefs.get("cacheTranslatorData") - + "\nextensions.zotero.downloadAssociatedFiles => "+Scholar.Prefs.get("downloadAssociatedFiles"); - - errorString = errorString.substr(1); - + var errorString = this._generateErrorString(error); Scholar.debug("translation using "+this.translator[0].label+" failed: \n"+errorString); if(this.type == "web") { @@ -927,6 +913,27 @@ Scholar.Translate.prototype._translationComplete = function(returnValue, error) } } +/* + * generates a useful error string, for submitting and debugging purposes + */ +Scholar.Translate.prototype._generateErrorString = function(error) { + var errorString = ""; + if(typeof(error) == "string") { + errorString = "\nthrown exception => "+error; + } else { + for(var i in error) { + if(typeof(error[i]) != "object") { + errorString += "\n"+i+' => '+error[i]; + } + } + } + + errorString += "\nurl => "+this.path + + "\nextensions.zotero.cacheTranslatorData => "+Scholar.Prefs.get("cacheTranslatorData") + + "\nextensions.zotero.downloadAssociatedFiles => "+Scholar.Prefs.get("downloadAssociatedFiles"); + return errorString.substr(1); +} + /* * runs an HTTP request to report a translation error */ diff --git a/chrome/chromeFiles/content/scholar/xpcom/utilities.js b/chrome/chromeFiles/content/scholar/xpcom/utilities.js index a1f190237..550dd7b56 100644 --- a/chrome/chromeFiles/content/scholar/xpcom/utilities.js +++ b/chrome/chromeFiles/content/scholar/xpcom/utilities.js @@ -158,6 +158,7 @@ Scholar.Utilities.capitalizeSkipWords = ["but", "or", "yet", "so", "for", "and", "nor", "a", "an", "the", "at", "by", "from", "in", "into", "of", "on", "to", "with", "up", "down"]; Scholar.Utilities.prototype.capitalizeTitle = function(title) { + title = this.cleanString(title); title = title.replace(/ : /g, ": "); var words = title.split(" "); @@ -172,7 +173,7 @@ Scholar.Utilities.prototype.capitalizeTitle = function(title) { for(var i=1; i