From 0d0253c93a64d2b5206e902c648e1e2c6bc5d510 Mon Sep 17 00:00:00 2001 Message-Id: <0d0253c93a64d2b5206e902c648e1e2c6bc5d510.1715644847.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sun, 11 May 2008 18:28:07 +0100 Subject: [PATCH] more templates plus support code changes Organization: Straylight/Edgeware From: Richard Kettlewell --- lib/sink.c | 16 ++++++ lib/sink.h | 3 ++ scripts/htmlman | 6 +-- server/actions.c | 12 ++--- server/disorder-cgi.h | 2 +- server/login.c | 2 +- server/macros-disorder.c | 2 +- templates/Makefile.am | 9 ++-- templates/about.tmpl | 75 ++++++++++++-------------- templates/choose.tmpl | 14 ++--- templates/choosealpha.tmpl | 98 ---------------------------------- templates/credits.tmpl | 26 --------- templates/error.tmpl | 19 +++---- templates/help.tmpl | 106 ++++++++++++++++++------------------- templates/login.tmpl | 14 ++--- templates/macros.tmpl | 81 ++++++++++++++++++++++++---- templates/new.tmpl | 14 ++--- templates/playing.tmpl | 19 +++++-- templates/prefs.tmpl | 14 ++--- templates/recent.tmpl | 14 ++--- templates/search.tmpl | 14 ++--- templates/stdhead.tmpl | 22 -------- templates/stylesheet.tmpl | 25 --------- templates/topbar.tmpl | 68 ------------------------ templates/topbarend.tmpl | 20 ------- templates/volume.tmpl | 61 --------------------- 26 files changed, 256 insertions(+), 500 deletions(-) delete mode 100644 templates/choosealpha.tmpl delete mode 100644 templates/credits.tmpl delete mode 100644 templates/stdhead.tmpl delete mode 100644 templates/stylesheet.tmpl delete mode 100644 templates/topbar.tmpl delete mode 100644 templates/topbarend.tmpl delete mode 100644 templates/volume.tmpl diff --git a/lib/sink.c b/lib/sink.c index a3e9257..e904005 100644 --- a/lib/sink.c +++ b/lib/sink.c @@ -131,6 +131,22 @@ struct sink *sink_dynstr(struct dynstr *output) { return (struct sink *)s; } +/* discard sink **************************************************************/ + +static int sink_discard_write(struct sink attribute((unused)) *s, + const void attribute((unused)) *buffer, + int nbytes) { + return nbytes; +} + +/** @brief Return a sink which discards all output */ +struct sink *sink_discard(void) { + struct sink *s = xmalloc(sizeof *s); + + s->write = sink_discard_write; + return s; +} + /* Local Variables: c-basic-offset:2 diff --git a/lib/sink.h b/lib/sink.h index cde7161..15462ae 100644 --- a/lib/sink.h +++ b/lib/sink.h @@ -50,6 +50,9 @@ struct sink *sink_stdio(const char *name, FILE *fp); struct sink *sink_dynstr(struct dynstr *output); /* return a sink which appends to @output@. */ +struct sink *sink_discard(void); +/* reutrn a sink which junks everything */ + int sink_vprintf(struct sink *s, const char *fmt, va_list ap); int sink_printf(struct sink *s, const char *fmt, ...) attribute((format (printf, 2, 3))); diff --git a/scripts/htmlman b/scripts/htmlman index fa966dd..17e53e4 100755 --- a/scripts/htmlman +++ b/scripts/htmlman @@ -43,13 +43,13 @@ title=$(basename $1) echo "" echo " " if $stdhead; then - echo "@include{stdhead}@" + echo "@quiethead" fi echo " $title" echo " " echo " " if $stdhead; then - echo "@include{topbar}@" + echo "@stdmenu{}" fi printf "
"
 # this is kind of painful using only BREs
@@ -67,7 +67,7 @@ nroff -Tascii -man "$1" | ${GNUSED} \
                        s!<\1>!!g'
 echo "
