3306016e75fc47950f66ce0c43194f164c126681
[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:document method="xml" encoding="ISO-8859-1"
75       doctype-public="-//W3C//DTD XHTML 1.1//EN"
76       doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
77       href="{translate(concat($g_outdir, @room, '-', @date, '-', @time, '.html'), ' ', '_')}">
78     <html>
79       <head>
80         <title><xsl:value-of select="@title" /></title>
81         <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
82       </head>
83       <body><div class="content">
84         <xsl:call-template name="header" />
85         <h2>Information</h2>
86         <div>
87           <p><xsl:value-of select="@title" />.</p>
88           <p>
89             Held in <xsl:value-of select="@room" />, on
90             <xsl:value-of select="@date" />, at
91             <xsl:value-of select="@time" />.
92           </p>
93         </div>
94         <h2>Abstract</h2>
95         <xsl:if test="abstract">
96           <xsl:apply-templates select="abstract/node()" />
97         </xsl:if>
98         <xsl:if test="not(abstract)">
99           <xsl:apply-templates select="short/node()" />
100         </xsl:if>
101         <xsl:call-template name="footer" />
102       </div></body>
103     </html>
104   </xsl:document>
105 </xsl:template>
106
107 <xsl:template match="generate-event-files">
108   <xsl:apply-templates select="document(concat($g_root, '/events.xml'))/eventdefs" />
109 </xsl:template>
110
111 <xsl:template match="old-events">
112   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
113     <xsl:sort select="translate(@date, '-', '')"
114         order="descending" data-type="number" />
115     <xsl:if test="not(preceding-sibling::*[csc:term(@date)=csc:term(current()/@date)]) and not(csc:term(@date) = csc:term($g_date))">
116       <p><a href="{translate(concat('old-',csc:term(@date)), ' ', '_')}">
117         <xsl:value-of select="csc:term(@date)" />
118       </a></p>
119       <xsl:document method="xml" encoding="ISO-8859-1"
120             doctype-public="-//W3C//DTD XHTML 1.1//EN"
121             doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
122             href="{translate(concat($g_outdir, 'old-', csc:term(@date), '.html'), ' ', '_')}">
123         <html>
124           <head>
125             <title>Events for <xsl:value-of select="csc:term(@date)" /></title>
126             <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
127           </head>
128           <body><div class="content">
129             <xsl:call-template name="header" />
130             <xsl:call-template name="events-by-term">
131                 <xsl:with-param name="date" select="@date" />
132             </xsl:call-template>
133             <xsl:call-template name="footer" />
134           </div></body>
135         </html>
136       </xsl:document>
137     </xsl:if>
138   </xsl:for-each>
139 </xsl:template>
140
141 </xsl:stylesheet>