3 . "$_EXEC/indexmeta.sh"
8 local meta file link name
10 if [ "${META_NAME%/}" != "${META_NAME}" ]; then
11 printf '[a .list .dir href="%s?%s" . %s]' \
12 "$(URL "${PATH_INFO%/}/${META_NAME}")" "${w_refuri#*\?}" \
13 "$(HTML "${META_NAME%/}")"
17 file="$_DATA/${PATH_INFO%/}/$(list_fullname "${META_NAME}")"
18 if [ -f "$file" ]; then
19 link="$(URL "${PATH_INFO%/}/${file#${_DATA}/${PATH_INFO}}")"
20 name="$(HTML "${PATH_INFO%/}/${file#${_DATA}/${PATH_INFO}}")"
21 printf '[div .list .file
22 [a href="%s" [img src="%s?a=thumbnail"]][label . %s]
23 [span .time %i:%02imin] [span .dim %ix%i] %s
24 [checkbox "select" "%s" id="select_%s"][label for="select_%s" +]
26 "$link" "$link" "${name##/}" \
27 "$((META_LENGTH / 60))" "$((META_LENGTH % 60))" \
28 "$META_WIDTH" "$META_HEIGHT" \
29 "$(printf %s\\n "${META_TAGS}" \
30 | sed -r 's;^;,;; s;,+;,;g; s;,$;;;
31 :X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
32 )" "$name" "$link" "$link"
34 debug "Canning record for nonexist file: $META_NAME"
35 meta_purge "$_DATA/$ITEM/$META_NAME"
39 [ "$FILTER" ] && list_fex="$(
42 | sed -E 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \
44 [ "${f##*[A-Z]*}" ] && tl="y;ABCDEFGHIJKLMNOPQRSTUVWXYZ;abcdefghijklmnopqrstuvwxyz;;"
47 ~\\\$:*) fex="h; ${tl} /${f#~\\\$:}/d; g;${fex}";;
48 \\\$:*) fex="h; ${tl} /${f#\\\$:}/{g;${fex}}";;
49 ~*) fex="/(\ttags=([^\t]*,)?)(${f#\~})((,[^\t]*)?\t)/d; ${fex}";;
50 *) fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}";;
52 printf '%s\n' "${fex}"
59 file="$(printf %s\\n "$_DATA/$ITEM/$short".*)"
60 file="${file%%${BR}*}"
61 [ -e "$file" ] && printf %s\\n "${file#${_DATA}/${ITEM}/}"
65 if [ "$FILTER" ]; then
66 debug "FEX:" "$list_fex"
68 elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
69 grep -aviEe "$(STRING "${SEARCH}" \
70 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
71 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
73 elif [ "${SEARCH}" ]; then
74 grep -aiEe "$(STRING "${SEARCH}" \
75 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
76 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
84 local fm fn fn al length ln h w t c name group o buffer l
86 if [ $ORDER = Name ]; then
88 elif [ $ORDER = Group ]; then
89 { sort -n -k8 -k6,6 |sort -s -k7,7 ; echo '0 0 0 tags= comment= _'; } \
90 | while read -r length w h t c name group o; do
91 if [ "${ln%% *}" = "${group}" ]; then
93 buffer="${buffer}${BR}$length $w $h $t $c $name"
95 printf '%s\n' "$buffer" |while read -r l; do
96 [ "$l" ] && printf '%i %s\n' "$al" "$l"
99 buffer="$length $w $h $t $c $name"
103 | sort -s -n -k1,1 |sed -E 's;^[0-9]+\t;;;'
104 elif [ $ORDER = Length ]; then
106 elif [ $ORDER = Date ]; then
109 fn="$(list_fullname "${fn##* }")"
111 "$(stat -c %Y "$fn")" "${fm}"
113 | sort -srn -k1 |sed -E 's;^[0-9]+\t;;;'
118 local mode meta cachename
119 mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf index )"
121 cachename="$(printf '%s\n' "$mode" "$FILTER" "$SEARCH" "$ORDER" |sha1sum)"
122 cachename="$_DATA/$ITEM/.index/${cachename% -}.cache"
123 meta="$_DATA/$ITEM/.index/meta"
124 meta_dir "$_DATA/$ITEM/"
126 if [ "$mode" = browse ]; then
127 [ "$ITEM" ] && printf '0 0 0 \ \ ../\n'
129 find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
130 ) | sort |while read dir; do
131 printf '0 0 0 \\ \\ %s\n' "$(STRING "${dir#./}")"
134 if [ "$cachename" -nt "$meta" ]; then
140 | { [ -d "${cachename%/*}" ] && tee "$cachename" || cat; }
143 elif [ "$mode" = index ]; then
144 if [ -f "$cachename" -a ! "$(find "$_DATA" -path '*/.index/meta' -newer "$cachename")" ]; then
150 | { [ -d "${cachename%/*}" ] && tee "$cachename" || cat; }
156 local page i c n end qry
157 page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
158 end=$((page + LISTSIZE))
159 eval "$LOCAL_META" # localize vars from db_meta
161 printf '[div .itemlist '
164 if [ $c -gt $page -a $c -le $end ]; then
168 read -r discard || break
173 [ $(( c % LISTSIZE )) -gt 0 ] \
174 && end=$((c / LISTSIZE + 1)) \
175 || end=$((c / LISTSIZE))
177 printf '[div .pagination'
178 for n in $( seq 1 $end ); do
179 c=$(( (n - 1) * LISTSIZE + 1 ))
181 && printf '[a .page .current href="?p=%i&%s" %i]' "${c}" "${QUERY_STRING#p=*&}" "$n" \
182 || printf '[a .page href="?p=%i&%s" %i]' "${c}" "${QUERY_STRING#p=*&}" "$n"
187 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
193 printf ' by %s]' "$ORDER"
195 [meta name="viewport" content="width=device-width"]
196 [link rel=stylesheet href="/cgilite/common.css" ]
197 [link rel=stylesheet href="/style.css" ]
200 [a #t_bookmarks href="#bookmarks" ★]'
203 [a #t_prefs href="#prefs" ⚙]
209 [form method=POST action="?a=multitag"'
212 [ -d "$_DATA/$ITEM/.index" ] && { printf '
219 [ ! -d "$_DATA/$ITEM/.index" ] && { printf '
226 '; } | "$_EXEC/cgilite/html-sh.sed"