3 for n in "$@"; do case ${n%%=*} in
4 data) _DATA="${n#data=}";;
5 exec) _EXEC="${n#exec=}";;
6 debug) DEBUG="${n#debug=}";;
9 [ ! "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}"
10 [ ! "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}"
11 [ "$DEBUG" ] && exec 2>>"$DEBUG"
13 mkdir -p "${_DATA}/cache" "${_DATA}/mappings" "${_DATA}/export" "${_DATA}/lock" "${_DATA}/ical" "${_DATA}/vcard"
17 if [ ! "$DEBUG" ]; then
18 [ "$#" -gt 0 ] && : || cat;
19 elif [ "$#" -gt 0 ]; then
20 printf '%s\n' "$@" >>"$dbg"
26 . "$_EXEC/cgilite/cgilite.sh"
27 . "$_EXEC/cgilite/session.sh"
31 _PATH="$(PATH "/${PATH_INFO}")"
34 message="$(COOKIE message)"
35 [ "$message" ] && SET_COOKIE 0 message=''
38 if [ "$1" = "$2" ] || [ "$1" -eq "$2" ]; then
39 printf 'checked="checked"'
43 if [ "$1" = "$2" ] || [ "$1" -eq "$2" ]; then
44 printf 'selected="selected"'
49 local class="$1" style="$2"
50 printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
54 [meta name="viewport" content="width=device-width"]
55 [link rel="stylesheet" type="text/css" href="/style.css"]
57 [ -n "$style" ] && printf '
58 [link rel="stylesheet" type="text/css" href="%s"]
61 ] [body #top class="%s"
63 printf '[ul .menu [li [a "/cards/" . %s]][li [a "/courses/" . %s]]]' "$(l10n cards)" "$(l10n courses)"
64 [ "$message" ] && printf '[p #message\n%s\n]' "$(l10n "$message")"
68 | "${_EXEC}/cgilite/html-sh.sed"
72 topdir="/${topdir%%/*}"
77 /export/*.pdf) . "$_EXEC/cgilite/file.sh"
78 FILE "${_DATA}/${_PATH}" "application/pdf"
80 /export/*) . "$_EXEC/cgilite/file.sh"
81 FILE "${_DATA}/${_PATH}"
84 if [ -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}/index.cgi" ]; then
85 . "${_EXEC}/${_PATH}/index.cgi"
86 elif [ -f "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}" ]; then
88 elif [ -f "${_EXEC}/${_PATH}" -a -r "${_EXEC}/${_PATH}" ]; then
89 . "$_EXEC/cgilite/file.sh"
90 FILE "${_EXEC}/${_PATH}"
91 elif [ -d "${_EXEC}/${topdir}" -a -x "${_EXEC}/${topdir}/index.cgi" ]; then
92 . "${_EXEC}/${topdir}/index.cgi"
94 printf '%s\r\n' 'Status: 404 Not Found' 'Content-Length: 0' ''