| 1 | This file is part of DisOrder. |
| 2 | Copyright (C) 2008, 2009, 2011 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 3 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, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | GNU 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, see <http://www.gnu.org/licenses/>. |
| 16 | |
| 17 | |
| 18 | ------------------------------------------------------------------------ |
| 19 | Standard macros |
| 20 | |
| 21 | |
| 22 | This file is read before any other template. Its output is discarded |
| 23 | but side effects (definitions of macros) are retained. To override it, |
| 24 | create /etc/disorder/macros.tmpl that includes this file by absolute path |
| 25 | and then redefine macros as desired. |
| 26 | ------------------------------------------------------------------------ |
| 27 | |
| 28 | |
| 29 | @# Standard width and height of an image |
| 30 | @define {width} {} {16} |
| 31 | @define {height} {} {16} |
| 32 | |
| 33 | @# Standard <head> text |
| 34 | @# @name is the name of this page, for the <title> element |
| 35 | @define {stdhead} {name} |
| 36 | {@quiethead |
| 37 | <title>@label{@name.title}</title>} |
| 38 | |
| 39 | @# Non-displaying <head> text |
| 40 | @define {quiethead} {} |
| 41 | { <link rel=stylesheet |
| 42 | type="text/css" |
| 43 | href="@label{url.static}/disorder.css">} |
| 44 | |
| 45 | @# Standard menu |
| 46 | @# @current is the name of the current page, e.g. choosealpha, login |
| 47 | @define {stdmenu} {current} |
| 48 | { <div class=top> |
| 49 | <p class=menubar> |
| 50 | @menuitem{@current}{playing}{true} |
| 51 | @menuitem{@current}{recent}{true} |
| 52 | @menuitem{@current}{choose}{@right{play}} |
| 53 | @menuitem{@current}{manage}{true} |
| 54 | @menuitem{@current}{new}{true} |
| 55 | @menuitem{@current}{login}{true} |
| 56 | @menuitem{@current}{help}{true} |
| 57 | </p> |
| 58 | <div class=logo> |
| 59 | @menuicon{@current}{about}{true}{logosmall} |
| 60 | </div> |
| 61 | <div style="clear:both"></div> |
| 62 | </div> |
| 63 | } |
| 64 | |
| 65 | @define {menuurl} {name} |
| 66 | {@if{@eq{name}{playing}} |
| 67 | {@url} |
| 68 | {@url?action=@name}} |
| 69 | |
| 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} |
| 79 | { <a @if{@eq{@current}{@name}} |
| 80 | {class=activemenu} |
| 81 | {class=inactivemenu} |
| 82 | href="@menuurl{@name}" |
| 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>}} |
| 86 | |
| 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>}} |
| 113 | |
| 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 | © 2003-2011 Richard Kettlewell et al |
| 121 | </p>} |
| 122 | |
| 123 | @# Expand to the time that @id will be played |
| 124 | @# @what is the section |
| 125 | @# @id is the track ID |
| 126 | @define {mwhen} {what id} |
| 127 | {@when{@id}</td>} |
| 128 | |
| 129 | @# Expand to the 'who' field for @id |
| 130 | @# @what is the section |
| 131 | @# @id is the track ID |
| 132 | @define {mwho} {what id} |
| 133 | {@if{@eq{@who{@id}}{}} |
| 134 | {@if{@eq{@state{@id}}{random}} |
| 135 | {@label{@what.randomtrack}} |
| 136 | { }} |
| 137 | {@who{@id}}} |
| 138 | |
| 139 | @# Expand to the artist for @track |
| 140 | @# @what is the section |
| 141 | @# @track is the track name |
| 142 | @define {martist} {what track} |
| 143 | {@right{play} |
| 144 | {<a class=directory |
| 145 | href="@url?action=choose&dir=@urlquote{@dirname{@dirname{@track}}}" |
| 146 | title="@label{playing.artistverbose}">@part{@track}{artist}{short}</a>} |
| 147 | {<span class=directory |
| 148 | title="@part{@track}{artist}">@part{@track}{artist}{short}</span>}} |
| 149 | |
| 150 | @# Expand to the album for @track |
| 151 | @# @what is the section |
| 152 | @# @track is the track name |
| 153 | @define {malbum} {what track} |
| 154 | {@right{play} |
| 155 | {<a class=directory |
| 156 | href="@url?action=choose&dir=@urlquote{@dirname{@track}}" |
| 157 | title="@label{playing.albumverbose}">@part{@track}{album}{short}</a>} |
| 158 | {<span class=directory |
| 159 | title="@part{@track}{album}">@part{@track}{album}{short}</span>}} |
| 160 | |
| 161 | @# Expand to the title for @track |
| 162 | @# @what is the section |
| 163 | @# @track is the track name |
| 164 | @define {mtitle} {what track} |
| 165 | {<span title="@part{@track}{title}">@part{@track}{title}{short}</span>} |
| 166 | |
| 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} |
| 171 | {<a title="@part{@track}{title}" href="@url?action=play&track=@urlquote{@track}&back=@urlquote{@thisurl}">@part{@track}{title}{short}</a>} |
| 172 | |
| 173 | @# Expand to the remove/scratch entry for @id |
| 174 | @# @what is the section |
| 175 | @# @id is the track ID |
| 176 | @define {mremove} {what id} |
| 177 | {@if{@removable{@id}} |
| 178 | {<a class=imgbutton |
| 179 | href="@url?action=remove&id=@id@back"> |
| 180 | <img class=button src="@image{remove}" |
| 181 | width=@width height=@height |
| 182 | title="@label{@what.removeverbose}" |
| 183 | alt="@label{@what.scratch}"> |
| 184 | </a>} |
| 185 | {<img class=button src="@image{noremove}" |
| 186 | width=@width height=@height |
| 187 | title="@label{@what.removeverbose}" |
| 188 | alt="@label{@what.scratch}">}} |
| 189 | |
| 190 | @# Expand to a move button |
| 191 | @# @id is the track ID |
| 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&id=@id&delta=@delta@back"> |
| 199 | <img class=button src="@image{@dir}" |
| 200 | width=@width height=@height |
| 201 | title="@label{playing.@q{@dir}verbose}" |
| 202 | alt="@label{playing.@dir}"> |
| 203 | </a>} |
| 204 | {<img class=button src="@image{no@dir}" |
| 205 | width=@width height=@height |
| 206 | title="@label{playing.@q{@dir}verbose}" |
| 207 | alt="@label{playing.@dir}">}} |
| 208 | |
| 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 | |
| 278 | @# Expand to a submit button |
| 279 | @# @text is the text to put inside the button |
| 280 | @define {submit} {text} |
| 281 | {<button class=button name=submit type=submit>@text</button>} |
| 282 | |
| 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} |
| 288 | {<form method=POST class=button action="@url"> |
| 289 | <input type=hidden name=action value="@action"> |
| 290 | <input type=submit name=submit value="@text" title="@long"> |
| 291 | @formback@# |
| 292 | </form>} |
| 293 | |
| 294 | @# Used for inserting back= elements |
| 295 | @define {back} {} {} |
| 296 | @define {formback} {} {} |
| 297 | |
| 298 | Local variables: |
| 299 | mode:sgml |
| 300 | sgml-always-quote-attributes:nil |
| 301 | sgml-indent-step:1 |
| 302 | sgml-indent-data:t |
| 303 | indent-tabs-mode:nil |
| 304 | fill-column:79 |
| 305 | End: |