all repos — honk @ 0859494cc5be157d122e9d7191fb83ef169a69d6

my fork of honk

allow setting a few more custom messages
Ted Unangst tedu@tedunangst.com
Sun, 20 Oct 2019 16:28:09 -0400
commit

0859494cc5be157d122e9d7191fb83ef169a69d6

parent

3e1b9733df9c8ee5aa0c73213734a5fdf20146f6

5 files changed, 13 insertions(+), 10 deletions(-)

jump to
M docs/honk.8docs/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.gohonk.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.htmlviews/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.htmlviews/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.goweb.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)