/* @arg{NAME}
*
- * Expands to the CGI argument NAME, or the empty string if there is
- * no such argument.
+ * Expands to the UNQUOTED form of CGI argument NAME, or the empty string if
+ * there is no such argument. Use @argq for a quick way to quote the argument.
*/
static int exp_arg(int attribute((unused)) nargs,
char **args,
const char *s = cgi_get(args[0]);
if(s)
- return sink_writes(output,
- cgi_sgmlquote(s)) < 0 ? -1 : 0;
+ return sink_writes(output, s) < 0 ? -1 : 0;
+ else
+ return 0;
+}
+
+/* @argq{NAME}
+ *
+ * Expands to the (quoted) form of CGI argument NAME, or the empty string if
+ * there is no such argument. Use @arg for the unquoted argument.
+ */
+static int exp_argq(int attribute((unused)) nargs,
+ char **args,
+ struct sink *output,
+ void attribute((unused)) *u) {
+ const char *s = cgi_get(args[0]);
+
+ if(s)
+ return sink_writes(output, cgi_sgmlquote(s)) < 0 ? -1 : 0;
else
return 0;
}
static int exp_paused(int attribute((unused)) nargs,
char attribute((unused)) **args,
struct sink *output,
- void attribute((unused)) *u) {
+ void attribute((unused)) *u) {
dcgi_lookup(DCGI_PLAYING);
return mx_bool_result(output, (dcgi_playing
&& dcgi_playing->state == playing_paused));
e[n].display = trackname_transform(type, tracks[n], "display");
}
qsort(e, ntracks, sizeof (struct entry), compare_entry);
- /* Expand the subsiduary templates */
+ /* Expand the subsiduary templates. We chuck in @sort and @display because
+ * it is particularly easy to do so. */
for(n = 0; n < ntracks; ++n)
if((rc = mx_expand(mx_rewritel(m,
"index", make_index(n),
"track", tracks[n],
"first", n == 0 ? "true" : "false",
"last", n + 1 == ntracks ? "false" : "true",
+ "sort", e[n].sort,
+ "display", e[n].display,
(char *)0),
output, u)))
return rc;
* - @parity to "even" or "odd" alternately
* - @first to "true" on the first track and "false" otherwise
* - @last to "true" on the last track and "false" otherwise
+ * - @sort to the sort key for this track
+ * - @display to the UNQUOTED display string for this track
*
* RE is optional and if present is the regexp to match against.
*/
* - @parity to "even" or "odd" alternately
* - @first to "true" on the first directory and "false" otherwise
* - @last to "true" on the last directory and "false" otherwise
+ * - @sort to the sort key for this directory
+ * - @display to the UNQUOTED display string for this directory
*
* RE is optional and if present is the regexp to match against.
*/
/** @brief Register DisOrder-specific expansions */
void dcgi_expansions(void) {
mx_register("arg", 1, 1, exp_arg);
+ mx_register("argq", 1, 1, exp_argq);
mx_register("enabled", 0, 0, exp_enabled);
mx_register("error", 0, 0, exp_error);
mx_register("image", 1, 1, exp_image);
@stdmenu{choose}
<h1>@label:choose.title@</h1>
- @#{always have the first-letter bar, if choosealpha enabled}@
- @if{@eq{@label:sidebar.choosewhich@}{choosealpha}@}{
-
+ @if{@eq{@label{sidebar.choosewhich}}{choosealpha}}
+ {
<p class=choosealpha>
<a title="Directories starting with 'a'"
- href="@url@?action=choose&regexp=^(the )?a">A</a> |
+ href="@url?action=choose&regexp=^(the )?a">A</a> |
<a title="Directories starting with 'b'"
- href="@url@?action=choose&regexp=^(the )?b">B</a> |
+ href="@url?action=choose&regexp=^(the )?b">B</a> |
<a title="Directories starting with 'c'"
- href="@url@?action=choose&regexp=^(the )?c">C</a> |
+ href="@url?action=choose&regexp=^(the )?c">C</a> |
<a title="Directories starting with 'd'"
- href="@url@?action=choose&regexp=^(the )?d">D</a> |
+ href="@url?action=choose&regexp=^(the )?d">D</a> |
<a title="Directories starting with 'e'"
- href="@url@?action=choose&regexp=^(the )?e">E</a> |
+ href="@url?action=choose&regexp=^(the )?e">E</a> |
<a title="Directories starting with 'f'"
- href="@url@?action=choose&regexp=^(the )?f">F</a> |
+ href="@url?action=choose&regexp=^(the )?f">F</a> |
<a title="Directories starting with 'g'"
- href="@url@?action=choose&regexp=^(the )?g">G</a> |
+ href="@url?action=choose&regexp=^(the )?g">G</a> |
<a title="Directories starting with 'h'"
- href="@url@?action=choose&regexp=^(the )?h">H</a> |
+ href="@url?action=choose&regexp=^(the )?h">H</a> |
<a title="Directories starting with 'i'"
- href="@url@?action=choose&regexp=^(the )?i">I</a> |
+ href="@url?action=choose&regexp=^(the )?i">I</a> |
<a title="Directories starting with 'j'"
- href="@url@?action=choose&regexp=^(the )?j">J</a> |
+ href="@url?action=choose&regexp=^(the )?j">J</a> |
<a title="Directories starting with 'k'"
- href="@url@?action=choose&regexp=^(the )?k">K</a> |
+ href="@url?action=choose&regexp=^(the )?k">K</a> |
<a title="Directories starting with 'l'"
- href="@url@?action=choose&regexp=^(the )?l">L</a> |
+ href="@url?action=choose&regexp=^(the )?l">L</a> |
<a title="Directories starting with 'm'"
- href="@url@?action=choose&regexp=^(the )?m">M</a> |
+ href="@url?action=choose&regexp=^(the )?m">M</a> |
<a title="Directories starting with 'n'"
- href="@url@?action=choose&regexp=^(the )?n">N</a> |
+ href="@url?action=choose&regexp=^(the )?n">N</a> |
<a title="Directories starting with 'o'"
- href="@url@?action=choose&regexp=^(the )?o">O</a> |
+ href="@url?action=choose&regexp=^(the )?o">O</a> |
<a title="Directories starting with 'p'"
- href="@url@?action=choose&regexp=^(the )?p">P</a> |
+ href="@url?action=choose&regexp=^(the )?p">P</a> |
<a title="Directories starting with 'q'"
- href="@url@?action=choose&regexp=^(the )?q">Q</a> |
+ href="@url?action=choose&regexp=^(the )?q">Q</a> |
<a title="Directories starting with 'r'"
- href="@url@?action=choose&regexp=^(the )?r">R</a> |
+ href="@url?action=choose&regexp=^(the )?r">R</a> |
<a title="Directories starting with 's'"
- href="@url@?action=choose&regexp=^(the )?s">S</a> |
+ href="@url?action=choose&regexp=^(the )?s">S</a> |
<a title="Directories starting with 't'"
- href="@url@?action=choose&regexp=^(?!the [^t])t">T</a> |
+ href="@url?action=choose&regexp=^(?!the [^t])t">T</a> |
<a title="Directories starting with 'u'"
- href="@url@?action=choose&regexp=^(the )?u">U</a> |
+ href="@url?action=choose&regexp=^(the )?u">U</a> |
<a title="Directories starting with 'v'"
- href="@url@?action=choose&regexp=^(the )?v">V</a> |
+ href="@url?action=choose&regexp=^(the )?v">V</a> |
<a title="Directories starting with 'w'"
- href="@url@?action=choose&regexp=^(the )?w">W</a> |
+ href="@url?action=choose&regexp=^(the )?w">W</a> |
<a title="Directories starting with 'x'"
- href="@url@?action=choose&regexp=^(the )?x">X</a> |
+ href="@url?action=choose&regexp=^(the )?x">X</a> |
<a title="Directories starting with 'y'"
- href="@url@?action=choose&regexp=^(the )?y">Y</a> |
+ href="@url?action=choose&regexp=^(the )?y">Y</a> |
<a title="Directories starting with 'z'"
- href="@url@?action=choose&regexp=^(the )?z">Z</a> |
+ href="@url?action=choose&regexp=^(the )?z">Z</a> |
<a title="Directories starting with anything else"
- href="@url@?action=choose&regexp=^[^a-z]">*</a>
+ href="@url?action=choose&regexp=^[^a-z]">*</a>
</p>
- }@
+}
+
+@# TODO navigation...
+
+ <div class=directories>
+ <div class=filesdirectories>
+ @dirs{@arg{dir}}{@arg{re}}{
+ <p class=entry>
+ <a href="@url?action=choose&dir=@urlquote{@track}">
+ <img class=button src="@image{directory}" alt="">
+ @display
+ </a>
+ </p>}
+ </div>
+ </div>
- @if{@ne{@arg:directory@}{}@}{
- <p class=directoryname>@navigate{@arg:directory@}{/<a
- href="@url@?action=choose&directory=@urlquote{@fullname@}@">@basename@</a>}@:</p>
- }@
+@define{sometracks}{template}{}
- @if{@isdirectories@}{
- <div class=directories><div class=filesdirectories>
- <p class=heading>
- @label:choose.directories@
- </p>
- @choose{directories}{
- <p class=entry>
- <a
- href="@url@?action=choose&directory=@urlquote{@file@}@"
- title="@label:choose.directory@">
- <img class=button
- src="@image:directory@"
- alt="">
- @transform{@file@}{dir}{display}@
- </a>
- </p>
- }@
- </div></div>
- }@
- @if{@isfiles@}{
- <div class=files><div class=filesdirectories>
- <p class=heading>
- @label:choose.files@
- </p>
- @choose{files}{
- <p class=entry>
- @right{prefs}{<a class=imgprefs
- href="@url@?action=prefs&0_file=@urlquote{@resolve{@file@}@}@"
- ><img class=button
- src="@image:edit@"
- title="@label:choose.prefsverbose@"
- alt="@label:choose.prefs@"></a>}@
- <a
- href="@url@?action=play&file=@urlquote{@file@}@&back=@urlquote{@thisurl@}@"
- title="@label:choose.play@">@transform{@file@}{track}{display}@</a>
- @if{@eq{@trackstate{@file@}@}{playing}@}{[<b>playing</b>]}@
- @if{@eq{@trackstate{@file@}@}{queued}@}{[<b>queued</b>]}@
- </p>
- }@
- <p class=all>
- @right{prefs}{<a class=imgprefs
- href="@url@?action=prefs&directory=@urlquote{@arg:directory@}@&back=@urlquote{@thisurl@}@"
- ><img class=button
- src="@image:edit@"
- title="@label:choose.allprefsverbose@"
- alt="@label:choose.allprefs@"></a>}@
- <a class=button href="@url@?action=play&directory=@urlquote{@arg:directory@}@&back=@urlquote{@thisurl@}@">
- @label:choose.playall@
- </a>
- </p>
- </div></div>
- }@
+ <div class=files>
+ <div class=filesdirectories>
+ @dirs{@arg{dir}}{@arg{re}}{
+ <p class=entry>
+@define{sometracks}{template}{@template}@#
+ @rights{prefs}{
+ <a class=imgprefs
+ href="@url?action=prefs&0_file=@urlquote{@resolve{@track}}">
+ <img class=button
+ src="@image{edit}"
+ title="@label:choose.prefsverbose@"
+ alt="@label:choose.prefs@">
+ </a>
+ }@#
+ <a href="@url?action=play&file=@urlquote{@track}&back=@urlquote{@thisurl}"
+ title="@label{choose.play}">
+ @display
+ </a>
+ @if{@eq{@trackstate{@track}}{playing}}
+ {[<b>playing</b>]}
+ @if{@eq{@trackstate{@track}}{queued}}
+ {[<b>queued</b>]}
+ </p>}
+ @sometracks{
+ <p class=all>
+ @right{prefs}{
+ <a class=imgprefs
+ href="@url?action=prefs&dir=@urlquote{@arg{dir}}">
+ <img class=button
+ src="@image{edit}"
+ title="@label:choose.allprefsverbose@"
+ alt="@label:choose.allprefs@">
+ </a>}
+ <a class=button
+ href="@url?action=play&dir=@urlquote{@arg{dir}}"&back=@urlquote{@thisurl}">
+ @label{choose.playall}
+ </a>
+ </p>}
+ </div>
+ </div>
@credits
</body>