if [ "$type" = dir ]; then
name="${meta%% *}";
display="$(HTML "$name")"; link="$(URL "$ITEM/$name")"
- printf '[a .list .dir href="%s" %s]' "${link}?${w_reflink#*?}" "$name"
+ printf '[a .list .dir href="%s" %s]' "${link}?${w_refuri#*\?}" "$name"
return 0
fi
}
list_filemeta(){
- local meta base cbase fm
+ local meta base cbase fm cachename
base="$1"
meta="$_DATA/$ITEM/$base/.index/meta"
- cbase="$(STRING "$base")"
meta_dir "$_DATA/$ITEM/$base"
- grep -axE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' "$meta" \
- | while read -r fm; do
- printf '%s %s/%s\n' "${fm% *}" "$cbase" "${fm##* }"
- done
+ cachename="$(printf '%s\n' "$mode" "$FILTER" "$SEARCH" "$ORDER" |sha1sum)"
+ cachename="$_DATA/$ITEM/.index/${cachename% -}.cache"
+
+ if [ "$cachename" -nt "$meta" ] 2>&-; then
+ cat "$cachename"
+ else
+ cbase="$(STRING "$base")"
+ grep -axE '[0-9]+ [0-9]+ [0-9]+ tags=[^ ]* comment=[^ ]* .+' "$meta" \
+ | while read -r fm; do
+ printf '%s %s/%s\n' "${fm% *}" "$cbase" "${fm##* }"
+ done \
+ | list_filter \
+ | list_order \
+ | { [ -d "${meta%meta}" ] && tee "$cachename" || cat; }
+ fi
}
list_items() {
local mode meta
mode="$(COOKIE mode |grep -m1 -axE 'index|browse' || printf browse )"
-
+
if [ "$mode" = browse ]; then
- [ "$ITEM" ] && printf '..\n'
+ [ "$ITEM" ] && printf 'dir\t..\n'
(cd "$_DATA/$ITEM";
find ./ -type d \! -name .index -mindepth 1 -maxdepth 1 \
) | cut -d/ -f2- | sort |sed 's;^;dir\t;;'
}
list_paginate() {
- local page i c n end
+ local page i c n end qry
page="$(GET p |grep -axE '[0-9]+' || printf 1)"; c=1
end=$((page + LISTSIZE))
+ qry="${w_refuri#*\?}"; qry="${qry#p=*&}"
printf '[div .itemlist '
while read -r i; do
printf '[div .pagination'
for n in $( seq 1 $((c / LISTSIZE + 1)) ); do
printf '[a .page href="%s" %s]' \
- "?p=$(( (n - 1) * LISTSIZE + 1))&$qry" "$n"
+ "?p=$(( (n - 1) * LISTSIZE + 1))&${qry}" "$n"
done
printf ']'
}
printf '
[form method=POST action="?a=multitag"'
list_items \
- | list_filter \
- | list_order \
| list_paginate
printf '
[div #editing