]> git.plutz.net Git - webpoll/blobdiff - poll.sh
reset table padding from updated cgilite style
[webpoll] / poll.sh
diff --git a/poll.sh b/poll.sh
index de5b614c74321c93521a6ac0e1bb3c2e08f45d05..8e55600ed85ecabf7b766e88f6e930cbd415c64a 100644 (file)
--- a/poll.sh
+++ b/poll.sh
@@ -1,10 +1,16 @@
 #!/bin/sh
 
+. "${_EXEC}/comments.sh"
+. "${_EXEC}/languages.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
   :
@@ -69,6 +75,8 @@ table_poll() {
   local edit="$(GET edit)"
   local time date span name yes no maybe yc nc mc
 
+  table_date="${table_date:-"%A <br/> %B %_d, %Y"}"
+
   [ "$timelist" ] || return 1
 
   printf '[table .poll [thead\n'
@@ -79,7 +87,7 @@ table_poll() {
       span=0; for time in $timelist; do case $time in
         ${date}*) span=$((span + 1));;
       esac; done
-      date -d "$date" +"[th colspan=\"${span}\" . %A <br/> %B %_d, %Y]";
+      date -d "$date" +"[th colspan=\"${span}\" . ${table_date}]";
     done
     printf '[th]]\n'
   fi
@@ -220,19 +228,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.<br/> [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.<br/> [submit "bookmark" "add" Set Cookie]]'
+            fi)
+         ]
+
+          $(w_comments)
        ]
        EOF
 fi