]> git.plutz.net Git - serve0/blob - templates/advfilter.html.sh
merged filter and list page
[serve0] / templates / advfilter.html.sh
1 # Copyright 2014,2015 Paul Hänsch
2 #
3 # This file is part of Serve0
4
5 # Serve0 is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9
10 # Serve0 is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Affero General Public License for more details.
14
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Serve0  If not, see <http://www.gnu.org/licenses/>. 
17
18 cat <<EOF
19   <form class="panel" id="advfilter"
20         action="?action=filter" method="post" accept-charset="UTF-8">
21     <input disabled type="text" name="s" value="$search" placeholder="Search">
22     <label for="o2" class="order">Order by:</label>
23     <select disabled class="order" size="1" name="o" id="o2">
24       <option>Name</option>
25       <option>Date</option>
26       <option>Length</option>
27     </select>
28     <input disabled type="submit" name="submit" value="Find">
29
30     <a class="panel clearsearch" href="?">Clear All</a>
31     <a class="panel advanced hide" href="#">Hide</a>
32     <hr>
33
34     <p class="help">Up to <strong>10</strong> filter boxes will appear as you start selecting tags. You can select <strong>multiple</strong> tags in each box by holding down the <strong>Ctrl</strong>-key. Click the "<strong>Filter!</strong>" button when you are ready.</p>
35
36   $(for n in {0..9}; do
37     filter="$(printf '%s^' "$filters" |cut -d^ -f$(($n+1)))"
38     fneg="${filter%%[a-zA-Z]*}"
39     filter="${filter#!}"
40     fcat="${filter%%:*}"
41     [ "$fcat" = "$filter" ] && fcat=none
42
43     debug "fneg: $fneg  fcat: $fcat     filter: $filter"
44     
45     cat <<-EOF
46         <input class="tabhandle" type="checkbox" id="filter$n" $([ $n = 0 -o -n "$filter" ] && echo checked) >
47         <label class="tabhandle filter" for="filter$n">+ and</label>
48         <div class="tabcontent filter">
49           <input type="radio" name="type$n" value="pos" id="pos$n" ${fneg:-checked} ><label for="pos$n" class="conjunction">Any</label>
50           <input type="radio" name="type$n" value="neg" id="neg$n" ${fneg:+checked} ><label for="neg$n" class="conjunction">None</label>
51           <span class="help">of the items selected here:</span>
52
53           <label class="category">Category:</label>
54           <div class="category tabcontainer">
55             <div class="tab">
56             <input class="tabhandle" type="radio" name="category$n" id="cat${n}_none" value="none" $([ "none" = "$fcat" ] && echo checked)>
57             <label class="category tabhandle" for="cat${n}_none">general</label>
58             <select class="category tabcontent" class="input tagfilter" name="cfilter${n}_" size="12" multiple>
59               $(echo "$taglist" |grep -v : |while read item; do
60                   echo -E "$item" |egrep -q "^($filter)$" && \
61                     echo "<option selected >$item</option>" \
62                  || echo "<option>$item</option>"
63               done)
64             </select>
65             </div>
66           $( echo "$taglist" |sed -rn 's;^([^:]+):.*$;\1;p' |sort -u \
67              |while read cat; do echo "
68             <div class="tab">
69             <input class="tabhandle" type="radio" name="category$n" id="cat${n}_$cat" value="$cat" $([ "$cat" = "$fcat" ] && echo checked)>
70             <label class=\"category tabhandle\" for="cat${n}_$cat">$cat</label>
71             <select class=\"category tabcontent\" class=\"input tagfilter\" name="cfilter${n}_" size="12" multiple>
72               $(echo "$taglist" |sed -rn "s;^$cat:;;p" | while read item; do
73                  echo -E "${cat}:${item}" |egrep -q "^($filter)$" && \
74                     echo "<option selected >$item</option>" \
75                  || echo "<option>$item</option>"
76               done)
77             </select>
78             </div>
79           "
80           done)
81           </div>
82         </div>
83         EOF
84   done)
85
86     <p class="filter final">
87       <label for="o3" class="order">Order by:</label>
88       <select class="edit order" size="1" name="o" id="o3">
89         <option $([ "$_GET[\"o\"]" = Name ] && echo selected) >Name</option>
90         <option $([ "$_GET[\"o\"]" = Date ] && echo selected) >Date</option>
91         <option $([ "$_GET[\"o\"]" = Length ] && echo selected) >Length</option>
92       </select>
93       <input type="submit" value="Filter!">
94     </p>
95
96     <p class="quicklinks">
97       <label class="quicklinks">Most recent</label>
98       $(output=''
99         tac ${_DATA}/meta/recent |while [ "$(echo "$output" |wc -l)" -lt 10 ] && read line; do
100           line="<a href="$line">$line</a>"
101           echo "$output" |grep -qF "$line" || output="$output$line\n"
102         done
103         echo $output
104       )
105     </p>
106   </form>
107 EOF
108
109 # vi:set filetype=html: