]> git.plutz.net Git - serve0/blob - actions/filter.sh
styling for pagination links
[serve0] / actions / filter.sh
1 #!/bin/zsh
2 # Copyright 2014 - 2016 Paul Hänsch
3 #
4 # This file is part of Serve0
5 #
6 # Serve0 is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # Serve0 is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU Affero General Public License for more details.
15 #
16 # You should have received a copy of the GNU Affero General Public License
17 # along with Serve0  If not, see <http://www.gnu.org/licenses/>.
18
19 order=$(validate "${_POST[o]}" 'Name|Length|Date' Name)
20
21 for fn in {0..9}; do
22   category="$(validate "${_POST[category$fn]}" '[[:alnum:]_-]+' none)"
23
24   n=''; while [ -n "${_POST[cfilter${fn}_$n]}" ]; do
25     #cfilter="$(validate "${_POST[cfilter${fn}_$n]}" '[[:alnum:]\?!\._=\(\)+-]+' '#')"
26     cfilter="${_POST[cfilter${fn}_$n]}"
27
28     if [ -z "$n" ]; then
29       [ -n "$filters" ] && filters="${filters}^"
30       [ "${_POST[type$fn]}" = 'neg' ] && filters="${filters}!"
31       n=0
32     else
33       filters="${filters}|"
34       n=$(($n + 1))
35     fi
36     [ "$category" = "none" ] && filters="${filters}${cfilter}" \
37                              || filters="${filters}${category}:${cfilter}"
38   done
39 done
40
41 printf %s\\n "?o=${order}&f=${filters}" >>${_DATA}/meta/recent
42 redirect  "?o=${order}&f=${filters}"