Fixed translation of event URLs to strip single quote. This, in turn, fixed generatio...
[mspang/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     <xsl:if test="@preview">
27       s1.addVariable("image","http://mirror.csclub.uwaterloo.ca/csclub/<xsl:value-of select="@preview" />");
28     </xsl:if>
29     s1.write("player1");
30   </script>
31 </xsl:template>
32
33 <xsl:template match="mediaitem">
34   <xsl:call-template name="makemediaitem">
35     <xsl:with-param name="bittorrent">yes</xsl:with-param>
36   </xsl:call-template>
37   <xsl:call-template name="makemediaitem">
38     <xsl:with-param name="suffix">-uw</xsl:with-param>
39     <xsl:with-param name="infotext">
40       <p>
41         If you are in residence, downloading these files will not count
42         against your ResNet quota.
43       </p>
44     </xsl:with-param>
45   </xsl:call-template>
46   <xsl:variable name="thumb-url" select="concat('http://mirror.csclub.uwaterloo.ca/csclub/' ,thumbnail/@file)" />
47   <li class="media">
48       <a href= "{@title}">
49           <span>
50             <img class="media" src="{$thumb-url}" />
51             <span style="display: inline-block">
52                 <b><xsl:value-of select="presentor" />:</b>
53                 <br/>
54                 <xsl:value-of select="@title" />
55             </span>
56           </span>
57       </a>
58   </li>
59 </xsl:template>
60
61 <xsl:template name="makemediaitem">
62   <xsl:param name="suffix" />
63   <xsl:param name="infotext" />
64   <xsl:param name="bittorrent" />
65   <xsl:param name="ads" />
66   <xsl:variable name="realurl" select="concat('http://csclub.uwaterloo.ca/media/', csc:encode-for-uri(@title))" />
67   <xsl:document method="xml" encoding="ISO-8859-1"
68       doctype-public="-//W3C//DTD XHTML 1.1//EN"
69       doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
70       href="{concat($g_outdir, @title, $suffix, '.html')}">
71     <html>
72       <head>
73         <title><xsl:value-of select="@title" /></title>
74         <link rel="stylesheet" href="{$g_pre}default.css" type="text/css" />
75       </head>
76       <body><div class="content">
77         <xsl:call-template name="header">
78           <xsl:with-param name="title" select="@title" />
79           <xsl:with-param name="href" select="concat(@title, $suffix)" />
80         </xsl:call-template>
81         <xsl:call-template name="donate-now" />
82         <xsl:if test="$ads">
83           <xsl:call-template name="inline-ads" />
84         </xsl:if>
85         <xsl:if test="abstract">
86           <h2>Abstract</h2>
87           <div>
88             <xsl:apply-templates select="abstract/node()" />
89           </div>
90         </xsl:if>
91         <xsl:if test="flvfile">
92           <h2>View</h2>
93         <div>
94           <xsl:apply-templates select="flvfile">
95             <xsl:with-param name="mirror" select="$g_mirror" />
96           </xsl:apply-templates>
97         </div>
98         </xsl:if>
99         <xsl:if test="mediafile">
100           <h2>Download</h2>
101           <div>
102             <xsl:copy-of select="$infotext" />
103             <xsl:if test="$bittorrent = 'yes'">
104               <p class="mediafile">
105                 BitTorrent:
106                 <xsl:apply-templates select="mediafile">
107                   <xsl:with-param name="ext">.torrent</xsl:with-param>
108                   <xsl:with-param name="mirror" select="$g_mirror" />
109                 </xsl:apply-templates>
110               </p>
111             </xsl:if>
112             <p class="mediafile">
113               HTTP (web browser):
114               <xsl:apply-templates select="mediafile">
115                 <xsl:with-param name="mirror" select="$g_mirror" />
116               </xsl:apply-templates>
117             </p>
118           </div>
119         </xsl:if>
120         <xsl:if test="@buttons = 'yes'">
121           <p>
122             <!-- digg button -->
123             <script type="text/javascript">
124               digg_url = '<xsl:value-of select="$realurl" />';
125             </script>
126             <script src="http://digg.com/tools/diggthis.js"
127                     type="text/javascript">
128               <xsl:text> </xsl:text>
129             </script>
130             <!-- reddit button -->
131             <script type="text/javascript">
132               reddit_url = '<xsl:value-of select="$realurl" />';
133               reddit_title = '<xsl:value-of select="csc:encode-for-uri(@title)" />';
134             </script>
135             <script src="http://reddit.com/button.js?t=3"
136                     type="text/javascript">
137               <xsl:text> </xsl:text>
138             </script>
139           </p>
140         </xsl:if>
141         <xsl:if test="other">
142         <div>
143           <xsl:apply-templates select="other/node()" />
144           </div>
145         </xsl:if>
146         <p>
147           <!-- AddThis Bookmark Button -->
148           <script type="text/javascript">
149             addthis_url = '<xsl:value-of select="$realurl" />';
150             addthis_title = document.title;
151             addthis_pub = 'calumt';
152           </script>
153           <script type="text/javascript"
154                   src="http://s7.addthis.com/js/addthis_widget.php?v=12">
155             <xsl:text> </xsl:text>
156           </script>
157         </p>
158         <xsl:call-template name="donate-now" />
159         <xsl:call-template name="footer" />
160       </div></body>
161     </html>
162   </xsl:document>
163 </xsl:template>
164
165 </xsl:stylesheet>