3 . "$_EXEC/indexmeta.sh"
7 local name link path length width height tags comment n
9 link="$(URL "$ITEM/$1")"
10 path="$(HTML "$ITEM/$1")"
11 qry=$(HTML "$QUERY_STRING")
13 if [ -d "$_DATA/$ITEM/$1" ]; then
14 printf '[a .list .dir href="%s" %s]' "${path}?${qry}" "$name"
15 elif [ -f "$_DATA/$ITEM/$1" ]; then
16 read -r length width height tags comment n <<-EOF
17 $(meta_info "$_DATA/$ITEM/$1")
19 printf '[div .list .file
20 [a href="%s" [img src="%s?a=thumbnail"][label %s]]
21 [span .time %i:%imin] [span .dim %ix%i] %s
22 [checkbox "select" "%s" id="select_%s"][label for="select_%s" +]
24 "$link" "$link" "$name" \
25 "$((length / 60))" "$((length % 60))" \
27 "$(UNSTRING "${tags#tags=}" |tr , '\0' |xargs -r0 printf ' [span .tag %s]')" \
28 "$path" "$path" "$path"
30 printf 'Canning record for nonexist file: %s\n' "$1" >&2
31 meta_purge "$_DATA/$ITEM/$1"
37 find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
38 ) | cut -d/ -f2- | sort
41 [ "$FILTER" ] && list_fex="$(
44 | sed -r 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \
46 [ ! "${f#~}" ] && continue
48 && fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}" \
49 || fex="/(\ttags=([^\t]*,)?)(${f#~})((,[^\t]*)?\t)/d; ${fex}"
50 printf '%s\n' "${fex}"
57 [ ! "${sn%%*/*}" ] && base="${sn%/*}" || base=.
58 file="$(printf '%s' "$_DATA/$ITEM/$sn".*)"
60 [ -e "$_DATA/$ITEM/$base/${file}" ] \
61 && printf '%s\n' "${base}/${file}"
65 local meta base f fn file
67 meta="$_DATA/$ITEM/$base/.index/meta"
68 meta_dir "$_DATA/$ITEM/$base"
70 if [ $ORDER = Name ]; then
72 elif [ $ORDER = Length ]; then
77 | if [ "$FILTER" ]; then
79 elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
80 grep -aviE "$(STRING "${SEARCH#!}" |sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1\\+;g; tx;')"
82 grep -aiE "$(STRING "${SEARCH}" \
83 | sed -r ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
84 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
86 fi |cut -f6 | UNSTRING \
87 | while read -r fn; do
88 printf '%s\n' "${base}/${fn%${CR}}"
89 done | tee .index/debug
95 find ./ -path '*/.index/meta'
96 ) | while read -r meta; do
97 list_filemeta "${meta%/.index/meta}"
105 | xargs -rd'\n' stat -c '%Y %n' \
106 | sort -rn |cut -d/ -f2- \
107 | sed -r 's;\.[^\.]*$;;;'
112 mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf browse )"
114 [ "$mode" = browse -a "$ITEM" ] && printf '..\n'
116 if [ "$mode" = browse -a "$ORDER" = Date ]; then
118 list_filemeta . |list_dateorder
119 elif [ "$mode" = index -a "$ORDER" = Date ]; then
120 list_index |list_dateorder
121 elif [ "$mode" = browse ]; then
124 elif [ "$mode" = index ]; then
131 page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
132 end=$((page + LISTSIZE))
134 printf '[div .itemlist '
136 [ $c -ge $page -a $c -lt $end ] \
137 && list_item "$(list_fullname "$i")"
142 printf '[div .pagination'
143 for n in $( seq 1 $((c / LISTSIZE + 1)) ); do
144 printf '[a .page href="%s" %s]' \
145 "?p=$(( (n - 1) * LISTSIZE + 1))&$qry" "$n"
150 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
154 [html [head [title Listing]
155 [meta name="viewport" content="width=device-width"]
156 [link rel=stylesheet href="/style.css" ]
159 [a #t_bookmarks href="#bookmarks" ★]'
162 [a #t_avsearch href="#advsearch" Advanced]
163 [a #t_prefs href="#prefs" ⚙]
168 [form method=POST action="?a=multitag"'
173 [a href="#multitag" Add Tags]'
180 '; } | "$_EXEC/cgilite/html-sh.sed"