3 for n in "$@"; do case ${n%%=*} in
4 data) _DATA="${n#data=}";;
5 exec) _EXEC="${n#exec=}";;
6 base) _BASE="${n#base=}";;
7 debug) DEBUG="${n#debug=}";;
10 [ ! "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}"
11 [ ! "${_DATA%/}" ] && _DATA="${PWD%/}" || _DATA="${_DATA%/}"
13 [ "$DEBUG" ] && exec 2>>"$DEBUG"
15 mkdir -p "${_DATA}/cache" "${_DATA}/mappings" "${_DATA}/export" "${_DATA}/lock" "${_DATA}/ical" "${_DATA}/vcard"
19 if [ ! "$DEBUG" ]; then
20 [ "$#" -gt 0 ] && : || cat;
21 elif [ "$#" -gt 0 ]; then
22 printf '%s\n' "$@" >>"$dbg"
28 . "$_EXEC/cgilite/cgilite.sh"
29 . "$_EXEC/cgilite/session.sh"
33 _PATH="$(PATH "/${PATH_INFO}")"
34 _PATH="${_PATH#${_BASE}}"
37 message="$(COOKIE message)"
38 [ "$message" ] && SET_COOKIE 0 message=''
41 if [ "$1" = "$2" ] || [ "$1" -eq "$2" ]; then
42 printf 'checked="checked"'
46 if [ "$1" = "$2" ] || [ "$1" -eq "$2" ]; then
47 printf 'selected="selected"'
52 local class="$1" style="$2"
53 printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
57 [meta name="viewport" content="width=device-width"]
58 [link rel="stylesheet" type="text/css" href="%s/cgilite/common.css"]
59 [link rel="stylesheet" type="text/css" href="%s/style.css"]
60 ' "${_BASE}" "${_BASE}"
61 [ -n "$style" ] && printf '
62 [link rel="stylesheet" type="text/css" href="%s"]
65 ] [body #top class="%s"
67 printf '[ul .menu [li [a "%s/cards/" . %s]][li [a "%s/courses/" . %s]]]' "${_BASE}" "$(l10n cards)" "${_BASE}" "$(l10n courses)"
68 [ "$message" ] && printf '[p #message\n%s\n]' "$(l10n "$message")"
72 | "${_EXEC}/cgilite/html-sh.sed"
76 topdir="/${topdir%%/*}"
79 "/") REDIRECT "${_BASE}/cards/"
81 "/export"/*.pdf) . "$_EXEC/cgilite/file.sh"
82 FILE "${_DATA}/${_PATH}" "application/pdf"
84 "/export"/*) . "$_EXEC/cgilite/file.sh"
85 FILE "${_DATA}/${_PATH}"
88 if [ -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}/index.cgi" ]; then
89 . "${_EXEC}/${_PATH}/index.cgi"
90 elif [ -f "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}" ]; then
92 elif [ -f "${_EXEC}/${_PATH}" -a -r "${_EXEC}/${_PATH}" ]; then
93 . "$_EXEC/cgilite/file.sh"
94 FILE "${_EXEC}/${_PATH}"
95 elif [ -d "${_EXEC}/${topdir}" -a -x "${_EXEC}/${topdir}/index.cgi" ]; then
96 . "${_EXEC}/${topdir}/index.cgi"
98 printf '%s\r\n' 'Status: 404 Not Found' 'Content-Length: 0' ''