]> git.plutz.net Git - httpchat/commitdiff
functional front page
authorPaul Hänsch <paul@plutz.net>
Wed, 6 Jan 2021 22:56:27 +0000 (23:56 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 6 Jan 2021 22:56:27 +0000 (23:56 +0100)
index.cgi

index a1b6a08689c823dc75568902eb8c1d1bfad07df0..c5a814396d2be21513dc0a8e42596556244a1e35 100755 (executable)
--- a/index.cgi
+++ b/index.cgi
@@ -13,6 +13,7 @@ LOCATION="${LOCATION#/}"
 LOCATION="${LOCATION%%/*}"
 
 NICK_REGISTRATION="${NICK_REGISTRATION:-on}"
+CHANNEL_LIST="${ALLOW_LIST:-off}"
 
 # ToDo:
 # COOKIE_NICK_EXPIRE=$((86400 * 14))
@@ -97,9 +98,24 @@ case ${LOCATION} in
       REDIRECT /
     fi
     ;;
-  '') yield_page front <<-EOF
-       Front
+  '')
+    if [ "$(POST action)" = join ]; then
+      REDIRECT "./&$(POST channel |URL)"
+    else
+      yield_page front <<-EOF
+       [h1 Webchat]
+       [form method=POST
+         [label Join Channel: [input name=channel value='' placeholder="Name of Channel"][button type=submit name=action value=join Join]]
+       ]
+       $(if [ "$CHANNEL_LIST" = on ]; then
+         printf '[h2 Existing channels][div #channels'
+         $(for chan in "$_DATA/&"*; do
+           printf '[a href="./%s" . %s]\n' "$(HTML "${chan##*/}")" "$(HTML "${chan##*/}")"
+         done)
+         printf ']'
+       fi)
        EOF
+    fi
     ;;
   *) REDIRECT /
     ;;