1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-21 00:17:59 +01:00

Improve the help formatting with generous and ugly use of struts. Unfortunately, the HTML box model doesn't lend itself to automatic Vim-ish formatting.

--HG--
branch : xslt
This commit is contained in:
Kris Maglione
2009-10-28 04:37:53 -04:00
parent 21704fe309
commit 412f3101c1
5 changed files with 39 additions and 91 deletions

View File

@@ -46,11 +46,16 @@
</xsl:template> </xsl:template>
<xsl:template match="liberator:tags" mode="pass-2"> <xsl:template match="liberator:tags" mode="pass-2">
<html:div style="clear: right"/>
<xsl:call-template name="parse-tags"> <xsl:call-template name="parse-tags">
<xsl:with-param name="text" select="."/> <xsl:with-param name="text" select="."/>
</xsl:call-template> </xsl:call-template>
</xsl:template> </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>
</xsl:call-template>
</xsl:template>
<xsl:template name="parse-tags"> <xsl:template name="parse-tags">
<xsl:param name="text"/> <xsl:param name="text"/>
<tags> <tags>
@@ -60,6 +65,25 @@
</tags> </tags>
</xsl:template> </xsl:template>
<xsl:template match="liberator:item" mode="pass-2">
<xsl:copy>
<xsl:apply-templates select="liberator:tags|liberator:spec"/>
<html:hr style="border: 0; height: 0; margin: 0; width: 100%; float: right;"/>
<html:div liberator:highlight="HelpOptInfo">
<xsl:apply-templates select="liberator:type|liberator:default"/>
<html:div style="clear: both;"/>
</html:div>
<xsl:apply-templates select="liberator:description"/>
<html:div style="clear: both;"/>
</xsl:copy>
</xsl:template>
<xsl:template match="liberator:spec[preceding-sibling::liberator:spec]" mode="pass-2">
<html:div style="clear: both;"/>
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="liberator:default[not(@type='plain')]" mode="pass-2"> <xsl:template match="liberator:default[not(@type='plain')]" mode="pass-2">
<xsl:variable name="type" select="preceding-sibling::liberator:type[1] | following-sibling::liberator:type[1]"/> <xsl:variable name="type" select="preceding-sibling::liberator:type[1] | following-sibling::liberator:type[1]"/>
<xsl:copy> <xsl:copy>
@@ -146,12 +170,6 @@
</form> </form>
</xsl:template> </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>
</xsl:call-template>
</xsl:template>
<!-- This does't work. Why? <!-- This does't work. Why?
<xsl:include href="chrome://liberator/content/overlay.xsl"/> <xsl:include href="chrome://liberator/content/overlay.xsl"/>
--> -->

View File

@@ -1,72 +0,0 @@
<!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="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>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template name="splice-overlays">
<xsl:param name="elem"/>
<xsl:param name="tag"/>
<xsl:for-each select="$overlaydoc/*[@insertbefore=$tag]">
<xsl:apply-templates select="."/>
</xsl:for-each>
<xsl:choose>
<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>
<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="$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-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-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-overlays">
<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: -->

View File

