+list_items() {
+ mode="$(COOKIE mode |grep -m1 -xE 'index|browse' || printf browse )"
+
+ [ "$mode" = browse -a "$ITEM" ] && printf '..\n'
+
+ if [ "$mode" = browse -a "$ORDER" = Date ]; then
+ list_fs_browse | sort -rn | cut -d/ -f2-
+ elif [ "$mode" = browse -a "$ORDER" = Name ]; then
+ list_fs_browse | sort -k 2 | cut -d/ -f2-
+ elif [ "$mode" = index -a "$ORDER" = Date ]; then
+ list_fs_index | sort -rn | cut -d/ -f2-
+ elif [ "$mode" = index -a "$ORDER" = Name ]; then
+ list_fs_index | sort -k 2 | cut -d/ -f2-
+ elif [ "$mode" = browse -a "$ORDER" = Length ]; then
+ list_browse
+ elif [ "$mode" = index -a "$ORDER" = Length ]; then
+ list_index
+ fi
+}
+
+list_paginate() {
+ 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 ']'
+}
+
+w_tagging(){
+ printf '[div #multitag [input type="hidden" name="ref" value="%s"]' "$(HTML "$REQUEST_URI")"
+ printf '[a href="#" Hide][br]'
+ find "$_DATA/$ITEM" -path '*/.index/meta' \
+ -exec cut -f4 '{}' + \
+ | cut -d= -f2- |tr , '\n' | sort -u \
+ | while read tag; do
+ cat_old="${category}"; category="${tag%%:*}"
+ [ "$category" = "$tag" ] && category="(none)"
+ [ "$cat_old" -a "$cat_old" != "$category" ] && printf ']]'
+ [ "$cat_old" != "$category" ] \
+ && printf '[fieldset [legend %s:][select name="tag" size=4 multiple' $(HTML "$category")
+ printf '[option value="%s" %s]' "$(HTML "$tag")" "$(HTML "${tag#*:}")"
+ done
+ printf ']][fieldset [legend New:][textarea name=newtag\n][button type=Submit Add Tags]]]'
+}
+