Merge branch 'master' of disk:/users/www/www/
[mspang/www.git] / xsl / events.xsl
1 <?xml version='1.0'?>
2
3 <xsl:stylesheet version="2.0"
4     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5     xmlns:xs="http://www.w3.org/2001/XMLSchema"
6     xmlns:csc="http://www.csclub.uwaterloo.ca/xslt">
7
8 <xsl:template match="events" 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 name="events-by-term">
41   <p>The events for <xsl:value-of select="csc:term($g_date)" /> are listed here.
42     You can also <a href="{$pre}events.ics">download an ICS</a> of them.</p>
43   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
44     <xsl:sort select="translate(@date, '-', '')" 
45         order="ascending" data-type="number" />
46     <xsl:if test="csc:term(@date) = csc:term($g_date)">
47       <h3><a href="{translate(concat($pre, 'events/', @room, '-', @date, '-', @time, '.html'), ' ', '_')}"><xsl:value-of select="@title" /></a></h3>
48       <p>
49         <strong>
50           <xsl:value-of select="@room" />, 
51           <xsl:value-of select="@date" />, 
52           <xsl:value-of select="@time" />:
53         </strong>
54         <xsl:value-of select="short" />.
55       </p>
56     </xsl:if>
57   </xsl:for-each>
58 </xsl:template>
59
60 <xsl:template match="eventdefs">
61   <xsl:apply-templates/>
62 </xsl:template>
63
64 <xsl:template match="eventitem">
65   <xsl:result-document method="xml" encoding="ISO-8859-1" 
66       doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
67       doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
68       href="{translate(concat($g_root, '/events/', @room, '-', @date, '-', @time, '.html'), ' ', '_')}">
69     <html>
70       <head>
71         <title><xsl:value-of select="@title" /></title>
72         <link rel="stylesheet" href="{$pre}default.css" type="text/css" />
73       </head>
74       <body><div>
75         <xsl:call-template name="header" />
76         <h2>Information</h2>
77         <div>
78           Held in <xsl:value-of select="@room" />, on
79           <xsl:value-of select="@date" />, at <xsl:value-of select="@time" />.
80         </div>
81         <h2>Abstract</h2>
82         <xsl:apply-templates select="abstract/node()" />
83         <xsl:call-template name="footer" />
84       </div></body>
85     </html>
86   </xsl:result-document>
87 </xsl:template>
88
89 <xsl:template match="generate-event-files">
90   <xsl:apply-templates select="document(concat($g_root, '/events.xml'))/eventdefs" />
91 </xsl:template>
92
93 <xsl:key name="eventterm" match="/eventdefs/eventitem" use="csc:term(@date)" />
94
95 <xsl:template match="old-events">
96   <xsl:for-each select="document(concat($g_root, '/events.xml'))/eventdefs/eventitem">
97     <xsl:sort select="translate(@date, '-', '')" 
98         order="descending" data-type="number" />
99     <xsl:if test="not(preceding-sibling::*[csc:term(@date)=csc:term(current()/@date)]) and not(csc:term(@date) = csc:term($g_date))">
100       <p><a href="{translate(concat('old-',csc:term(@date), '.html'), ' ', '_')}">
101         <xsl:value-of select="csc:term(@date)" />
102       </a></p>
103       <xsl:result-document method="xml" encoding="ISO-8859-1" 
104             doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" 
105             doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
106             href="{translate(concat($g_root, '/events/old-', csc:term(@date), '.html'), ' ', '_')}">
107         <html>
108           <head>
109             <title>Events for <xsl:value-of select="csc:term(@date)" /></title>
110             <link rel="stylesheet" href="{$pre}default.css" type="text/css" />
111           </head>
112           <body><div>
113             <xsl:call-template name="header" />
114             <xsl:call-template name="events-by-term" />
115             <xsl:call-template name="footer" />
116           </div></body>
117         </html>
118       </xsl:result-document>
119     </xsl:if>
120   </xsl:for-each>
121 </xsl:template>
122
123 </xsl:stylesheet>