. "$_EXEC/cgilite/cgilite.sh"
-FILTER="$(GET filter)"
-ORDER="$(GET o |grep -m1 -axE 'firstname|lastname|bdate' || printf firstname)"
-# LISTSIZE="$(COOKIE pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
-ITEM="$(PATH "${PATH_INFO#/}")"; ITEM="${ITEM#/}"
+_PATH="$(PATH "/${PATH_INFO}")"
ACTION="$(GET a)"
-if [ -d "${_EXEC}/${ITEM%%/*}" -a -x "${_EXEC}/${ITEM%%/*}/main.cgi" ]; then
- . "${_EXEC}/${ITEM%%/*}/main.cgi"
-elif [ "$ITEM" = "style.css" ]; then
+yield_page() {
+ local class="$1" style="$2"
+ printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
+ { printf '
+ [html [head
+ [meta name="viewport" content="width=device-width"]
+ [link rel="stylesheet" type="text/css" href="/style.css"]
+ '
+ [ -n "$style" ] && printf '
+ [link rel="stylesheet" type="text/css" href="%s"]
+ ' "$style"
+ printf '
+ ] [body class="%s"
+ ' "$class"
+ cat
+ printf '] ]'
+ } \
+ | "${_EXEC}/cgilite/html-sh.sed"
+}
+
+if [ -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}/main.cgi" ]; then
+ . "${_EXEC}/${_PATH}/main.cgi"
+elif [ ! -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}" ]; then
+ . "${_EXEC}/${_PATH}"
+elif [ ! -x "${_EXEC}/${_PATH}" -a -r "${_EXEC}/${_PATH}" ]; then
. "$_EXEC/cgilite/file.sh"
- [ -r "$_DATA/$ITEM" ] && FILE "$_DATA/$ITEM" \
- || FILE "$_EXEC/style.css"
-# elif [ -d "${_EXEC}/${ITEM%%/*}" -a ! -x "${_EXEC}/$ITEM" ]; then
-# . "$_EXEC/cgilite/file.sh"
-# FILE "${_EXEC}/$ITEM"
+ FILE "${_EXEC}/${_PATH}"
else
printf 'Status: 404 Not Found\r\nContent-Length: 0\r\n\r\n'
fi