X-Git-Url: http://git.plutz.net/?a=blobdiff_plain;f=list.sh;h=d6228347bec5006fea4cad050b6c868abb0da8d0;hb=7068cdba834b18fd78cb48c3e0e1d72c40887a25;hp=52b78b2b26878bda15a0e4d2f2fadec050dd2d07;hpb=a6d47d63a2ae5495d06c4514be273d5168b71855;p=serve0 diff --git a/list.sh b/list.sh index 52b78b2..d622834 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}".*)" @@ -119,6 +138,7 @@ printf 'Content-Type: text/html;charset=utf-8\r\n\r\n' "$_EXEC/cgilite/html-sh.sed" <<-EOF [!DOCTYPE HTML] [html [head [title Listing] + [meta name="viewport" content="width=device-width"] [link rel=stylesheet href="/style.css" ] ] [body [div #navigation @@ -128,6 +148,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 \