settings_menu(){
printf '
- [form #settings method="POST" action="?"
+ [form #settings method="POST" action="?settings"
[hidden "session_key" "%s"]
- [h1 Settings][a .settings href="?" Close]'
+ [h1 Settings][a .settings href="?" Close]
+ ' "$SESSION_KEY"
+ if [ "$ERROR" ]; then
+ printf '[p .error %s %s]' "${ERROR%% *}" "$(HTML "${ERROR#.* }")"
+ unset ERROR
+ fi
printf '
[a .section href="#nick" Nickname]
[div #nick [input name="nickname" value="%s"][submit "action" "nick" Set Cookie]]
- ' "$SESSION_KEY" "$(HTML "${nickname#\?}")"
+ ' "$(HTML "${nickname#\?}")"
printf '
[a .section href="#register" Register Nickname]
[div #register
if [ -d "$_DATA/@${LOCATION#~}" ]; then
pubinfo="$_DATA/@${LOCATION#~}/pubinfo"
else
+ # ToDo Edit / Display of public user information
REDIRECT /
fi
;;
# Remove trailing CR, which may have been added by browser
s;\r$;;;
# Collapse white spaces
- s;[\r\t\n ]+; ;;
+ s;[\r\t\n ]+; ;g;
# Remove starting and trailing white spaces
s;^ ;;; s; $;;;
# Usernames starting with & # ? @ + will be invalid
SET_COOKIE +1209600 "nick=$(POST nickname |URL)"
REDIRECT "$(URL "/$LOCATION")"
else
- # ToDo: Return Error Message
- REDIRECT "$(URL "/$LOCATION")?settings#nick"
+ export ERROR=".nick This nickname has already been registered elsewhere"
fi
;;
register)
SET_COOKIE +"$((86400 * 365))" "nick=$(URL "${regnick}")"
REDIRECT "$(URL "/$LOCATION")"
else
- # ToDo: Return Error Message
- REDIRECT "$(URL "/$LOCATION")?settings#register"
+ export ERROR=".register This nickname has already been registered elsewhere"
fi
;;
esac
content: "x";
padding: 0 1ex;
}
+#settings .error {
+ padding: 1ex 1ex .5ex 1ex;
+ background-color: #FCC;
+ font-weight: bold;
+}
#settings a.section {
display: block;
font-weight: bold;
overflow: hidden;
transition: max-height .5s;
}
+#settings .error.nick ~ a.section + #nick,
+#settings .error.register ~ a.section + #register,
#settings a.section + *:target {
max-height: 20ex;
padding: 1ex 1ex .5ex 1ex;