commit 6f8050a58a8872cdf4ad3fb5c6ef545af3bbe68c
parent 15be768d395a9fe4d28a2f72841b719ef3ef95ce
Author: Alexander Cobleigh <cblgh@cblgh.org>
Date: Thu, 13 Jan 2022 19:15:10 +0100
Merge pull request #20 from ftrvxmtrx/post-latest
add #bottom ref to threads
Diffstat:
3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/html/head.html b/html/head.html
@@ -115,6 +115,9 @@
</a>
<nav>
<ul type="menu">
+ {{ if .QuickNav }}
+ <li><a href="#bottom">bottom</a></li>
+ {{end}}
<li><a href="/about">about</a></li>
{{ if .LoggedIn }}
<li><a href="/logout">logout</a></li>
diff --git a/html/thread.html b/html/thread.html
@@ -32,7 +32,7 @@
{{ if .LoggedIn }}
<section aria-label="Respond into this thread">
<form method="POST">
- <div class="post-container" >
+ <div id="bottom" class="post-container" >
<label class="visually-hidden" for="content">Your answer:</label>
<textarea required name="content" id="content" placeholder="Tabula rasa"></textarea>
<button type="submit">Post</button>
diff --git a/server/server.go b/server/server.go
@@ -23,6 +23,7 @@ import (
type TemplateData struct {
Data interface{}
+ QuickNav bool
LoggedIn bool // TODO (2022-01-09): put this in a middleware || template function or sth?
LoggedInID int
Title string
@@ -190,8 +191,12 @@ func (h RequestHandler) ThreadRoute(res http.ResponseWriter, req *http.Request)
for i, post := range thread {
thread[i].Content = util.Markup(post.Content)
}
- title := thread[0].ThreadTitle
- view := TemplateData{Data: ThreadData{title, thread, req.URL.Path}, LoggedIn: loggedIn, LoggedInID: userid, Title: title}
+ data := ThreadData{Posts: thread, ThreadURL: req.URL.Path}
+ view := TemplateData{Data: &data, QuickNav: true, LoggedIn: loggedIn, LoggedInID: userid}
+ if len(thread) > 0 {
+ data.Title = thread[0].ThreadTitle
+ view.Title = data.Title
+ }
h.renderView(res, "thread", view)
}