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