" if $stdhead; then - echo "@include{topbarend}@" + echo "@credits" fi echo " " echo "" diff --git a/server/actions.c b/server/actions.c index aca4db0..c0a8cb4 100644 --- a/server/actions.c +++ b/server/actions.c @@ -171,7 +171,9 @@ static const struct action { */ void dcgi_expand(const char *name) { const char *p; - + + /* Parse macros first */ + mx_expand_file("macros.tmpl", sink_discard(), 0); /* For unknown actions check that they aren't evil */ for(p = name; *p && isalnum((unsigned char)*p); ++p) ; @@ -220,12 +222,8 @@ void dcgi_action(const char *action) { } /** @brief Generate an error page */ -void dcgi_error(const char *msg, ...) { - va_list ap; - - va_start(ap, msg); - byte_xvasprintf(&dcgi_error_string, msg, ap); - va_end(ap); +void dcgi_error(const char *key) { + dcgi_error_string = xstrdup(key); dcgi_expand("error"); } diff --git a/server/disorder-cgi.h b/server/disorder-cgi.h index 95b36c6..b3aa4aa 100644 --- a/server/disorder-cgi.h +++ b/server/disorder-cgi.h @@ -62,7 +62,7 @@ extern char *dcgi_error_string; void dcgi_expand(const char *name); void dcgi_action(const char *action); -void dcgi_error(const char *msg, ...); +void dcgi_error(const char *key); void dcgi_login(void); void dcgi_lookup(unsigned want); void dcgi_lookup_reset(void); diff --git a/server/login.c b/server/login.c index 5144934..891ebe1 100644 --- a/server/login.c +++ b/server/login.c @@ -132,7 +132,7 @@ void dcgi_login(void) { dcgi_client = disorder_new(0); /* Reconnect */ if(disorder_connect_cookie(dcgi_client, dcgi_cookie)) { - dcgi_error("Cannot connect to server"); + dcgi_error("connect"); exit(0); } /* If there was a cookie but it went bad, we forget it */ diff --git a/server/macros-disorder.c b/server/macros-disorder.c index b35ad24..13276e9 100644 --- a/server/macros-disorder.c +++ b/server/macros-disorder.c @@ -734,7 +734,7 @@ static int exp_error(int attribute((unused)) nargs, char attribute((unused)) **args, struct sink *output, void attribute((unused)) *u) { - return sink_writes(output, cgi_sgmlquote(dcgi_error_string)) < 0 ? -1 : 0; + return sink_writes(output, dcgi_error_string) < 0 ? -1 : 0; } /* @image{NAME} diff --git a/templates/Makefile.am b/templates/Makefile.am index 93f8692..16bc70a 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -18,11 +18,10 @@ # USA # -pkgdata_DATA=about.tmpl choose.tmpl credits.tmpl playing.tmpl recent.tmpl \ - stdhead.tmpl stylesheet.tmpl search.tmpl about.tmpl volume.tmpl \ - prefs.tmpl help.tmpl choosealpha.tmpl topbar.tmpl \ - topbarend.tmpl error.tmpl new.tmpl login.tmpl \ - options options.labels \ +pkgdata_DATA=about.tmpl choose.tmpl playing.tmpl recent.tmpl \ + search.tmpl about.tmpl prefs.tmpl help.tmpl error.tmpl \ + new.tmpl login.tmpl macros.tmpl \ + options options.labels \ options.columns static_DATA=disorder.css staticdir=${pkgdatadir}/static diff --git a/templates/about.tmpl b/templates/about.tmpl index 93d0d11..d153bef 100644 --- a/templates/about.tmpl +++ b/templates/about.tmpl @@ -20,60 +20,55 @@ USA --> -@include:stdhead@ - @label:about.title@ +@stdhead{about} -@include{topbar}@ -

- About DisOrder

-

Copyright

+@stdmenu{about} -

DisOrder - version @version@ - select and play digital - audio files

+

About DisOrder

-

