diff options
-rw-r--r-- | Makefile | 24 | ||||
-rw-r--r-- | data/lib/bzpage.js | 7 | ||||
-rw-r--r-- | lib/libbugzilla.js | 92 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | update.rdf | 15 |
5 files changed, 71 insertions, 69 deletions
@@ -1,24 +1,32 @@ -VERNO=$(shell js -e 'print(JSON.parse(read("package.json")).version);') +VERNO=$(shell rhino -e 'print(JSON.parse(readFile("package.json")).version);') WEBDIR=/home/matej/Dokumenty/website/fedorahosted/ UPSTREAM_XPI_URL=https://fedorahosted.org/released/bugzilla-triage-scripts/bugzilla-triage-$(VERNO).xpi UPDATE_URL=https://fedorahosted.org/released/bugzilla-triage-scripts/update.rdf -all: install +all: bugzilla-triage-$(VERNO).xpi update.rdf install: local-install - #make -C $(WEBDIR) - #websync + make -C $(WEBDIR) + websync -local-install: bugzilla-triage.xpi update.rdf - rsync -av bugzilla-triage.xpi $(WEBDIR) +local-install: bugzilla-triage-$(VERNO).xpi update.rdf + rsync -av bugzilla-triage*.xpi $(WEBDIR) rsync -av jsons/Config_data.json $(WEBDIR) -bugzilla-triage.xpi: package.json lib/*.js +bugzilla-triage-$(VERNO).xpi: package.json lib/*.js cfx xpi --update-link=$(UPSTREAM_XPI_URL) --update-url=$(UPDATE_URL) tidy -i -xml -utf8 -m bugzilla-triage.update.rdf + unzip bugzilla-triage.xpi install.rdf + sed -i -e '/maxVer/s/[0-9]\+\./10./' \ + -e '/minVer/s/[0-9]\+\./6./' install.rdf + sed -i -e '/maxVer/s/[0-9]\+\./10./' \ + -e '/minVer/s/[0-9]\+\./6./' bugzilla-triage.update.rdf + zip -9mqT bugzilla-triage.xpi install.rdf + mv bugzilla-triage.xpi bugzilla-triage-$(VERNO).xpi -update.rdf: bugzilla-triage.xpi +update.rdf: bugzilla-triage-$(VERNO).xpi tidy -i -xml -utf8 -m update.rdf clean: find . -name \*~ -print -delete + rm -f -v *.xpi bugzilla-triage.update.rdf diff --git a/data/lib/bzpage.js b/data/lib/bzpage.js index f3f5e27..4bba873 100644 --- a/data/lib/bzpage.js +++ b/data/lib/bzpage.js @@ -358,13 +358,18 @@ function completeInit() { function startup() { // First, preflight check ... if we are not logged in, there // is nothing we can do. + console.log("startup: Starting!"); var logoutLink = Array.some(document.links, function (x) { return x.search === "?logout=1" ; }); - if (!logoutLink) { + if (document.getElementById("brElementPlace_location")) { + console.error("Hit multiple firing protection!") return null; // This should just finish whole content script without // doing any harm to anybody. } + else { + console.myDebug("Didn't hit multiple firing protection!"); + } // Prepare for query buttons // element ID brElementPlace_location is later used in JSON files diff --git a/lib/libbugzilla.js b/lib/libbugzilla.js index 7458601..18cd2b5 100644 --- a/lib/libbugzilla.js +++ b/lib/libbugzilla.js @@ -290,6 +290,17 @@ exports.createUpstreamBug = function createUpstreamBug(urlStr, subjectStr, comme }); }; + +function processPageModeREs() { + var confD = config.configData; + ['bugPageMatch', 'skipMatch'].forEach(function (key) { + confD[key] = confD[key+"Str"].map(function (REStr) { + return new RegExp(REStr); + }); + }); +} + + function loginToAllBugzillas(callback) { var loginCallsCounter = 0, bugzilla = ""; @@ -308,6 +319,8 @@ function loginToAllBugzillas(callback) { onComplete: function onComplete(credentials) { // (we can have more than one set of credentials per bugzilla; // well, theoretically) + debug("loginToAllBugzillas: credentials found:\n" + + credentials.toSource()); credentials.forEach(function(credential) { // ... login! makeJSONRPCCall(credential.url + "/jsonrpc.cgi", @@ -365,21 +378,13 @@ var makeJSONRPCCall = exports.makeJSONRPCCall = function makeJSONRPCCall(url, me }).post(); }; -function processPageModeREs() { - var confD = config.configData; - ['bugPageMatch', 'skipMatch'].forEach(function (key) { - confD[key] = confD[key+"Str"].map(function (REStr) { - return new RegExp(REStr); - }); - }); -} - /** * Preprocess JSON into config data structure. * * Should be completely side-effects free pure function. */ function processConfigJSON(rawJSON) { + var config = {}; config.gJSONData = rawJSON; var origConstData = config.gJSONData.configData; @@ -430,12 +435,12 @@ function processConfigJSON(rawJSON) { }); } else { - config.configData.bugPageMatch = origConstData.matches; - config.configData.skipMatch = []; + config.configData.bugPageMatchStr = origConstData.matches; + config.configData.skipMatchStr = []; origConstData.matches. forEach(function(x) { skippingURLParts.forEach(function (part) { - config.configData.skipMatch.push(x. + config.configData.skipMatchStr.push(x. replace("show_bug.cgi.*", part + ".cgi")); }); }); @@ -466,28 +471,30 @@ function processConfigJSON(rawJSON) { config.configData[attrib] = origConstData[attrib]; } }); + + return(config); } +function ConfigurationLoadError(msg) { + this.name = "ConfigurationLoadError"; + this.message = msg || "Cannot load configuration!"; +} +ConfigurationLoadError.prototype = new Error(); +ConfigurationLoadError.constructor = ConfigurationLoadError; + + function fetchConfigurationJSON(url, callback) { + debug("Fetching configuration JSON from " + url); var retValue = null; Request({ url: url, onComplete: function (response) { if (response.status == 200) { - processConfigJSON(response.json); - myStorage.storage.configJSON.meta.eTag = response.headers['Etag']; - myStorage.storage.configJSON.meta.lastModified = - response.headers['Last-Modified']; - myStorage.storage.configJSON.parsedJSON = config; + config = processConfigJSON(response.json); + debug("Loaded configuration: " + config); } else { - // If we cannot get JSON from the real URL, we are happy - // with getting our fix from anywhere, including (possibly) - // expired cache - if (myStorage.storage.configJSON && - myStorage.storage.configJSON.parsedJSON) { - config = myStorage.storage.configJSON.parsedJSON; - } + throw new ConfigurationLoadError("Cannot load configuration from " + url); } if ("submitsLogging" in config.gJSONData.configData && config.gJSONData.configData.submitsLogging) { @@ -503,39 +510,6 @@ exports.initialize = function initialize(callback) { var urlStr = preferences.get(prefJSONURLName, JSONURLDefault); preferences.set(prefJSONURLName, urlStr); - if (!myStorage.storage.configJSON) { - myStorage.storage.configJSON = {}; - myStorage.storage.configJSON.meta = { - eTag: "", - lastModified: null - }; - } - - var req = new xhrMod.XMLHttpRequest(); - req.open("HEAD", urlStr, true); - req.onreadystatechange = function (aEvt) { - if (req.readyState == 4) { - if(req.status == 200) { - var _curETag = req.getResponseHeader("ETag"); - var _curLastModified = new Date(req.getResponseHeader("Last-Modified")); - if ((_curETag == myStorage.storage.configJSON.meta.eTag) - || (_curLastModified <= - myStorage.storage.configJSON.meta.lastModified)) { - debug("Loading from cache!"); - // use cached values - config = myStorage.storage.configJSON.parsedJSON; - if ("submitsLogging" in config.gJSONData.configData && - config.gJSONData.configData.submitsLogging) { - logger.initialize(); - } - loginToAllBugzillas(callback); - } - else { // cache is not up-to-date - debug("Too old cache!"); - fetchConfigurationJSON(urlStr, callback); - } - } - } - }; - req.send(); + debug("Starting initialize!"); + fetchConfigurationJSON(urlStr, callback); } diff --git a/package.json b/package.json index d30bb12..048edd5 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "description": "Additional buttons and other function helping in the triage on bugzilla", "author": "Matej Cepl (http://matej.ceplovi.cz)", "license": "MIT/X11 (http://opensource.org/licenses/mit-license.php) and MPL", - "version": "1.4.8", + "version": "1.4.90", "contributors": [ "Ehsan Akhgari (http://ehsanakhgari.org/) <ehsan@mozilla.com>", "Johnathan Nightingale (http://johnath.com) <johnath@mozilla.com>", @@ -172,6 +172,21 @@ xmlns:em="http://www.mozilla.org/2004/em-rdf#"> </em:targetApplication> </Description> </li> + <li> + <Description> + <em:version>1.4.90</em:version> + <em:targetApplication> + <Description> + <em:id> + {ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> + <em:minVersion>4.0b7</em:minVersion> + <em:maxVersion>10.0a1</em:maxVersion> + <em:updateLink> + https://fedorahosted.org/released/bugzilla-triage-scripts/bugzilla-triage-1.4.90.xpi</em:updateLink> + </Description> + </em:targetApplication> + </Description> + </li> </Seq> </em:updates> </Description> |