]> git.plutz.net Git - webpoll/blob - home.sh
reset table padding from updated cgilite style
[webpoll] / home.sh
1 #!/bin/sh
2
3 if [ "$REQUEST_METHOD" = POST ]; then
4   case $(POST start) in
5     date)
6       id="$(randomid)"
7       admin="$(randomid)"
8       file="$_DATA/$id"
9       # touch "$file"
10       DBM "$file" add adminkey "$admin"
11       REDIRECT "$_BASE/$id/$admin"
12       ;;
13     options)
14       id="$(randomid)"
15       touch "$_DATA/$id"
16       REDIRECT "$_BASE/$id/newoptions"
17       ;;
18     *) REDIRECT "$_BASE/";;
19   esac
20 else
21   [ "$PATH_INFO" != / ] && printf 'Status: 404 Not Found\r\n'
22   yield_page "Start a Poll" "home" <<-EOF
23         [main [form method=post
24           [submit "start" "date" Start a new poll]
25           $(if [ "$bookmarks" ]; then
26             printf '[h2 Recent Polls][ul .recent'
27             for page in $bookmarks; do
28               page="${page%/*}"
29               [ -f "$_DATA/$(checkid "$page")" ] \
30               && printf '[li [a href="./%s" . %s]]' "$page" "$(pagename "$page" |HTML)"
31             done
32             printf ']'
33           fi)
34         ]]
35         EOF
36 fi