X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=home.sh;fp=home.sh;h=bea9940e56af096080dff83507175b8eebe76463;hb=3e39dae6551b82017469fd4b2599a364ac288dba;hp=0000000000000000000000000000000000000000;hpb=5238c404a50861cf1dbbe610d2c4977c048d3b12;p=webpoll diff --git a/home.sh b/home.sh new file mode 100755 index 0000000..bea9940 --- /dev/null +++ b/home.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +if [ "$REQUEST_METHOD" = POST ]; then + case $(POST start) in + date) + id="$(randomid)" + admin="$(randomid)" + file="$_DATA/$id" + # touch "$file" + DBM "$file" add adminkey "$admin" + REDIRECT "$_BASE/$id/$admin" + ;; + options) + id="$(randomid)" + touch "$_DATA/$id" + REDIRECT "$_BASE/$id/newoptions" + ;; + *) REDIRECT "$_BASE/";; + esac +else + yield_page "Start a Poll" "home" <<-EOF + [form method=post + [submit "start" "date" Start a new poll] + $(if [ "$bookmarks" ]; then + printf '[h2 Recent Polls][ul .recent' + for page in $bookmarks; do + page="${page%/*}" + [ -f "$_DATA/$(checkid "$page")" ] \ + && printf '[li [a href="./%s" . %s]]' "$page" "$(pagename "$page" |HTML)" + done + printf ']' + fi) + ] + EOF +fi