allow setting a few more custom messages
Ted Unangst tedu@tedunangst.com
Sun, 20 Oct 2019 16:28:09 -0400
5 files changed,
13 insertions(+),
10 deletions(-)
M
docs/honk.8
→
docs/honk.8
@@ -81,14 +81,12 @@ Site CSS may be overridden by creating a
.Pa views/local.css file. .Pp -A custom message me be set by editing the database. +Custom messages may be set by editing the database. (Sorry.) .Dl insert into config values ('servermsg', 'message'); +.Dl insert into config values ('aboutmsg', 'message'); +.Dl insert into config values ('loginmsg', 'message'); .Pp -The -.Pa views/about.html -page doesn't change too frequently. -It should be safe to edit. .Ss ADMIN New users can be added with the .Ic adduser
M
honk.go
→
honk.go
@@ -137,7 +137,9 @@ }
var serverName string var iconName = "icon.png" -var serverMsg = "Things happen." +var serverMsg = template.HTML(`<h2>Things happen.</h2>`) +var aboutMsg = template.HTML(`<h3>What is honk?</h3><p>Honk is amazing!`) +var loginMsg = template.HTML(`<h2>login</h2>`) func ElaborateUnitTests() { }@@ -160,6 +162,8 @@ if dbversion != myVersion {
log.Fatal("incorrect database version. run upgrade.") } getconfig("servermsg", &serverMsg) + getconfig("aboutmsg", &aboutMsg) + getconfig("loginmsg", &loginMsg) getconfig("servername", &serverName) getconfig("usersep", &userSep) getconfig("honksep", &honkSep)
M
views/about.html
→
views/about.html
@@ -1,7 +1,6 @@
{{ template "header.html" . }} <main> <div class="info"> -<h3>What is honk?</h3> -<p>Honk is amazing! +{{ .AboutMsg }} </div> </main>
M
views/login.html
→
views/login.html
@@ -1,8 +1,8 @@
{{ template "header.html" . }} <main> <div class="info"> +{{ .LoginMsg }} <form action="/dologin" method="POST"> - <p><span class="title">login</span> <p><input tabindex=1 type="text" name="username" autocomplete=off> - username <p><input tabindex=1 type="password" name="password"> - password <p><button tabindex=1 name="login" value="login">login</button>
M
web.go
→
web.go
@@ -98,7 +98,7 @@ } else {
userid = u.UserID switch r.URL.Path { case "/atme": - templinfo["PageName"] = "at me!" + templinfo["ServerMessage"] = "at me!" templinfo["PageName"] = "atme" honks = gethonksforme(userid, 0) case "/events":@@ -1586,6 +1586,8 @@ http.ServeFile(w, r, "docs/"+name)
} func servehtml(w http.ResponseWriter, r *http.Request) { templinfo := getInfo(r) + templinfo["AboutMsg"] = aboutMsg + templinfo["LoginMsg"] = loginMsg err := readviews.Execute(w, r.URL.Path[1:]+".html", templinfo) if err != nil { log.Print(err)