3 _EXEC="${_EXEC:-${0%/*}/}"
7 . "$_EXEC"/cgilite/cgilite.sh
8 . "$_EXEC"/cgilite/session.sh
9 . "$_EXEC"/cgilite/file.sh
10 . "$_EXEC"/cgilite/storage.sh
11 #. "$_EXEC"/session_lock.sh
14 PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")"
16 #git init "$_DATA" >/dev/null &
19 title="${1:-Webpoll}" page="$2"
20 printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \
21 "Content-Security-Policy: script-src 'none'" \
25 [meta name="viewport" content="width=device-width"]
26 [link rel="stylesheet" type="text/css" href="%s/common.css"]
27 [link rel="stylesheet" type="text/css" href="%s/widgets.css"]
28 [link rel="stylesheet" type="text/css" href="%s/webpoll.css"]
31 ' "$_BASE" "$_BASE" "$_BASE" "$title" "$page"
34 } |"$_EXEC/cgilite/html-sh.sed" -u
39 local file="$_DATA/$id"
40 if [ -f "$file" ]; then
41 DBM "$file" get title || printf 'Unnamed Page'
48 if [ "$REQUEST_METHOD" = POST ]; then
53 REDIRECT "$_BASE/$id/newdate"
58 REDIRECT "$_BASE/$id/newoptions"
60 *) REDIRECT "$_BASE/";;
63 recent="$(COOKIE pages)"
64 yield_page "Start a Poll" "home" <<-EOF
66 [submit "start" "date" Start a new poll]
67 $(if [ "$recent" ]; then
68 printf '[h2 Recent Polls][ul .recent'
69 for page in $recent; do
70 [ -f "$_DATA/$(checkid "$page")" ] \
71 && printf '[li [a href="./%s" . %s]]' "$page" "$(pagename "$page" |HTML)"
79 page_newdate() { . $_EXEC/newdate.sh; }
82 /favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';;
83 /common.css) FILE "$_EXEC/cgilite/common.css";;
84 /widgets.css|/webpoll.css) FILE "${_EXEC}/${PATH_INFO}";;
86 /*/newdate) page_newdate;;