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#\~}" ] || continue
55 [ "${f#\~}" = "$f" ] \
56 && fex="/(\ttags=([^\t]*,)?)(${f})((,[^\t]*)?\t)/{${fex}}" \
57 || fex="/(\ttags=([^\t]*,)?)(${f#\~})((,[^\t]*)?\t)/d; ${fex}"
58 printf '%s\n' "${fex}"
65 [ ! "${sn%%*/*}" ] && base="${sn%/*}" || base=.
66 file="$(printf '%s' "$_DATA/$ITEM/$sn".*)"
68 [ -e "$_DATA/$ITEM/$base/${file}" ] \
69 && printf '%s\n' "${base}/${file}"
73 if [ "$FILTER" ]; then
74 debug "FEX:" "$list_fex"
76 elif [ "${SEARCH#!}" != "${SEARCH}" ]; then
77 grep -aviEe "$(STRING "${SEARCH}" \
78 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
79 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
81 elif [ "${SEARCH}" ]; then
82 grep -aiEe "$(STRING "${SEARCH}" \
83 | sed -E ':x s;((^|[^\\])(\\\\)*)\+;\1 ;g; tx;
84 s;((^|[^\\])(\\\\)*)\\\+;\1+;g;
92 local fm fn fn al length ln h w t c name buffer l
94 if [ $ORDER = Name ]; then
95 sort -k6 |sed 's;^;metashort\t;;'
96 elif [ $ORDER = Group ]; then
99 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;;
101 s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^ 0-9]*)([0-9]+)(.*)$;\1\r\3 \2;;
103 | { sort -n -k7 -k8 -k9 -k10 -k11 |sort -s -k6,6 ; echo '0 0 0 tags= comment= _'; } \
104 | while read -r length h w t c name; do
105 if [ "${ln%% *}" = "${name%% *}" ]; then
107 buffer="${buffer}${BR}$length $h $w $t $c $name"
109 printf '%s\n' "$buffer" |while read -r l; do
110 [ "$l" ] && printf '%s %s\n' "$al" "$l"
113 buffer="$length $h $w $t $c $name"
117 | sort -s -n -k1,1 |sed -E 's;^[0-9]+\t;metashort\t;;' \
118 | sed -E ':X s;^([^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\t]+\t[^\r]*)\r([^ ]*) ([^ ]+)( .*)?$;\1\3\2\4;; tX'
119 elif [ $ORDER = Length ]; then
120 sort -sn -k1 |sed 's;^;metashort\t;;'
121 elif [ $ORDER = Date ]; then
124 fn="$(list_fullname "$(UNSTRING "${sn%${CR}}")")"
125 printf '%i %s %s\n' \
126 "$(stat -c %Y "$fn")" "${fm% *}" "$fn"
128 | sort -srn -k1 |sed -E 's;^[0-9]+\t;metalong\t;;'
133 local meta base cbase fm cachename
135 meta="$_DATA/$ITEM/$base/.index/meta"
136 meta_dir "$_DATA/$ITEM/$base"
138 cachename="$(printf '%s\n' "$mode" "$FILTER" "$SEARCH" "$ORDER" |sha1sum)"
139 cachename="$_DATA/$ITEM/.index/${cachename% -}.cache"
141 if [ "$cachename" -nt "$meta" ] 2>&-; then
144 cbase="$(STRING "$base")"
145 grep -axE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' "$meta" \
146 | while read -r fm; do
147 printf '%s %s/%s\n' "${fm% *}" "$cbase" "${fm##* }"
151 | { [ -d "${meta%meta}" ] && tee "$cachename" || cat; }
157 mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf index )"
159 if [ "$mode" = browse ]; then
160 [ "$ITEM" ] && printf 'dir\t..\n'
162 find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
163 ) | cut -d/ -f2- | sort |sed 's;^;dir\t;;'
165 elif [ "$mode" = index ]; then
167 find ./ -path '*/.index/meta'
168 ) | while read -r meta; do
169 list_filemeta "${meta%/.index/meta}"
175 local page i c n end qry
176 page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
177 end=$((page + LISTSIZE))
178 qry="${w_refuri#*\?}"; qry="${qry#p=*&}"
180 printf '[div .itemlist '
183 [ $c -gt $page -a $c -le $end ] && list_item "$i"
187 [ $(( c % LISTSIZE )) -gt 0 ] \
188 && end=$((c / LISTSIZE + 1)) \
189 || end=$((c / LISTSIZE))
191 printf '[div .pagination'
192 for n in $( seq 1 $end ); do
193 c=$(( (n - 1) * LISTSIZE + 1 ))
195 && printf '[a .page .current href="%s" %s]' "?p=${c}&${qry}" "$n" \
196 || printf '[a .page href="%s" %s]' "?p=${c}&${qry}" "$n"
201 printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
207 printf ' by %s]' "$ORDER"
209 [meta name="viewport" content="width=device-width"]
210 [link rel=stylesheet href="/style.css" ]
213 [a #t_bookmarks href="#bookmarks" ★]'
216 [a #t_avsearch href="#advsearch" Advanced]
217 [a #t_prefs href="#prefs" ⚙]
223 [form method=POST action="?a=multitag"'
226 [ -d "$_DATA/$ITEM/.index" ] && { printf '
233 [ ! -d "$_DATA/$ITEM/.index" ] && { printf '
240 '; } | "$_EXEC/cgilite/html-sh.sed"