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 export MD_HTML="false"
15 if [ "$(which awk)" ]; then
16 markdown() { awk -f "$_EXEC/cgilite/markdown.awk"; }
18 markdown() { busybox awk -f "$_EXEC/cgilite/markdown.awk"; }
21 PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")"
23 #git init "$_DATA" >/dev/null &
26 title="${1:-Webpoll}" page="$2"
27 printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \
28 "Content-Security-Policy: script-src 'none'" \
32 [meta name="viewport" content="width=device-width"]
33 [link rel="stylesheet" type="text/css" href="%s/common.css"]
34 [link rel="stylesheet" type="text/css" href="%s/widgets.css"]
35 [link rel="stylesheet" type="text/css" href="%s/webpoll.css"]
38 ' "$_BASE" "$_BASE" "$_BASE" "$(HTML "$title")" "$page"
41 } |"$_EXEC/cgilite/html-sh.sed" -u
46 local file="$_DATA/$id"
47 if [ -f "$file" ]; then
48 DBM "$file" get title || printf 'Unnamed Page'
55 if [ "$REQUEST_METHOD" = POST ]; then
60 REDIRECT "$_BASE/$id/newdate"
65 REDIRECT "$_BASE/$id/newoptions"
67 *) REDIRECT "$_BASE/";;
70 recent="$(COOKIE pages)"
71 yield_page "Start a Poll" "home" <<-EOF
73 [submit "start" "date" Start a new poll]
74 $(if [ "$recent" ]; then
75 printf '[h2 Recent Polls][ul .recent'
76 for page in $recent; do
77 [ -f "$_DATA/$(checkid "$page")" ] \
78 && printf '[li [a href="./%s" . %s]]' "$page" "$(pagename "$page" |HTML)"
86 page_newdate() { . "$_EXEC"/newdate.sh; }
87 page_poll() { . "$_EXEC/poll.sh"; }
90 /favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';;
91 /common.css) FILE "$_EXEC/cgilite/common.css";;
92 /widgets.css|/webpoll.css) FILE "${_EXEC}/${PATH_INFO}";;
94 /*/newdate) page_newdate;;
96 /[0-9a-zA-Z:=]???????????????) page_poll;;