Statistics
| Branch: | Tag: | Revision:

dvbd / dvbdguide / tv.xsl @ 4e104f20

History | View | Annotate | Download (6.58 KB)

1
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
2
<xsl:key name="sched" match="/root/scheduled/programme" use="concat(@start,@channel)"/>
3
<xsl:key name="rec" match="/root/recordings/programme" use="concat(@start,@channel)"/>
4
<xsl:key name="fav" match="/root/favourites/programme" use="@title"/>
5
<xsl:output method="html" indent="yes"/>
6

    
7
<xsl:template match="/">
8
  <html>
9
    <head>
10
      <title>TV Listings</title>
11
      <link rel="stylesheet" href="tv.css" type="text/css"/>
12
    </head>
13
    <body>
14
      <form method="POST" action="tv.cgi">
15
        <input type="hidden" name="offset" value="{/root/offset}"/>
16
        <xsl:apply-templates select="/root/tv"/>
17
      </form>
18
    </body>
19
  </html>
20
</xsl:template>
21

    
22
<!-- Main starting/ending HTML -->
23
<xsl:template match="tv">
24
  <h1>TV Listings</h1>
25
  <xsl:variable name="now" select="/root/now"/>
26

    
27
  <p>
28
  <xsl:call-template name="navbar"/>
29
  <h2 id="favourites">Favourites</h2>
30
  </p>
31
  <table class="programmes" id="fav">
32
    <xsl:apply-templates select="programme[substring(@stop,0,15) &gt;= $now and key('fav', title)]"/>
33
  </table>
34

    
35
  <p>
36
  <xsl:call-template name="navbar"/>
37
  <h2 id="next">Next</h2>
38
  </p>
39
  <table class="programmes" id="next">
40
    <xsl:apply-templates select="programme[substring(@start,0,15) &gt;= $now]"/>
41
  </table>
42
  
43
  <p>
44
  <xsl:call-template name="navbar"/>
45
  <h2 id="now">Already Started</h2>
46
  </p>
47
  <table class="programmes" id="now">
48
    <xsl:apply-templates select="programme[substring(@start,0,15) &lt;= $now and $now &lt; substring(@stop,0,15)]"/>
49
  </table>
50

    
51
  <p>
52
  <xsl:call-template name="navbar"/>
53
  <h2 id="scheduled">Scheduled</h2>
54
  </p>
55
  <table class="programmes" id="scheduled">
56
    <xsl:apply-templates select="programme[key('sched', concat(@start,@channel))]">
57
      <xsl:with-param name="scheduled">true</xsl:with-param>
58
    </xsl:apply-templates>
59
  </table>
60

    
61
  <p>
62
  <xsl:call-template name="navbar"/>
63
  <h2 id="recording">Recording</h2>
64
  </p>
65
  <table class="programmes" id="recording">
66
    <xsl:apply-templates select="programme[key('rec', concat(@start,@channel))]">
67
      <xsl:with-param name="scheduled">true</xsl:with-param>
68
  </xsl:apply-templates>
69
  </table>
70
</xsl:template>
71

    
72
<xsl:template name="navbar">
73
  <div class="navbar">
74
    <table class="navbar">
75
      <tr class="navbar">
76
	<td>
77
	  <table class="navbar">
78
	    <tr class="navbar">
79
	      <td class="navbar"><a href="#favourites">Favourites</a></td>
80
	      <td class="navbar"><a href="#next">Next</a></td>
81
	      <td class="navbar"><a href="#now">Already Started</a></td>
82
	      <td class="navbar"><a href="#scheduled">Scheduled</a></td>
83
	      <td class="navbar"><a href="#recording">Recording</a></td>
84
	      <td class="navbar"><a href="">Refresh</a></td>
85
	    </tr>
86
	 </table>
87
       </td>
88
      </tr>
89
      <tr class="navbar">
90
	<td>
91
	  <table class="navbar" width="100%">
92
	    <tr class="navbar">
93
	      <xsl:call-template name="display-offset"/>
94
	    </tr>
95
	  </table>
96
	</td>
97
      </tr>
98
    </table>
99
  </div>
100
</xsl:template>
101

    
102
<!-- HTML for each 'programme' tag -->
103
<xsl:template match="tv/programme">
104
  <xsl:param name="scheduled">false</xsl:param>
