summaryrefslogtreecommitdiff
path: root/stylesheets/toc2html.xsl
blob: 03985bae00c12380c22917a6dab5bcf1c0b38346 (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
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:yelp="http://www.gnome.org/yelp/ns"
                xmlns="http://www.w3.org/1999/xhtml"
                extension-element-prefixes="yelp"
                version="1.0">

<xsl:param name="help_icon"/>
<xsl:param name="help_icon_size"/>

<xsl:param name="yelp.color.text"/>
<xsl:param name="yelp.color.anchor"/>
<xsl:param name="yelp.color.background"/>
<xsl:param name="yelp.color.base0"/>
<xsl:param name="yelp.color.base1"/>
<xsl:param name="yelp.color.base2"/>
<xsl:param name="yelp.color.base3"/>
<xsl:param name="yelp.color.selected0"/>
<xsl:param name="yelp.color.selected1"/>
<xsl:param name="yelp.color.selected2"/>
<xsl:param name="yelp.color.selected3"/>

<xsl:template match="toc">
  <yelp:document href="{@id}">
    <html>
      <head>
        <title>
          <xsl:value-of select="title[1]"/>
        </title>
        <style><xsl:text>
        body {
          padding-top: 0px;
          padding-left: 0px;
          padding-right: 12px;
        }
        h1 { font-size: 2em; margin-bottom: 0.4em; }
        h1 img { float: right; }
        h1 { color: </xsl:text>
        <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; }
        h2 { color: </xsl:text>
        <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; }
        h3 { color: </xsl:text>
        <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; }
        h4 { color: </xsl:text>
        <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; }
        h5 { color: </xsl:text>
        <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; }
        h6 { color: </xsl:text>
        <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; }
        h7 { color: </xsl:text>
        <xsl:value-of select="$yelp.color.selected1"/><xsl:text>; }
        div[class~="leftbar"] {
          width: 200px;
          text-align: center;
        }
        div[class~="body"] {
          background-image: url("</xsl:text>
          <xsl:value-of select="$help_icon"/><xsl:text>");
          background-position: </xsl:text>
          <xsl:value-of select="(192 - $help_icon_size) div 2"/><xsl:text>px 0px;
          background-repeat: no-repeat;
          height: 200px;
        }
        div[class~="rightbar"] {
          padding-left: 200px;
        }
        div[class~="tocs"] { border-top: solid 1px; }
        div[class~="docs"] { border-top: solid 1px; }
        ul {
          margin-left: 16px;
          padding-left: 0px;
        }
        li {
          margin-top: 0.4em;
          margin-left: 0px;
          padding-left: 0px;
          font-size: 1.2em;
          list-style-type: square;
        }
        dl { margin-left: 0px; padding-left: 0px; }
        dt { font-size: 1.2em; margin-top: 0.6em; }
        dd { margin-left: 16px; margin-top: 0.2em; }
        a { text-decoration: none; }
        a:hover { text-decoration: underline; }
        </xsl:text></style>
      </head>
      <body>
        <xsl:apply-templates mode="body.mode" select="."/>
      </body>
    </html>
  </yelp:document>
  <xsl:apply-templates select="toc[.//doc]"/>
</xsl:template>

<xsl:template mode="body.mode" match="toc">
  <div class="body">
    <div class="rightbar">
      <h1>
        <xsl:if test="icon">
          <img src="{icon/@file}"/>
        </xsl:if>
        <xsl:apply-templates select="title[1]/node()"/>
      </h1>
      <xsl:if test="toc[.//doc]">
        <div class="tocs">
          <ul>
            <xsl:for-each select="toc[../@id = 'index' or .//doc]">
              <xsl:sort select="number(../@id = 'index') * position()"/>
              <xsl:sort select="title"/>
              <li class="toc">
                <a href="x-yelp-toc:{@id}">
                  <xsl:apply-templates select="title[1]/node()"/>
                </a>
              </li>
            </xsl:for-each>
          </ul>
        </div>
      </xsl:if>
      <xsl:if test="doc">
        <div class="docs">
          <dl>
            <xsl:for-each select="doc">
              <xsl:sort select="title"/>
              <dt class="doc">
                <a href="{@href}" title="{@href}">
                  <xsl:if test="tooltip">
                    <xsl:attribute name="title">
                      <xsl:value-of select="tooltip"/>
                    </xsl:attribute>
                  </xsl:if>
                  <xsl:value-of select="title"/>
                </a>
              </dt>
              <dd>
                <xsl:value-of select="description"/>
              </dd>
            </xsl:for-each>
          </dl>
        </div>
      </xsl:if>
    </div>
  </div>
</xsl:template>

</xsl:stylesheet>