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