]> git.plutz.net Git - serve0/blob - templates/advfilter.html.sh
styling for pagination links
[serve0] / templates / advfilter.html.sh
1 # Copyright 2014 - 2016 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 category_tabs(){
19   for cat in "$@"; do
20   cat <<EOF
21   <div class="tab">
22     <input class="tabhandle" type="radio" name="category$n" id="cat${n}_$cat" value="$cat" $([ "$cat" = "$fcat" ] && printf checked)>
23     <label class="category tabhandle" for="cat${n}_$cat">$([ "$cat" = none ] && printf %s general || printf %s "$cat")</label>
24     <select class="category tabcontent" class="input tagfilter" name="cfilter${n}_" size="12" multiple>
25       $(category_selected "$cat" "$filter")
26     </select>
27   </div>
28 EOF
29   done
30 }
31
32 filterbox(){
33   for n in "$@"; do
34     filter="$(printf '%s^' "$filters" |cut -d^ -f$(($n+1)))"
35     fneg="${filter%%[a-zA-Z]*}"
36     filter="${filter#!}"
37     fcat="${filter%%:*}"
38     [ "$fcat" = "$filter" ] && fcat=none
39     
40     debug "fneg: $fneg  fcat: $fcat     filter: $filter"
41     
42     cat <<-EOF
43         <input class="tabhandle" type="checkbox" id="filter$n" $([ $n = 0 -o -n "$filter" ] && printf checked) >
44         <label class="tabhandle filter" for="filter$n">+ and</label>
45         <fieldset class="tabcontent filter">
46           <input type="radio" name="type$n" value="pos" id="pos$n" ${fneg:-checked} ><label for="pos$n" class="conjunction">Any</label>
47           <input type="radio" name="type$n" value="neg" id="neg$n" ${fneg:+checked} ><label for="neg$n" class="conjunction">None</label>
48           <span class="help">of the items selected here:</span>
49         
50           <label class="category">Category:</label>
51           <div class="category tabcontainer">
52             $(category_tabs $(list_categories) )
53           </div>
54         </fieldset>
55         EOF
56   done
57 }
58
59 cat <<EOF
60   <form class="panel switchable top" id="advfilter"
61         action="?action=filter" method="post" accept-charset="UTF-8">
62
63     <a class="panel toggle" href="#">Hide</a>
64     <a class="panel" href="?p=quicklinks">Most recent</a>
65
66     <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>
67     $(filterbox {0..9})
68
69     <fieldset class="filter final">
70       <label for="o3" class="order">Order by:</label>
71       <select class="edit order" size="1" name="o" id="o3">
72         <option $([ "${_GET[o]}" = Name ] && printf selected) >Name</option>
73         <option $([ "${_GET[o]}" = Date ] && printf selected) >Date</option>
74         <option $([ "${_GET[o]}" = Length ] && printf selected) >Length</option>
75       </select>
76       <input type="submit" value="Filter!">
77     </fieldset>
78   </form>
79 EOF
80
81 # vi:set filetype=html: