Fixed some bad HTML.
[www/www.git] / xsl / events.xsl
1 <?xml version='1.0'?>
2
3 <xsl:stylesheet version="1.1"
4     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5     xmlns:csc="http://csclub.uwaterloo.ca/xsltproc"
6     xmlns="http://www.w3.org/1999/xhtml"
7     exclude-result-prefixes="csc">
8 <xsl:output method="xml" />
9
10 <xsl:template name="events">
11   <tr>
12     <th colspan="2" class="news">Upcoming Events</th>
13   </tr>
14   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
15     <xsl:sort select="translate(@date, '-', '')"
16         order="ascending" data-type="number" />
17     <xsl:if test="translate(@date, '-', '') &gt;= translate($g_date, '-', '')">
18       <tr>
19         <td class="eventdate"><xsl:value-of select="@date" /></td>
20         <td rowspan="2" valign="top" class="eventitem">
21           <a href="{translate(concat($g_pre, 'events/', @room, '-', @date, '-', @time), ' ', '_')}">
22             <xsl:value-of select="@title" />
23           </a>.
24           <xsl:value-of select="short" />
25         </td>
26       </tr>
27       <tr>
28         <td class="eventroom">
29           <xsl:value-of select="@time" />,
30           <xsl:value-of select="@room" />
31         </td>
32       </tr>
33     </xsl:if>
34   </xsl:for-each>
35   <tr>
36     <td class="eventitem" colspan="2">
37       <a href="events/">Past events</a> are available.
38     </td>
39   </tr>
40 </xsl:template>
41
42 <xsl:template match="events-this-term">
43   <xsl:call-template name="events-by-term">
44     <xsl:with-param name="date" select="$g_date" />
45   </xsl:call-template>
46 </xsl:template>
47
48 <xsl:template name="events-by-term">
49   <xsl:param name="date" />
50   <p>The events for <xsl:value-of select="csc:term($date)" /> are listed here.
51     You can also <a href="{$g_pre}events.ics">download an ICS</a> of them.</p>
52   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
53     <xsl:sort select="translate(@date, '-', '')"
54         order="ascending" data-type="number" />
55     <xsl:if test="csc:term(@date) = csc:term($date)">
56       <h3><a href="{translate(concat($g_pre, 'events/', @room, '-', @date, '-', @time), ' ', '_')}"><xsl:value-of select="@title" /></a></h3>
57       <p>
58         <strong>
59           <xsl:value-of select="@room" />,
60           <xsl:value-of select="@date" />,
61           <xsl:value-of select="@time" />:
62         </strong>
63         <xsl:value-of select="short" />.
64       </p>
65     </xsl:if>
66   </xsl:for-each>
67 </xsl:template>
68
69 <xsl:template match="eventdefs">
70   <xsl:apply-templates/>
71 </xsl:template>
72
73 <xsl:template match="eventitem">
74   <xsl:variable name="event_translate_fix"> '</xsl:variable>
75   <xsl:document method="xml" encoding="ISO-8859-1"
76       doctype-public="-//W3C//DTD XHTML 1.1//EN"
77       doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
78       href="{translate(concat($g_outdir, @room, '-', @date, '-', @time, '.html'), $event_translate_fix, '_')}">
79     <html>
80       <head>
81         <title><xsl:value-of select="@title" /></title>
82         <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
83       </head>
84       <body><div class="content">
85         <xsl:call-template name="header" />
86         <h2>Information</h2>
87         <div>
88           <p><xsl:value-of select="@title" />.</p>
89           <p>
90             Held in <xsl:value-of select="@room" />, on
91             <xsl:value-of select="@date" />, at
92             <xsl:value-of select="@time" />.
93           </p>
94         </div>
95         <h2>Abstract</h2>
96         <xsl:if test="abstract">
97           <xsl:apply-templates select="abstract/node()" />
98         </xsl:if>
99         <xsl:if test="not(abstract)">
100           <xsl:apply-templates select="short/node()" />
101         </xsl:if>
102         <xsl:call-template name="footer" />
103       </div></body>
104     </html>
105   </xsl:document>
106 </xsl:template>
107
108 <xsl:template match="generate-event-files">
109   <xsl:apply-templates select="document(concat($g_root, '/events.xml'))/eventdefs" />
110 </xsl:template>
111
112 <xsl:template match="old-events">
113   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
114     <xsl:sort select="translate(@date, '-', '')"
115         order="descending" data-type="number" />
116     <xsl:if test="not(preceding-sibling::*[csc:term(@date)=csc:term(current()/@date)]) and not(csc:term(@date) = csc:term($g_date))">
117       <p><a href="{translate(concat('old-',csc:term(@date)), ' ', '_')}">
118         <xsl:value-of select="csc:term(@date)" />
119       </a></p>
120       <xsl:document method="xml" encoding="ISO-8859-1"
121             doctype-public="-//W3C//DTD XHTML 1.1//EN"
122             doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
123             href="{translate(concat($g_outdir, 'old-', csc:term(@date), '.html'), ' ', '_')}">
124         <html>
125           <head>
126             <title>Events for <xsl:value-of select="csc:term(@date)" /></title>
127             <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
128           </head>
129           <body><div class="content">
130             <xsl:call-template name="header" />
131             <xsl:call-template name="events-by-term">
132                 <xsl:with-param name="date" select="@date" />
133             </xsl:call-template>
134             <xsl:call-template name="footer" />
135           </div></body>
136         </html>
137       </xsl:document>
138     </xsl:if>
139   </xsl:for-each>
140 </xsl:template>
141
142 </xsl:stylesheet>