X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=cards%2Ffilter_card.sh;h=2b25acb8f5dca7f4377964883ce1dcbf738b7605;hp=d09adabc07cf5f23c8b9d5925cf296835f3cb09a;hb=6071860354f8edb8392d2b3c1f339fdeacbab540;hpb=d5fb0b81bce3f19153b9c74f4bc17fe7a3043a7c diff --git a/cards/filter_card.sh b/cards/filter_card.sh index d09adab..2b25acb 100755 --- a/cards/filter_card.sh +++ b/cards/filter_card.sh @@ -17,16 +17,33 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . -if [ "$(POST choice)" = new_filter ]; then - filter="$( - seq 0 100 |while read n; do - printf %s "$(POST filter$n)" - done | sed -r \ - 's;\|+;\|;g; s;\^+;\^;g; s;:\|;:;g; - :X; s;\^[^:]*:\^;\^;g; /\^[^:]*:\^/bX; - s;^\^;;; s;\^[^:]*:$;;;' - )" - REDIRECT "/cards/?order=$(POST order)&filter=${filter}" -else - REDIRECT '/cards/' -fi +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;\^[^:]*:$;;;' +)" + +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