X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=actions%2Ffilter_card.sh;h=cc0f9127e404fbbaf52ba752ad97d4545dc70ddc;hp=b5ce333aa85c91db928833abb94f6347ca7efdc7;hb=8144adb77a33850bca9c60f0b040b39f4a5da91f;hpb=16a2240ce347132c7000ca22989e83801cf3ebf0 diff --git a/actions/filter_card.sh b/actions/filter_card.sh index b5ce333..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,25 +19,15 @@ cgi_post -case "${_POST[choice]}"; in - new_filter) - for n in '' {0..100}; do - debug "N: $n; ${_POST[filter$n]}" - [ -z "${_POST[filter$n]+x}" ] && break - filterval="${_POST[filter$n]}" - filtertype="${_POST[filtertype$n]}" - filter="${filtertype}:${filterval}${filter+^${filter}}" - done - order="${_POST[order]}" - echo -n "Location: ?p=cards&filter=$filter&filtertype=advanced&order=$order\n\n" - ;; - #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