X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=060d7dcc0670432a98b0ea97dcb671a64ae8288f;hb=HEAD;hp=51a7c0f312995245e071a5b7e97ea535b73d82e0;hpb=2cfdff52842b5c1ac1a4c42289f5bc67328d01d1;p=webpoll diff --git a/index.cgi b/index.cgi index 51a7c0f..060d7dc 100755 --- a/index.cgi +++ b/index.cgi @@ -1,15 +1,21 @@ #!/bin/sh -_EXEC="${_EXEC:-${0%/*}/}" -_DATA="${_DATA:-.}" - -. "$_EXEC"/cgilite/cgilite.sh -#. "$_EXEC"/cgilite/session.sh +. "${_EXEC:-${0%/*}}"/cgilite/cgilite.sh +. "$_EXEC"/cgilite/session.sh . "$_EXEC"/cgilite/file.sh -#. "$_EXEC"/session_lock.sh +. "$_EXEC"/cgilite/storage.sh . "$_EXEC"/widgets.sh -#git init "$_DATA" >/dev/null & +# PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")" + +# bookmarks_cookie="$(COOKIE bookmarks |grep -xE '[0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?( [0-9a-zA-Z:=]{16}(/[0-9a-zA-Z:=]{16})?)*')" +bookmarks='' +for bm in $(COOKIE bookmarks); do + [ -f "${_DATA}/$(checkid "${bm%/*}")" ] && bookmarks="${bookmarks}${bookmarks:+ }${bm}" +done +if [ "$bookmarks" ]; then + SET_COOKIE +$((182 * 86400)) bookmarks="${bm}" Path="${_BASE}/" +fi yield_page(){ title="${1:-Webpoll}" page="$2" @@ -19,26 +25,40 @@ yield_page(){ { printf '[html [head [meta name="viewport" content="width=device-width"] - [link rel="stylesheet" type="text/css" href="common.css"] - [link rel="stylesheet" type="text/css" href="widgets.css"] + [link rel="stylesheet" type="text/css" href="%s/common.css"] + [link rel="stylesheet" type="text/css" href="%s/widgets.css"] + [link rel="stylesheet" type="text/css" href="%s/webpoll.css"] [title %s] ] [body class="%s" - ' "$title" "$page" + ' "$_BASE" "$_BASE" "$_BASE" "$(HTML "$title")" "$page" cat printf '] ]' } |"$_EXEC/cgilite/html-sh.sed" -u } -case ${PATH_INFO##*/} in - favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';; - common.css) FILE "$_EXEC/cgilite/common.css";; - widgets.css) FILE "$_EXEC/widgets.css";; - '') yield_page <<-EOF - $(w_month date1 2019-12 24) - $(w_month date2 2020-01) - $(w_month date3 2020-02) - EOF - return 0 - ;; +pagename() { + local id="$1" + local file="$_DATA/$id" + if [ -f "$file" ]; then + DBM "$file" get title || printf 'Unnamed Page' + else + return 1; + fi +} + + page_home() { . "$_EXEC"/home.sh; } +page_newdate() { . "$_EXEC"/newdate.sh; } + page_poll() { . "$_EXEC"/poll.sh; } + +case ${PATH_INFO} in + /favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';; + /common.css) FILE "$_EXEC/cgilite/common.css";; + /widgets.css|/webpoll.css) FILE "${_EXEC}/${PATH_INFO}";; + /) page_home;; + /[0-9a-zA-Z:=]???????????????/[0-9a-zA-Z:=]???????????????) page_newdate;; + /*/newoptions);; + /[0-9a-zA-Z:=]???????????????) page_poll;; + /*) page_home;; esac +exit 0