From: Paul Hänsch Date: Wed, 6 Jan 2021 22:56:27 +0000 (+0100) Subject: functional front page X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=49fc802575556130184fd9a8dc85296ed9ec3835;p=httpchat functional front page --- diff --git a/index.cgi b/index.cgi index a1b6a08..c5a8143 100755 --- 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 / ;;