@@ -134,11 +134,11 @@ Highlights.prototype.CSS = <![CDATA[
HelpBorder,liberator|* border-color: silver; border-width: 0px; border-style: solid; HelpBorder,liberator|* border-color: silver; border-width: 0px; border-style: solid;
HelpCode,liberator|code display: block; white-space: pre; margin-left: 2em; font-family: courier, monospace; HelpCode,liberator|code display: block; white-space: pre; margin-left: 2em; font-family: courier, monospace;
HelpDefault,liberator|default display: block; float: left; margin-right: 1ex; margin-bottom: 1em; white-space: pre; HelpDefault,liberator|default margin-right: 1ex; white-space: pre;
HelpDefault::after content: ")" HelpDefault::after content: ")"
HelpDefault::before content: "(default: "; HelpDefault::before content: "(default: ";
HelpDescription,liberator|description display: block; clear: both; HelpDescription,liberator|description display: block;
HelpEm,liberator|em font-weight: bold; HelpEm,liberator|em font-weight: bold;
HelpEx,liberator|ex display: inline-block; color: #527BBD; font-weight: bold; HelpEx,liberator|ex display: inline-block; color: #527BBD; font-weight: bold;
@@ -147,7 +147,7 @@ Highlights.prototype.CSS = <![CDATA[
HelpExample,liberator|example display: block; margin: 1em 0; HelpExample,liberator|example display: block; margin: 1em 0;
HelpExample::before content: "Example: "; font-weight: bold; HelpExample::before content: "Example: "; font-weight: bold;
HelpHead,liberator|h1 display: block; margin: 1em 0; padding-bottom: .2ex; border-bottom-width: 1px; font-size: 2em; font-weight: bold; color: #527BBD; clear: both; HelpHead,liberator|h1 display: block; margin: 1em 0; padding-bottom: .2ex; border-bottom-width: 1px; font-size: 2em; font-weight: bold; color: #527BBD; clear: both;
HelpItem,liberator|item display: block; margin: 1em 1em 1em 10em; HelpItem,liberator|item display: block; margin: 1em 1em 1em 10em; clear: both;
HelpKey,liberator|k color: #102663; HelpKey,liberator|k color: #102663;
@@ -163,11 +163,12 @@ Highlights.prototype.CSS = <![CDATA[
HelpOpt,liberator|o color: #106326; HelpOpt,liberator|o color: #106326;
HelpOpt:hover text-decoration: underline; cursor: pointer; HelpOpt:hover text-decoration: underline; cursor: pointer;
HelpOptInfo display: inline-block; margin-bottom: 1ex;
HelpParagraph,liberator|p display: block; margin: 1em 0em; clear: right; HelpParagraph,liberator|p display: block; margin: 1em 0em;
HelpSpec,liberator|spec display: block; margin: 0 2em 0 -10em; float: left; clear: left; color: #527BBD; HelpSpec,liberator|spec display: block; margin-left: -10em; float: left; clear: left; color: #527BBD;
HelpString,liberator|str display: inline-block; color: green; font-weight: normal; HelpString,liberator|str display: inline-block; color: green; font-weight: normal; vertical-align: text-top;
HelpString::before content: '"'; HelpString::before content: '"';
HelpString::after content: '"'; HelpString::after content: '"';
@@ -184,7 +185,7 @@ Highlights.prototype.CSS = <![CDATA[
HelpTag,liberator|tag display: inline-block; color: #527BBD; margin-left: 1ex; font-size: 8pt; font-weight: bold; HelpTag,liberator|tag display: inline-block; color: #527BBD; margin-left: 1ex; font-size: 8pt; font-weight: bold;
HelpTags,liberator|tags display: block; float: right; clear: right; HelpTags,liberator|tags display: block; float: right; clear: right;
HelpTopic,liberator|t color: #102663; HelpTopic,liberator|t color: #102663;
HelpType,liberator|type display: block; float: left; margin-right: 1ex; margin-bottom: 1em; HelpType,liberator|type margin-right: 2ex;
HelpWarning,liberator|warning display: block; margin: 1em 0em; HelpWarning,liberator|warning display: block; margin: 1em 0em;
HelpWarning::before content: "Warning: "; color: red; font-weight: bold; HelpWarning::before content: "Warning: "; color: red; font-weight: bold;
@@ -276,10 +277,10 @@ function Highlights(name, store)
this.selector = function (class) this.selector = function (class)
{ {
let [, hl, rest] = class.match(/^(\w*)(.*)/); let [, hl, rest] = class.match(/^(\w*)(.*)/);
class = "[liberator|highlight~=" + hl + "]" let pattern = "[liberator|highlight~=" + hl + "]"
if (highlight[hl] && highlight[hl].class != class) if (highlight[hl] && highlight[hl].class != class)
class = highlight[hl].selector; pattern = highlight[hl].selector;
return class + rest; return pattern + rest;
}; };
/** /**

View File

@@ -1186,7 +1186,8 @@ function Tabs() //{{{
if (!tab) if (!tab)
tab = getBrowser().mTabContainer.selectedItem; tab = getBrowser().mTabContainer.selectedItem;
getBrowser().replaceTabWithWindow(tab); services.get("windowWatcher")
.openWindow(window, window.getBrowserURL(), null, "chrome,dialog=no,all", tab);
}, },
/** /**

View File

@@ -53,6 +53,6 @@ do
done done
[ -f "$top/$jar" ] && rm -f "$top/$jar" [ -f "$top/$jar" ] && rm -f "$top/$jar"
(set -e; cd $stage; zip -r "$top/$jar" *) || exit 1 (set -e; cd $stage; zip -9r "$top/$jar" *) || exit 1
rm -rf "$stage" rm -rf "$stage"