X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=index.cgi;h=c5a814396d2be21513dc0a8e42596556244a1e35;hb=49fc802575556130184fd9a8dc85296ed9ec3835;hp=ac9a110149f9e8b79a992b946b4cd6321c2df85c;hpb=b0674d5fc925ab90c4bea072b0986a43be2471ef;p=httpchat diff --git a/index.cgi b/index.cgi index ac9a110..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)) @@ -37,6 +38,7 @@ yield_page(){ } settings_menu(){ + local nick="$(HTML "${nickname#\?}")" printf ' [form #settings method="POST" action="?settings" [hidden "session_key" "%s"] @@ -46,17 +48,22 @@ settings_menu(){ printf '[p .error %s %s]' "${ERROR%% *}" "$(HTML "${ERROR#.* }")" unset ERROR fi - printf ' + if [ "$NICK_REGISTRATION" != on -o "$nickname" = '?Guest' ]; then + printf ' + [a .section href="#nick" Nickname] + [div #nick .open [input name="nickname" placeholder="%s"][submit "action" "nick" Set Cookie]] + ' "$nick" + else + printf ' [a .section href="#nick" Nickname] [div #nick [input name="nickname" placeholder="%s"][submit "action" "nick" Set Cookie]] - ' "$(HTML "${nickname#\?}")" - [ "$NICK_REGISTRATION" = on -a "$nickname" != '?Guest' ] && printf ' [a .section href="#register" Register Nickname] [div #register [p Registration will set a permanent Cookie in your Browser. Registration requires neither a password, nor an email address.] [input name="regnick" value="%s"][submit "action" "register" Register] - ]' "$(HTML "${nickname#\?}")" + ]' "$nick" "$nick" + fi printf ']' } @@ -91,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 / ;;