From 9a3463f307e0e4eb3d8f80c3e732cfa425adcb86 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Fri, 14 May 2021 10:45:55 +0200 Subject: [PATCH] make therapies dir at startup, stub support for base location --- index.cgi | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/index.cgi b/index.cgi index 138ae74..841917d 100755 --- a/index.cgi +++ b/index.cgi @@ -3,14 +3,16 @@ for n in "$@"; do case ${n%%=*} in data) _DATA="${n#data=}";; exec) _EXEC="${n#exec=}";; + base) _BASE="${n#base=}";; debug) DEBUG="${n#debug=}";; esac; done [ ! "${_EXEC%/}" ] && _EXEC="$(realpath "${0%/*}")" || _EXEC="${_EXEC%/}" -[ ! "${_DATA%/}" ] && _DATA=. || _DATA="${_DATA%/}" +[ ! "${_DATA%/}" ] && _DATA="${PWD%/}" || _DATA="${_DATA%/}" +_BASE="${_BASE%/}" [ "$DEBUG" ] && exec 2>>"$DEBUG" -mkdir -p "${_DATA}/cache" "${_DATA}/mappings" "${_DATA}/export" "${_DATA}/lock" "${_DATA}/ical" "${_DATA}/vcard" +mkdir -p "${_DATA}/cache" "${_DATA}/mappings" "${_DATA}/export" "${_DATA}/lock" "${_DATA}/ical" "${_DATA}/vcard" "${_DATA}/therapies" . "$_EXEC/cgilite/cgilite.sh" . "$_EXEC/cgilite/session.sh" @@ -18,6 +20,7 @@ mkdir -p "${_DATA}/cache" "${_DATA}/mappings" "${_DATA}/export" "${_DATA}/lock" . "$_EXEC/l10n.sh" _PATH="$(PATH "/${PATH_INFO}")" +_PATH="${_PATH#${_BASE}}" ACTION="$(GET a)" message="$(COOKIE message)" @@ -39,11 +42,11 @@ yield_page() { printf 'Content-Type: text/html; charset=utf-8\r\n\r\n' { printf ' [html [head - [title Lobster] + [title Lobster] [meta name="viewport" content="width=device-width"] - [link rel="stylesheet" type="text/css" href="/cgilite/common.css"] - [link rel="stylesheet" type="text/css" href="/style.css"] - ' + [link rel="stylesheet" type="text/css" href="%s/cgilite/common.css"] + [link rel="stylesheet" type="text/css" href="%s/style.css"] + ' "${_BASE}" "${_BASE}" [ -n "$style" ] && printf ' [link rel="stylesheet" type="text/css" href="%s"] ' "$style" @@ -61,7 +64,7 @@ topdir="${_PATH#/}" topdir="/${topdir%%/*}" case ${_PATH} in - /) REDIRECT /cards/ + "/") REDIRECT "${_BASE}/cards/" ;; *) if [ -d "${_EXEC}/${_PATH}" -a -x "${_EXEC}/${_PATH}/index.cgi" ]; then -- 2.39.2