]> git.plutz.net Git - webpoll/blob - index.cgi
avoid accidental octals in math expression, fix week number in january after 52 week...
[webpoll] / index.cgi
1 #!/bin/sh
2
3 _EXEC="${_EXEC:-${0%/*}/}"
4 _DATA="${_DATA:-.}"
5
6 . "$_EXEC"/cgilite/cgilite.sh
7 #. "$_EXEC"/cgilite/session.sh
8 . "$_EXEC"/cgilite/file.sh
9 #. "$_EXEC"/session_lock.sh
10 . "$_EXEC"/widgets.sh
11
12 #git init "$_DATA" >/dev/null &
13
14 yield_page(){
15   title="${1:-Webpoll}" page="$2"
16   printf '%s\r\n' 'Content-Type: text/html; charset=utf-8' \
17                   "Content-Security-Policy: script-src 'none'" \
18                   ''
19   { printf '[html
20     [head
21       [meta name="viewport" content="width=device-width"]
22       [link rel="stylesheet" type="text/css" href="common.css"]
23       [link rel="stylesheet" type="text/css" href="widgets.css"]
24       [title %s]
25     ] [body class="%s"
26   ' "$title" "$page"
27   cat
28   printf '] ]'
29   } |"$_EXEC/cgilite/html-sh.sed" -u
30 }
31
32 case ${PATH_INFO##*/} in
33   favicon.ico) printf '%s\r\n' 'Content-Length: 0' '';;
34   common.css) FILE "$_EXEC/cgilite/common.css";;
35   widgets.css) FILE "$_EXEC/widgets.css";;
36   '') yield_page <<-EOF
37         $(w_month date1 2019-12 24)
38         $(w_month date2 2020-01)
39         $(w_month date3 2020-02)
40         EOF
41     return 0
42     ;;
43 esac
44