105
  <tr class="r{position() mod 2}">
106
    <td class="date-time">
107
      <span class="date">
108
        <xsl:value-of select="substring(@start,7,2)"/>/<xsl:value-of select="concat(substring(@start,5,2),' ')"/>
109
      </span>
110
      <span class="time">
111
        <xsl:value-of select="substring(@start,9,2)"/>:<xsl:value-of select="substring(@start,11,2)"/>
112
      </span> - <span class="time"> <xsl:value-of select="substring(@stop,9,2)"/>:<xsl:value-of select="substring(@stop,11,2)"/> </span>
113
    </td>
114
    <xsl:choose>
115
      <xsl:when test="category='Film'">
116
        <div class="film">
117
          <td class="title">
118
            Film:
119
            <span class="film-title">
120
              <xsl:value-of select="title"/>
121
              <xsl:if test="sub-title">
122
                - <xsl:value-of select="sub-title"/>
123
              </xsl:if>
124
            </span>
125
            [<xsl:element name="a"><xsl:attribute name="href">http://www.imdb.com/Title?<xsl:value-of select="title"/>%20<xsl:if test="date">(<xsl:value-of select="date"/>)</xsl:if></xsl:attribute>imdb</xsl:element>]
126
          </td>
127
        </div>
128
      </xsl:when>
129
      <xsl:otherwise>
130
        <td class="title">
131
          <xsl:value-of select="title"/>
132
          <xsl:if test="sub-title">
133
            - <xsl:value-of select="sub-title"/>
134
          </xsl:if>
135
        </td>
136
      </xsl:otherwise>
137
    </xsl:choose>
138

    
139
    <div class="channel-{@channel}">
140
      <td class="channel">
141
        <span class="channel">
142
          <xsl:variable name="channel" select="@channel"/>
143
          <xsl:value-of select="/root/tv/channel[@id=$channel]/display-name[1]"/>
144
        </span>
145
      </td>
146
    </div>
147
  </tr>
148

    
149
  <tr class="r{position() mod 2}">
150
    <td class="button">
151
      <xsl:choose>
152
        <xsl:when test="$scheduled='true'">
153
          <button name="cancel" type="submit"
154
            value="{@channel}|||{title}|||{sub-title}|||{@start}|||{@stop}">Cancel</button>
155
        </xsl:when>
156
        <xsl:otherwise>
157
          <xsl:choose>
158
            <xsl:when test="key('rec', concat(@start,@channel)) or key('sched', concat(@start,@channel))">
159
                <button name="cancel" type="submit"
160
                  value="{@channel}|||{title}|||{sub-title}|||{@start}|||{@stop}">Cancel</button>
161
                
162
              <p>
163
                <xsl:choose>
164
                  <xsl:when test="key('sched', concat(@start,@channel))">
165
                    <a href="#scheduled">Scheduled</a>
166
                  </xsl:when>
167
                  <xsl:otherwise>
168
                    <a href="#recording">Recording</a>
169
                  </xsl:otherwise>
170
                </xsl:choose>
171
              </p>
172
            </xsl:when>
173
            <xsl:otherwise>
174
              <button name="record" type="submit" 
175
                value="{@channel}|||{title}|||{sub-title}|||{@start}|||{@stop}">Record</button>
176
            </xsl:otherwise>
177
          </xsl:choose>
178
        </xsl:otherwise>
179
      </xsl:choose>
180
    </td>
181
    <td colspan="2">
182
      <xsl:value-of select="desc"/>
183
    </td>
184
  </tr>
185
</xsl:template>
186

    
187
<xsl:template name="display-offset">
188
  <xsl:variable name="offset"><xsl:value-of select="/root/offset"/></xsl:variable>
189
  <xsl:for-each select="/root/day">
190
    <xsl:choose>
191
      <xsl:when test="number(@offset)=number($offset)">
192
        <td class="currentday">
193
          <xsl:value-of select="."/>
194
        </td>
195
      </xsl:when>
196
      <xsl:otherwise>
197
        <td class="navbar">
198
          <a href="?offset={@offset}"><xsl:value-of select="."/></a>
199
        </td>
200
      </xsl:otherwise>
201
    </xsl:choose>
202
  </xsl:for-each>
203
</xsl:template>
204

    
205
</xsl:stylesheet>
206