X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=poll.sh;h=7ab0e9d58dea7414449584d78dc0046e9fcb48b9;hb=2785c687f62b164d5c08a20481270c66653a6bff;hp=5624284347abf702012712528d37fb126fa39f12;hpb=83fc1c222fd0c89d90e780ef93c5da048da3f5de;p=webpoll
diff --git a/poll.sh b/poll.sh
index 5624284..7ab0e9d 100644
--- a/poll.sh
+++ b/poll.sh
@@ -1,10 +1,15 @@
#!/bin/sh
+. "${_EXEC}/comments.sh"
+
id="$(checkid "${PATH_INFO#/}")"
file="${_DATA}/${id}"
#cancel if poll is invalid
-[ "$id" -a -f "$file" ] || REDIRECT "$_BASE/"
+if [ ! "$id" -o ! -f "$file" ]; then
+ page_home;
+ return 0
+fi
if expr match "$bookmarks" ".*${id}.*" >/dev/null; then
:
@@ -88,8 +93,12 @@ table_poll() {
if [ "$splittimes" = yes -o "$todall" ]; then
printf '[tr .tod [th]'
for time in $timelist; do
- [ "${time#*_}" = "${time}" ] && time="_${time}"
- printf '[th . %s]' "${time#*_}"
+ case $time in
+ *-*-*_*:*) time="${time#*_}";;
+ *-*-*) time="";;
+ *:*);; # time="${time}"
+ esac
+ printf '[th . %s]' "${time}"
done
printf '[th]]\n'
fi
@@ -216,19 +225,24 @@ else
pagename="$(pagename "$id")"
yield_page "$pagename" poll <<-EOF
- [form method=POST
+ [main
[section .description
[h1 .title $(HTML "$pagename")]
$(DBM "$file" get description |markdown)
]
- $(table_poll || printf '[p Poll parameters are invalid]')
- $(if [ "$admin" ]; then
- printf '[section .bookmark You have bookmarked the admin page of this poll: [a href="./%s" modify poll]]' "$(URL ${id}/${admin})"
- elif [ "$bookmarks" ]; then
- printf '[section .bookmark This poll has been bookmarked and is accessible via a link on the front page.]'
- else
- printf '[section .bookmark Polls are accessible only via their URL. You can set a Cookie to bookmark all polls you visit. Bookmarked polls will be listed on the frontpage.
[submit "bookmark" "add" Set Cookie]]'
- fi)
+ [form method=POST
+ $(table_poll || printf '[p Poll parameters are invalid]')
+
+ $(if [ "$admin" ]; then
+ printf '[section .bookmark You have bookmarked the admin page of this poll: [a href="./%s" modify poll]]' "$(URL ${id}/${admin})"
+ elif [ "$bookmarks" ]; then
+ printf '[section .bookmark This poll has been bookmarked and is accessible via a link on the front page.]'
+ else
+ printf '[section .bookmark Polls are accessible only via their URL. You can set a Cookie to bookmark all polls you visit. Bookmarked polls will be listed on the frontpage.
[submit "bookmark" "add" Set Cookie]]'
+ fi)
+ ]
+
+ $(w_comments)
]
EOF
fi