From 36a7062732ede1219d99b3270a95fcd75df6eeea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Tue, 17 Jul 2018 01:54:28 +0200 Subject: [PATCH] application of tag filters --- advsearch.sh | 20 ++++++++++++++++++++ index.cgi | 3 +++ 2 files changed, 23 insertions(+) create mode 100644 advsearch.sh 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 \ -- 2.39.2