chiark / gitweb /
Switch to GPL v3
[disorder] / templates / macros.tmpl
CommitLineData
460b9539 1This file is part of DisOrder.
1a3dba67 2Copyright (C) 2008 Richard Kettlewell
460b9539 3
e7eb3a27 4This program is free software: you can redistribute it and/or modify
460b9539 5it under the terms of the GNU General Public License as published by
e7eb3a27 6the Free Software Foundation, either version 3 of the License, or
460b9539 7(at your option) any later version.
8
e7eb3a27
RK
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
460b9539 13
14You should have received a copy of the GNU General Public License
e7eb3a27 15along with this program. If not, see <http://www.gnu.org/licenses/>.
9faa7a88 16
0d0253c9
RK
17
18------------------------------------------------------------------------
19Standard macros
20
21
22This file is read before any other template. Its output is discarded
23but side effects (definitions of macros) are retained. To override it,
24create /etc/disorder/macros.tmpl that includes this file by absolute path
d8b8f26c 25and then redefine macros as desired.
0d0253c9
RK
26------------------------------------------------------------------------
27
28
1a3dba67
RK
29@# Standard width and height of an image
30@define {width} {} {16}
31@define {height} {} {16}
32
0d0253c9
RK
33@# Standard <head> text
34@# @name is the name of this page, for the <title> element
35@define {stdhead} {name}
36 {@quiethead
0d0253c9
RK
37<title>@label{@name.title}</title>}
38
39@# Non-displaying <head> text
40@define {quiethead} {}
99955407
RK
41 { <link rel=stylesheet
42 type="text/css"
43 href="@label{url.static}/disorder.css">}
0d0253c9
RK
44
45@# Standard menu
46@# @current is the name of the current page, e.g. choosealpha, login
47@define {stdmenu} {current}
5d30e04b
RK
48 { <div class=top>
49 <p class=menubar>
0d0253c9 50@menuitem{@current}{playing}{true}
99955407 51@menuitem{@current}{recent}{true}
0d0253c9 52@menuitem{@current}{choose}{@right{play}}
0d0253c9 53@menuitem{@current}{manage}{true}
be968860 54@menuitem{@current}{new}{true}
0d0253c9
RK
55@menuitem{@current}{login}{true}
56@menuitem{@current}{help}{true}
99955407 57 </p>
5d30e04b 58 <div class=logo>
153115c0 59@menuicon{@current}{about}{true}{logosmall}
5d30e04b
RK
60 </div>
61 <div style="clear:both"></div>
62 </div>
0d0253c9
RK
63}
64
153115c0
RK
65@define {menuurl} {name}
66 {@if{@eq{name}{playing}}
67 {@url}
68 {@url?action=@name}}
69
0d0253c9
RK
70@# Menu entry
71@# Used by @stdmenu
72@# @current is the name of the current page (not necessarily the action that
73@# got there!)
74@# @name is the name of the menu item
75@# @available is true if the menu item is available, else false
76@#
77@define {menuitem} {current name available}
78 {@if{@available}
5d30e04b
RK
79 { <a @if{@eq{@current}{@name}}
80 {class=activemenu}
81 {class=inactivemenu}
153115c0 82 href="@menuurl{@name}"
5d30e04b
RK
83 title="@label{menu.@q{@name}verbose}">@label{menu.@name}</a>}
84 { <span class=invalidmenu
85 title="@label{menu.@q{@name}verbose}">@label{menu.@name}</span>}}
0d0253c9 86
153115c0
RK
87@# Icon-based menu entry (very similar to @menuitem)
88@# Used by @stdmenu
89@# @current is the name of the current page
90@# @name is the name of the menu item
91@# @available is true if the menu item is available, else false
92@# @icon is the name of the icon
93@#
94@define {menuicon} {current name available icon}
95 {@if{@available}
96 { <a class=menuicon
97 href="@menuurl{@name}">
98 <img @if{@eq{@current}{@name}}
99 {class=activemenu}
100 {class=inactivemenu}
101 title="@label{menu.@q{@name}verbose}"
102 alt="@label{menu.@name}"
103 src="@image{@icon}">
104 </a>}
105 { <span class=menuicon>
106 <img @if{@eq{@current}{@name}}
107 {class=activemenu}
108 {class=inactivemenu}
109 title="@label{menu.@q{@name}verbose}"
110 alt="@label{menu.@name}"
111 src="@image{@icon@_inactive}">
112 </a>}}
9faa7a88 113
0d0253c9
RK
114@# Standard footer text
115@define {credits} {}
116 {<p class=credits>
117 <a href="http://www.greenend.org.uk/rjk/disorder/"
118 title="DisOrder web site">DisOrder
119 version @version</a>
120 &copy; 2003-2008 Richard Kettlewell et al
121</p>}
a2c4ad5f
RK
122
123@# Expand to the time that @id will be played
1a3dba67
RK
124@# @what is the section
125@# @id is the track ID
a2c4ad5f
RK
126@define {mwhen} {what id}
127 {@when{@id}</td>}
128
129@# Expand to the 'who' field for @id
1a3dba67
RK
130@# @what is the section
131@# @id is the track ID
a2c4ad5f
RK
132@define {mwho} {what id}
133 {@if{@eq{@who{@id}}{}}
134 {@if{@eq{@state{@id}}{random}}
135 {@label{@what.randomtrack}}
136 {&nbsp;}}
137 {@who{@id}}}
138
139@# Expand to the artist for @track
1a3dba67
RK
140@# @what is the section
141@# @track is the track name
a2c4ad5f
RK
142@define {martist} {what track}
143 {@right{play}
144 {<a class=directory
e7ce7665
RK
145 href="@url?action=choose&amp;dir=@urlquote{@dirname{@dirname{@track}}}"
146 title="@label{playing.artistverbose}">@part{@track}{artist}{short}</a>}
a2c4ad5f 147 {<span class=directory
99955407 148 title="@part{@track}{artist}">@part{@track}{artist}{short}</span>}}
a2c4ad5f
RK
149
150@# Expand to the album for @track
1a3dba67
RK
151@# @what is the section
152@# @track is the track name
a2c4ad5f
RK
153@define {malbum} {what track}
154 {@right{play}
155 {<a class=directory
e7ce7665
RK
156 href="@url?action=choose&amp;dir=@urlquote{@dirname{@track}}"
157 title="@label{playing.albumverbose}">@part{@track}{album}{short}</a>}
a2c4ad5f 158 {<span class=directory
99955407 159 title="@part{@track}{album}">@part{@track}{album}{short}</span>}}
a2c4ad5f
RK
160
161@# Expand to the title for @track
1a3dba67
RK
162@# @what is the section
163@# @track is the track name
a2c4ad5f 164@define {mtitle} {what track}
99955407 165 {<span title="@part{@track}{title}">@part{@track}{title}{short}</span>}
a2c4ad5f 166
e7ce7665
RK
167@# As @mtitle but make a link to play the track
168@# @what is the section
169@# @track is the track name
170@define {mtitleplay} {what track}
02eaa49d 171 {<a title="@part{@track}{title}" href="@url?action=play&#38;track=@urlquote{@track}&#38;back=@urlquote{@thisurl}">@part{@track}{title}{short}</a>}
e7ce7665 172
a2c4ad5f 173@# Expand to the remove/scratch entry for @id
1a3dba67
RK
174@# @what is the section
175@# @id is the track ID
a2c4ad5f
RK
176@define {mremove} {what id}
177 {@if{@removable{@id}}
178 {<a class=imgbutton
179 href="@url?action=remove&#38;id=@id@back">
180 <img class=button src="@image{remove}"
30d85588 181 width=@width height=@height
a2c4ad5f
RK
182 title="@label{@what.removeverbose}"
183 alt="@label{@what.scratch}">
184 </a>}
185 {<img class=button src="@image{noremove}"
30d85588 186 width=@width height=@height
a2c4ad5f
RK
187 title="@label{@what.removeverbose}"
188 alt="@label{@what.scratch}">}}
189
af106f2d 190@# Expand to a move button
1a3dba67 191@# @id is the track ID
af106f2d
RK
192@# @dir should be a direction: up, upall, down or downall
193@# @delta should be the distance, +ve for up and -ve for down
194@# This macro calls @movable to check that the move is possible.
195@define {mmove} {id dir delta}
196 {@if{@movable{@id}{@delta}}
197 {<a class=imgbutton
198 href="@url?action=move&#38;id=@id&#38;delta=@delta@back">
199 <img class=button src="@image{@dir}"
30d85588 200 width=@width height=@height
af106f2d
RK
201 title="@label{playing.@q{@dir}verbose}"
202 alt="@label{playing.@dir}">
203 </a>}
204 {<img class=button src="@image{no@dir}"
30d85588
RK
205 width=@width height=@height
206 title="@label{playing.@q{@dir}verbose}"
207 alt="@label{playing.@dir}">}}
5fb0c1a0 208
02eaa49d
RK
209@# Size of input box for preferences forms
210@define{prefsize}{}{40}
211
212@# Expand to the weight of a track. This macro knows the default weight,
213@# and does two lookups, which is rather inelegant.
214@# @track is the track name.
215@define{weight}{track}{@if{@eq{@pref{@track}{weight}}{}}
216 {90000}
217 {@pref{@track}{weight}}}
218
219@# Expand to preference form section for a track
220@# @index is the track number
221@# @track is the track name
222@define {mprefs} {index track}
223 {
224 <p class="prefs_head">Preferences for <span class="prefs_track">@quote{@resolve{@track}}</span>:</p>
225 <input type=hidden name="@index@__track" value="@quote{@resolve{@track}}">
226 <table class=prefs>
227 <tr class=headings>
228 <th class="prefs_name">@label{prefs.name}</th>
229 <th class="prefs_value">@label{prefs.value}</th>
230 </tr>
231 <tr class=even>
232 <td class="prefs_name">@label{heading.title}</td>
233 <td class="prefs_value">
234 <input size=@prefsize type=text name="@index@__title"
235 value="@part{@track}{title}{display}">
236 </td>
237 </tr>
238 <tr class=odd>
239 <td class="prefs_name">@label{heading.album}</td>
240 <td class="prefs_value">
241 <input size=@prefsize type=text name="@index@__album"
242 value="@part{@track}{album}{display}">
243 </td>
244 </tr>
245 <tr class=even>
246 <td class="prefs_name">@label{heading.artist}</td>
247 <td class="prefs_value">
248 <input size=@prefsize type=text name="@index@__artist"
249 value="@part{@track}{artist}{display}">
250 </td>
251 </tr>
252 <tr class=odd>
253 <td class="prefs_name">@label{prefs.tags}</td>
254 <td class="prefs_value">
255 <input size=@prefsize type=text name="@index@__tags"
256 value="@pref{@track}{tags}">
257 </td>
258 </tr>
259 <tr class=even>
260 <td class="prefs_name">@label{prefs.weight}</td>
261 <td class="prefs_value">
262 <input size=@prefsize type=text name="@index@__weight"
263 value="@weight{@track}">
264 </td>
265 </tr>
266 <tr class=odd>
267 <td class="prefs_name">@label{prefs.random}</td>
268 <td class="prefs_value">
269 <input type=checkbox value=true
270 name="@index@__random"
271 @if{@ne{@pref{@track}{pick_at_random}}{0}}
272 {checked}>
273 </td>
274 </tr>
275 </table>
276}
277
8b15f02d
RK
278@# Expand to a submit button
279@# @text is the text to put inside the button
280@define {submit} {text}
57f55a15 281 {<button class=button name=submit type=submit>@text</button>}
8b15f02d 282
3b95af9c
RK
283@# Expand to an action button
284@# @text is the text to put inside the button
285@# @long is the text to put in the caption
286@# @action is the target action
287@define {actbutton} {text long action}
d8b8f26c 288 {<form method=POST class=button action="@url">
cf4ae3d5
RK
289 <input type=hidden name=action value="@action">
290 <input type=submit name=submit value="@text" title="@long">
291@formback@#
292 </form>}
3b95af9c 293
cf4ae3d5 294@# Used for inserting back= elements
3b95af9c 295@define {back} {} {}
cf4ae3d5 296@define {formback} {} {}
3b95af9c 297
5fb0c1a0
RK
298Local variables:
299mode:sgml
300sgml-always-quote-attributes:nil
301sgml-indent-step:1
302sgml-indent-data:t
303indent-tabs-mode:nil
304fill-column:79
305End: