3 . "$_EXEC/indexmeta.sh"
7 local meta type length width height tags comment name display link
8 meta="${1}"; type="${meta%% *}"; meta="${meta#* }"
10 if [ "$type" = dir ]; then
12 display="$(HTML "$name")"; link="$(URL "${PATH_INFO%/}/$name")"
13 printf '[a .list .dir href="%s" %s]' "${link}?${w_refuri#*\?}" "$name"
17 length="${meta%% *}"; meta="${meta#* }"
18 width="${meta%% *}"; meta="${meta#* }"
19 height="${meta%% *}"; meta="${meta#* }"
20 tags="${meta%% *}"; meta="${meta#* }"
21 comment="${meta%% *}"; meta="${meta#* }"
22 name="${meta%% *}"; meta="${meta#* }"
24 if [ "$type" = metashort ]; then
25 name="$(list_fullname "$(UNSTRING "${name%${CR}}")")"
27 if [ -f "$_DATA/${PATH_INFO%/}/$name" ]; then
28 link="$(URL "${PATH_INFO%/}/${name#./}")"
29 name="$(HTML "${PATH_INFO%/}/${name#./}")"
30 printf '[div .list .file
31 [a href="%s" [img src="%s?a=thumbnail"]][label . %s]
32 [span .time %i:%02imin] [span .dim %ix%i] %s
33 [checkbox "select" "%s" id="select_%s"][label for="select_%s" +]
35 "$link" "$link" "${name##/}" \
36 "$((length / 60))" "$((length % 60))" \
38 "$(UNSTRING "${tags#tags=}" \
39 | sed -r 's;^;,;; s;,+;,;g; s;,$;;;
40 :X s;,-?([^,]+)(,|$); [span .tag\n \1]\2;; tX;'
41 )" "$name" "$link" "$link"
43 debug "Canning record for nonexist file: $name"
44 meta_purge "$_DATA/$ITEM/$name"
49 [ "$FILTER" ] && list_fex="$(
52 | sed -E 's;\^;\n;g; s;[]\/\(\)\\\^\$\?\.\+\*\;\[\{\}];\\&;g' \
54 [ "${f##*[A-Z]*}" ] && tl="y;ABCDEFGHIJKLMNOPQRSTUVWXYZ;abcdefghijklmnopqrstuvwxyz;;"
57 ~\\\$:*) fex="h; ${tl} /${f#~\\\$:}/d; g;${fex}";;
58 \\\$:*) fex="h; ${tl} /${f#\\\$:}/{g;${fex}}";;
59 ~*) fex="/(\ttags=([^\t]*,)?)(${f#\~})((,[^\t]*)?\t)/d; ${fex}";;
60 *) fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}";;
62 printf '%s\n' "${fex}"
69 [ ! "${sn%%*/*}" ] && base="${sn%/*}" || base=.
70 file="$(printf '%s' "$_DATA/$ITEM/$sn".*)"
72 [ -e "$_DATA/$ITEM/$base/${file}" ] \
73 && printf '%s\n' "${base}/${file}"
77 if [ "$FILTER" ]; then
78 debug "FEX:" "$list_fex"
80 elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
81 grep -aviEe "$(STRING "${SEARCH}" \
82 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
83 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
85 elif [ "${SEARCH}" ]; then
86 grep -aiEe "$(STRING "${SEARCH}" \
87 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
88 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
96 local fm fn fn al length ln h w t c name buffer l
98 if [ $ORDER = Name ]; then
99 sort -k6 |sed 's;^;metashort\t;;'
100 elif [ $ORDER = Group ]; then
103 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;;
105 s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)([0-9]+)(.*)$;\1\r\3 \2;;
107 | { sort -n -k7 -k8 -k9 -k10 -k11 |sort -s -k6,6 ; echo '0 0 0 tags= comment= _'; } \
108 | while read -r length h w t c name; do
109 if [ "${ln%% *}" = "${name%% *}" ]; then
111 buffer="${buffer}${BR}$length $h $w $t $c $name"
113 printf '%s\n' "$buffer" |while read -r l; do
114 [ "$l" ] && printf '%s %s\n' "$al" "$l"
117 buffer="$length $h $w $t $c $name"
121 | sort -s -n -k1,1 |sed -E 's;^[0-9]+\t;metashort\t;;' \
122 | sed -E ':X s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*)\r([^ ]*) ([^ ]+)( .*)?$;\1\3\2\4;; tX'
123 elif [ $ORDER = Length ]; then
124 sort -sn -k1 |sed 's;^;metashort\t;;'
125 elif [ $ORDER = Date ]; then
128 fn="$(list_fullname "$(UNSTRING "${sn%${CR}}")")"
129 printf '%i %s %s\n' \
130 "$(stat -c %Y "$fn")" "${fm% *}" "$fn"
132 | sort -srn -k1 |sed -E 's;^[0-9]+\t;metalong\t;;'
137 local meta base cbase fm cachename
139 meta="$_DATA/$ITEM/$base/.index/meta"
140 meta_dir "$_DATA/$ITEM/$base"
142 cachename="$(printf '%s\n' "$mode" "$FILTER" "$SEARCH" "$ORDER" |sha1sum)"
143 cachename="$_DATA/$ITEM/.index/${cachename% -}.cache"
145 if [ "$cachename" -nt "$meta" ] 2>&-; then
148 cbase="$(STRING "$base")"
149 grep -axE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' "$meta" \
150 | while read -r fm; do
151 printf '%s %s/%s\n' "${fm% *}" "$cbase" "${fm##* }"
155 | { [ -d "${meta%meta}" ] && tee "$cachename" || cat; }
161 mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf index )"
163 if [ "$mode" = browse ]; then
164 [ "$ITEM" ] && printf 'dir\t..\n'
166 find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
167 ) | cut -d/ -f2- | sort |sed 's;^;dir\t;;'
169 elif [ "$mode" = index ]; then
171 find ./ -path '*/.index/meta'
172 ) | while read -r meta; do
173 list_filemeta "${meta%/.index/meta}"
179 local page i c n end qry
180 page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
181 end=$((page + LISTSIZE))
182 qry="${w_refuri#*\?}"; qry="${qry#p=*&}"
184 printf '[div .itemlist '
187 [ $c -gt $page -a $c -le $end ] && list_item "$i"
191 [ $(( c % LISTSIZE )) -gt 0 ] \
192 && end=$((c / LISTSIZE + 1)) \
193 || end=$((c / LISTSIZE))
195 printf '[div .pagination'
196 for n in $( seq 1 $end ); do
197 c=$(( (n - 1) * LISTSIZE + 1 ))
199 && printf '[a .page .current href="%s" %s]' "?p=${c}&${qry}" "$n" \
200 || printf '[a .page href="%s" %s]' "?p=${c}&${qry}" "$n"
205 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
211 printf ' by %s]' "$ORDER"
213 [meta name="viewport" content="width=device-width"]
214 [link rel=stylesheet href="/cgilite/common.css" ]
215 [link rel=stylesheet href="/style.css" ]
218 [a #t_bookmarks href="#bookmarks" ★]'
221 [a #t_prefs href="#prefs" ⚙]
227 [form method=POST action="?a=multitag"'
230 [ -d "$_DATA/$ITEM/.index" ] && { printf '
237 [ ! -d "$_DATA/$ITEM/.index" ] && { printf '
244 '; } | "$_EXEC/cgilite/html-sh.sed"