]> git.plutz.net Git - confetti/blobdiff - index.cgi
drop pasted card info from course functions
[confetti] / index.cgi
index e0bf125ec5c1ad6f4d7501d76cb5c3aaa09ae0f2..093a5c4a90051bb87e717c6619c7cffd6cde997a 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -10,22 +10,46 @@ esac; done
 [ -z "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}"
 
 . "$_EXEC/cgilite/cgilite.sh"
+. "$_EXEC/cgilite/session.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#/}")"
+_PATH="$(PATH "/${PATH_INFO}")"
 ACTION="$(GET a)"
 
-if [ -d "${_EXEC}/${ITEM%%/*}/main.cgi" ]
-  . "${_EXEC}/${ITEM%%/*}/main.cgi"
-elif [ "$ITEM" = "/style.css" ]; then
-  . "$_EXEC/cgilite/file.sh"
-  [ -r "$_DATA/$ITEM" ] && FILE "$_DATA/$ITEM" \
-                        || FILE "$_EXEC/style.css"
-elif [ -d "${_EXEC}/${ITEM%%/*}" -a ! -x "${_EXEC}/$ITEM" ]
+message="$(COOKIE message)"
+[ "$message" ] && SET_COOKIE 0 message=''
+
+checked(){  [ "$1" = "$2" ] || [ "$1" -eq "$2" ] && printf 'checked="checked"' 2>/dev/null; }
+selected(){ [ "$1" = "$2" ] || [ "$1" -eq "$2" ] && printf 'selected="selected"' 2>/dev/null; }
+
+yield_page() {
+  local class="$1" style="$2"
+  printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
+  { printf '
+       [html [head
+          [title Confetti]
+         [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
+    [ "$message" ] && printf '[p #message\n%s\n]' $(l10n "$message")
+    printf '] ]'
+  } \
+  | "${_EXEC}/cgilite/html-sh.sed"
+}
+
+if   [   -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}/index.cgi" ]; then
+  . "${_EXEC}/${_PATH}/index.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"
-  FILE "${_EXEC}/$ITEM"
+  FILE "${_EXEC}/${_PATH}"
 else
   printf 'Status: 404 Not Found\r\nContent-Length: 0\r\n\r\n'
 fi