X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=list.sh;h=9482a311e862a58d6c0d896815805af91a6d0aaa;hb=0a576d1d2ce23eb3043adcd7adb7b45c89ba6051;hp=607ea201ed6580ef2a0d5087c72860600669708c;hpb=ee2a0b2dc2a7a72f6c7cb16fa5108c5597637e7d;p=serve0 diff --git a/list.sh b/list.sh index 607ea20..9482a31 100644 --- a/list.sh +++ b/list.sh @@ -6,7 +6,7 @@ list_item() { local name path length width height tags comment n name="$(HTML "$1")" - path="$(HTML "$ITEM/$1")" + path="$(URL "${ITEM}/${1}")" if [ -d "$_DATA/$ITEM/$1" ]; then printf '[a .list .dir href="%s?%s" %s]' \ @@ -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 \