3 . "$_EXEC/indexmeta.sh"
8 local meta file link name
16 if [ "${META_NAME%/}" != "${META_NAME}" ]; then
17 printf '[a .list .dir href="%s?%s" . %s]' \
18 "$(URL "${PATH_INFO%/}/${META_NAME}")" "${w_refuri#*\?}" \
19 "$(HTML "${META_NAME%/}")"
23 file="$_DATA/${PATH_INFO%/}/$(list_fullname "${META_NAME}")"
24 if [ -f "$file" ]; then
25 link="$(URL "${PATH_INFO%/}/${file#${_DATA}/${PATH_INFO}}")"
26 name="$(HTML "${PATH_INFO%/}/${file#${_DATA}/${PATH_INFO}}")"
27 printf '[div .list .file
28 [a href="%s" [img src="%s?a=thumbnail"]][label . %s]
29 [span .time %i:%02imin] [span .dim %ix%i] %s
30 [checkbox "select" "%s" id="select_%s"][label for="select_%s" +]
32 "$link" "$link" "${name##/}" \
33 "$((META_LENGTH / 60))" "$((META_LENGTH % 60))" \
34 "$META_WIDTH" "$META_HEIGHT" \
35 "$(printf %s\\n "${META_TAGS}" \
36 | sed -r 's;^;,;; s;,+;,;g; s;,$;;;
37 :X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
38 )" "$name" "$link" "$link"
40 debug "Canning record for nonexist file: $META_NAME"
41 meta_purge "$_DATA/$ITEM/$META_NAME"
45 [ "$FILTER" ] && list_fex="$(
48 | sed -E 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \
50 [ "${f##*[A-Z]*}" ] && tl="y;ABCDEFGHIJKLMNOPQRSTUVWXYZ;abcdefghijklmnopqrstuvwxyz;;"
53 ~\\\$:*) fex="h; ${tl} /${f#~\\\$:}/d; g;${fex}";;
54 \\\$:*) fex="h; ${tl} /${f#\\\$:}/{g;${fex}}";;
55 ~*) fex="/(\ttags=([^\t]*,)?)(${f#\~})((,[^\t]*)?\t)/d; ${fex}";;
56 *) fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}";;
58 printf '%s\n' "${fex}"
64 local short="$(UNSTRING "${1%${CR}}")" file
65 file="$(printf %s\\n "$_DATA/$ITEM/$short".*)"
66 file="${file%%${BR}*}"
67 [ -e "$file" ] && printf %s\\n "${file#${_DATA}/${ITEM}/}"
71 if [ "$FILTER" ]; then
72 debug "FEX:" "$list_fex"
74 elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
75 grep -aviEe "$(STRING "${SEARCH}" \
76 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
77 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
79 elif [ "${SEARCH}" ]; then
80 grep -aiEe "$(STRING "${SEARCH}" \
81 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
82 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
90 local fm fn fn al length ln h w t c name buffer l
92 if [ $ORDER = Name ]; then
94 elif [ $ORDER = Group ]; then
97 s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)-([0-9a-zA-Z_-]{11}\r|ph[0-9a-f]{13}\r|[0-9]{8}\r)(.*)$;\1-\r\3 \2\n;;
99 s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)([0-9]+)(.*)$;\1\r\3 \2;;
101 | { sort -n -k7 -k8 -k9 -k10 -k11 |sort -s -k6,6 ; echo '0 0 0 tags= comment= _'; } \
102 | while read -r length w h t c name; do
103 if [ "${ln%% *}" = "${name%% *}" ]; then
105 buffer="${buffer}${BR}$length $w $h $t $c $name"
107 printf '%s\n' "$buffer" |while read -r l; do
108 [ "$l" ] && printf '%i %s\n' "$al" "$l"
111 buffer="$length $w $h $t $c $name"
115 | sort -s -n -k1,1 |sed -E 's;^[0-9]+\t;;;' \
116 | sed -E ':X s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*)\r([^ ]*) ([^ ]+)( .*)?$;\1\3\2\4;; tX'
117 elif [ $ORDER = Length ]; then
119 elif [ $ORDER = Date ]; then
121 fn="$(list_fullname "${fm##* }")"
123 "$(stat -c %Y "$fn")" "${fm}"
125 | sort -srn -k1 |sed -E 's;^[0-9]+\t;;;'
130 local mode meta cachename
131 mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf index )"
133 cachename="$(printf '%s\n' "$mode" "$FILTER" "$SEARCH" "$ORDER" |sha1sum)"
134 cachename="$_DATA/$ITEM/.index/${cachename% -}.cache"
135 meta="$_DATA/$ITEM/.index/meta"
136 meta_dir "$_DATA/$ITEM/"
138 if [ "$mode" = browse ]; then
139 [ "$ITEM" ] && printf '0 0 0 \ \ ../\n'
141 find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
142 ) | sort |while read dir; do
143 printf '0 0 0 \\ \\ %s\n' "$(STRING "${dir#./}")"
146 if [ "$cachename" -nt "$meta" ]; then
152 | { [ -d "${cachename%/*}" ] && tee "$cachename" || cat; }
155 elif [ "$mode" = index ]; then
156 if [ -f "$cachename" -a ! "$(find "$_DATA" -path '*/.index/meta' -newer "$cachename")" ]; then
162 | { [ -d "${cachename%/*}" ] && tee "$cachename" || cat; }
168 local page i c n end qry
169 page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
170 end=$((page + LISTSIZE))
171 qry="${w_refuri#*\?}"; qry="${qry#p=*&}"
173 printf '[div .itemlist '
176 [ $c -gt $page -a $c -le $end ] && list_item "$i"
180 [ $(( c % LISTSIZE )) -gt 0 ] \
181 && end=$((c / LISTSIZE + 1)) \
182 || end=$((c / LISTSIZE))
184 printf '[div .pagination'
185 for n in $( seq 1 $end ); do
186 c=$(( (n - 1) * LISTSIZE + 1 ))
188 && printf '[a .page .current href="%s" %s]' "?p=${c}&${qry}" "$n" \
189 || printf '[a .page href="%s" %s]' "?p=${c}&${qry}" "$n"
194 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
200 printf ' by %s]' "$ORDER"
202 [meta name="viewport" content="width=device-width"]
203 [link rel=stylesheet href="/cgilite/common.css" ]
204 [link rel=stylesheet href="/style.css" ]
207 [a #t_bookmarks href="#bookmarks" ★]'
210 [a #t_prefs href="#prefs" ⚙]
216 [form method=POST action="?a=multitag"'
219 [ -d "$_DATA/$ITEM/.index" ] && { printf '
226 [ ! -d "$_DATA/$ITEM/.index" ] && { printf '
233 '; } | "$_EXEC/cgilite/html-sh.sed"