Merge branch 'master' of caffeine:/users/www/www/
[mspang/www.git] / xsl / news.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 match="newsdefs">
11   <xsl:apply-templates select="newsitem[csc:term(@date) = csc:term($g_date)]">
12     <xsl:sort select="translate(@date, '-', '')"
13         order="descending" data-type="number" />
14   </xsl:apply-templates>
15 </xsl:template>
16
17 <xsl:template match="newsitem">
18   <tr>
19     <td class="newsdate"><xsl:value-of select="@date" /></td>
20     <td rowspan="2" valign="top" class="newsitem"><xsl:apply-templates/></td>
21   </tr>
22   <tr>
23     <td class="newsauthor"><xsl:value-of select="@author" /></td>
24   </tr>
25 </xsl:template>
26
27 <xsl:template match="news" name="news">
28   <tr>
29     <th colspan="2" class="news">News</th>
30   </tr>
31   <xsl:apply-templates select="document(concat($g_root, '/news.xml'))/newsdefs" />
32   <tr>
33     <td class="newsitem" colspan="2">
34       <a href="news/">Older news items</a> are available. Make sure you check
35       out the <a href="/newsgroup/thread.php?group=uw.csc">uw.csc</a>
36       newsgroup and our announcement boards on the second and third floor of
37       MC for more updates. You can also
38       <a href="events.ics">download an ICS</a> of our events.
39     </td>
40   </tr>
41 </xsl:template>
42
43 <xsl:template name="news-by-term">
44   <xsl:param name="date" />
45   <p>The news for <xsl:value-of select="csc:term($date)" /> is listed here.</p>
46   <xsl:for-each select="document(concat($g_root, '/news.xml'))/newsdefs/newsitem">
47     <xsl:sort select="translate(@date, '-', '')"
48         order="descending" data-type="number" />
49     <xsl:if test="csc:term(@date) = csc:term($date)">
50       <p>
51         <strong>
52           <xsl:value-of select="@date" />,
53           <xsl:value-of select="@author" />:
54         </strong>
55         <xsl:apply-templates/>
56       </p>
57     </xsl:if>
58   </xsl:for-each>
59 </xsl:template>
60
61 <xsl:template match="old-news">
62   <xsl:for-each select="document(concat($g_root, '/news.xml'))/newsdefs/newsitem">
63     <xsl:sort select="translate(@date, '-', '')"
64         order="descending" data-type="number" />
65     <xsl:if test="not(preceding-sibling::*[csc:term(@date)=csc:term(current()/@date)]) and not(csc:term(@date) = csc:term($g_date))">
66       <p><a href="{translate(concat('old-', csc:term(@date)), ' ', '_')}">
67         <xsl:value-of select="csc:term(@date)" />
68       </a></p>
69       <xsl:document method="xml" encoding="ISO-8859-1"
70           doctype-public="-//W3C//DTD XHTML 1.1//EN"
71           doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
72           href="{translate(concat($g_outdir, 'old-', csc:term(@date), '.html'), ' ', '_')}">
73         <html>
74           <head>
75             <title>News for <xsl:value-of select="csc:term(@date)" /></title>
76             <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
77           </head>
78           <body><div class="content">
79             <xsl:call-template name="header" />
80             <xsl:call-template name="news-by-term">
81               <xsl:with-param name="date" select="@date" />
82             </xsl:call-template>
83             <xsl:call-template name="footer" />
84           </div></body>
85         </html>
86       </xsl:document>
87     </xsl:if>
88   </xsl:for-each>
89 </xsl:template>
90
91 </xsl:stylesheet>