3 . "$_EXEC/indexmeta.sh"
7 local name path length width height tags comment n
9 path="$(URL "$ITEM/$1")"
10 qry=$(HTML "$QUERY_STRING")
12 if [ -d "$_DATA/$ITEM/$1" ]; then
13 printf '[a .list .dir href="%s" %s]' "${path}?${qry}" "$name"
14 elif [ -f "$_DATA/$ITEM/$1" ]; then
15 read -r length width height tags comment n <<-EOF
16 $(meta_info "$_DATA/$ITEM/$1")
18 printf '[div .list .file
19 [a href="%s" [img src="%s?a=thumbnail"][label %s]]
20 [span .time %i:%imin] [span .dim %ix%i] %s
21 [checkbox "select" "%s" id="select_%s" form="multitag"][label for="select_%s" +]
23 "$path" "$path" "$name" \
24 "$((length / 60))" "$((length % 60))" \
26 "$(UNSTRING "${tags#tags=}" |tr , '\0' |xargs -r0 printf ' [span .tag %s]')" \
27 "$path" "$path" "$path"
29 printf 'Canning record for nonexist file: %s\n' "$1" >&2
30 meta_purge "$_DATA/$ITEM/$1"
36 find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
37 ) | cut -d/ -f2- | sort
40 [ "$FILTER" ] && list_fex="$(
43 | sed -r 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \
45 [ ! "${f#~}" ] && continue
47 && fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}" \
48 || fex="/(\ttags=([^\t]*,)?)(${f#~})((,[^\t]*)?\t)/d; ${fex}"
49 printf '%s\n' "${fex}"
56 [ ! "${sn%%*/*}" ] && base="${sn%/*}" || base=.
57 file="$(printf '%s' "$_DATA/$ITEM/$sn".*)"
59 [ -e "$_DATA/$ITEM/$base/${file}" ] \
60 && printf '%s\n' "${base}/${file}"
64 local meta base f fn file
66 meta="$_DATA/$ITEM/$base/.index/meta"
67 meta_dir "$_DATA/$ITEM/$base"
69 if [ $ORDER = Name ]; then
71 elif [ $ORDER = Length ]; then
76 | if [ "$FILTER" ]; then
78 elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
79 grep -viE "$(STRING "${SEARCH#!}")"
81 grep -iE "$(STRING "${SEARCH}")"
82 fi |cut -f6 | UNSTRING \
83 | while read -r fn; do
84 printf '%s\n' "${base}/${fn%${CR}}"
91 find ./ -path '*/.index/meta'
92 ) | while meta="$(line)"; do
93 list_filemeta "${meta%/.index/meta}"
101 | xargs -rd'\n' stat -c '%Y %n' \
102 | sort -rn |cut -d/ -f2- \
103 | sed -r 's;\.[^\.]*$;;;'
108 mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )"
110 [ "$mode" = browse -a "$ITEM" ] && printf '..\n'
112 if [ "$mode" = browse -a "$ORDER" = Date ]; then
114 list_filemeta . |list_dateorder
115 elif [ "$mode" = index -a "$ORDER" = Date ]; then
116 list_index |list_dateorder
117 elif [ "$mode" = browse ]; then
120 elif [ "$mode" = index ]; then
127 page="$(GET p |grep -xE '[0-9]+' || printf 1)"; c=1
128 end=$((page + LISTSIZE))
130 printf '[div .itemlist '
132 [ $c -ge $page -a $c -lt $end ] \
133 && list_item "$(list_fullname "$i")"
138 printf '[div .pagination'
139 for n in $( seq 1 $((c / LISTSIZE + 1)) ); do
140 printf '[a .page href="%s" %s]' \
141 "?p=$(( (n - 1) * LISTSIZE + 1))&$qry" "$n"
146 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
150 [html [head [title Listing]
151 [meta name="viewport" content="width=device-width"]
152 [link rel=stylesheet href="/style.css" ]
155 [a #t_bookmarks href="#bookmarks" ★]'
158 [a #t_avsearch href="#advsearch" Advanced]
159 [a #t_prefs href="#prefs" ⚙]
164 [form method=POST action="?a=multitag"'
169 [a href="#multitag" Add Tags]'
176 '; } | "$_EXEC/cgilite/html-sh.sed"