chiark / gitweb /
Fix pause button
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 May 2008 15:19:59 +0000 (16:19 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 May 2008 15:19:59 +0000 (16:19 +0100)
server/dcgi.c
templates/playing.tmpl

index 4ad1b5c..2037282 100644 (file)
@@ -544,73 +544,6 @@ static int compare_result(const void *a, const void *b) {
   return c;
 }
 
-static void exp_search(int nargs,
-                      char **args,
-                      cgi_sink *output,
-                      void *u) {
-  dcgi_state *ds = u, substate;
-  char **tracks;
-  const char *q, *context, *part, *template;
-  int ntracks, n, m;
-  struct result *r;
-
-  switch(nargs) {
-  case 2:
-    part = args[0];
-    context = "sort";
-    template = args[1];
-    break;
-  case 3:
-    part = args[0];
-    context = args[1];
-    template = args[2];
-    break;
-  default:
-    assert(!"should never happen");
-    part = context = template = 0;     /* quieten compiler */
-  }
-  if(ds->tracks == 0) {
-    /* we are the top level, let's get some search results */
-    if(!(q = cgi_get("query"))) return;        /* no results yet */
-    if(disorder_search(ds->g->client, q, &tracks, &ntracks)) return;
-    if(!ntracks) return;
-  } else {
-    tracks = ds->tracks;
-    ntracks = ds->ntracks;
-  }
-  assert(ntracks != 0);
-  /* sort tracks by the appropriate part */
-  r = xmalloc(ntracks * sizeof *r);
-  for(n = 0; n < ntracks; ++n) {
-    r[n].track = tracks[n];
-    if(disorder_part(ds->g->client, (char **)&r[n].sort,
-                    tracks[n], context, part))
-      fatal(0, "disorder_part() failed");
-  }
-  qsort(r, ntracks, sizeof (struct result), compare_result);
-  /* expand the 2nd arg once for each group.  We re-use the passed-in tracks
-   * array as we know it's guaranteed to be big enough and isn't going to be
-   * used for anything else any more. */
-  memset(&substate, 0, sizeof substate);
-  substate.g = ds->g;
-  substate.first = 1;
-  n = 0;
-  while(n < ntracks) {
-    substate.tracks = tracks;
-    substate.ntracks = 0;
-    m = n;
-    while(m < ntracks
-         && !strcmp(r[m].sort, r[n].sort))
-      tracks[substate.ntracks++] = r[m++].track;
-    substate.last = (m == ntracks);
-    expandstring(output, template, &substate);
-    substate.index++;
-    substate.first = 0;
-    n = m;
-  }
-  assert(substate.last != 0);
-}
-
 static void exp_stats(int attribute((unused)) nargs,
                      char attribute((unused)) **args,
                      cgi_sink *output,
@@ -638,84 +571,6 @@ static char *expandarg(const char *arg, dcgi_state *ds) {
   return d.vec;
 }
 
-static void exp_isfiles(int attribute((unused)) nargs,
-                       char attribute((unused)) **args,
-                       cgi_sink *output,
-                       void *u) {
-  dcgi_state *ds = u;
-
-  lookups(ds, DC_FILES);
-  sink_printf(output->sink, "%s", bool2str(!!ds->g->nfiles));
-}
-
-static void exp_isdirectories(int attribute((unused)) nargs,
-                             char attribute((unused)) **args,
-                             cgi_sink *output,
-                             void *u) {
-  dcgi_state *ds = u;
-
-  lookups(ds, DC_DIRS);
-  sink_printf(output->sink, "%s", bool2str(!!ds->g->ndirs));
-}
-
-static void exp_choose(int attribute((unused)) nargs,
-                      char **args,
-                      cgi_sink *output,
-                      void *u) {
-  dcgi_state *ds = u;
-  dcgi_state substate;
-  int nfiles, n;
-  char **files;
-  struct entry *e;
-  const char *type, *what = expandarg(args[0], ds);
-
-  if(!strcmp(what, "files")) {
-    lookups(ds, DC_FILES);
-    files = ds->g->files;
-    nfiles = ds->g->nfiles;
-    type = "track";
-  } else if(!strcmp(what, "directories")) {
-    lookups(ds, DC_DIRS);
-    files = ds->g->dirs;
-    nfiles = ds->g->ndirs;
-    type = "dir";
-  } else {
-    error(0, "unknown @choose@ argument '%s'", what);
-    return;
-  }
-  e = xmalloc(nfiles * sizeof (struct entry));
-  for(n = 0; n < nfiles; ++n) {
-    e[n].path = files[n];
-    e[n].sort = trackname_transform(type, files[n], "sort");
-    e[n].display = trackname_transform(type, files[n], "display");
-  }
-  qsort(e, nfiles, sizeof (struct entry), compare_entry);
-  memset(&substate, 0, sizeof substate);
-  substate.g = ds->g;
-  substate.first = 1;
-  for(n = 0; n < nfiles; ++n) {
-    substate.last = (n == nfiles - 1);
-    substate.index = n;
-    substate.entry = &e[n];
-    expandstring(output, args[1], &substate);
-    substate.first = 0;
-  }
-}
-
-static void exp_file(int attribute((unused)) nargs,
-                    char attribute((unused)) **args,
-                    cgi_sink *output,
-                    void *u) {
-  dcgi_state *ds = u;
-
-  if(ds->entry)
-    cgi_output(output, "%s", ds->entry->path);
-  else if(ds->track)
-    cgi_output(output, "%s", ds->track->track);
-  else if(ds->tracks)
-    cgi_output(output, "%s", ds->tracks[0]);
-}
-
 static void exp_navigate(int attribute((unused)) nargs,
                         char **args,
                         cgi_sink *output,
@@ -755,57 +610,6 @@ static void exp_fullname(int attribute((unused)) nargs,
   cgi_output(output, "%.*s", ds->nav_len, ds->nav_path);
 }
 
-static void exp_files(int attribute((unused)) nargs,
-                     char **args,
-                     cgi_sink *output,
-                     void *u) {
-  dcgi_state *ds = u;
-  dcgi_state substate;
-  const char *nfiles_arg, *directory;
-  int nfiles, numfile;
-  struct kvp *k;
-
-  memset(&substate, 0, sizeof substate);
-  substate.g = ds->g;
-  if((directory = cgi_get("directory"))) {
-    /* Prefs for whole directory. */
-    lookups(ds, DC_FILES);
-    /* Synthesize args for the file list. */
-    nfiles = ds->g->nfiles;
-    for(numfile = 0; numfile < nfiles; ++numfile) {
-      k = xmalloc(sizeof *k);
-      byte_xasprintf((char **)&k->name, "%d_file", numfile);
-      k->value = ds->g->files[numfile];
-      k->next = cgi_args;
-      cgi_args = k;
-    }
-  } else {
-    /* Args already present. */
-    if((nfiles_arg = cgi_get("files"))) nfiles = atoi(nfiles_arg);
-    else nfiles = 1;
-  }
-  for(numfile = 0; numfile < nfiles; ++numfile) {
-    substate.index = numfile;
-    expandstring(output, args[0], &substate);
-  }
-}
-
-static void exp_nfiles(int attribute((unused)) nargs,
-                      char attribute((unused)) **args,
-                      cgi_sink *output,
-                      void *u) {
-  dcgi_state *ds = u;
-  const char *files_arg;
-
-  if(cgi_get("directory")) {
-    lookups(ds, DC_FILES);
-    cgi_output(output, "%d", ds->g->nfiles);
-  } else if((files_arg = cgi_get("files")))
-    cgi_output(output, "%s", files_arg);
-  else
-    cgi_output(output, "1");
-}
-
 /*
 Local Variables:
 c-basic-offset:2
index 5a767e4..bc0200e 100644 (file)
@@ -74,8 +74,8 @@ USA
    <div class=mgmt>
      <p class=mgmt>
        @if{@paused}
-         {@onoff{class}{resume}{enabled}}
-         {@onoff{class}{pause}{disabled}}
+         {@onoff{pause}{resume}{enabled}}
+         {@onoff{pause}{pause}{disabled}}
        @if{@random-enabled}
          {@onoff{random}{randomdisable}{enabled}}
          {@onoff{random}{randomenable}{disabled}}