[Pkg-mozext-commits] [personasplus] 11/42: Bug 848183: Fetch initial persona data from AMO rather than hard coding it in service.js
David Prévot
taffit at moszumanska.debian.org
Wed Feb 3 16:15:39 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository personasplus.
commit 6d3a25573d8587ed96c7bd1a7895ed31e3a20dc5
Author: Kris Maglione <maglione.k at gmail.com>
Date: Fri Mar 22 12:28:05 2013 -0700
Bug 848183: Fetch initial persona data from AMO rather than hard coding it in service.js
---
Makefile | 11 +++---
extension/content/personas.js | 2 +-
extension/defaults/preferences/prefs.js | 4 +++
extension/modules/service.js | 63 +++++++++++++--------------------
4 files changed, 36 insertions(+), 44 deletions(-)
diff --git a/Makefile b/Makefile
index aaf9d8d..bb990ea 100644
--- a/Makefile
+++ b/Makefile
@@ -7,22 +7,25 @@ XPI = $(DIST)$(NAME)-$(VERSION).xpi
NAME = personas-plus
VERSION = $(shell sed -rn 's,.*<em:version>(.*)</em:version>,\1,p; /em:version/q' <$(EXTENSION_ROOT)install.rdf)
-FILE_EXTENSIONS = jpg css dtd js png properties xml xul
-
# Oh GNU make...
space :=
space +=
+FILE_EXTENSIONS = jpg css dtd js png properties xml xul
+ROOT_DIRECTORIES = content skin locale modules components defaults
+
FILES = install.rdf \
chrome.manifest \
- $(shell set -x; cd $(EXTENSION_ROOT); find content skin locale modules components defaults -regex '.*\.\($(subst $(space),\|,$(FILE_EXTENSIONS))\)$$')
+ $(shell set -x; cd $(EXTENSION_ROOT); \
+ find $(ROOT_DIRECTORIES) -regex '.*\.\($(subst $(space),\|,$(FILE_EXTENSIONS))\)$$')
xpi: $(XPI)
+ @echo Created XPI file://$(XPI)
$(XPI): $(FILES:%=$(EXTENSION_ROOT)%) Makefile
mkdir -p $(DIST)
cd $(EXTENSION_ROOT)
7z a $@ $(FILES)
- echo Created XPI file://$(XPI)
.ONESHELL:
+.PHONY: xpi
diff --git a/extension/content/personas.js b/extension/content/personas.js
index 72e6b8a..66e43cd 100644
--- a/extension/content/personas.js
+++ b/extension/content/personas.js
@@ -1148,7 +1148,7 @@ let PersonaController = {
_createPersonaItem: function(persona) {
let item = document.createElement("menuitem");
- let theme = persona.theme || persona;
+ let theme = PersonaService.getPersonaJSON(persona);
let headerURI;
if (persona.custom) {
diff --git a/extension/defaults/preferences/prefs.js b/extension/defaults/preferences/prefs.js
index 86a65b6..1257046 100644
--- a/extension/defaults/preferences/prefs.js
+++ b/extension/defaults/preferences/prefs.js
@@ -57,6 +57,10 @@ pref("extensions.personas.featured-feed.url", "https://addons.mozilla.org/en-US/
pref("extensions.personas.browse.url", "https://addons.mozilla.org/themes/");
+pref("extensions.personas.addon-details.url", "https://services.addons.mozilla.org/en-US/api/1.5/addon/%ADDON_SLUG%/?format=json");
+
+pref("extensions.personas.initial.slug", "groovy-blue");
+
// The authorizedHosts preference is a comma and/or space-separated list
// of domains allowed to set and preview personas.
// At a minimum, it must contain a value matching the domain at which the web
diff --git a/extension/modules/service.js b/extension/modules/service.js
index a9a26a0..6e4b2f7 100644
--- a/extension/modules/service.js
+++ b/extension/modules/service.js
@@ -178,42 +178,19 @@ let PersonaService = {
else if (LightweightThemeManager && LightweightThemeManager.currentTheme)
this.changeToPersona(LightweightThemeManager.currentTheme);
else {
- this.changeToPersona({
- "id":"33",
- "name":"Groovy Blue",
- "accentcolor":"#6699ff",
- "textcolor":"#07188d",
- "header":"3\/3\/33\/tbox-groovy_blue.jpg",
- "footer":"3\/3\/33\/stbar-groovy_blue.jpg",
- "category":"Abstract",
- "description":null,
- "author":"Lee.Tom",
- "username":"Lee.Tom",
- "detailURL":"https:\/\/www.getpersonas.com\/persona\/33",
- "headerURL":"http:\/\/www.getpersonas.com\/static\/3\/3\/33\/tbox-groovy_blue.jpg",
- "footerURL":"http:\/\/www.getpersonas.com\/static\/3\/3\/33\/stbar-groovy_blue.jpg",
- "previewURL":"http:\/\/www.getpersonas.com\/static\/3\/3\/33\/preview.jpg",
- "iconURL":"http:\/\/www.getpersonas.com\/static\/3\/3\/33\/preview_small.jpg",
- "dataurl":"data:image\/png;base64,\/9j\/4AAQSkZJRgABAQEASABIAAD\/2" +
- "wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQIC" +
- "AQECAQEBAgICAgICAgICAQICAgICAgICAgL\/2wBDAQEBAQEBAQEBAQ" +
- "ECAQEBAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICA" +
- "gICAgICAgICAgICAgL\/wAARCAAQABADAREAAhEBAxEB\/8QAFwAAAw" +
- "EAAAAAAAAAAAAAAAAABAcICv\/EACAQAAIDAAEFAQEAAAAAAAAAAAME" +
- "AQIFBgcIERIjEyX\/xAAZAQACAwEAAAAAAAAAAAAAAAADCAQFBwn\/x" +
- "AAlEQACAQMCBgMBAAAAAAAAAAABAgMEERIAIQUGExQiMQcyM1L\/2gA" +
- "MAwEAAhEDEQA\/AL9p21L52peGctNVXkGbWsGZhNZlXBWo0sHVSVucA" +
- "9BryNibVm9Iq3ahWLengV+g03yTMyl+6aV1YE45YmTZsGsCVxBUjx+p" +
- "sovuFgi5IjlgRUhI7RjYHyJy93Y5EKxBW+9wrKN9wjsft65bGnnPK4+" +
- "kTguZqqKcdJstEzbuzyTdErUtSFqszqY4uR7lQGdQ+q13rML1vWIrN1" +
- "U\/I1N2FTG6oKipx6pUlijxRM+ICsRE8scbuqSDEqCvsAiRJyNRvUBH" +
- "qcq9I5XdFTxaNbKcmxdWMcYRSt\/IqokK5a0NdQOicaI0cEnGi6eWiW" +
- "TKvqghltgpT1GECpZj+DYQmXSG97SAtxBkXibk9Ul4TzXMk3dSV6wMg" +
- "a6MSDshAuB+xYiNQVs4F8jZV1u9RwmCKGdKWneSorMFJGPTQGRWkYlj" +
- "ZVAyKqQRckAG+i+M9rHGtTUI31CU3dwGWRG+GN7lTWmhe4VpCxNRnr+" +
- "y47Wm9qxSwigg5A0YJT6yDifOtS0MS8Km6JmDdZelgASbgeyrEfUtdg" +
- "4VXKoSU0bhlDJStUxz00KgWWORAuboP6IAIBIywKgKSRd7Btf\/2Q=="
- });
+ let addonSlug = this._prefs.get("initial.slug");
+ let url = this._prefs.get("addon-details.url")
+ .replace("%ADDON_SLUG%", addonSlug);
+
+ this._makeRequest(url, function (event) {
+ let responseJSON = JSON.parse(event.target.responseText);
+ this.changeToPersona(this.getPersonaJSON(responseJSON));
+ // There seems to be a bug in the LightweightThemeManager that
+ // prevents this from being called automatically at this
+ // point.
+ LightweightThemeManager.themeChanged(
+ LightweightThemeManager.currentTheme);
+ }.bind(this));
}
}
@@ -733,6 +710,16 @@ let PersonaService = {
this._showPersonaChangeNotification();
},
+ getPersonaJSON: function(data) {
+ if (data.theme) {
+ if (data.learnmore && !data.theme.detailURL)
+ data.theme.detailURL = data.learnmore
+ .replace(/([?&])src=api($|&)/, "$1src=personas-plus$2");
+ return data.theme;
+ }
+ return data;
+ },
+
/**
* Reverts the current persona to the previously selected persona, if
* available
@@ -838,9 +825,7 @@ let PersonaService = {
break;
}
- if (randomItem && randomItem.theme)
- return randomItem.theme;
- return randomItem;
+ return this.getPersonaJSON(randomItem);
}
return this.currentPersona;
},
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/personasplus.git
More information about the Pkg-mozext-commits
mailing list