From 78efa64e092d96e15dc40283b73f3af117b2d0a3 Mon Sep 17 00:00:00 2001 Message-Id: <78efa64e092d96e15dc40283b73f3af117b2d0a3.1714828041.git.mdw@distorted.org.uk> From: Mark Wooding Date: Tue, 2 Oct 2007 18:37:16 +0100 Subject: [PATCH] web support for noticed.db Organization: Straylight/Edgeware From: Richard Kettlewell --- CHANGES | 5 +++ lib/client.h | 2 +- server/dcgi.c | 44 ++++++++++++++++++++++--- server/dcgi.h | 3 ++ server/trackdb-int.h | 2 +- server/trackdb.h | 2 +- templates/Makefile.am | 2 +- templates/choose.html | 6 ++-- templates/disorder.css | 8 ++++- templates/help.html | 18 +++++++++++ templates/new.html | 70 ++++++++++++++++++++++++++++++++++++++++ templates/options.labels | 8 +++++ templates/sidebar.html | 5 ++- templates/topbar.html | 5 ++- 14 files changed, 166 insertions(+), 14 deletions(-) create mode 100644 templates/new.html diff --git a/CHANGES b/CHANGES index 92615e4..7ea23b2 100644 --- a/CHANGES +++ b/CHANGES @@ -41,6 +41,11 @@ tracks kept on the queue to be controlled. There is a new utility disorder-decode which can decode OGG, MP3, WAV and FLAC. The example config file uses it. +** Web Interface + +The "New" screen display tracks recently added to the database. From +here they can be played or their preferences changed. + ** Network Play DisOrder can broadcast audio over a network, allowing it to be played on diff --git a/lib/client.h b/lib/client.h index a7d0ff9..773c555 100644 --- a/lib/client.h +++ b/lib/client.h @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2006 Richard Kettlewell + * Copyright (C) 2004, 2005, 2006, 2007 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 diff --git a/server/dcgi.c b/server/dcgi.c index 2892a43..b818883 100644 --- a/server/dcgi.c +++ b/server/dcgi.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2006 Richard Kettlewell + * Copyright (C) 2004, 2005, 2006, 2007 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 @@ -117,6 +117,8 @@ static void lookups(dcgi_state *ds, unsigned want) { disorder_queue(ds->g->client, &ds->g->queue); if(need & DC_PLAYING) disorder_playing(ds->g->client, &ds->g->playing); + if(need & DC_NEW) + disorder_new_tracks(ds->g->client, &ds->g->new, &ds->g->nnew, 0); if(need & DC_RECENT) { /* we need to reverse the order of the list */ disorder_recent(ds->g->client, &r); @@ -483,7 +485,7 @@ static void exp_length(int attribute((unused)) nargs, cgi_sink *output, void *u) { dcgi_state *ds = u; - long length; + long length = 0; if(ds->track && (ds->track->state == playing_started @@ -491,8 +493,11 @@ static void exp_length(int attribute((unused)) nargs, && ds->track->sofar >= 0) cgi_output(output, "%ld:%02ld/", ds->track->sofar / 60, ds->track->sofar % 60); - if(!ds->track || disorder_length(ds->g->client, ds->track->track, &length)) - length = 0; + length = 0; + if(ds->track) + disorder_length(ds->g->client, ds->track->track, &length); + else if(ds->tracks) + disorder_length(ds->g->client, ds->tracks[0], &length); if(length) cgi_output(output, "%ld:%02ld", length / 60, length % 60); else @@ -627,6 +632,25 @@ static void exp_recent(int attribute((unused)) nargs, } } +static void exp_new(int attribute((unused)) nargs, + char **args, + cgi_sink *output, + void *u) { + dcgi_state *ds = u; + dcgi_state s; + + lookups(ds, DC_NEW); + memset(&s, 0, sizeof s); + s.g = ds->g; + s.first = 1; + for(s.index = 0; s.index < ds->g->nnew; ++s.index) { + s.last = s.index + 1 < ds->g->nnew; + s.tracks = &ds->g->new[s.index]; + expandstring(output, args[0], &s); + s.first = 0; + } +} + static void exp_url(int attribute((unused)) nargs, char attribute((unused)) **args, cgi_sink *output, @@ -918,6 +942,16 @@ static void exp_isrecent(int attribute((unused)) nargs, sink_printf(output->sink, "%s", bool2str(!!ds->g->recent)); } +static void exp_isnew(int attribute((unused)) nargs, + char attribute((unused)) **args, + cgi_sink *output, + void *u) { + dcgi_state *ds = u; + + lookups(ds, DC_NEW); + sink_printf(output->sink, "%s", bool2str(!!ds->g->nnew)); +} + static void exp_id(int attribute((unused)) nargs, char attribute((unused)) **args, cgi_sink *output, @@ -1385,6 +1419,7 @@ static const struct cgi_expansion expansions[] = { { "isfiles", 0, 0, 0, exp_isfiles }, { "isfirst", 0, 0, 0, exp_isfirst }, { "islast", 0, 0, 0, exp_islast }, + { "isnew", 0, 0, 0, exp_isnew }, { "isplaying", 0, 0, 0, exp_isplaying }, { "isqueue", 0, 0, 0, exp_isqueue }, { "isrecent", 0, 0, 0, exp_isrecent }, @@ -1392,6 +1427,7 @@ static const struct cgi_expansion expansions[] = { { "length", 0, 0, 0, exp_length }, { "navigate", 2, 2, EXP_MAGIC, exp_navigate }, { "ne", 2, 2, 0, exp_ne }, + { "new", 1, 1, EXP_MAGIC, exp_new }, { "nfiles", 0, 0, 0, exp_nfiles }, { "nonce", 0, 0, 0, exp_nonce }, { "not", 1, 1, 0, exp_not }, diff --git a/server/dcgi.h b/server/dcgi.h index 6f832f1..89908a2 100644 --- a/server/dcgi.h +++ b/server/dcgi.h @@ -30,10 +30,13 @@ typedef struct dcgi_global { #define DC_VOLUME 0x0008 #define DC_DIRS 0x0010 #define DC_FILES 0x0020 +#define DC_NEW 0x0040 struct queue_entry *queue, *playing, *recent; int volume_left, volume_right; char **files, **dirs; int nfiles, ndirs; + char **new; + int nnew; } dcgi_global; typedef struct dcgi_state { diff --git a/server/trackdb-int.h b/server/trackdb-int.h index 1ba890b..2b12c81 100644 --- a/server/trackdb-int.h +++ b/server/trackdb-int.h @@ -1,6 +1,6 @@ /* * This file is part of DisOrder - * Copyright (C) 2005 Richard Kettlewell + * Copyright (C) 2005, 2007 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 diff --git a/server/trackdb.h b/server/trackdb.h index 3e7976a..b3b3715 100644 --- a/server/trackdb.h +++ b/server/trackdb.h @@ -1,6 +1,6 @@ /* * This file is part of DisOrder - * Copyright (C) 2005, 2006 Richard Kettlewell + * Copyright (C) 2005, 2006, 2007 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 diff --git a/templates/Makefile.am b/templates/Makefile.am index b799dbb..db7c836 100644 --- a/templates/Makefile.am +++ b/templates/Makefile.am @@ -21,7 +21,7 @@ pkgdata_DATA=about.html choose.html credits.html playing.html recent.html \ stdhead.html stylesheet.html search.html about.html volume.html \ sidebar.html prefs.html help.html choosealpha.html topbar.html \ - sidebarend.html topbarend.html error.html \ + sidebarend.html topbarend.html error.html new.html \ options options.labels \ options.columns static_DATA=disorder.css diff --git a/templates/choose.html b/templates/choose.html index 03744f7..e6a39cb 100644 --- a/templates/choose.html +++ b/templates/choose.html @@ -58,9 +58,9 @@ USA @label:choose.prefs@ - - @transform{@file@}{track}{display}@ - + @transform{@file@}{track}{display}@ @if{@eq{@trackstate{@file@}@}{playing}@}{[playing]}@ @if{@eq{@trackstate{@file@}@}{queued}@}{[queued]}@

diff --git a/templates/disorder.css b/templates/disorder.css index 34c44db..dd1364c 100644 --- a/templates/disorder.css +++ b/templates/disorder.css @@ -24,7 +24,7 @@ h1.title { font-size: 18pt } -/* playing and recent *********************************************************/ +/* playing, recent and new ***************************************************/ /* table of current and future tracks */ table.playing { @@ -38,6 +38,12 @@ table.recent { border-spacing: 0 /* no unsightly gaps between cells */ } +/* table of newly added played tracks */ +table.new { + width: 100%; /* use the full available width */ + border-spacing: 0 /* no unsightly gaps between cells */ +} + /* titles in tables */ th { text-align: left diff --git a/templates/help.html b/templates/help.html index 00dc978..e9a5c84 100644 --- a/templates/help.html +++ b/templates/help.html @@ -133,6 +133,24 @@ USA + + +
+ +

This screen displays tracks recently added to the database, + most recent first. The @label:choose.prefs@ button can be used to edit the details + for a track; see Editing Preferences below, + and clicking on the track title will add it to the queue.

+ +

The time tracks are remembered for is controlled by the server + configuration. See the "noticed_history" option in disorder_config(5) for + more details.

+ +
+
diff --git a/templates/new.html b/templates/new.html new file mode 100644 index 0000000..e98f7af --- /dev/null +++ b/templates/new.html @@ -0,0 +1,70 @@ + + + + +@include:stdhead@ + @label:new.title@ + + +@include{@label{menu}@}@ +

@label:new.title@

+ +@#{only display the table if there is something to put in it}@ +@if{@isnew@}{ + + + + + + + + + @new{ + + + + + + + + }@ +
@label:heading.artist@@label:heading.album@@label:heading.title@@label:heading.length@ 
@part:artist@@part:album@@part:title@@length@@label:choose.prefs@
+}@ + +@include{@label{menu}@end}@ + + +@@ + diff --git a/templates/options.labels b/templates/options.labels index bd87554..1e71315 100644 --- a/templates/options.labels +++ b/templates/options.labels @@ -78,6 +78,9 @@ label playing.albumverbose "more tracks from this album" # for recently played page label recent.title "Recently Played" +# <TITLE> for new tracks page +label new.title "New tracks" + # <TITLE> for choose track page label choose.title "Pick track" @@ -98,6 +101,9 @@ label choose.prefsverbose "edit track information" label choose.allprefs "Edit all" label choose.allprefsverbose "edit all track information" +# Caption for play-track links +label choose.play "Add track to queue" + # <TITLE> for search page label search.title Search @@ -145,6 +151,7 @@ label sidebar.choose Choose label sidebar.random Random label sidebar.search Search label sidebar.recent Recent +label sidebar.new New label sidebar.about About label sidebar.volume Volume label sidebar.help Help @@ -155,6 +162,7 @@ label sidebar.playingverbose "current and queued tracks" label sidebar.chooseverbose "choose tracks" label sidebar.searchverbose "word search among track names" label sidebar.recentverbose "recently played tracks" +label sidebar.newverbose "newly added tracks" label sidebar.aboutverbose "about DisOrder" label sidebar.volumeverbose "volume control" label sidebar.helpverbose "basic user guide" diff --git a/templates/sidebar.html b/templates/sidebar.html index acdaba8..9a075c3 100644 --- a/templates/sidebar.html +++ b/templates/sidebar.html @@ -5,6 +5,9 @@ <p class=sidebarlink> <a class=sidebarlink href="@url@?action=recent&nonce=@nonce@">@label:sidebar.recent@</a> </p> + <p class=sidebarlink> + <a class=sidebarlink href="@url@?action=new&nonce=@nonce@">@label:sidebar.new@</a> + </p> <p class=sidebarlink> <a class=sidebarlink href="@url@?action=@label:sidebar.choosewhich@&nonce=@nonce@">@label:sidebar.choose@</a> </p> @@ -28,7 +31,7 @@ @@ <!-- This file is part of DisOrder. -Copyright (C) 2004, 2005 Richard Kettlewell +Copyright (C) 2004, 2005, 2007 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 diff --git a/templates/topbar.html b/templates/topbar.html index 654e4f9..1dbbdd3 100644 --- a/templates/topbar.html +++ b/templates/topbar.html @@ -5,6 +5,9 @@ <a class=@if{@eq{@action@}{recent}@}{activemenu}{inactivemenu}@ href="@url@?action=recent&nonce=@nonce@" title="@label:sidebar.recentverbose@">@label:sidebar.recent@</a> + <a class=@if{@eq{@action@}{new}@}{activemenu}{inactivemenu}@ + href="@url@?action=new&nonce=@nonce@" + title="@label:sidebar.newverbose@">@label:sidebar.new@</a> <a class=@if{@or{@eq{@action@}{choose}@} {@eq{@action@}{choosealpha}@}@} {activemenu} @@ -33,7 +36,7 @@ @@ <!-- This file is part of DisOrder. -Copyright (C) 2005 Richard Kettlewell +Copyright (C) 2005, 2007 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 -- [mdw]