--- /dev/null
+#!/bin/sh
+
+[ -z "${_EXEC%/}" ] && _EXEC=. || _EXEC="${_DATA%/}"
+[ -z "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}"
+
+. "$_EXEC/cgilite/cgilite.sh"
+. "$_EXEC/widgets.sh"
+
+filter="$(GET f)"
+search="$(GET s)"
+order="$(GET o |grep -m1 -xE 'Date|Name|Length' || printf Name)"
+pagesize="$(COOKIE pagesize |grep -m1 -xE '[1-9][0-9]*' || printf 50)"
+
+item="$(printf %s "${PATH_INFO#/}" |sed -r ':X /(^|\/)\.\.($|\/)/s;(^|[^/]*/)..(/|$);;; tX;')"
+
+case $(GET a) in
+ setprefs)
+ printf 'Status: 303 See Other\r\n'
+ SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -xE '[1-9][0-9]*' || printf 50)"
+ SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -xE 'yes' || printf no)"
+ printf 'Location: %s\r\n\r\n' "$(POST ref)"
+ ;;
+esac
+
+if [ -f "$_DATA/$item" ]; then
+ case $(GET a) in
+ tag)
+ ;;
+ download)
+ ;;
+ thumbnail)
+ ;;
+ delete)
+ ;;
+ *)
+ ;;
+ esac
+elif [ -d "$_DATA/$item" ]; then
+ case $(GET a) in
+ multitag)
+ ;;
+ *) printf 'Content-Type: text/html;charset=utf-8\r\n\r\n'
+ "$_EXEC/cgilite/html-sh.sed" <<-EOF
+ [!DOCTYPE HTML]
+ [html [head [title Listing]
+ ] [body
+ $(w_search) $(w_prefs)
+ ] ]
+ EOF
+ exit 0
+ ;;
+ esac
+else
+ printf 'Status: 404 Not Found\r\n\r\n'
+ exit 0
+fi
--- /dev/null
+#!/bin/sh
+
+w_search(){
+ printf '
+ [form method=GET action=?
+ [select name=o size=1
+ [option disabled=disabled Order By]
+ [option value=Name Name]
+ [option value=Date Date]
+ [option value=Length Length]
+ ]
+ [input name=s placeholder=Search value="%s"]
+ ]
+ ' \
+ "$(HTML "$search")"
+}
+
+w_prefs(){
+ printf '
+ [form method=POST action=?a=setprefs
+ [hidden "ref" "%s"]
+ [label for=prefs_ps Pagesize]
+ [input type=number name=pagesize value="%s"]
+ [checkbox "fakemp4" "yes" #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file ending]
+ [submit "store" "store" Set Cookie]
+ ]
+ ' \
+ "$(HTML "$REQUEST_URI")" "$pagesize"
+}