summaryrefslogtreecommitdiff
path: root/templates/du2html.xsl
blob: 37253333d0965ad3b89e74a17e81a0e757131562 (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
<?xml version="1.0" encoding="utf-8"?>
<x:stylesheet xmlns:x="http://www.w3.org/1999/XSL/Transform"
              xmlns="http://www.w3.org/1999/xhtml"
              xmlns:e="http://exslt.org/common"
              xmlns:s="http://exslt.org/strings"
              xmlns:wc="http://webcoso.thenautilus.net/"
              exclude-result-prefixes="wc e"
              version="1.0"
              >
 
 <x:import href="reST.xsl"/>
 
 <x:param name="language" select="'en'"/>
 <x:param name="path"/>
 <x:param name="filename"/>
 
 <x:variable name="langs-rtf">
  <x:choose>
   <x:when test="$language = 'it'">
    <lang>it</lang>
    <lang>en</lang>
   </x:when>
   <x:when test="$language = 'en'">
    <lang>en</lang>
    <lang>it</lang>
   </x:when>
   <x:otherwise> <!-- uh? -->
    <lang><x:value-of select="$language"/></lang>
   </x:otherwise>
  </x:choose>
 </x:variable>
 <x:variable name="langs" select="e:node-set($langs-rtf)/node()"/>
 
 <x:output method="html" encoding="utf-8"
           doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
           indent="yes"/>
 
 <x:template match="system_message" />
 <x:template match="*[@classes='system-messages']" />
 
 <!--
     i casini con quel ancestor::document sono dovuti a:
 
     1) il fatto che $filename non è il nome del documento che stiamo
        toccando, quando espandiamo i documenti dentro al feed
 
     2) un bug di LibXML o LibXSLT, per cui /document/@source non va
 -->
 
 <x:template match="reference">
  <x:element name="a">
   <x:attribute name="href">
    <x:choose>
     <x:when test="@refid">
      <x:value-of select="concat('#', @refid)" />
     </x:when>
     <x:when test="@refuri">
      <x:value-of select="@refuri"/>
     </x:when>
    </x:choose>
   </x:attribute>
 
   <x:choose>
    <x:when test="@refuri and string(.)=string(@refuri)">
     <x:apply-templates select="wc:title-for($langs,ancestor::document/@source,@refuri)"/>
    </x:when>
    <x:otherwise>
     <x:apply-templates />
    </x:otherwise>
   </x:choose>
  </x:element>
 </x:template>
 
 <x:template match="target[@refid and not(@refuri)]">
  <a name="{@refid}"/>
 </x:template>
 
 <x:template match="target[@names and not(@refuri)]">
  <x:for-each select="s:split(@names,' ')/token">
   <a name="{.}"/>
  </x:for-each>
 </x:template>
 
 <!-- qui ce ne freghiamo del @source, tanto viene usata solo per i
      documenti stand-alone -->
 
 <x:template match="/document">
  <html xml:lang="{$language}" lang="{$language}">
   <head>
    <title><x:value-of select="title"/></title>
    <link rel="stylesheet" type="text/css" href="/thenautilus.css" />
    <x:for-each select="docinfo/field[field_name='css']/field_body/*/list_item|docinfo/field[field_name='css']/field_body/paragraph">
     <link rel="stylesheet" type="text/css" href="{normalize-space(.)}" />
    </x:for-each>
    <x:for-each select="docinfo/field[field_name='inline-css']/field_body">
     <style type="text/css">
      <x:value-of select="." disable-output-escaping="yes" />
     </style>
    </x:for-each>
   </head>
   <body>
    <div id="content">
     <h1><x:apply-templates select="title/node()"/></h1>
     <x:apply-templates/>
    </div>
    <div id="tags">
     <x:apply-templates select="wc:tagged()"/>
    </div>
    <div id="dates">
     <x:apply-templates select="wc:dates-for($language,$filename,'./')"/>
    </div>
   </body>
  </html>
 </x:template>
 
 <x:template match="/wc:dates">
  <span id="created">
   <x:if test="$language='it'">Creato: </x:if>
   <x:if test="$language='en'">Created: </x:if>
   <span class="date created"><x:value-of select="wc:creation-date"/></span>
  </span>
  <x:text> </x:text>
  <span id="lastmod">
   <x:if test="$language='it'">Ultima modifica: </x:if>
   <x:if test="$language='en'">Last change: </x:if>
   <span class="date lastmod"><x:value-of select="wc:last-change"/></span>
  </span>
 </x:template>
 
 <x:template match="/wc:tags">
  <ul>
   <x:apply-templates/>
  </ul>
 </x:template>
 
 <x:template match="wc:tag">
  <li>
   <span class="tag title">
    <a href="{concat('/tags/',@name,'/')}">
     <x:apply-templates select="wc:title-for($language,$filename,concat('/tags/',@name,'/'))"/>
    </a>
   </span>
  </li>
 </x:template>
 
 <x:template match="wc:doc">
  <x:value-of select="wc:message('wc:doc',.)"/>
  <li>
   <a class="tag doc" href="{@uri}"><x:apply-templates select="wc:title-for($language,$filename,@uri)"/></a>
   (<span class="tag doc langs"><x:apply-templates/></span>)
  </li>
 </x:template>
 
 <x:template match="wc:lang">
  <x:value-of select="wc:message('wc:lang',.)"/>
  <x:choose>
   <x:when test=".!=$language">
    <a href="{../@uri}{.}" class="lang"><x:value-of select="."/></a>
   </x:when>
   <x:otherwise>
    <span class="lang"><x:value-of select="."/></span>
   </x:otherwise>
  </x:choose>
  <x:if test="following-sibling::wc:lang"> | </x:if>
 </x:template>
 
</x:stylesheet>