From 47bdc1256bfdb0c3c9043911f4dbc6021196929f Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sun, 20 Oct 2019 16:28:09 -0400 Subject: [PATCH] allow setting a few more custom messages --- docs/honk.8 | 8 +++----- honk.go | 6 +++++- views/about.html | 3 +-- views/login.html | 2 +- web.go | 4 +++- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/docs/honk.8 b/docs/honk.8 index 92b8ca7..6d69578 100644 --- a/docs/honk.8 +++ b/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 diff --git a/honk.go b/honk.go index 09cfada..1bd6da0 100644 --- a/honk.go +++ b/honk.go @@ -137,7 +137,9 @@ type Honker struct { var serverName string var iconName = "icon.png" -var serverMsg = "Things happen." +var serverMsg = template.HTML(`

Things happen.

`) +var aboutMsg = template.HTML(`

What is honk?

Honk is amazing!`) +var loginMsg = template.HTML(`

login

`) func ElaborateUnitTests() { } @@ -160,6 +162,8 @@ func main() { 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) diff --git a/views/about.html b/views/about.html index 1a3bd1b..4c7cc92 100644 --- a/views/about.html +++ b/views/about.html @@ -1,7 +1,6 @@ {{ template "header.html" . }}
-

What is honk?

-

Honk is amazing! +{{ .AboutMsg }}

diff --git a/views/login.html b/views/login.html index 999d97b..b10c008 100644 --- a/views/login.html +++ b/views/login.html @@ -1,8 +1,8 @@ {{ template "header.html" . }}
+{{ .LoginMsg }}
-

login

- username

- password

diff --git a/web.go b/web.go index da937e9..930fecd 100644 --- a/web.go +++ b/web.go @@ -98,7 +98,7 @@ func homepage(w http.ResponseWriter, r *http.Request) { 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 @@ func servehelp(w http.ResponseWriter, r *http.Request) { } 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)