[Pkg-mozext-commits] [ubiquity-extension] 01/06: Imported Upstream version 0.6.4~pre20141206
Gabriele Giacone
gg0-guest at moszumanska.debian.org
Sat Dec 6 20:13:58 UTC 2014
This is an automated email from the git hooks/post-receive script.
gg0-guest pushed a commit to branch master
in repository ubiquity-extension.
commit 31bcca3181a90ff1a519c05d30b96be12d020cfb
Author: Gabriele Giacone <1o5g4r8o at gmail.com>
Date: Sat Dec 6 04:11:36 2014 +0100
Imported Upstream version 0.6.4~pre20141206
---
builtin-feeds/builtincmds.js | 13 ++++
chrome/content/header.js | 4 +-
feed-parts/footer/final.js | 1 +
install.rdf | 4 +-
modules/cmdutils.js | 7 ++-
modules/codesource.js | 6 +-
modules/default_feed_plugin.js | 2 +-
modules/feedmanager.js | 2 +-
modules/nountypes.js | 2 +-
modules/nounutils.js | 2 +-
modules/parser/new/parser.js | 7 +--
modules/setup.js | 9 +--
modules/skin_feed_plugin.js | 4 +-
modules/utils.js | 13 +---
modules/webjsm.js | 12 ++--
standard-feeds/calendar.html | 11 ----
standard-feeds/calendar.js | 137 -----------------------------------------
standard-feeds/general.js | 1 +
standard-feeds/search.xhtml | 10 +--
19 files changed, 53 insertions(+), 194 deletions(-)
diff --git a/builtin-feeds/builtincmds.js b/builtin-feeds/builtincmds.js
index 99cd4d5..a7ecaee 100644
--- a/builtin-feeds/builtincmds.js
+++ b/builtin-feeds/builtincmds.js
@@ -258,3 +258,16 @@ CmdUtils.CreateCommand({
return his;
},
});
+
+// Gist feed auto-detection
+CmdUtils.onPageLoad(doc => {
+ var node = doc.querySelector('.files .info.file-name')
+ if (!node) return
+ var name = node.textContent.trim()
+ if (!name || !/\.ub(?:iq(?:uity)?)?\.(js|xhtml|css)$/i.test(name)) return
+ var link = doc.createElement('link')
+ link.rel = name.endsWith('css') ? 'ubiquity-skin' : 'commands'
+ link.href =
+ 'https://gist.githubusercontent.com'+ doc.location.pathname +'/raw/'
+ doc.head.appendChild(link)
+}, /^https:\/\/gist\.github\.com\/\w+\/\w+$/)
diff --git a/chrome/content/header.js b/chrome/content/header.js
index 813ef40..93c0fb7 100644
--- a/chrome/content/header.js
+++ b/chrome/content/header.js
@@ -90,10 +90,10 @@ function createNavLinks() {
}
function setupHelp(clickee, help) {
- var [toggler] = $(clickee).click(function toggleHelp() {
+ var toggler = $(clickee).click(function toggleHelp() {
$(help)[(this.off ^= 1) ? "slideUp" : "slideDown"]();
[this.textContent, this.bin] = [this.bin, this.textContent];
- });
+ })[0];
toggler.textContent = L("ubiquity.showhidehelp.show");
toggler.bin = L("ubiquity.showhidehelp.hide");
toggler.off = true;
diff --git a/feed-parts/footer/final.js b/feed-parts/footer/final.js
index 935e5d6..5b6dd5c 100644
--- a/feed-parts/footer/final.js
+++ b/feed-parts/footer/final.js
@@ -12,6 +12,7 @@
__proto__: func,
name: func.name.slice(_index + 1).replace("_", " ", "g"),
execute: func,
+ arguments: null,
}); continue;
case "startup": hasRunOnce || func(); continue;
case "pageLoad": pageLoadFuncs.push(func); continue;
diff --git a/install.rdf b/install.rdf
index 194c3ec..77deedb 100755
--- a/install.rdf
+++ b/install.rdf
@@ -11,8 +11,8 @@
with minimum and maximum supported versions. -->
<targetApplication><rdf:Description>
<!--Firefox--><id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</id>
- <minVersion>28.0</minVersion>
- <maxVersion>31.0a1</maxVersion>
+ <minVersion>32.0</minVersion>
+ <maxVersion>35.0a1</maxVersion>
</rdf:Description></targetApplication>
<!-- Front End MetaData -->
diff --git a/modules/cmdutils.js b/modules/cmdutils.js
index 66d2350..bd5bf27 100644
--- a/modules/cmdutils.js
+++ b/modules/cmdutils.js
@@ -700,7 +700,8 @@ function CreateCommand(options) {
for (let label in modifiers) toNounType(modifiers, label);
}
NEW_IMPROVED_ARGUMENT_API:
- { let args = options.arguments || options.argument;
+ {
+ let args = options.arguments || options.argument
if (!args) {
command.arguments = [];
break NEW_IMPROVED_ARGUMENT_API;
@@ -714,7 +715,7 @@ function CreateCommand(options) {
// arguments: {"role label": noun, ...}
let a = [], re = /^[a-z]+(?=(?:[$_:\s]([^]+))?)/;
for (let key in args) {
- let [role, label] = re.exec(key) || 0;
+ let [role, label] = re.exec(key) || [];
if (role) a.push({role: role, label: label, nountype: args[key]});
}
args = a;
@@ -741,7 +742,7 @@ function CreateCommand(options) {
}
CreateCommand.executeDefault = function executeDefault() {
var {proto: {execute}, global} = this, uri;
- try { uri = global.Utils.uri(execute) } catch ([]) {}
+ try { uri = global.Utils.uri(execute) } catch (_) {}
if (uri) return Utils.focusUrlInBrowser(uri.spec);
if (execute == null) execute = L("ubiquity.cmdutils.noactiondef");
global.displayMessage(execute, this);
diff --git a/modules/codesource.js b/modules/codesource.js
index 79f292c..6750148 100644
--- a/modules/codesource.js
+++ b/modules/codesource.js
@@ -122,7 +122,7 @@ RemoteUriCodeSource.prototype = {
var req = self._req = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"]
.createInstance(Ci.nsIXMLHttpRequest);
req.mozBackgroundRequest = true;
- req.open("GET", Utils.gist.fixRawUrl(this._feedInfo.srcUri.spec), true);
+ req.open("GET", this._feedInfo.srcUri.spec, true);
req.overrideMimeType("text/plain");
req.onreadystatechange = function RUCS__onXhrChange() {
if (req.readyState < 4) return;
@@ -156,7 +156,7 @@ function LocalUriCodeSource(uri, noReload) {
this._cachedTimestamp = 0;
if (this.uri.scheme == "resource") try {
this.uri = Utils.uri(Utils.ResProtocolHandler.resolveURI(this.uri));
- } catch ([]) {}
+ } catch (_) {}
}
LocalUriCodeSource.isValidUri =
@@ -192,7 +192,7 @@ LocalUriCodeSource.prototype = {
req.overrideMimeType("text/plain");
req.send(null);
- if (req.status !== 0)
+ if (req.status > 200)
throw new Error("XHR returned status " + req.status);
let code = req.responseText;
diff --git a/modules/default_feed_plugin.js b/modules/default_feed_plugin.js
index 378c2f9..774db02 100644
--- a/modules/default_feed_plugin.js
+++ b/modules/default_feed_plugin.js
@@ -87,7 +87,7 @@ function DefaultFeedPlugin(feedManager, messageService, webJsm, baseUrl) {
this.onSubscribeClick = function DFP_onSubscribeClick(pageUrl, targetLink) {
var doc = targetLink.ownerDocument;
var title = targetLink.title || Utils.gist.getName(doc) || doc.title;
- var commandsUrl = Utils.gist.fixRawUrl(targetLink.href);
+ var commandsUrl = targetLink.href;
// Clicking on "subscribe" takes them to the warning page:
var confirmUrl = CONFIRM_URL + Utils.paramsToString({
url: pageUrl,
diff --git a/modules/feedmanager.js b/modules/feedmanager.js
index 910ea43..c53051e 100644
--- a/modules/feedmanager.js
+++ b/modules/feedmanager.js
@@ -269,7 +269,7 @@ FMgrProto.installToWindow = function FMgr_installToWindow(window) {
// called when the feed manager no longer needs to be used.
FMgrProto.finalize = function FMgr_finalize() {
- for (var feed of this._feeds) feed.finalize();
+ for (var k in this._feeds) this._feeds[k].finalize();
};
FMgrProto.__getFeed = function FMgr___getFeed(uri) {
diff --git a/modules/nountypes.js b/modules/nountypes.js
index 1749410..0ee4ec4 100644
--- a/modules/nountypes.js
+++ b/modules/nountypes.js
@@ -805,7 +805,7 @@ function getGmailContacts(ok, ng) {
},
error: googleContactsError,
success: function googleClientLoggedIn(data, status, xhr) {
- var [, auth] = /^Auth=(.+)/m.exec(data) || 0;
+ var [, auth] = /^Auth=(.+)/m.exec(data) || [];
if (!auth) return this.error(xhr);
jQuery.ajax({
url: "https://www.google.com/m8/feeds/contacts/default/full",
diff --git a/modules/nounutils.js b/modules/nounutils.js
index 2aabae0..f1bac97 100644
--- a/modules/nounutils.js
+++ b/modules/nounutils.js
@@ -224,7 +224,7 @@ function makeSugg(text, html, data, score, selectionIndices) {
// we'll stick some html tags into the summary so that the part
// that comes from the text selection can be visually marked in
// the suggestion list.
- var [start, end] = selectionIndices || 0;
+ var [start, end] = selectionIndices || [];
summary = (
start < end
? (Utils.escapeHtml(summary.slice(0, start)) +
diff --git a/modules/parser/new/parser.js b/modules/parser/new/parser.js
index c65d24b..39fefa7 100644
--- a/modules/parser/new/parser.js
+++ b/modules/parser/new/parser.js
@@ -212,10 +212,10 @@ Parser.prototype = {
"as they are not compatible with Parser 2.");
gOldAlerted = true;
}
-
+
this.refreshCommandList();
},
-
+
addCommandToList: function addCommandToList(command) {
if (command.oldAPI && !gOldAlerted) {
var msgService = new AlertMessageService();
@@ -224,7 +224,7 @@ Parser.prototype = {
gOldAlerted = true;
}
},
-
+
refreshCommandList: function addCommandToList() {
var verbs = this._verbList;
@@ -1112,7 +1112,6 @@ Parser.prototype = {
if (!parse.args.object) return [];
let baseParses = [parse];
- let returnArr = [];
let rolesToTry = this._otherRolesCache;
if (parse._verb.id) {
rolesToTry = {};
diff --git a/modules/setup.js b/modules/setup.js
index 6aa3dda..e0b4db9 100755
--- a/modules/setup.js
+++ b/modules/setup.js
@@ -83,9 +83,6 @@ var UbiquitySetup = {
source: "email.js",
title: "Mozilla Email Commands",
}, {
- source: "calendar.js",
- title: "Mozilla Calendar Commands",
- }, {
source: "search.xhtml",
title: "Mozilla Web Search Commands",
}],
@@ -122,17 +119,17 @@ var UbiquitySetup = {
this.__maybeReset();
- var self = this, wjm;
+ var self = this;
Utils.AddonManager.getAddonByID(
"ubiquity at labs.mozilla.com",
function setAddonInfo(addon) {
self.version = addon.version;
self.baseUrl = addon.getResourceURI("").spec;
- wjm = new WebJsModule(onWJMLoad);
+ WebJsModule(onWJMLoad);
});
- function onWJMLoad() {
+ function onWJMLoad(wjm) {
wjm.importScript("resource://ubiquity/scripts/jquery.js", function () {
wjm.importScript("resource://ubiquity/scripts/jquery_setup.js");
gWebJsModule = wjm;
diff --git a/modules/skin_feed_plugin.js b/modules/skin_feed_plugin.js
index 3273cd4..87d7ce3 100644
--- a/modules/skin_feed_plugin.js
+++ b/modules/skin_feed_plugin.js
@@ -84,7 +84,7 @@ var SFP = Utils.extend(SkinFeedPlugin.prototype, {
makeFeed: function SFP_makeFeed(baseFeed, eventHub)
SkinFeed(baseFeed, eventHub, this._msgService),
onSubscribeClick: function SFP_onSubscribeClick(pageUrl, link) {
- var cssUrl = Utils.gist.fixRawUrl(link.href), me = this;
+ var cssUrl = link.href, me = this;
me._webJsm.jQuery.ajax({
url: cssUrl,
dataType: "text",
@@ -184,7 +184,7 @@ Utils.extend(SkinFeed.prototype, {
get metaData() {
if (this._dataCache) return this._dataCache;
var {css} = this, data = {};
- var [, block] = /=skin=\s*([^]+)\s*=\/skin=/.exec(css) || 0;
+ var [, block] = /=skin=\s*([^]+)\s*=\/skin=/.exec(css) || [];
if (block) {
let re = /^[ \t]*@(\w+)[ \t]+(.+)/mg, m;
while ((m = re.exec(block))) data[m[1]] = m[2].trim();
diff --git a/modules/utils.js b/modules/utils.js
index dcc66f1..05dcdac 100755
--- a/modules/utils.js
+++ b/modules/utils.js
@@ -545,7 +545,7 @@ function getLocalUrl(url, charset) {
req.overrideMimeType("text/plain" + (charset ? ";charset=" + charset : ""));
req.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT");
req.send(null);
- if (req.status !== 0) throw Error("failed to get " + url);
+ if (req.status > 200) throw Error("failed to get " + url);
return req.responseText;
}
@@ -963,7 +963,7 @@ var gPrefs = Utils.prefs = {
try {
return gPrefBranch.getComplexValue(
name, Ci.nsIPrefLocalizedString).data;
- } catch ([]) {}
+ } catch (_) {}
return gPrefBranch.getComplexValue(name, nsISupportsString).data;
case PREF_BOOL:
return gPrefBranch.getBoolPref(name);
@@ -1404,7 +1404,7 @@ Utils.gist = {
if (search.length > 1)
try { return decodeURIComponent(search).slice(1) } catch (e) {}
- var name = "gist:" + /\w+/.exec(pathname), sep = " \u2013 ";
+ var name = "gist:" + /\w+\/\w+/.exec(pathname), sep = " \u2013 ";
var desc = document.querySelector(".gist-description");
if (desc && /\S/.test(desc.textContent))
@@ -1415,11 +1415,4 @@ Utils.gist = {
return name;
},
-
- // === {{{ Utils.gist.fixRawUrl(url) }}} ===
- // Maps <http://gist.github.com/X.txt> to <https://raw.github.com/gist/X>.
- fixRawUrl: function gist_fixRawUrl(url) {
- var match = /^https?:\/\/gist\.github\.com(\/\d+)\.txt\b/.exec(url);
- return match ? "https://raw.github.com/gist" + match[1] : url;
- },
};
diff --git a/modules/webjsm.js b/modules/webjsm.js
index cf74f2c..76b5848 100644
--- a/modules/webjsm.js
+++ b/modules/webjsm.js
@@ -56,8 +56,8 @@ const Ci = Components.interfaces;
// == The WebJsModule Class ==
//
-// The constructor requires a callback function, which is called when the
-// {{{WebJsModule}}} is finished initializing itself. Optionally, the
+// The constructor requires a callback function, which is passed the
+// {{{WebJsModule}}} instance when ready. Optionally, the
// constructor can also take an instance of a DOM window, which it will
// use to host any JS code. If unspecified, the hidden DOM window is
// used.
@@ -69,14 +69,14 @@ function WebJsModule(callback, window) {
var importedScripts = {};
- var self = this;
var iframe = window.document.createElement("iframe");
iframe.setAttribute("src", "chrome://ubiquity/content/hiddenframe.html");
Utils.listenOnce(iframe, "pageshow", function WJM__onPageShow() {
// Have our instance dynamically inherit the properties of the
// hidden window.
- self.__proto__ = iframe.contentWindow;
- callback();
+ callback(Object.create(iframe.contentWindow, {
+ importScript: {value: WJM_importScript},
+ }));
});
window.document.documentElement.appendChild(iframe);
@@ -89,7 +89,7 @@ function WebJsModule(callback, window) {
// Once the script is imported, any globals it created can be
// directly accessed as properties of the {{{WebJsModule}}} instance.
- this.importScript = function WJM_importScript(url, callback) {
+ function WJM_importScript(url, callback) {
if (url in importedScripts) return;
var doc = iframe.contentDocument, script = doc.createElement('script');
script.setAttribute('src', url);
diff --git a/standard-feeds/calendar.html b/standard-feeds/calendar.html
deleted file mode 100644
index 999dcbd..0000000
--- a/standard-feeds/calendar.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0"?>
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
- xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
-<head>
- <title>Ubiquity Standard Calendar Commands</title>
- <link rel="commands" href="calendar.js"/>
-</head>
-<body>
-<p>This feed contains Calendar-related commands.</p>
-</body>
-</html>
\ No newline at end of file
diff --git a/standard-feeds/calendar.js b/standard-feeds/calendar.js
deleted file mode 100644
index e1f2c7f..0000000
--- a/standard-feeds/calendar.js
+++ /dev/null
@@ -1,137 +0,0 @@
-const GCalendar = "https://www.google.com/calendar/";
-const Apology = ("<p>" +
- "Currently, only works with " +
- "Google Calendar".link("http://calendar.google.com") +
- " so you'll need a Google account to use it." +
- "</p>");
-
-CmdUtils.CreateCommand({
- names: ["add to google calendar", "quick add"],
- argument: {object_event: noun_arb_text},
- serviceDomain: "calendar.google.com",
- icon: "chrome://ubiquity/skin/icons/calendar_google.ico",
- description: "Adds an event to your calendar.",
- help: (
- <>
- <a href="http://www.google.com/support/calendar/bin/answer.py?answer=36604"
- title="Quick Add">Enter the event naturally</a>. e.g.:
- <ul>
- <li>3pm Lunch with Myk and Thunder</li>
- <li>Jono's Birthday on Friday</li>
- </ul>
- </>) + Apology,
- execute: function qa_execute(args) {
- var event = args.object.text;
- var authKey = Utils.getCookie(".www.google.com", "CAL");
- var me = this;
- function needLogin() {
- me._say(_("Authorization error"),
- _("Please make sure you are logged in to Google Calendar"));
- }
- if (!authKey) {
- needLogin();
- return;
- }
- var req = new XMLHttpRequest;
- req.open("POST", GCalendar + "feeds/default/private/full", false);
- req.setRequestHeader("Authorization", "GoogleLogin auth=" + authKey);
- req.setRequestHeader("Content-type", "application/atom+xml");
- req.send(<entry xmlns="http://www.w3.org/2005/Atom"
- xmlns:gCal="http://schemas.google.com/gCal/2005">
- <content type="text">{event}</content>
- <gCal:quickadd value="true"/>
- </entry>.toXMLString());
- switch (req.status) {
- case 201:
- this._say(_("Event created"),
- req.responseXML.getElementsByTagName("title")[0].textContent);
- Utils.tabs.reload(/^https?:\/\/www\.google\.com\/calendar\b/);
- break;
-
- case 401:
- needLogin();
- break;
-
- default:
- this._say(_("Error creating the event"),
- req.status + " " + req.statusText);
- }
- },
- preview: function qa_preview(pb, {object: {html}}) {
- pb.innerHTML = html || this.previewDefault();
- },
- _say: function qa__say(title, text) {
- displayMessage({
- icon: this.icon,
- title: this.name + ": " + title,
- text: text,
- });
- }
-});
-
-function linksToButtons($links) {
- var keys = ["P", "N"];
- if ($links.length > 2) keys.splice(1, 0, "T");
- $links.each(function eachLink(i) {
- var txt = this.textContent, key = keys[i];
- if (txt[0] !== key) txt += " (" + key + ")";
- jQuery(this).replaceWith(<button value={this.href} accesskey={key}
- >{txt}</button>.toXMLString());
- });
-}
-
-function dateParam(date) ({as_sdt: date.toString("yyyyMMdd")});
-
-// TODO this should take a plugin argument specifying the calendar provider.
-CmdUtils.CreateCommand({
- names: ["check google calendar"],
- argument: {object: noun_type_date},
- serviceDomain: "calendar.google.com",
- icon : "chrome://ubiquity/skin/icons/calendar_google.ico",
- description: "Checks what events are on your calendar for a given date.",
- help: 'Try issuing "check on thursday"' + Apology,
- execute: function gcale_execute({object: {data}}) {
- Utils.openUrlInBrowser(GCalendar + Utils.paramsToString(dateParam(data)));
- },
- // url is for recursing pagination
- preview: function gcale_preview(pblock, args, url) {
- var date = args.object.data, me = this;
- if (!date) {
- pblock.innerHTML = this.description;
- return;
- }
- pblock.innerHTML = _("Checking Google Calendar for events on ${date}.",
- {date: date.toString("dddd, dS MMMM, yyyy")});
- CmdUtils.previewGet(
- pblock,
- url || GCalendar + "m",
- dateParam(date),
- function getCalendar(htm) {
- var [cal] = /<div class[^]+$/.exec(htm) || 0;
- if (!cal) {
- pblock.innerHTML = _(
- 'Please <a href="${url}" accesskey="L">Login</a>.', this);
- return;
- }
- var $c = $('<div class="calendar">' + cal).eq(0);
- $c.find(".c1:nth(1)").remove();
- $c.find("form").parent().remove();
- $c.find("div[class] > span:first-child").css({
- fontWeight: "bold",
- display: "inline-block",
- margin: "1ex 0 0.5ex",
- });
- CmdUtils.absUrl($c, this.url);
- linksToButtons($c.find(".c1 > a"));
- $c.find("button").focus(function btn() {
- this.blur();
- this.disabled = true;
- gcale_preview.call(me, pblock, args, this.value);
- return false;
- });
- pblock.innerHTML = "";
- $c.appendTo(pblock);
- },
- "text");
- },
-});
diff --git a/standard-feeds/general.js b/standard-feeds/general.js
index 8c7fda8..82ee8c0 100644
--- a/standard-feeds/general.js
+++ b/standard-feeds/general.js
@@ -181,6 +181,7 @@ const MS_TRANSLATOR_LIMIT = 1e4
, fr: "French"
, de: "German"
, el: "Greek"
+ , he: "Hebrew"
, hi: "Hindi"
, hu: "Hungarian"
, id: "Indonesian"
diff --git a/standard-feeds/search.xhtml b/standard-feeds/search.xhtml
index 6acefd3..2891a16 100644
--- a/standard-feeds/search.xhtml
+++ b/standard-feeds/search.xhtml
@@ -560,7 +560,7 @@ CmdUtils.CreateCommand({
Operation: "ItemSearch",
Condition: "All",
Merchant: "All",
- ResponseGroup: "ItemAttributes,Images",
+ ResponseGroup: "ItemAttributes,Images,Offers",
AssociateTag: "matyr-20", // required
SearchIndex: searchIndex,
Keywords: text,
@@ -585,9 +585,11 @@ CmdUtils.CreateCommand({
const MAX_RESULTS = 35; // 1 ~ 9, a ~ z
function iter(itemIndex) {
var itemDetails = jQuery(this),
- itemAttrs = itemDetails.find("ItemAttributes"),
- listPrice = itemAttrs.find("ListPrice"),
- smallImage = itemDetails.find("SmallImage:first");
+ itemAttrs = itemDetails.find("ItemAttributes"),
+ listPrice = itemDetails.find("OfferSummary > LowestNewPrice"),
+ smallImage = itemDetails.find("SmallImage:first");
+ if (!listPrice.length)
+ listPrice = itemAttrs.find("ListPrice");
return {
title: itemAttrs.find("Title").text(),
url: itemDetails.find("DetailPageURL").text(),
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/ubiquity-extension.git
More information about the Pkg-mozext-commits
mailing list