X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=actions%2Ffilter_card.sh;h=cc0f9127e404fbbaf52ba752ad97d4545dc70ddc;hp=9de02886d428b5d7261608d0f67b12adc9ce50a0;hb=8144adb77a33850bca9c60f0b040b39f4a5da91f;hpb=69e661b5c8ec195bd3c4998a623a60607b47059e diff --git a/actions/filter_card.sh b/actions/filter_card.sh index 9de0288..cc0f912 100755 --- a/actions/filter_card.sh +++ b/actions/filter_card.sh @@ -1,6 +1,6 @@ #!/bin/zsh -# Copyright 2014 Paul Hänsch +# Copyright 2014, 2017 Paul Hänsch # # This file is part of Confetti. # @@ -19,14 +19,15 @@ cgi_post -case "${_POST[choice]}"; in - new_filter) - filter="${_POST[filter]}" - filtertype="${_POST[filtertype]}" - order="${_POST[order]}" - echo -n "Location: ?p=cards&filter=$filter&filtertype=$filtertype&order=$order\n\n" - ;; - *) - echo -n "Location: ?p=cards\n\n" - ;; -esac +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