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