summaryrefslogtreecommitdiff
path: root/common/content/help.xsl
blob: 628fed6df89f4b1472fb14544c7f380c02669e07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!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:output method="xml" indent="no"/>

    <xsl:template match="liberator:document">
        <html:html liberator:highlight="Help">
            <html:head>
                <html:title><xsl:value-of select="@title"/></html:title>
                <html:base href="liberator://help/{@name}"/>
                <html:script type="text/javascript"
                    src="chrome://liberator/content/help.js"/>
            </html:head>
            <html:body liberator:highlight="HelpBody">
                <html:div class="liberator-logo"/>
                <xsl:call-template name="parse-tags">
                    <xsl:with-param name="text" select="concat(@name, '.html')"/>
                </xsl:call-template>
                <xsl:apply-templates/>
            </html:body>
        </html:html>
    </xsl:template>

    <xsl:template match="liberator:include" mode="pass-2">
        <xsl:apply-templates select="document(@href)/liberator:document/node()"/>
    </xsl:template>

    <xsl:template match="liberator:dl" mode="pass-2">
        <xsl:copy>
            <column/>
            <column/>
            <xsl:for-each select="liberator:dt">
                <tr>
                    <xsl:apply-templates select="."/>
                    <xsl:apply-templates select="following-sibling::liberator:dd[position()=1]"/>
                </tr>
            </xsl:for-each>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="liberator:tags" mode="pass-2">
        <xsl:call-template name="parse-tags">
            <xsl:with-param name="text" select="."/>
        </xsl:call-template>
    </xsl:template>

    <xsl:template name="parse-tags">
        <xsl:param name="text"/>
        <tags>
        <xsl:for-each select="str:tokenize($text)">
            <html:a id="{.}"><tag><xsl:value-of select="."/></tag></html:a>
        </xsl:for-each>
        </tags>
    </xsl:template>

    <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:copy>
            <xsl:choose>
                <xsl:when test="starts-with($type, 'string')">
                    <str><xsl:apply-templates/></str>
                </xsl:when>
                <xsl:otherwise>
                    <span>
                        <xsl:choose>
                            <xsl:when test="$type = 'boolean'">
                                <xsl:attribute name="highlight" namespace="http://vimperator.org/namespaces/liberator">Boolean</xsl:attribute>
                            </xsl:when>
                            <xsl:when test="$type = 'number'">
                                <xsl:attribute name="highlight" namespace="http://vimperator.org/namespaces/liberator">Number</xsl:attribute>
                            </xsl:when>
                            <xsl:when test="$type = 'charlist'">
                                <xsl:attribute name="highlight" namespace="http://vimperator.org/namespaces/liberator">String</xsl:attribute>
                            </xsl:when>
                        </xsl:choose>
                        <xsl:apply-templates/>
                    </span>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:copy>
    </xsl:template>

    <xsl:template name="linkify-tag">
        <xsl:param name="contents"/>
        <xsl:variable name="tag" select="str:tokenize($contents, ' [')[1]"/>
        <html:a href="liberator://help-tag/{$tag}" style="color: inherit;">
            <xsl:if test="
                //liberator:tags[contains(concat(' ', ., ' '), concat(' ', $tag, ' '))] |
                //liberator:tag[contains(concat(' ', ., ' '), concat(' ', $tag, ' '))] |
                //@tag[contains(concat(' ', ., ' '), concat(' ', $tag, ' '))]">
                <xsl:attribute name="href">#<xsl:value-of select="$tag"/></xsl:attribute>
            </xsl:if>
            <xsl:value-of select="$contents"/>
        </html:a>
    </xsl:template>
    <xsl:template match="liberator:o" mode="pass-2">
        <xsl:copy>
            <xsl:call-template name="linkify-tag">
                <xsl:with-param name="contents" select='concat("&#39;", text(), "&#39;")'/>
            </xsl:call-template>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="liberator:k|liberator:t" mode="pass-2">
        <xsl:copy>
            <xsl:call-template name="linkify-tag">
                <xsl:with-param name="contents" select="text()"/>
            </xsl:call-template>
        </xsl:copy>
    </xsl:template>
    <xsl:template match="liberator:k[@name]" mode="pass-2">
        <xsl:copy>
            <xsl:call-template name="linkify-tag">
                <xsl:with-param name="contents" select="concat('&lt;', @name, '>', .)"/>
            </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">
                <xsl:with-param name="contents" select="."/>
            </xsl:call-template>
        </xsl:copy>
    </xsl:template>

    <xsl:template match="liberator:link" mode="pass-2">
        <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-----MIIHPwYJKoZIhvcNAQcEoIIHMDCCBywCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1UEBhMCVVMxCzAJ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DYwNTE0NDk1OFowIwYJKoZIhvcNAQkEMRYEFBpY8FafLq7i3V0czWS9TbR/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>
        </xsl:call-template>
    </xsl:template>

    <!-- This does't work. Why?
    <xsl:include href="chrome://liberator/content/overlay.xsl"/>
    -->
    <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-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: -->