]> git.plutz.net Git - webpoll/blob - index.cgi
reset table padding from updated cgilite style
[webpoll] / index.cgi
1 #!/bin/sh
2
3 . "${_EXEC:-${0%/*}}"/cgilite/cgilite.sh
4 . "$_EXEC"/cgilite/session.sh
5 . "$_EXEC"/cgilite/file.sh
6 . "$_EXEC"/cgilite/storage.sh
7 . "$_EXEC"/widgets.sh
8
9 # PATH_INFO="$(PATH "/${PATH_INFO#${_BASE}}")"
10
11 # 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})?)*')"
12 bookmarks=''
13 for bm in $(COOKIE bookmarks); do
14   [ -f "${_DATA}/$(checkid "${bm%/*}")" ] && bookmarks="${bookmarks}${bookmarks:+ }${bm}"
15 done
16 if [ "$bookmarks" ]; then
17   SET_COOKIE +$((182 * 86400)) bookmarks="${bm}" Path="${_BASE}/"
18 fi
19
20 yield_page(){
21   title="${1:-Webpoll}" page="$2"
22   printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \
23                   "Content-Security-Policy: script-src 'none'" \
24                   ''
25   { printf '[html
26     [head
27       [meta name="viewport" content="width=device-width"]
28       [link rel="stylesheet" type="text/css" href="%s/common.css"]
29       [link rel="stylesheet" type="text/css" href="%s/widgets.css"]
30       [link rel="stylesheet" type="text/css" href="%s/webpoll.css"]
31       [title %s]
32     ] [body class="%s"
33   ' "$_BASE" "$_BASE" "$_BASE" "$(HTML "$title")" "$page"
34   cat
35   printf '] ]'
36   } |"$_EXEC/cgilite/html-sh.sed" -u
37 }
38
39 pagename() {
40   local id="$1"
41   local file="$_DATA/$id"
42   if [ -f "$file" ]; then
43     DBM "$file" get title || printf 'Unnamed Page'
44   else
45     return 1;
46   fi
47 }
48
49    page_home() { . "$_EXEC"/home.sh; }
50 page_newdate() { . "$_EXEC"/newdate.sh; }
51    page_poll() { . "$_EXEC"/poll.sh; }
52
53 case ${PATH_INFO} in
54   /favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';;
55   /common.css) FILE "$_EXEC/cgilite/common.css";;
56   /widgets.css|/webpoll.css) FILE "${_EXEC}/${PATH_INFO}";;
57   /) page_home;;
58   /[0-9a-zA-Z:=]???????????????/[0-9a-zA-Z:=]???????????????) page_newdate;;
59   /*/newoptions);;
60   /[0-9a-zA-Z:=]???????????????) page_poll;;
61   /*) page_home;;
62 esac
63
64 exit 0