+ find ./ -path '*/.index/meta'
+ ) | while meta="$(line)"; do
+ list_filemeta "${meta%/.index/meta}"
+ done
+}
+
+list_items() {
+ local mode
+ mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )"
+
+ [ "$mode" = browse -a "$ITEM" ] && printf '..\n'
+
+ if [ "$mode" = browse -a "$ORDER" = Date ]; then
+ list_directories
+ list_filemeta . |cut -f2- \
+ | xargs -rd'\n' stat -c '%Y %n' \
+ | sort -rn |cut -d/ -f2-
+ elif [ "$mode" = browse -a "$ORDER" = Name ]; then
+ list_directories
+ list_filemeta . \
+ | sort -k 2 |cut -d/ -f2-
+ elif [ "$mode" = index -a "$ORDER" = Date ]; then
+ list_index |cut -f2- \
+ | xargs -rd'\n' stat -c '%Y %n' \
+ | sort -rn | cut -d/ -f2-
+ elif [ "$mode" = index -a "$ORDER" = Name ]; then
+ list_index | sort -k 2 | cut -d/ -f2-
+ elif [ "$mode" = browse -a "$ORDER" = Length ]; then
+ list_directories
+ list_filemeta . \
+ | sort -n |cut -d/ -f2-
+ elif [ "$mode" = index -a "$ORDER" = Length ]; then
+ list_index \
+ | sort -n |cut -d/ -f2-
+ fi
+}
+
+list_paginate() {
+ local page i c n
+ page="$(GET p |grep -xE '[0-9]+' || printf 1)"
+
+ printf '[div .itemlist '
+ while i="$(line)"; do
+ c=$((${c-0} + 1))
+ if [ $c -lt $page ]; then
+ true
+ elif [ $c -lt $((LISTSIZE + page)) ]; then
+ list_item "$i"
+ fi
+ done
+ printf ']'
+
+ printf '[div .pagination'
+ for n in $(seq 1 $((c / LISTSIZE + 1)) ); do
+ printf '[a .page href="%s" %s]' \
+ "?p=$(( (n - 1) * LISTSIZE + 1))" "$n"
+ done
+ printf ']'