mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-04 05:15:46 +01:00
Minor help fixes. Almost time to merge. Need to get rid of these silly security warnings flooding the console.
--HG-- branch : xslt
This commit is contained in:
@@ -38,7 +38,7 @@ function makeChannel(url, orig)
|
||||
return channel;
|
||||
}
|
||||
function fakeChannel(orig)
|
||||
makeChannel("chrome://does/not/exist/in/any/reasonable/configuration", orig);
|
||||
makeChannel("chrome://liberator/content/does/not/exist", orig);
|
||||
function redirect(to, orig)
|
||||
{
|
||||
let html = <html><head><meta http-equiv="Refresh" content={"0;" + to}/></head></html>.toXMLString();
|
||||
@@ -94,9 +94,9 @@ function Liberator()
|
||||
{
|
||||
this.wrappedJSObject = this;
|
||||
|
||||
this.__defineGetter__("helpNamespaces", function () NAMESPACES ? NAMESPACES.slice() : null);
|
||||
this.__defineGetter__("helpNamespaces", function () this.NAMESPACES ? this.NAMESPACES.slice() : null);
|
||||
this.__defineSetter__("helpNamespaces", function (namespaces) {
|
||||
if (!NAMESPACES)
|
||||
if (!this.NAMESPACES)
|
||||
parseHelpTags(namespaces);
|
||||
});
|
||||
|
||||
@@ -112,6 +112,7 @@ function Liberator()
|
||||
return result;
|
||||
}
|
||||
|
||||
this.httpGet = httpGet;
|
||||
function httpGet(url)
|
||||
{
|
||||
try
|
||||
@@ -126,8 +127,9 @@ function Liberator()
|
||||
|
||||
const self = this;
|
||||
this.HELP_TAGS = {};
|
||||
this.FILE_MAP = { all: "chrome://liberator/locale/all.xml" };
|
||||
var NAMESPACES = null;
|
||||
this.FILE_MAP = {};
|
||||
this.OVERLAY_MAP = {};
|
||||
this.NAMESPACES = null;
|
||||
var HELP_FILES = null;
|
||||
|
||||
function XSLTProcessor(sheet)
|
||||
@@ -139,23 +141,34 @@ function Liberator()
|
||||
|
||||
function findHelpFile(file)
|
||||
{
|
||||
for each (let namespace in NAMESPACES)
|
||||
let result = [];
|
||||
for each (let namespace in self.NAMESPACES)
|
||||
{
|
||||
let url = ["chrome://", namespace, "/locale/", file, ".xml"].join("");
|
||||
let res = httpGet(url);
|
||||
if (res && res.responseXML.documentElement.localName == "document")
|
||||
return [url, res.responseXML];
|
||||
if (res)
|
||||
{
|
||||
if (res.responseXML.documentElement.localName == "document")
|
||||
self.FILE_MAP[file] = url;
|
||||
if (res.responseXML.documentElement.localName == "overlay")
|
||||
self.OVERLAY_MAP[file] = url;
|
||||
if (res.responseXML.documentElement.localName == "document")
|
||||
result = [url, res.responseXML];
|
||||
}
|
||||
}
|
||||
return []
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseHelpTags(namespaces)
|
||||
{
|
||||
HELP_FILES = [];
|
||||
NAMESPACES = Array.slice(namespaces);
|
||||
self.NAMESPACES = Array.slice(namespaces);
|
||||
|
||||
findHelpFile("all");
|
||||
|
||||
const XSLT = XSLTProcessor("chrome://liberator/content/help.xsl");
|
||||
self.HELP_TAGS.all = "all";
|
||||
for each (let namespace in NAMESPACES)
|
||||
for each (let namespace in self.NAMESPACES)
|
||||
{
|
||||
let files = xpath(
|
||||
httpGet("chrome://" + namespace + "/locale/all.xml").responseXML,
|
||||
@@ -163,8 +176,9 @@ function Liberator()
|
||||
for each (let file in files)
|
||||
{
|
||||
let [url, doc] = findHelpFile(file.value);
|
||||
if (doc)
|
||||
self.FILE_MAP[file.value] = url;
|
||||
if (!doc)
|
||||
continue;
|
||||
self.FILE_MAP[file.value] = url;
|
||||
doc = XSLT.transformToDocument(doc);
|
||||
for (let elem in xpath(doc, "//liberator:tag/text()"))
|
||||
self.HELP_TAGS[elem.textContent] = file.value;
|
||||
@@ -193,7 +207,7 @@ Liberator.prototype = {
|
||||
defaultPort: -1,
|
||||
allowPort: function (port, scheme) false,
|
||||
protocolFlags: 0
|
||||
| nsIProtocolHandler.URI_IS_UI_RESOURCE
|
||||
| nsIProtocolHandler.URI_LOADABLE_BY_ANYONE
|
||||
| nsIProtocolHandler.URI_IS_LOCAL_RESOURCE,
|
||||
|
||||
newURI: function (spec, charset, baseURI)
|
||||
@@ -213,8 +227,9 @@ Liberator.prototype = {
|
||||
{
|
||||
case "help":
|
||||
let url = this.FILE_MAP[uri.path.replace(/^\/|#.*/g, "")];
|
||||
if (!url)
|
||||
break;
|
||||
return makeChannel(url, uri);
|
||||
case "help-overlay":
|
||||
url = this.OVERLAY_MAP[uri.path.replace(/^\/|#.*/g, "")];
|
||||
return makeChannel(url, uri);
|
||||
case "help-tag":
|
||||
let tag = uri.path.substr(1);
|
||||
|
||||
@@ -77,14 +77,23 @@ function Bookmarks() //{{{
|
||||
|
||||
function loadBookmark(node)
|
||||
{
|
||||
let uri = util.newURI(node.uri);
|
||||
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
||||
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
||||
let bmark = new Bookmark(node.uri, node.title, node.icon && node.icon.spec, keyword, tags, node.itemId);
|
||||
try
|
||||
{
|
||||
let uri = util.newURI(node.uri);
|
||||
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
||||
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
||||
let bmark = new Bookmark(node.uri, node.title, node.icon && node.icon.spec, keyword, tags, node.itemId);
|
||||
|
||||
bookmarks.push(bmark);
|
||||
bookmarks.push(bmark);
|
||||
|
||||
return bmark;
|
||||
return bmark;
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
liberator.dump("Failed to create bookmark for URI: " + node.uri);
|
||||
liberator.reportError(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function readBookmark(id)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
xmlns:str="http://exslt.org/strings"
|
||||
extension-element-prefixes="str">
|
||||
|
||||
<xsl:output method="xml"/>
|
||||
<xsl:output method="xml" indent="no"/>
|
||||
|
||||
<xsl:template match="liberator:document">
|
||||
<html:html liberator:highlight="Help">
|
||||
@@ -121,6 +121,9 @@
|
||||
</xsl:call-template>
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:ol" mode="pass-2">
|
||||
<html:ol><xsl:apply-templates select="@*|node()"/></html:ol>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:ex" mode="pass-2">
|
||||
<xsl:copy>
|
||||
<xsl:call-template name="linkify-tag">
|
||||
@@ -133,6 +136,16 @@
|
||||
<html:a href="{@topic}"><xsl:apply-templates select="@*|node()"/></html:a>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="liberator:pan[liberator:handle]">
|
||||
<form style="text-align:center" html="http://www.w3.org/1999/xhtml"
|
||||
action="https://www.paypal.com/cgi-bin/webscr" method="post">
|
||||
<input type="hidden" name="cmd" value="_s-xclick"/>
|
||||
<input type="image" src="chrome://liberator/content/x-click-but21.gif" border="0" name="submit" alt="Donate with PayPal"/>
|
||||
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIHPwYJKoZIhvcNAQcEoIIHMDCCBywCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwDQYJKoZIhvcNAQEBBQAEgYAUOJADCwiik68MpIUKcMAtNfs4Cx6RY7604ZujgKj7WVaiELWyhUUDSaq8+iLYaNkRUq+dDld96KwhfodqP3MEmIzpQ/qKvh5+4JzTWSBU5G1lHzc4NJQw6TpXKloPxxXhuGKzZ84/asKZIZpLfkP5i8VtqVFecu7qYc0q1U2KoDELMAkGBSsOAwIaBQAwgbwGCSqGSIb3DQEHATAUBggqhkiG9w0DBwQIWR7nX4WwgcqAgZgO41g/NtgfBwI14LlJx3p5Hc4nHsQD2wyu5l4BMndkc3mc0uRTXvzutcfPBxYC4aGV5UDn6c+XPzsne+OAdSs4/0a2DJe85SBDOlVyOekz3rRhy5+6XK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ggEAMAwGA1UdEwQFMAMBAf8wDQYJKoZIhvcNAQEFBQADgYEAgV86VpqAWuXvX6Oro4qJ1tYVIT5DgWpE692Ag422H7yRIr/9j/iKG4Thia/Oflx4TdL+IFJBAyPK9v6zZNZtBgPBynXb048hsP16l2vi0k5Q2JKiPDsEfBhGI+HnxLXEaUWAcVfCsQFvd2A1sxRr67ip5y2wwBelUecP3AjJ+YcxggGaMIIBlgIBATCBlDCBjjELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMRYwFAYDVQQHEw1Nb3VudGFpbiBWaWV3MRQwEgYDVQQKEwtQYXlQYWwgSW5jLjETMBEGA1UECxQKbGl2ZV9jZXJ0czERMA8GA1UEAxQIbGl2ZV9hcGkxHDAaBgkqhkiG9w0BCQEWDXJlQHBheXBhbC5jb20CAQAwCQYFKw4DAhoFAKBdMBgGCSqGSIb3DQEJAzELBgkqhkiG9w0BBwEwHAYJKoZIhvcNAQkFMQ8XDTA4MDYwNTE0NDk1OFowIwYJKoZIhvcNAQkEMRYEFBpY8FafLq7i3V0czWS9TbR/RjyQMA0GCSqGSIb3DQEBAQUABIGAPvYR9EC2ynooWAvX0iw9aZYTrpX2XrTl6lYkZaLrhM1zKn4RuaiL33sPtq0o0uSKm98gQHzh4P6wmzES0jzHucZjCU4VlpW0fC+/pJxswbW7Qux+ObsNx3f45OcvprqMMZyJiEOULcNhxkm9pCeXQMUGwlHoRRtAxYK2T8L/rQQ=-----END PKCS7-----
|
||||
"/>
|
||||
</form>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="liberator:tag|@tag" mode="pass-2">
|
||||
<xsl:call-template name="parse-tags">
|
||||
<xsl:with-param name="text"><xsl:value-of select="."/></xsl:with-param>
|
||||
@@ -142,18 +155,18 @@
|
||||
<!-- This does't work. Why?
|
||||
<xsl:include href="chrome://liberator/content/overlay.xsl"/>
|
||||
-->
|
||||
<xsl:variable name="local" select="concat('chrome://&liberator.name;/locale/', /liberator:document/@name, '.xml')"/>
|
||||
<xsl:variable name="localdoc" select="document($local)/liberator:overlay"/>
|
||||
<xsl:variable name="overlay" select="concat('liberator://help-overlay/', /liberator:document/@name)"/>
|
||||
<xsl:variable name="overlaydoc" select="document($overlay)/liberator:overlay"/>
|
||||
|
||||
<xsl:template name="splice-locals">
|
||||
<xsl:template name="splice-overlays">
|
||||
<xsl:param name="elem"/>
|
||||
<xsl:param name="tag"/>
|
||||
<xsl:for-each select="$localdoc/*[@insertbefore=$tag]">
|
||||
<xsl:for-each select="$overlaydoc/*[@insertbefore=$tag]">
|
||||
<xsl:apply-templates select="."/>
|
||||
</xsl:for-each>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$localdoc/*[@replace=$tag] and not($elem[@replace])">
|
||||
<xsl:for-each select="$localdoc/*[@replace=$tag]">
|
||||
<xsl:when test="$overlaydoc/*[@replace=$tag] and not($elem[@replace])">
|
||||
<xsl:for-each select="$overlaydoc/*[@replace=$tag]">
|
||||
<xsl:apply-templates select="." mode="pass-2"/>
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
@@ -163,25 +176,25 @@
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:for-each select="$localdoc/*[@insertafter=$tag]">
|
||||
<xsl:for-each select="$overlaydoc/*[@insertafter=$tag]">
|
||||
<xsl:apply-templates select="."/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="liberator:document/liberator:tags|liberator:document/liberator:tag">
|
||||
<xsl:call-template name="splice-locals">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(., ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:document/*[liberator:tags]">
|
||||
<xsl:call-template name="splice-locals">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(liberator:tags, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:*[@tag and not(@replace)]">
|
||||
<xsl:call-template name="splice-locals">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(@tag, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
xmlns:str="http://exslt.org/strings"
|
||||
extension-element-prefixes="str">
|
||||
|
||||
<xsl:variable name="local" select="concat('chrome://&liberator.name;/locale/', /liberator:document/@name, '.xml')"/>
|
||||
<xsl:variable name="localdoc" select="document($local)/liberator:overlay"/>
|
||||
<xsl:variable name="overlay" select="concat('liberator://help-overlay/', /liberator:document/@name)"/>
|
||||
<xsl:variable name="overlaydoc" select="document($overlay)/liberator:overlay"/>
|
||||
|
||||
<xsl:template match="liberator:document">
|
||||
<xsl:copy>
|
||||
@@ -17,15 +17,15 @@
|
||||
</xsl:copy>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template name="splice-locals">
|
||||
<xsl:template name="splice-overlays">
|
||||
<xsl:param name="elem"/>
|
||||
<xsl:param name="tag"/>
|
||||
<xsl:for-each select="$localdoc/*[@insertbefore=$tag]">
|
||||
<xsl:for-each select="$overlaydoc/*[@insertbefore=$tag]">
|
||||
<xsl:apply-templates select="."/>
|
||||
</xsl:for-each>
|
||||
<xsl:choose>
|
||||
<xsl:when test="$localdoc/*[@replace=$tag] and not($elem[@replace])">
|
||||
<xsl:for-each select="$localdoc/*[@replace=$tag]">
|
||||
<xsl:when test="$overlaydoc/*[@replace=$tag] and not($elem[@replace])">
|
||||
<xsl:for-each select="$overlaydoc/*[@replace=$tag]">
|
||||
<xsl:apply-templates select="." mode="pass-2"/>
|
||||
</xsl:for-each>
|
||||
</xsl:when>
|
||||
@@ -35,25 +35,25 @@
|
||||
</xsl:for-each>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:for-each select="$localdoc/*[@insertafter=$tag]">
|
||||
<xsl:for-each select="$overlaydoc/*[@insertafter=$tag]">
|
||||
<xsl:apply-templates select="."/>
|
||||
</xsl:for-each>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="liberator:document/liberator:tags|liberator:document/liberator:tag">
|
||||
<xsl:call-template name="splice-locals">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(., ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:document/*[liberator:tags]">
|
||||
<xsl:call-template name="splice-locals">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(liberator:tags, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
</xsl:template>
|
||||
<xsl:template match="liberator:*[@tag and not(@replace)]">
|
||||
<xsl:call-template name="splice-locals">
|
||||
<xsl:call-template name="splice-overlays">
|
||||
<xsl:with-param name="tag" select="substring-before(concat(@tag, ' '), ' ')"/>
|
||||
<xsl:with-param name="elem" select="self::node()"/>
|
||||
</xsl:call-template>
|
||||
|
||||
@@ -155,7 +155,7 @@ Highlights.prototype.CSS = <![CDATA[
|
||||
HelpLink:hover text-decoration: underline;
|
||||
|
||||
HelpList,liberator|ul display: block; list-style: outside disc;
|
||||
HelpOrderedList,liberator|ol display: block; list-style: outside numeric;
|
||||
HelpOrderedList,liberator|*>html:ol display: block; list-style: outside decimal;
|
||||
HelpListItem,liberator|li display: list-item; margin-left: 1.5em;
|
||||
|
||||
HelpNote,liberator|note display: block; margin: 1em 0em;
|
||||
|
||||
@@ -88,9 +88,9 @@
|
||||
Set the filetype to mail when editing email at Gmail:
|
||||
</p>
|
||||
|
||||
<code>
|
||||
<ex>:autocmd LocationChange .* :set editor=<str>gvim -f</str></ex>
|
||||
<ex>:autocmd LocationChange mail\\.google\\.com :set editor=<str>gvim -f -c 'set ft=mail'</str></ex>
|
||||
<code><!-- Why is the XSLT processor mangling newlines? -->
|
||||
<ex>:autocmd LocationChange .* :set editor=<str>gvim -f</str></ex>

|
||||
<ex>:autocmd LocationChange mail\\.google\\.com :set editor=<str>gvim -f -c 'set ft=mail'</str></ex>
|
||||
</code>
|
||||
|
||||
</document>
|
||||
|
||||
Reference in New Issue
Block a user