]> git.plutz.net Git - confetti/blobdiff - cards/filter_card.sh
refactoring card display
[confetti] / cards / filter_card.sh
index cc0f9127e404fbbaf52ba752ad97d4545dc70ddc..d09adabc07cf5f23c8b9d5925cf296835f3cb09a 100755 (executable)
@@ -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.
 # 
 # You should have received a copy of the GNU Affero General Public License
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
-cgi_post
-
-if [ "${_POST[choice]}" = new_filter ]; then
+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;\^[^:]*:$;;;'
+    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;\^[^:]*:$;;;'
   )"
-  printf 'Location: ?p=cards&order=%s&filter=%s\n\n' "${_POST[order]}" "$filter"
+  REDIRECT "/cards/?order=$(POST order)&filter=${filter}"
 else
-  printf 'Location: ?p=cards\n\n'
+  REDIRECT '/cards/'
 fi