X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=list.sh;h=5c6634db6d397fa5cf3baa1806b9afd71e225fc3;hb=b22f5dedd33a3c4b3a42f06072923b0f75b6799f;hp=607ea201ed6580ef2a0d5087c72860600669708c;hpb=ee2a0b2dc2a7a72f6c7cb16fa5108c5597637e7d;p=serve0 diff --git a/list.sh b/list.sh index 607ea20..5c6634d 100644 --- a/list.sh +++ b/list.sh @@ -34,14 +34,33 @@ list_directories(){ ) | cut -d/ -f2- | sort } +[ "$FILTER" ] && list_fex="$( + fex='p' + STRING "$FILTER^" \ + | sed -r 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \ + | while read -r f; do + [ ! "${f#~}" ] && continue + [ "${f#~}" = "$f" ] \ + && fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}" \ + || fex="/(\ttags=([^\t]*,)?)(${f#~})((,[^\t]*)?\t)/d; ${fex}" + printf '%s\n' "${fex}" + done \ + | tail -n1 +)" + list_filemeta(){ local meta base f fn file base="$1" meta="$1/.index/meta" meta_dir "$_DATA/$ITEM/$base" - grep -iE "$(STRING "${SEARCH}")" "$_DATA/$ITEM/$meta" \ - | cut -f1,6- \ + if [ "$FILTER" ]; then + sed -nr "$list_fex" "$_DATA/$ITEM/$meta" + elif [ "${SEARCH#!}" != "${SEARCH}" ]; then + grep -viE "$(STRING "${SEARCH#!}")" "$_DATA/$ITEM/$meta" + else + grep -iE "$(STRING "${SEARCH}")" "$_DATA/$ITEM/$meta" + fi |cut -f1,6- \ | while f="$(line)"; do fn="$(UNSTRING "${f#* }")"; fn="${fn%${CR}}"; file="$(printf '%s\n' "$_DATA/$ITEM/$base/${fn}".*)" @@ -69,7 +88,7 @@ list_items() { if [ "$mode" = browse -a "$ORDER" = Date ]; then list_directories list_filemeta . |cut -f2- \ - | xargs -d\n stat -c '%Y %n' \ + | xargs -rd'\n' stat -c '%Y %n' \ | sort -rn |cut -d/ -f2- elif [ "$mode" = browse -a "$ORDER" = Name ]; then list_directories @@ -77,7 +96,7 @@ list_items() { | sort -k 2 |cut -d/ -f2- elif [ "$mode" = index -a "$ORDER" = Date ]; then list_index |cut -f2- \ - | xargs -d'\n' stat -c '%Y %n' \ + | xargs -rd'\n' stat -c '%Y %n' \ | sort -rn | cut -d/ -f2- elif [ "$mode" = index -a "$ORDER" = Name ]; then list_index | sort -k 2 | cut -d/ -f2- @@ -128,6 +147,7 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n' [a #t_prefs href="#prefs" ⚙] ] $(w_prefs) + $(w_advsearch) [form method=POST action="?a=multitag" $(list_items \