Remove .html from internal links
[www/www.git] / xsl / media.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="mediafile">
11   <xsl:param name="ext" />
12   <xsl:param name="mirror" />
13     <a href="{$mirror}{@file}{$ext}"><xsl:value-of select="@type" /></a>
14     <xsl:if test="position() != last()"> | </xsl:if>
15 </xsl:template>
16
17 <xsl:template match="flvfile">
18   <xsl:param name="mirror" />
19   <script type="text/javascript" src="../flash/swfobject.js"><xsl:text> </xsl:text></script>
20   <p id="player1"><a href="http://www.macromedia.com/go/getflashplayer">
21     Get the Flash Player</a> to see this video using Flash Player.</p>
22   <script type="text/javascript">
23     var s1 = new SWFObject("../flash/flvplayer.swf","single","400","300","7");
24     s1.addParam("allowfullscreen","true");
25     s1.addVariable("file","<xsl:value-of select="$mirror" /><xsl:value-of select="@file" />");
26     s1.addVariable("autostart","true");
27     <xsl:if test="@preview">
28       s1.addVariable("image","http://csclub.uwaterloo.ca/files/<xsl:value-of select="@preview" />");
29     </xsl:if>
30     s1.write("player1");
31   </script>
32 </xsl:template>
33
34 <xsl:template match="mediaitem">
35   <xsl:call-template name="makemediaitem">
36     <xsl:with-param name="mirror" select="$g_mirror_csc" />
37     <xsl:with-param name="bittorrent">yes</xsl:with-param>
38     <xsl:with-param name="ads">yes</xsl:with-param>
39   </xsl:call-template>
40   <xsl:call-template name="makemediaitem">
41     <xsl:with-param name="suffix">-uw</xsl:with-param>
42     <xsl:with-param name="infotext">
43       <p>
44         If you are in residence, downloading these files will not count
45         against your ResNet quota.
46       </p>
47     </xsl:with-param>
48     <xsl:with-param name="mirror" select="$g_mirror_cs" />
49   </xsl:call-template>
50   <li><a href= "{@title}"><xsl:value-of select="@title" /></a></li>
51 </xsl:template>
52
53 <xsl:template name="makemediaitem">
54   <xsl:param name="suffix" />
55   <xsl:param name="infotext" />
56   <xsl:param name="mirror" />
57   <xsl:param name="bittorrent" />
58   <xsl:param name="ads" />
59   <xsl:variable name="realurl" select="concat('http://csclub.uwaterloo.ca/media/', csc:encode-for-uri(@title))" />
60   <xsl:document method="xml" encoding="ISO-8859-1"
61       doctype-public="-//W3C//DTD XHTML 1.1//EN"
62       doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
63       href="{concat($g_outdir, @title, $suffix)}">
64     <html>
65       <head>
66         <title><xsl:value-of select="@title" /></title>
67         <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
68       </head>
69       <body><div class="content">
70         <xsl:call-template name="header">
71           <xsl:with-param name="title" select="@title" />
72           <xsl:with-param name="href" select="concat(@title, $suffix)" />
73         </xsl:call-template>
74         <xsl:call-template name="donate-now" />
75         <xsl:if test="$ads">
76           <xsl:call-template name="inline-ads" />
77         </xsl:if>
78         <xsl:if test="abstract">
79           <h2>Abstract</h2>
80           <div>
81             <xsl:apply-templates select="abstract/node()" />
82           </div>
83         </xsl:if>
84         <xsl:if test="flvfile">
85           <h2>View</h2>
86         <div>
87           <xsl:apply-templates select="flvfile">
88             <xsl:with-param name="mirror" select="$mirror" />
89           </xsl:apply-templates>
90         </div>
91         </xsl:if>
92         <xsl:if test="mediafile">
93           <h2>Download</h2>
94           <div>
95             <xsl:copy-of select="$infotext" />
96             <xsl:if test="$bittorrent = 'yes'">
97               <p class="mediafile">
98                 BitTorrent:
99                 <xsl:apply-templates select="mediafile">
100                   <xsl:with-param name="ext">.torrent</xsl:with-param>
101                   <xsl:with-param name="mirror" select="$mirror" />
102                 </xsl:apply-templates>
103               </p>
104             </xsl:if>
105             <p class="mediafile">
106               HTTP (web browser):
107               <xsl:apply-templates select="mediafile">
108                 <xsl:with-param name="mirror" select="$mirror" />
109               </xsl:apply-templates>
110             </p>
111           </div>
112         </xsl:if>
113         <xsl:if test="@buttons = 'yes'">
114           <p>
115             <!-- digg button -->
116             <script type="text/javascript">
117               digg_url = '<xsl:value-of select="$realurl" />';
118             </script>
119             <script src="http://digg.com/tools/diggthis.js"
120                     type="text/javascript">
121               <xsl:text> </xsl:text>
122             </script>
123             <!-- reddit button -->
124             <script type="text/javascript">
125               reddit_url = '<xsl:value-of select="$realurl" />';
126               reddit_title = '<xsl:value-of select="csc:encode-for-uri(@title)" />';
127             </script>
128             <script src="http://reddit.com/button.js?t=3"
129                     type="text/javascript">
130               <xsl:text> </xsl:text>
131             </script>
132           </p>
133         </xsl:if>
134         <xsl:if test="other">
135         <div>
136           <xsl:apply-templates select="other/node()" />
137           </div>
138         </xsl:if>
139         <p>
140           <!-- AddThis Bookmark Button -->
141           <script type="text/javascript">
142             addthis_url = '<xsl:value-of select="$realurl" />';
143             addthis_title = document.title;
144             addthis_pub = 'calumt';
145           </script>
146           <script type="text/javascript"
147                   src="http://s7.addthis.com/js/addthis_widget.php?v=12">
148             <xsl:text> </xsl:text>
149           </script>
150         </p>
151         <xsl:call-template name="donate-now" />
152         <xsl:call-template name="footer" />
153       </div></body>
154     </html>
155   </xsl:document>
156 </xsl:template>
157
158 </xsl:stylesheet>