exp_search, fold search into choose, not really finished
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 May 2008 11:50:42 +0000 (12:50 +0100)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 17 May 2008 11:50:42 +0000 (12:50 +0100)
server/macros-disorder.c
templates/Makefile.am
templates/choose.tmpl
templates/help.tmpl
templates/macros.tmpl
templates/search.tmpl [deleted file]

index 80eb476..189d51d 100644 (file)
@@ -912,6 +912,31 @@ static int exp_dirs(int nargs,
   return exp__files_dirs(nargs, args, output, u, "dir", disorder_directories);
 }
 
+static int exp__search_shim(disorder_client *c, const char *terms,
+                            const char attribute((unused)) *re,
+                            char ***vecp, int *nvecp) {
+  return disorder_search(c, terms, vecp, nvecp);
+}
+
+/** @search{KEYWORDS}{TEMPLATE}
+ *
+ * For each track matching KEYWORDS, expands TEMPLATE with the
+ * following expansions:
+ * - @track to the UNQUOTED directory name
+ * - @index to the directory number from 0
+ * - @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 track
+ * - @display to the UNQUOTED display string for this track
+ */
+static int exp_search(int nargs,
+                    const struct mx_node **args,
+                    struct sink *output,
+                    void *u) {
+  return exp__files_dirs(nargs, args, output, u, "track", exp__search_shim);
+}
+
 /** @brief Register DisOrder-specific expansions */
 void dcgi_expansions(void) {
   mx_register("arg", 1, 1, exp_arg);
@@ -951,6 +976,7 @@ void dcgi_expansions(void) {
   mx_register_magic("queue", 1, 1, exp_queue);
   mx_register_magic("recent", 1, 1, exp_recent);
   mx_register_magic("right", 1, 3, exp_right);
+  mx_register_magic("search", 2, 2, exp_search);
   mx_register_magic("tracks", 2, 3, exp_tracks);
 }
 
index 16bc70a..bf55c08 100644 (file)
@@ -19,7 +19,7 @@
 #
 
 pkgdata_DATA=about.tmpl choose.tmpl playing.tmpl recent.tmpl           \
-            search.tmpl about.tmpl prefs.tmpl help.tmpl error.tmpl     \
+            about.tmpl prefs.tmpl help.tmpl error.tmpl                 \
             new.tmpl login.tmpl macros.tmpl                            \
             options options.labels                                     \
             options.columns
index 0b08491..6277c12 100644 (file)
@@ -86,6 +86,31 @@ USA
    </p>
 }
 
+@# Always have a search form
+   <form class=search
+         action="@url"
+         method=POST
+         enctype="multipart/form-data" accept-charset=utf-8>
+     <p class=search>Enter search terms:
+       <input class=query name=query type=text value="@argq{query}"
+              size=50>
+       <button class=search name=submit type=submit>
+         @label{search.search}
+       </button>
+       <input name=action type=hidden value=search>
+     </p>
+   </form>
+
+   @if{@ne{@arg{query}}{}}
+      {
+@# There's a search query
+        @search{@arg{query}}{
+          <p>TODO @quote{@track}</p>
+        }
+      }
+      {
+@# No search query
+
 @# TODO navigation...
 
    <div class=directories>
@@ -110,10 +135,10 @@ USA
        @rights{prefs}{
         <a class=imgprefs
            href="@url?action=prefs&#38;0_file=@urlquote{@resolve{@track}}">
-        <img class=button
-             src="@image{edit}"
-             title="@label:choose.prefsverbose@"
-             alt="@label:choose.prefs@">
+         <img class=button
+              src="@image{edit}"
+              title="@label:choose.prefsverbose@"
+              alt="@label:choose.prefs@">
         </a>
        }@#
        <a href="@url?action=play&#38;file=@urlquote{@track}&#38;back=@urlquote{@thisurl}"
@@ -143,6 +168,8 @@ USA
     </div>
    </div>
 
+   }
+
 @credits
  </body>
 </html>
index 86abea2..b5bd559 100644 (file)
@@ -231,9 +231,12 @@ USA
 
    <h2 class=helptitle>Search</h2>
 
+   
    <div class=helpsection>
 
-    <p>This screen allows you to search for keywords in track names.  If you
+     TODO  search is folded into choose now
+
+     <p>This screen allows you to search for keywords in track names.  If you
     specify more than one keyword then only tracks containing all of them are
     listed.  Results are grouped by artist, album and title.</p>
 
index 1a6554d..b471599 100644 (file)
@@ -53,7 +53,6 @@ and then redefines macros as desired.
         {<p class=menubar>
 @menuitem{@current}{playing}{true}
 @menuitem{@current}{choose}{@right{play}}
-@menuitem{@current}{search}{@right{play}}
 @menuitem{@current}{manage}{true}
 @menuitem{@current}{login}{true}
 @menuitem{@current}{help}{true}
diff --git a/templates/search.tmpl b/templates/search.tmpl
deleted file mode 100644 (file)
index 8b836f6..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
-<!--
-This file is part of DisOrder.
-Copyright (C) 2003, 2004, 2005, 2007, 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
--->
-<html>
- <head>
-@stdhead{search}
- </head>
- <body>
-@stdmenu{search}
-   <h1>@label:search.title@</h1>
-
-   <form class=search action="@url@" method=POST
-         enctype="multipart/form-data" accept-charset=utf-8>
-     <p class=search>Enter search terms:
-     <input class=query name=query type=text value="@arg:query@"
-      size=50>
-     <button class=search name=submit type=submit>
-      @label:search.search@
-     </button>
-     <input name=action type=hidden value=search>
-     </p>
-   </form>
-
-   <div class=searchresults>
-    @search{artist}{display}{
-    <div class="search_artist">
-     <p>Artist:
-      <span class="search_artist">@part:artist@</span></p>
-     @search{album}{display}{
-     <div class="search_album">
-      <p>Album:
-       <span class="search_album">@part:album@</span></p>
-      @search{title}{
-      <div class="search_title">
-       <p>Title:
-       <a href="@url@?action=play&#38;file=@urlquote{@file@}@&#38;back=@urlquote{@thisurl@}@">@part:title@</a>
-       @if{@eq{@trackstate{@file@}@}{playing}@}{[<b>playing</b>]}@
-       @if{@eq{@trackstate{@file@}@}{queued}@}{[<b>queued</b>]}@
-       </p>
-      </div>
-      }@
-     </div>
-     }@
-    </div>
-    }@
-   </div>
-
-@credits
- </body>
-</html>
-@discard{
-Local variables:
-mode:sgml
-sgml-always-quote-attributes:nil
-sgml-indent-step:1
-sgml-indent-data:t
-indent-tabs-mode:nil
-fill-column:79
-End:
-}@#