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