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