#!/bin/sh _EXEC=. _DATA=. . "$_EXEC/cgilite/logging.sh" . "$_EXEC/cgilite/cgilite.sh" . "$_EXEC/cgilite/session.sh" . "$_EXEC/cgilite/storage.sh" LOCATION="$(PATH "$PATH_INFO")" LOCATION="${LOCATION#/}" LOCATION="${LOCATION%%/*}" yield_page(){ page="$1" printf 'Content-Type: text/html; charset=utf-8\r\n\r\n' { printf '[html [head [meta name="viewport" content="width=device-width"] [link rel="stylesheet" type="text/css" href="/webchat.css"] [title Webchat] ] [body class="%s" ' "$page" cat printf '] ]' } |"$_EXEC/cgilite/html-sh.sed" -u } settings_menu(){ printf ' [input #check_settings type="checkbox"][label for=check_settings Settings] [div #settings [h1 Settings][label for=check_settings Close] [input #set_nick type=radio name="setting" value="nick" selected][label for=set_nick Nickname] [div [input name="nickname" value="%s"][submit "action" "nick" Set Cookie]] ] ' "$(HTML "${nickname#\?}")" } case ${LOCATION} in \&?*) chatfile="$_DATA/${LOCATION}" . $_EXEC/channel.sh exit 0 ;; @?*) if [ -d "$_DATA/${LOCATION}" ]; then chatfile="$_DATA/${LOCATION}/?${SESSION_ID}" . $_EXEC/channel.sh else REDIRECT / fi exit 0 ;; ~?*) if [ -d "$_DATA/@${LOCATION#~}" ]; then pubinfo="$_DATA/@${LOCATION#~}/pubinfo" page=pubinfo else REDIRECT / fi ;; webchat.css) . "$_EXEC/file.sh" FILE "$_EXEC/webchat.css" exit 0 ;; '') page=front;; *) REDIRECT /;; esac case "$page $(POST action)" in pubinfo\ *);; front\ *) yield_page front <<-EOF Front EOF ;; esac