~aw/fishbb

829ed25265433b5d3f863d1d87dab75f82d8c3b3 — alex wennerberg 2 months ago 858c675
proper page titles and some nav cleanup
4 files changed, 26 insertions(+), 12 deletions(-)

M TODO
M views/forum.html
M views/header.html
M web.go
M TODO => TODO +0 -1
@@ 2,7 2,6 @@ Setup fishbb.org (cloud provider)

FEATURES:
rate limit registration
proper page titles

Login/Reigster:
finish up oauth integration

M views/forum.html => views/forum.html +2 -2
@@ 2,7 2,7 @@
<table class="nav-table" id="threads">
  <tr><th style="width:50%">Thread</th><th style="text-align:center;width:4rem;">Replies</th><th style="width:30%">Last Post</th></tr>
  <div class="body-header">
	  <a href="/thread/new?forumid={{.ForumID}}"><button class="top-button">New Thread</button></a>
	  <a href="/thread/new?forumid={{.Forum.ID}}"><button class="top-button">New Thread</button></a>
  {{ template "pagelist.html" . }}
</div>
{{ if not (len .Threads) }}


@@ 13,7 13,7 @@
    <td>
		{{ if .Locked }} {{ template "lock.svg" }} {{ end }}
		{{ if .Pinned }} {{ template "pin.svg" }} {{ end }}
		<a class="title-link" href="/f/{{$.ForumSlug}}/{{.ID}}">{{.Title}}</a><br>
		<a class="title-link" href="/f/{{$.Forum.Slug}}/{{.ID}}">{{.Title}}</a><br>
		<div class="flex-between">
		<div>
			by <a href="/user/{{.Author.ID}}">{{.Author.Username}}</a> <span class="text-alt" title="{{.Created}}">{{ timeago .Created }}</span>

M views/header.html => views/header.html +9 -2
@@ 9,8 9,15 @@
  <div id="page-header">
	  <div>
		  <a href="/"><img src="/a?a={{.Config.BoardName}}" width=18px></a>
		  <a href="/" class="title-link">{{.Config.BoardName}}</a><br>
      {{.Config.BoardDescription}}
		  <a href="/" class="title-link">{{.Config.BoardName}}</a>
		  {{ if .Forum }}
		  &gt; <a class="title-link" href="/f/{{.Forum.Slug}}"</a>{{ .Forum.Name }}</a>
		  {{ end }}<br>
		  {{ if .Forum }}
		  {{ .Forum.Description }}
		  {{ else }}
		  {{.Config.BoardDescription}}
		  {{ end }}
    </div>
    <div id="nav">
      {{ if not .User }}

M web.go => web.go +15 -7
@@ 31,8 31,10 @@ func serveHTML(w http.ResponseWriter, r *http.Request, name string, info map[str
	info["Version"] = softwareVersion
	info["CSRFToken"] = GetCSRF(r)
	var title = config.BoardName
	if name != "index" {
		title += " > " + name
	if info["Subtitle"] != nil {
		title = info["Subtitle"].(string) + " - " + title
	} else if name != "index" {
		title = name + " - " + title
	}
	info["Title"] = title
	err := views.ExecuteTemplate(w, name+".html", info)


@@ 80,25 82,29 @@ func indexPage(w http.ResponseWriter, r *http.Request) {

func forumPage(w http.ResponseWriter, r *http.Request) {
	tmpl := make(map[string]any)
	fid := getForumID(r.PathValue("forum"))
	f, err := getForumBySlug(r.PathValue("forum"))
	if err != nil {
		serverError(w, r, err)
		return
	}
	page := page(r)
	threads, err := getThreads(fid, page)
	threads, err := getThreads(f.ID, page)
	if err != nil {
		serverError(w, r, err)
		return
	}
	count, err := getThreadCount(fid)
	count, err := getThreadCount(f.ID)
	if err != nil {
		serverError(w, r, err)
		return
	}
	tmpl["ForumID"] = fid
	tmpl["ForumSlug"] = r.PathValue("forum")
	tmpl["Forum"] = f
	tmpl["Threads"] = threads
	// pagination
	tmpl["Page"] = page
	tmpl["ItemCount"] = count
	tmpl["Threads"] = threads
	tmpl["Subtitle"] = f.Name
	serveHTML(w, r, "forum", tmpl)
}



@@ 125,6 131,7 @@ func threadPage(w http.ResponseWriter, r *http.Request) {
	tmpl["ItemCount"] = thread.Replies + 1
	tmpl["Forum"] = forum
	tmpl["Posts"] = getPosts(threadID, page)
	tmpl["Subtitle"] = thread.Title
	serveHTML(w, r, "thread", tmpl)
}



@@ 384,6 391,7 @@ func userPage(w http.ResponseWriter, r *http.Request) {
		return
	}
	tmpl["InfoUser"] = info
	tmpl["Subtitle"] = info.Username
	// TODO specific DNE error?
	serveHTML(w, r, "user", tmpl)
}