From e5d3008e6531ac043c59266de1618ded8c3605d4 Mon Sep 17 00:00:00 2001 From: jrburke Date: Fri, 19 Nov 2010 12:30:32 -0800 Subject: [PATCH] add in settings for staging, update extension version number, start a bit of refactoring on first run detection. --- Makefile | 2 +- .../src/chrome/content/overlay.js | 70 ++++++++++++------- extensions/firefox-share/src/install.rdf | 2 +- tasks.txt | 2 + web/share/share.css | 7 +- 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index a1d6e10..13b2694 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ static_dir=$(TOPSRCDIR)/web-static webbuild_dir=$(TOPSRCDIR)/tools/webbuild requirejs_dir=$(webbuild_dir)/requirejs -version := 0.7.1 +version := 0.7.2 ifeq ($(release_build),) xpi_type := dev diff --git a/extensions/firefox-share/src/chrome/content/overlay.js b/extensions/firefox-share/src/chrome/content/overlay.js index 62c9527..1292378 100755 --- a/extensions/firefox-share/src/chrome/content/overlay.js +++ b/extensions/firefox-share/src/chrome/content/overlay.js @@ -37,6 +37,12 @@ var FFSHARE_EXT_ID = "ffshare@mozilla.org"; Components.utils.import("resource://ffshare/modules/injector.js"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); + // This add-on manager is only available in Firefox 4+ + try { + Components.utils.import("resource://gre/modules/AddonManager.jsm"); + } catch (e) { + } + var slice = Array.prototype.slice, ostring = Object.prototype.toString, empty = {}, fn, @@ -583,39 +589,51 @@ var FFSHARE_EXT_ID = "ffshare@mozilla.org"; errorPage: 'chrome://ffshare/content/down.html', + addButton: function () { + // Place the button in the toolbar. This should only be called + // on first install or upgrade. + try { + //Not needed since we add to the end. + //var afterId = "urlbar-container"; // ID of element to insert after + var navBar = document.getElementById("nav-bar"), + curSet = navBar.currentSet.split(","), set; + + if (curSet.indexOf(buttonId) === -1) { + //The next two lines place it between url and search bars. + //pos = curSet.indexOf(afterId) + 1 || curSet.length; + //var set = curSet.slice(0, pos).concat(buttonId).concat(curSet.slice(pos)); + //Add it to the end of the toolbar. + set = curSet.concat(buttonId).join(","); + + navBar.setAttribute("currentset", set); + navBar.currentSet = set; + document.persist(navBar.id, "currentset"); + try { + BrowserToolboxCustomizeDone(true); + } + catch (e) {} + } + } + catch (e) {} + }, + onLoad: function () { // initialization code if (this.firstRun) { - // Place the button in the toolbar on first load. - try { - //Not needed since we add to the end. - //var afterId = "urlbar-container"; // ID of element to insert after - var navBar = document.getElementById("nav-bar"), - curSet = navBar.currentSet.split(","), set; - - if (curSet.indexOf(buttonId) === -1) { - //The next two lines place it between url and search bars. - //pos = curSet.indexOf(afterId) + 1 || curSet.length; - //var set = curSet.slice(0, pos).concat(buttonId).concat(curSet.slice(pos)); - //Add it to the end of the toolbar. - set = curSet.concat(buttonId).join(","); - - navBar.setAttribute("currentset", set); - navBar.currentSet = set; - document.persist(navBar.id, "currentset"); - try { - BrowserToolboxCustomizeDone(true); - } - catch (e) {} - } - } - catch (e) {} + this.addButton(); //Register first run listener. gBrowser.getBrowserForTab(gBrowser.selectedTab).addProgressListener(firstRunProgressListener, Components.interfaces.nsIWebProgress.STATE_DOCUMENT); this.addedFirstRunProgressListener = true; } + //Figure out if this is a first install/upgrade case. + if (typeof AddonManager !== 'undefined') { + AddonManager.getAddonByID(FFSHARE_EXT_ID, function (addon) { + log("My extension's version is [" + addon.version + "]"); + }); + } + try { gBrowser.addProgressListener(canShareProgressListener); } catch (e) { @@ -805,6 +823,8 @@ var FFSHARE_EXT_ID = "ffshare@mozilla.org"; if (!ffshare.shareUrl) { if (ffshare.system === 'dev') { ffshare.shareUrl = 'http://linkdrop.caraveo.com:5000/share/'; + } else if (ffshare.system === 'staging') { + ffshare.shareUrl = 'https://f1-staging.mozillamessaging.com/share/'; } else { ffshare.shareUrl = 'https://f1.mozillamessaging.com/share/'; } @@ -813,6 +833,8 @@ var FFSHARE_EXT_ID = "ffshare@mozilla.org"; if (!ffshare.frontpageUrl) { if (ffshare.system === 'dev') { ffshare.frontpageUrl = 'http://linkdrop.caraveo.com:5000/'; + } else if (ffshare.system === 'staging') { + ffshare.frontpageUrl = 'http://f1-staging.mozillamessaging.com/'; } else { ffshare.frontpageUrl = 'http://f1.mozillamessaging.com/'; } diff --git a/extensions/firefox-share/src/install.rdf b/extensions/firefox-share/src/install.rdf index a90ea15..5012b03 100755 --- a/extensions/firefox-share/src/install.rdf +++ b/extensions/firefox-share/src/install.rdf @@ -4,7 +4,7 @@ ffshare@mozilla.org 2 F1 by Mozilla Labs - 0.7.1 + 0.7.2 Mozilla http://f1.mozillamessaging.com/ diff --git a/tasks.txt b/tasks.txt index 7760d6f..3edc21d 100644 --- a/tasks.txt +++ b/tasks.txt @@ -7,6 +7,8 @@ * HTML5/FF friendly option for the video - Bryan * Support long URLs better: - Shane * Make sure db can deal with long urls better (used to minimize bitly shortenings) +* Build xpi on staging box - Gozer +* For staging box, reference staging xpi for the install button. * Email template design - Andy * optional bugs * HTML5 autocomplete - James diff --git a/web/share/share.css b/web/share/share.css index 902d9aa..049a3ec 100644 --- a/web/share/share.css +++ b/web/share/share.css @@ -61,15 +61,10 @@ body.status { } /* Turn off some things if not in dev */ +html.staging body li.debugTab, html.prod body li.debugTab { display: none; } -/* -html.prod body li.gmailTab, -html.prod body #settings li.gmailSettings { - display: none; -} -*/ a { text-decoration: none;