Change some http://www.csclub links to http://csclub links
[www/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="$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="$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_root, '/media/', @title, $suffix, '.html')}">
62     <html>
63       <head>
64         <title><xsl:value-of select="@title" /></title>
65         <link rel="stylesheet" href="{$pre}default.css" type="text/css" />
66       </head>
67       <body><div>
68         <xsl:call-template name="header" />
69         <xsl:if test="abstract">
70           <h2>Abstract</h2>
71           <div>
72             <xsl:apply-templates select="abstract/node()" />
73           </div>
74         </xsl:if>
75         <xsl:if test="flvfile">
76           <h2>View</h2>
77         <div>
78           <xsl:apply-templates select="flvfile">
79             <xsl:with-param name="mirror" select="$mirror" />
80           </xsl:apply-templates>
81         </div>
82         </xsl:if>
83         <xsl:if test="mediafile">
84           <h2>Download</h2>
85           <div>
86             <xsl:copy-of select="$infotext" />
87             <xsl:if test="$bittorrent = 'yes'">
88               <p class="mediafile">
89                 BitTorrent:
90                 <xsl:apply-templates select="mediafile">
91                   <xsl:with-param name="ext">.torrent</xsl:with-param>
92                   <xsl:with-param name="mirror" select="$mirror" />
93                 </xsl:apply-templates>
94               </p>
95             </xsl:if>
96             <p class="mediafile">
97               HTTP (web browser):
98               <xsl:apply-templates select="mediafile">
99                 <xsl:with-param name="mirror" select="$mirror" />
100               </xsl:apply-templates>
101             </p>
102           </div>
103         </xsl:if>
104         <xsl:if test="@buttons = 'yes'">
105           <p>
106             <!-- digg button -->
107             <script type="text/javascript">
108               digg_url = '<xsl:value-of select="$realurl" />';
109             </script>
110             <script src="http://digg.com/tools/diggthis.js"
111                     type="text/javascript">
112               <xsl:text> </xsl:text>
113             </script>
114             <!-- reddit button -->
115             <script type="text/javascript">
116               reddit_url = '<xsl:value-of select="$realurl" />';
117               reddit_title = '<xsl:value-of select="fn:encode-for-uri(@title)" />';
118             </script>
119             <script src="http://reddit.com/button.js?t=3"
120                     type="text/javascript">
121               <xsl:text> </xsl:text>
122             </script>
123           </p>
124         </xsl:if>
125         <xsl:if test="other">
126         <div>
127           <xsl:copy-of select="other/node()"/>
128           </div>
129         </xsl:if>
130         <p>
131           <!-- AddThis Bookmark Button -->
132           <script type="text/javascript">
133             addthis_url = '<xsl:value-of select="$realurl" />';
134             addthis_title = document.title;
135             addthis_pub = 'calumt';
136           </script>
137           <script type="text/javascript"
138                   src="http://s7.addthis.com/js/addthis_widget.php?v=12">
139             <xsl:text> </xsl:text>
140           </script>
141         </p>
142         <xsl:if test="$ads">
143           <xsl:call-template name="inline-ads" />
144         </xsl:if>
145         <xsl:call-template name="footer" />
146       </div></body>
147     </html>
148   </xsl:result-document>
149 </xsl:template>
150
151 </xsl:stylesheet>