From: Paul Hänsch Date: Mon, 16 Jul 2018 23:54:28 +0000 (+0200) Subject: application of tag filters X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=36a7062732ede1219d99b3270a95fcd75df6eeea;p=serve0 application of tag filters --- diff --git a/advsearch.sh b/advsearch.sh new file mode 100644 index 0000000..6f85ed2 --- /dev/null +++ b/advsearch.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +f='' +ref="$(POST ref)" +order="$(POST order |grep -m1 -xE 'Name|Date|Length' || printf Name)" + +for n in 1 2 3 4 5 6 7 8 9; do + [ "$(POST pol_$n)" = neg ] \ + && f="$f~" + cat="$(POST cat_$n)" + for m in $(seq 1 $(POST_COUNT tag_$n)); do + tag="$(POST tag_$n $m)" + [ ! "${tag##${cat}:*}" ] || [ "$cat" = '*' -a "${tag##*:*}" ] \ + && f="${f}${tag}|" + done + f="${f%[|^]}^" +done +f="${f%^}" + +REDIRECT "${ref%%\?*}?o=${order}&f=${f}" diff --git a/index.cgi b/index.cgi index a8ddaa8..7a1a3ef 100755 --- a/index.cgi +++ b/index.cgi @@ -48,6 +48,9 @@ elif [ -f "$_DATA/$ITEM" ]; then esac elif [ -d "$_DATA/$ITEM" ]; then case $(GET a) in + advsearch) + . "$_EXEC/advsearch.sh" + ;; spawnindex) if [ "$(POST recursive)" = yes ]; then find "$_DATA/$ITEM" -depth -type d \! -name .index \