]> git.plutz.net Git - confetti/blob - index.cgi
stubs for rewrite of courses section
[confetti] / index.cgi
1 #!/bin/sh
2
3 for n in "$@"; do case ${n%%=*} in
4   data) _DATA="${n#data=}";;
5   exec) _exec="${n#exec=}";;
6   noerr) exec 2>&-;;
7 esac; done
8
9 [ -z "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}"
10 [ -z "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}"
11
12 . "$_EXEC/cgilite/cgilite.sh"
13 . "$_EXEC/cgilite/session.sh"
14
15 _PATH="$(PATH "/${PATH_INFO}")"
16 ACTION="$(GET a)"
17
18 message="$(COOKIE message)"
19 [ "$message" ] && SET_COOKIE 0 message=''
20
21 yield_page() {
22   local class="$1" style="$2"
23   printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
24   { printf '
25         [html [head
26           [title Confetti]
27           [meta name="viewport" content="width=device-width"]
28           [link rel="stylesheet" type="text/css" href="/style.css"]
29     '
30     [ -n "$style" ] && printf '
31           [link rel="stylesheet" type="text/css" href="%s"]
32     ' "$style"
33     printf '
34         ] [body class="%s"
35     ' "$class"
36     cat
37     [ "$message" ] && printf '[p #message\n%s\n]' $(l10n "$message")
38     printf '] ]'
39   } \
40   | "${_EXEC}/cgilite/html-sh.sed"
41 }
42
43 if   [   -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}/index.cgi" ]; then
44   . "${_EXEC}/${_PATH}/index.cgi"
45 elif [ ! -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}" ]; then
46   . "${_EXEC}/${_PATH}"
47 elif [ ! -x "${_EXEC}/${_PATH}" -a -r "${_EXEC}/${_PATH}" ]; then
48   . "$_EXEC/cgilite/file.sh"
49   FILE "${_EXEC}/${_PATH}"
50 else
51   printf 'Status: 404 Not Found\r\nContent-Length: 0\r\n\r\n'
52 fi