From 8f9616f198b617214724183e32d598339c3bbbc4 Mon Sep 17 00:00:00 2001
Message-Id: <8f9616f198b617214724183e32d598339c3bbbc4.1727134321.git.mdw@distorted.org.uk>
From: Mark Wooding
Date: Tue, 1 Jan 2008 13:27:10 +0000
Subject: [PATCH] Sort out static content. There is a new expansion
@image:NAME@ which produces the URL for the static content called NAME (or
NAME.png if you don't supply an extexnsion). The labels images.NAME can be
used to indirect role names.
Organization: Straylight/Edgeware
From: Richard Kettlewell
url.static still has its old meaning but does not appear in
options.labels as it has a sensible default.
This is then used throughout to find images and the stylesheet.
The main options file is now the same for Debian and non-Debian. On
Debian a deafult empty options.user file is installed.
Updated a lot of copyright dates.
---
README | 2 +-
debian/Makefile.am | 4 +--
debian/conffiles.disorder-server | 1 +
debian/etc.disorder.options | 15 -----------
debian/etc.disorder.options.user | 2 ++
debian/rules | 6 +++--
disobedience/menu.c | 2 +-
doc/disorder_config.5.in | 15 +++++++++--
server/cgi.c | 7 ++++-
server/cgi.h | 4 ++-
server/dcgi.c | 23 +++++++++++++++-
templates/about.html | 2 +-
templates/choose.html | 4 +--
templates/credits.html | 4 +--
templates/disorder.css | 2 +-
templates/error.html | 2 +-
templates/help.html | 34 +++++++++++------------
templates/new.html | 4 +--
templates/options.labels | 19 ++++++-------
templates/playing.html | 46 ++++++++++++++++----------------
templates/recent.html | 4 +--
templates/stylesheet.html | 4 +--
templates/volume.html | 6 ++---
23 files changed, 121 insertions(+), 91 deletions(-)
delete mode 100644 debian/etc.disorder.options
create mode 100644 debian/etc.disorder.options.user
diff --git a/README b/README
index 5f1c632..11bbbb0 100644
--- a/README
+++ b/README
@@ -257,7 +257,7 @@ Copyright
"Nothing but another drug, a licence that you buy and sell"
DisOrder - select and play digital audio files
-Copyright (C) 2003-2007 Richard Kettlewell
+Copyright (C) 2003-2008 Richard Kettlewell
Portions copyright (C) 2007 Ross Younger
Portions copyright (C) 2007 Mark Wooding
Portions extracted from MPG321, http://mpg321.sourceforge.net/
diff --git a/debian/Makefile.am b/debian/Makefile.am
index ec4dab2..6296b24 100644
--- a/debian/Makefile.am
+++ b/debian/Makefile.am
@@ -1,6 +1,6 @@
#
# This file is part of DisOrder
-# Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
+# 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
@@ -22,7 +22,7 @@ noinst_SCRIPTS=rules
EXTRA_DIST=README.Debian config.disorder-server control \
copyright README.RTP \
- etc.disorder.options etc.disorder.config htaccess \
+ etc.disorder.options.user etc.disorder.config htaccess \
postinst.disorder-server prerm.disorder-server \
postrm.disorder-server \
templates.disorder-server conffiles.disorder-server \
diff --git a/debian/conffiles.disorder-server b/debian/conffiles.disorder-server
index 41df91d..5d44ee4 100644
--- a/debian/conffiles.disorder-server
+++ b/debian/conffiles.disorder-server
@@ -1,3 +1,4 @@
/etc/disorder/config
/etc/disorder/options
+/etc/disorder/options.user
/etc/init.d/disorder
diff --git a/debian/etc.disorder.options b/debian/etc.disorder.options
deleted file mode 100644
index 3a696ef..0000000
--- a/debian/etc.disorder.options
+++ /dev/null
@@ -1,15 +0,0 @@
-# debian-specific disorder options
-include options.labels
-
-# default columns
-include options.columns
-
-# trackname transformations - supply your own or keep the default
-include options.transform
-
-# where to find static web content
-label url.static /disorder/
-label links.css /disorder/disorder.css
-
-# user overrides - you supply this
-include options.user
diff --git a/debian/etc.disorder.options.user b/debian/etc.disorder.options.user
new file mode 100644
index 0000000..8c8a20a
--- /dev/null
+++ b/debian/etc.disorder.options.user
@@ -0,0 +1,2 @@
+# This file is included from /etc/disorder/options as its last act, so you can
+# use it to override any of the default settings.
diff --git a/debian/rules b/debian/rules
index e9f8d9f..805a5e0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -1,6 +1,6 @@
#! /usr/bin/make -f
#
-# Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
+# 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
@@ -156,8 +156,10 @@ pkg-disorder-server: build
debian/disorder-server/etc/init.d/disorder
$(INSTALL_DATA) debian/etc.disorder.config \
debian/disorder-server/etc/disorder/config
- $(INSTALL_DATA) debian/etc.disorder.options \
+ $(INSTALL_DATA) templates/options \
debian/disorder-server/etc/disorder/options
+ $(INSTALL_DATA) debian/etc.disorder.options.user \
+ debian/disorder-server/etc/disorder/options.user
$(LIBTOOL) --mode=install $(INSTALL_PROGRAM) server/disorder.cgi \
$(shell pwd)/debian/disorder-server/usr/lib/cgi-bin/disorder
dpkg-shlibdeps -Tdebian/substvars.disorder-server \
diff --git a/disobedience/menu.c b/disobedience/menu.c
index 346e2fa..99b9e7e 100644
--- a/disobedience/menu.c
+++ b/disobedience/menu.c
@@ -155,7 +155,7 @@ static void about_popup_got_version(void attribute((unused)) *v,
FALSE/*fill*/,
1/*padding*/);
gtk_box_pack_start(GTK_BOX(vbox),
- gtk_label_new("\xC2\xA9 2004-2007 Richard Kettlewell"),
+ gtk_label_new("\xC2\xA9 2004-2008 Richard Kettlewell"),
FALSE/*expand*/,
FALSE/*fill*/,
1/*padding*/);
diff --git a/doc/disorder_config.5.in b/doc/disorder_config.5.in
index a58f787..a2e6383 100644
--- a/doc/disorder_config.5.in
+++ b/doc/disorder_config.5.in
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
+.\" 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
@@ -911,7 +911,18 @@ The ID of the current track.
If \fIBOOL\fR expands to \fBtrue\fR then expands to \fITRUEPART\fR, otherwise
to \fIFALSEPART\fR (which may be omitted).
.TP
-.B @include:\fIPATH\fR@
+.B @image:\fINAME\fB@
+Expands to the (possibly relative) URL for image \fINAME\fR.
+.IP
+If there is a label \fBimages.\fINAME\fR then that will be the image base name.
+Otherwise the image base name is \fINAME\fB.png\fR or just \fINAME\fR if it
+alraedy has an extension. Thus labels may be defined to give images role
+names.
+.IP
+If there is a label \fBurl.static\fR then that is the base URL for images. If
+it is not defined then \fB/disorder\fR is used as a default.
+.TP
+.B @include:\fIPATH\fB@
Include the named file as if it were a template file. If \fIPATH\fR
starts with a \fB/\fR then it is used as-is; otherwise, ".html" is
appended and the template path is searched.
diff --git a/server/cgi.c b/server/cgi.c
index 5e475ed..5abf145 100644
--- a/server/cgi.c
+++ b/server/cgi.c
@@ -1,6 +1,6 @@
/*
* This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2006 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 2006, 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
@@ -603,6 +603,11 @@ const char *cgi_label(const char *key) {
return label;
}
+int cgi_label_exists(const char *key) {
+ read_options();
+ return kvp_get(labels, key) ? 1 : 0;
+}
+
char **cgi_columns(const char *name, int *ncolumns) {
struct column *c;
diff --git a/server/cgi.h b/server/cgi.h
index 6c387d7..385b9f2 100644
--- a/server/cgi.h
+++ b/server/cgi.h
@@ -1,6 +1,6 @@
/*
* This file is part of DisOrder.
- * Copyright (C) 2004, 2005 Richard Kettlewell
+ * Copyright (C) 2004, 2005, 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
@@ -86,6 +86,8 @@ char *cgi_makeurl(const char *url, ...);
const char *cgi_label(const char *key);
/* look up the translated label @key@ */
+int cgi_label_exists(const char *key);
+
char **cgi_columns(const char *name, int *nheadings);
/* return the list of columns for @name@ */
diff --git a/server/dcgi.c b/server/dcgi.c
index 69c9214..19a8021 100644
--- a/server/dcgi.c
+++ b/server/dcgi.c
@@ -1,6 +1,6 @@
/*
* This file is part of DisOrder.
- * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
+ * 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
@@ -1697,6 +1697,26 @@ static void exp_userinfo(int attribute((unused)) nargs,
cgi_output(output, "%s", value);
}
+static void exp_image(int attribute((unused)) nargs,
+ char **args,
+ cgi_sink *output,
+ void attribute((unused)) *u) {
+ char *labelname;
+ const char *imagestem;
+
+ byte_xasprintf(&labelname, "images.%s", args[0]);
+ if(cgi_label_exists(labelname))
+ imagestem = cgi_label(labelname);
+ else if(strchr(args[0], '.'))
+ imagestem = args[0];
+ else
+ byte_xasprintf((char **)&imagestem, "%s.png", args[0]);
+ if(cgi_label_exists("url.static"))
+ cgi_output(output, "%s/%s", cgi_label("url.static"), imagestem);
+ else
+ cgi_output(output, "/disorder/%s", imagestem);
+}
+
static const struct cgi_expansion expansions[] = {
{ "#", 0, INT_MAX, EXP_MAGIC, exp_comment },
{ "action", 0, 0, 0, exp_action },
@@ -1712,6 +1732,7 @@ static const struct cgi_expansion expansions[] = {
{ "fullname", 0, 0, 0, exp_fullname },
{ "id", 0, 0, 0, exp_id },
{ "if", 2, 3, EXP_MAGIC, exp_if },
+ { "image", 1, 1, 0, exp_image },
{ "include", 1, 1, 0, exp_include },
{ "index", 0, 0, 0, exp_index },
{ "isdirectories", 0, 0, 0, exp_isdirectories },
diff --git a/templates/about.html b/templates/about.html
index b8242b5..5022e35 100644
--- a/templates/about.html
+++ b/templates/about.html
@@ -34,7 +34,7 @@ USA
version @version@ - select and play digital
audio files
- Copyright © 2003-2007 Richard Kettlewell
+
Copyright © 2003-2008 Richard Kettlewell
Portions copyright © 2007 Ross Younger
Portions copyright © 2007 Mark Wooding
diff --git a/templates/choose.html b/templates/choose.html
index cfd0b4b..394397e 100644
--- a/templates/choose.html
+++ b/templates/choose.html
@@ -57,7 +57,7 @@ USA
@right{prefs}{}@
}@
diff --git a/templates/credits.html b/templates/credits.html
index 6cc1f5c..c9a9ac8 100644
--- a/templates/credits.html
+++ b/templates/credits.html
@@ -1,11 +1,11 @@
DisOrder
-version @version@ © 2003-2007 Richard Kettlewell
+version @version@ © 2003-2008 Richard Kettlewell
@@
@@ -47,7 +47,7 @@ USA
title="@label:playing.pauseverbose@">@label:playing.pause@
-
+
}@
@if{@random-enabled@}{
@@ -57,7 +57,7 @@ USA
title="@label:playing.randomdisableverbose@">@label:playing.random@
-
+
}{
@@ -66,7 +66,7 @@ USA
title="@label:playing.randomenableverbose@">@label:playing.random@
-
+
}@
@if{@enabled@}{
@@ -76,7 +76,7 @@ USA
title="@label:playing.disableverbose@">@label:playing.playing@
-
+
}{
@@ -85,7 +85,7 @@ USA
title="@label:playing.enableverbose@">@label:playing.playing@
-
+
}@
}@
@@ -155,10 +155,10 @@ USA
@length@ |
@if{@scratchable@}{}{}@ |
@if{@arg:mgmt@}{
@@ -194,10 +194,10 @@ USA
@length@ |
@if{@removable@}{}{}@ |
@@ -207,24 +207,24 @@ USA
|
}{
|
|
}@
@@ -233,24 +233,24 @@ USA
|
|
}{
|
|
}@
diff --git a/templates/recent.html b/templates/recent.html
index 2efb1f9..c9e1674 100644
--- a/templates/recent.html
+++ b/templates/recent.html
@@ -1,7 +1,7 @@
|