]> git.plutz.net Git - serve0/commitdiff
application of tag filters
authorPaul Hänsch <paul@plutz.net>
Mon, 16 Jul 2018 23:54:28 +0000 (01:54 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 16 Jul 2018 23:54:28 +0000 (01:54 +0200)
advsearch.sh [new file with mode: 0644]
index.cgi

diff --git a/advsearch.sh b/advsearch.sh
new file mode 100644 (file)
index 0000000..6f85ed2
--- /dev/null
@@ -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}"
index a8ddaa85499a5efb97a368d057b22fc63165314f..7a1a3efd2106a677365c2a8ab7c927c8b7608bc7 100755 (executable)
--- 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 \