summaryrefslogtreecommitdiff
path: root/common/content
diff options
context:
space:
mode:
authorKris Maglione <kris@vimperator.org>2009-10-25 20:06:50 -0400
committerKris Maglione <kris@vimperator.org>2009-10-25 20:06:50 -0400
commit486ac5954a89c61642e8d2aa86e5cd0f00cd2702 (patch)
treeabb1b20e983f52c87e8c9a3e5234eb1858d4fcee /common/content
parent10091e0fd1f1cc8508bbe17e4d3cd7f92d773535 (diff)
downloadpentadactyl-486ac5954a89c61642e8d2aa86e5cd0f00cd2702.tar.gz
Get rid of silly config.helpFiles.
--HG-- branch : xslt rename : common/components/chrome-data.js => common/components/protocols.js
Diffstat (limited to 'common/content')
-rw-r--r--common/content/configbase.js7
-rw-r--r--common/content/help.xsl9
-rw-r--r--common/content/liberator.js9
-rw-r--r--common/content/overlay.xsl72
4 files changed, 83 insertions, 14 deletions
diff --git a/common/content/configbase.js b/common/content/configbase.js
index 41a5ada2..51a59608 100644
--- a/common/content/configbase.js
+++ b/common/content/configbase.js
@@ -51,13 +51,6 @@ const configbase = { //{{{
hostApplication: null,
/**
- * @property {[string]} A list of HTML help files available under
- * chrome://liberator/locale/. Used to generate help tag indexes for
- * the :help command.
- */
- helpFiles: [],
-
- /**
* @property {function} Called on liberator startup to allow for any
* arbitrary application-specific initialization code.
*/
diff --git a/common/content/help.xsl b/common/content/help.xsl
index 5763d4e3..e2e7f896 100644
--- a/common/content/help.xsl
+++ b/common/content/help.xsl
@@ -10,9 +10,6 @@
<xsl:output method="xml"/>
- <xsl:variable name="local" select="concat('chrome://&liberator.name;/locale/', /liberator:document/@name, '.xml')"/>
- <xsl:variable name="localdoc" select="document($local)/liberator:overlay"/>
-
<xsl:template match="liberator:document">
<html:html liberator:highlight="Help">
<html:head>
@@ -142,6 +139,12 @@
</xsl:call-template>
</xsl:template>
+ <!-- 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:template name="splice-locals">
<xsl:param name="elem"/>
<xsl:param name="tag"/>
diff --git a/common/content/liberator.js b/common/content/liberator.js
index 6daf3c58..96006379 100644
--- a/common/content/liberator.js
+++ b/common/content/liberator.js
@@ -215,7 +215,7 @@ const liberator = (function () //{{{
options.add(["helpfile", "hf"],
"Name of the main help file",
- "string", "intro.html");
+ "string", "intro");
options.add(["loadplugins", "lpl"],
"Load plugin scripts when starting up",
@@ -1356,6 +1356,8 @@ const liberator = (function () //{{{
*/
findHelp: function (topic, unchunked)
{
+ if (topic in services.get("liberator:").FILE_MAP)
+ return topic;
unchunked = !!unchunked;
let items = completion._runCompleter("help", topic, null, unchunked).items;
let partialMatch = null;
@@ -1388,8 +1390,8 @@ const liberator = (function () //{{{
if (!topic && !unchunked)
{
let helpFile = options["helpfile"];
- if (config.helpFiles.indexOf(helpFile) != -1)
- liberator.open("liberator://help/" + helpFile.replace(/\.html$/, ""), { from: "help" });
+ if (helpFile in services.get("liberator:").FILE_MAP)
+ liberator.open("liberator://help/" + helpFile, { from: "help" });
else
liberator.echomsg("Sorry, help file " + helpFile.quote() + " not found");
return;
@@ -1725,7 +1727,6 @@ const liberator = (function () //{{{
liberator.log("Initializing liberator object...", 0);
services.get("liberator:").helpNamespaces = [config.name.toLowerCase(), "liberator"];
- services.get("liberator:").helpFiles = config.helpFiles.map(function (f) f.replace(/\..*/, ""));
config.features.push(getPlatformFeature());
diff --git a/common/content/overlay.xsl b/common/content/overlay.xsl
new file mode 100644
index 00000000..4e4dd393
--- /dev/null
+++ b/common/content/overlay.xsl
@@ -0,0 +1,72 @@
+<!DOCTYPE document SYSTEM "chrome://liberator/content/liberator.dtd">
+
+<xsl:stylesheet version="1.0"
+ xmlns="http://vimperator.org/namespaces/liberator"
+ xmlns:liberator="http://vimperator.org/namespaces/liberator"
+ xmlns:html="http://www.w3.org/1999/xhtml"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ 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:template match="liberator:document">
+ <xsl:copy>
+ <xsl:apply-templates/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template name="splice-locals">
+ <xsl:param name="elem"/>
+ <xsl:param name="tag"/>
+ <xsl:for-each select="$localdoc/*[@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:apply-templates select="." mode="pass-2"/>
+ </xsl:for-each>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:for-each select="$elem">
+ <xsl:apply-templates select="." mode="pass-2"/>
+ </xsl:for-each>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:for-each select="$localdoc/*[@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: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: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:with-param name="tag" select="substring-before(concat(@tag, ' '), ' ')"/>
+ <xsl:with-param name="elem" select="self::node()"/>
+ </xsl:call-template>
+ </xsl:template>
+
+ <xsl:template match="@*|node()" mode="pass-2">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"/>
+ </xsl:copy>
+ </xsl:template>
+ <xsl:template match="@*|node()">
+ <xsl:apply-templates select="." mode="pass-2"/>
+ </xsl:template>
+</xsl:stylesheet>
+
+<!-- vim:se ft=xslt sts=4 sw=4 et: -->