chiark / gitweb /
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 80eb4765d196c5732409a75d141af87c88303ded..189d51d10cfd65e6fc814ad8ab0d071ff39f66a4 100644 (file)
@@ -912,6 +912,31 @@ static int exp_dirs(int nargs,
   return exp__files_dirs(nargs, args, output, u, "dir", disorder_directories);
 }
 
   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);
 /** @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("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);
 }
 
   mx_register_magic("tracks", 2, 3, exp_tracks);
 }
 
index 16bc70a8a7f9df1a7f2adfb896fe52c91c590fe5..bf55c08d25ad82e9af6d4ac3fc8b56f2357a41a1 100644 (file)
@@ -19,7 +19,7 @@
 #
 
 pkgdata_DATA=about.tmpl choose.tmpl playing.tmpl recent.tmpl           \
 #
 
 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
             new.tmpl login.tmpl macros.tmpl                            \
             options options.labels                                     \
             options.columns
index 0b084917dcb874c19bd2a4572b10157f2c49926d..6277c12ff156871ef21137b5d82d9b519bc2f535 100644 (file)
@@ -86,6 +86,31 @@ USA
    </p>
 }
 
    </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>
 @# 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}}">
        @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}"
         </a>
        }@#
        <a href="@url?action=play&#38;file=@urlquote{@track}&#38;back=@urlquote{@thisurl}"
@@ -143,6 +168,8 @@ USA
     </div>
    </div>
 
     </div>
    </div>
 
+   }
+
 @credits
  </body>
 </html>
 @credits
  </body>
 </html>
index 86abea22098af8c822c439ee6e73e831b7550b39..b5bd5597431a960c08d4c4d9f8f2daf65105e3e3 100644 (file)
@@ -231,9 +231,12 @@ USA
 
    <h2 class=helptitle>Search</h2>
 
 
    <h2 class=helptitle>Search</h2>
 
+   
    <div class=helpsection>
 
    <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>
 
     specify more than one keyword then only tracks containing all of them are
     listed.  Results are grouped by artist, album and title.</p>
 
index 1a6554dbf6da4cb769b59062bb52aa7bce309830..b4715995ea1cb81107180595255496de78306cf1 100644 (file)
@@ -53,7 +53,6 @@ and then redefines macros as desired.
         {<p class=menubar>
 @menuitem{@current}{playing}{true}
 @menuitem{@current}{choose}{@right{play}}
         {<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}
 @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:
-}@#