X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=cards%2Ffilter_card.sh;h=2b25acb8f5dca7f4377964883ce1dcbf738b7605;hp=cc0f9127e404fbbaf52ba752ad97d4545dc70ddc;hb=6071860354f8edb8392d2b3c1f339fdeacbab540;hpb=43e7c60df0632fd383306a2d3c6dc8c4213d4b9d diff --git a/cards/filter_card.sh b/cards/filter_card.sh index cc0f912..2b25acb 100755 --- a/cards/filter_card.sh +++ b/cards/filter_card.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014, 2017 Paul Hänsch +# Copyright 2014, 2017, 2019 Paul Hänsch # # This file is part of Confetti. # @@ -17,17 +17,33 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . -cgi_post +filter="$( + seq 0 100 |while read n; do + filter_type="$(POST "filter_type${n}")" + filter_text="$(POST "filter_text${n}")" + [ ! "$filter_type" -a ! "$filter_text" ] && break + if [ "$filter_type" = CATEGORIES ]; then + printf '^CATEGORIES:' + seq 0 $(POST_COUNT filter_cat$n) |while read m; do + printf '|%s' "$(POST filter_cat$n $m)" + done + else + printf '^%s:%s' "$filter_type" "$filter_text" + fi + done | sed -r \ + 's;\|+;\|;g; s;\^+;\^;g; s;:\|;:;g; + :X; s;\^[^:]*:\^;\^;g; /\^[^:]*:\^/bX; + s;^\^;;; s;\^[^:]*:$;;;' +)" -if [ "${_POST[choice]}" = new_filter ]; then - filter="$( - for n in filter{0..100}; do - # [ -z "${_POST[$n]:+x}" ] && break - printf %s "${_POST[$n]}" - done \ - | sed -r 's;\|+;\|;g; s;\^+;\^;g; s;:\|;:;g; :X; s;\^[^:]*:\^;\^;g; /\^[^:]*:\^/bX; s;^\^;;; s;\^[^:]*:$;;;' - )" - printf 'Location: ?p=cards&order=%s&filter=%s\n\n' "${_POST[order]}" "$filter" -else - printf 'Location: ?p=cards\n\n' -fi +case $(POST choice) in + filter) + REDIRECT "/cards/?o=$(POST order)&f=${filter}" + ;; + new_filter) + REDIRECT "/cards/?o=$(POST order)&f=${filter}&newfilter=yes" + ;; + *) + REDIRECT '/cards/' + ;; +esac