diff options
author | Kris Maglione <maglione.k@gmail.com> | 2010-09-29 10:56:58 -0400 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2010-09-29 10:56:58 -0400 |
commit | 5477acfad6acdee6d4a37d0490b756a47712f514 (patch) | |
tree | aba561e63e1709529ae8c31805052a08f607ab50 /common | |
parent | 2e2e87c62746499588c41e6da64f1f3d465dfd57 (diff) | |
download | pentadactyl-5477acfad6acdee6d4a37d0490b756a47712f514.tar.gz |
Fix some help linking and exporting bugs.
Diffstat (limited to 'common')
-rw-r--r-- | common/components/protocols.js | 11 | ||||
-rw-r--r-- | common/content/commands.js | 6 | ||||
-rw-r--r-- | common/content/dactyl.js | 16 | ||||
-rw-r--r-- | common/content/help.xsl | 10 | ||||
-rw-r--r-- | common/locale/en-US/browsing.xml | 2 | ||||
-rw-r--r-- | common/locale/en-US/buffer.xml | 4 | ||||
-rw-r--r-- | common/locale/en-US/gui.xml | 2 | ||||
-rw-r--r-- | common/locale/en-US/insert.xml | 2 | ||||
-rw-r--r-- | common/locale/en-US/options.xml | 6 | ||||
-rw-r--r-- | common/locale/en-US/repeat.xml | 2 | ||||
-rw-r--r-- | common/modules/util.jsm | 20 |
11 files changed, 44 insertions, 37 deletions
diff --git a/common/components/protocols.js b/common/components/protocols.js index 68a4b8df..590dcf93 100644 --- a/common/components/protocols.js +++ b/common/components/protocols.js @@ -22,14 +22,7 @@ const nsIProtocolHandler = Components.interfaces.nsIProtocolHandler; const ioService = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); const prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService) .getBranch("extensions.dactyl."); - -let channel = Components.classesByID["{61ba33c0-3031-11d3-8cd0-0060b0fc14a3}"] - .getService(Ci.nsIProtocolHandler) - .newChannel(ioService.newURI("chrome://dactyl/content/data", null, null)) - .QueryInterface(Ci.nsIRequest); -const systemPrincipal = channel.owner; -channel.cancel(NS_BINDING_ABORTED); -channel = null; +const systemPrincipal = Cc["@mozilla.org/systemprincipal;1"].getService(Ci.nsIPrincipal); function dataURL(type, data) "data:" + (type || "application/xml;encoding=UTF-8") + "," + escape(data); function makeChannel(url, orig) { @@ -154,6 +147,8 @@ Dactyl.prototype = { return makeChannel(url, uri); case "help-tag": let tag = decodeURIComponent(uri.path.substr(1)); + if (tag in this.FILE_MAP) + return redirect("dactyl://help/" + tag, uri); if (tag in this.HELP_TAGS) return redirect("dactyl://help/" + this.HELP_TAGS[tag] + "#" + tag, uri); } diff --git a/common/content/commands.js b/common/content/commands.js index 119257ec..727b234b 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -1183,9 +1183,9 @@ const Commands = Module("commands", { function quote(q, list, map) { map = map || Commands.quoteMap; let re = RegExp("[" + list + "]", "g"); - let res = function (str) q + String.replace(str, re, function ($0) $0 in map ? map[$0] : ("\\" + $0)) + q; - res.list = list; - return res; + function quote(str) q + String.replace(str, re, function ($0) $0 in map ? map[$0] : ("\\" + $0)) + q; + quote.list = list; + return quote; }; Commands.quoteArg = { diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 916dd18e..59214079 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -507,13 +507,14 @@ const Dactyl = Module("dactyl", { '<?xml version="1.0"?>\n' + '<?xml-stylesheet type="text/xsl" href="chrome://dactyl/content/help.xsl"?>\n' + '<!DOCTYPE document SYSTEM "chrome://dactyl/content/dactyl.dtd">\n' + + unescape(encodeURI( // UTF-8 handling hack. <document xmlns={NS} name="plugins" title={config.appName + " Plugins"}> <h1 tag="using-plugins">Using Plugins</h1> <toc start="2"/> {body} - </document>.toXMLString(); + </document>.toXMLString())); fileMap["plugins"] = function () ['text/xml;charset=UTF-8', help]; addTags("plugins", util.httpGet("dactyl://help/plugins").responseXML); @@ -551,7 +552,7 @@ const Dactyl = Module("dactyl", { function fix(node) { switch(node.nodeType) { case Node.ELEMENT_NODE: - if (node instanceof HTMLScriptElement) + if (isinstance(node, [HTMLBaseElement, HTMLScriptElement])) return; data.push("<"); data.push(node.localName); @@ -565,10 +566,13 @@ const Dactyl = Module("dactyl", { set.add(styles, value); } if (name == "href") { - if (value.indexOf("dactyl://help-tag/") == 0) - value = services.get("io").newChannel(value, null, null).originalURI.path.substr(1); - if (!/[#\/]/.test(value)) - value += ".xhtml"; + value = node.href; + if (value.indexOf("dactyl://help-tag/") == 0) { + let uri = services.get("io").newChannel(value, null, null).originalURI; + value = uri.spec == value ? "javascript:;" : uri.path.substr(1); + } + if (!/^#|[\/](#|$)|^[a-z]+:/.test(value)) + value = value.replace(/(#|$)/, ".xhtml$1"); } if (name == "src" && value.indexOf(":") > 0) { chrome[value] = value.replace(/.*\//, "");; diff --git a/common/content/help.xsl b/common/content/help.xsl index 77d9c2e9..109fe73e 100644 --- a/common/content/help.xsl +++ b/common/content/help.xsl @@ -359,7 +359,15 @@ </xsl:template> <xsl:template match="dactyl:link" mode="help-2"> - <a href="{@topic}"> + <a> + <xsl:choose> + <xsl:when test="regexp:match(@topic, '^([a-zA-Z]*:|[^/]*#|/)', '')"> + <xsl:attribute name="href"><xsl:value-of select="@topic"/></xsl:attribute> + </xsl:when> + <xsl:otherwise> + <xsl:attribute name="href"><xsl:value-of select="concat('dactyl://help-tag/', @topic)"/></xsl:attribute> + </xsl:otherwise> + </xsl:choose> <xsl:if test="regexp:match(@topic, '^[a-zA-Z]*:', '') and not(starts-with(@topic, 'mailto:'))"> <xsl:attribute name="rel">external</xsl:attribute> diff --git a/common/locale/en-US/browsing.xml b/common/locale/en-US/browsing.xml index a7679a8b..8def5196 100644 --- a/common/locale/en-US/browsing.xml +++ b/common/locale/en-US/browsing.xml @@ -340,7 +340,7 @@ want to bypass &dactyl.appName;'s key handling and pass keys directly to <p> For example, at the URL <tt>http://www.example.com/dir1/dir2/file.htm</tt>, - <k>2gu</k> opens <tt>http://www.example.com/dir1/</tt>. + 2<k>gu</k> opens <tt>http://www.example.com/dir1/</tt>. </p> </description> </item> diff --git a/common/locale/en-US/buffer.xml b/common/locale/en-US/buffer.xml index 77e4336a..64259652 100644 --- a/common/locale/en-US/buffer.xml +++ b/common/locale/en-US/buffer.xml @@ -219,7 +219,7 @@ <p> Scroll window downwards by the amount specified in the <o>scroll</o> option. With <oa>count</oa>, scroll as if - <o>scroll</o> were set to <o>count</o>. + <o>scroll</o> were set to <oa>count</oa>. </p> </description> </item> @@ -233,7 +233,7 @@ <p> Scroll window upwards by the amount specified in the <o>scroll</o> option. With <oa>count</oa>, scroll as if - <o>scroll</o> were set to <o>count</o>. + <o>scroll</o> were set to <oa>count</oa>. </p> </description> </item> diff --git a/common/locale/en-US/gui.xml b/common/locale/en-US/gui.xml index ca5fca6e..1e145433 100644 --- a/common/locale/en-US/gui.xml +++ b/common/locale/en-US/gui.xml @@ -48,7 +48,7 @@ <p> Opens the &dactyl.host; addon manager, where extensions and themes may be installed, removed, disabled, and configured. See also - <ex>:extensions</ex>, <ex>:extinstall</ex>, <ex>:extoptions</ex>, + <ex>:extensions</ex>, <ex>:extadd</ex>, <ex>:extoptions</ex>, <ex>:extenable</ex>, <ex>:extdisable</ex>, and <ex>:extdelete</ex>. </p> </description> diff --git a/common/locale/en-US/insert.xml b/common/locale/en-US/insert.xml index b727c561..7f3f2706 100644 --- a/common/locale/en-US/insert.xml +++ b/common/locale/en-US/insert.xml @@ -8,7 +8,7 @@ title="&dactyl.appName; Insert Mode" xmlns="&xmlns.dactyl;" xmlns:html="&xmlns.html;"> -<h1 tag="Insert-mode Insert mode-insert">Insert mode</h1> +<h1 tag="insert-mode insert mode-insert">Insert mode</h1> <toc start="2"/> <!-- TODO: This makes no sense. Rewrite. --> diff --git a/common/locale/en-US/options.xml b/common/locale/en-US/options.xml index c27aab9b..6491919c 100644 --- a/common/locale/en-US/options.xml +++ b/common/locale/en-US/options.xml @@ -264,7 +264,7 @@ <p>&dactyl.host; options can be viewed and set with the following commands:</p> <item> - <tags>:prefs :preferences</tags> + <tags>:pref :prefs :preferences</tags> <spec>:pref<oa>erences</oa></spec> <description> <p> @@ -277,7 +277,7 @@ </item> <item> - <tags>:prefs! :preferences!</tags> + <tags>:pref! :prefs! :preferences!</tags> <spec>:pref<oa>erences</oa>!</spec> <description> <p> @@ -1401,7 +1401,7 @@ <item> - <tags>'verbose', 'vbs'</tags> + <tags>'vbs' 'verbose'</tags> <spec>'verbose' 'vbs'</spec> <type>number</type> <default>1</default> diff --git a/common/locale/en-US/repeat.xml b/common/locale/en-US/repeat.xml index 20b4aabd..5ec7dae0 100644 --- a/common/locale/en-US/repeat.xml +++ b/common/locale/en-US/repeat.xml @@ -178,7 +178,7 @@ line, you can use, </p> - <code><ex>js</ex> <<<em>EOF</em> + <code><ex>:js</ex> <<<em>EOF</em> <hl key="Object">var</hl> hello = <hl key="Key">function</hl> () { alert(<str>Hello world</str>); } diff --git a/common/modules/util.jsm b/common/modules/util.jsm index c73d30e6..508126a1 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -275,7 +275,7 @@ const Util = Module("Util", { * @param {boolean} asIterator Whether to return the results as an * XPath iterator. */ - evaluateXPath: (function () { + evaluateXPath: update( function evaluateXPath(expression, doc, elem, asIterator) { if (!doc) doc = util.activeWindow.content.document; @@ -296,15 +296,15 @@ const Util = Module("Util", { : function () { for (let i = 0; i < this.snapshotLength; i++) yield this.snapshotItem(i); } } }); - } - evaluateXPath.resolver = function lookupNamespaceURI(prefix) ({ - xul: XUL.uri, - xhtml: XHTML.uri, - xhtml2: "http://www.w3.org/2002/06/xhtml2", - dactyl: NS.uri - }[prefix] || null); - return evaluateXPath; - })(), + }, + { + resolver: function lookupNamespaceURI(prefix) ({ + xul: XUL.uri, + xhtml: XHTML.uri, + xhtml2: "http://www.w3.org/2002/06/xhtml2", + dactyl: NS.uri + }[prefix] || null) + }), extend: function extend(dest) { Array.slice(arguments, 1).filter(util.identity).forEach(function (src) { |