Copyright © 2003-2008 Richard Kettlewell
- Portions copyright © 2007 Ross Younger
- Portions copyright © 2007 Mark Wooding

+

Copyright

-

Portions extracted from - MPG321, - Copyright © 2001 Joe Drew, - Copyright © 2000-2001 Robert Leslie

+

DisOrder version @version + - software Jukebox

-

This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version.

+

Copyright © 2003-2008 Richard Kettlewell
Portions + copyright © 2007 Ross Younger
+ Portions copyright © 2007, 2008 Mark Wooding

-

This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details.

+

Portions extracted from MPG321, Copyright © 2001 Joe + Drew, Copyright © 2000-2001 Robert Leslie

-

You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA

+

This program is free software; you can redistribute it and/or modify it + under the terms of the GNU + General Public License as published by the Free Software Foundation; + either version 2 of the License, or (at your option) any later version.

-@include{topbarend}@ +

This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details.

+ +

You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., 59 + Temple Place, Suite 330, Boston, MA 02111-1307 USA

+ +@credits -@@ - +}@# diff --git a/templates/choose.tmpl b/templates/choose.tmpl index 844fe9a..10ccf22 100644 --- a/templates/choose.tmpl +++ b/templates/choose.tmpl @@ -20,11 +20,10 @@ USA --> -@include:stdhead@ - @label:choose.title@ +@stdhead{choose} -@include{topbar}@ +@stdmenu{choose}

@label:choose.title@

@#{always have the first-letter bar, if choosealpha enabled}@ @@ -146,15 +145,16 @@ USA }@ -@include{topbarend}@ +@credits -@@ - +}@# diff --git a/templates/choosealpha.tmpl b/templates/choosealpha.tmpl deleted file mode 100644 index 4027834..0000000 --- a/templates/choosealpha.tmpl +++ /dev/null @@ -1,98 +0,0 @@ - - - - -@include:stdhead@ - @label:choose.title@ - - -@include{topbar}@ -

@label:choose.title@

- -

- A | - B | - C | - D | - E | - F | - G | - H | - I | - J | - K | - L | - M | - N | - O | - P | - Q | - R | - S | - T | - U | - V | - W | - X | - Y | - Z | - * -

- -@include{topbarend}@ - - -@@ - diff --git a/templates/credits.tmpl b/templates/credits.tmpl deleted file mode 100644 index cb8d48f..0000000 --- a/templates/credits.tmpl +++ /dev/null @@ -1,26 +0,0 @@ -@discard{ -This file is part of DisOrder. -Copyright (C) 2004-2008 Richard Kettlewell - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, but -WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -USA ---> -}@# -

- DisOrder - version @version - © 2003-2008 Richard Kettlewell et al -

diff --git a/templates/error.tmpl b/templates/error.tmpl index 64ad6ff..715e61d 100644 --- a/templates/error.tmpl +++ b/templates/error.tmpl @@ -20,28 +20,25 @@ USA --> -@include:stdhead@ - @label:error.title@ +@stdhead{error} -@include{topbar}@ -

@label:error.title@

+@stdmenu{error} +

@label{error.title}

-

@label{error.@label:error@}@

- -

@label:error.generic@

+

@label{error.@error}

+

@label{error.generic}

-@include{topbarend}@ +@credits -@@ - +}@# diff --git a/templates/help.tmpl b/templates/help.tmpl index 8e298ef..86abea2 100644 --- a/templates/help.tmpl +++ b/templates/help.tmpl @@ -20,11 +20,10 @@ USA --> -@include{stdhead}@ - @label{help.title}@ +@stdhead{help} -@include{topbar}@ +@stdmenu{help}

@label{help.title}@

Introduction

@@ -48,8 +47,8 @@ USA being listed first.) Where possible, estimated start times are given.

-

Each track has a @label:playing.scratch@ +

Each track has a @label{playing.scratch} button next to it. For the currently playing track this can be used to stop playing the track before it has finished; this is called “scratching”. For a track in the queue it @@ -76,32 +75,32 @@ USA