Fix Feedback Comments + Fixed Nav Anchor Workaround

* Admin Feedback page: fix the visit button to go to a reported comment.
* CSS: with the fixed top nav bar, anchor links (like to the FAQ or
  specific comments on a thread) were scrolling so the anchor was below
  the nav bar. Add a scroll-padding-top to work around this.
This commit is contained in:
Noah Petherbridge 2024-11-23 16:45:39 -08:00
parent 39398a1f78
commit 90b7eea0dc
3 changed files with 19 additions and 13 deletions

View File

@ -137,19 +137,9 @@ func Feedback() http.HandlerFunc {
} }
} }
case "comments": case "comments":
// Get this comment. // Redirect to the comment redirector.
comment, err := models.GetComment(fb.TableID) templates.Redirect(w, fmt.Sprintf("/go/comment?id=%d", fb.TableID))
if err != nil { return
session.FlashError(w, r, "Couldn't get comment ID %d: %s", fb.TableID, err)
} else {
// What was the comment on?
switch comment.TableName {
case "threads":
// Visit the thread.
templates.Redirect(w, fmt.Sprintf("/forum/thread/%d", comment.TableID))
return
}
}
case "forums": case "forums":
// Get this forum. // Get this forum.
forum, err := models.GetForum(fb.TableID) forum, err := models.GetForum(fb.TableID)

View File

@ -105,6 +105,16 @@ From: <a href="/u/%s">@%s</a>
if comment, err := models.GetComment(uint64(tableID)); err == nil { if comment, err := models.GetComment(uint64(tableID)); err == nil {
tableLabel = fmt.Sprintf(`A comment written by "%s"`, comment.User.Username) tableLabel = fmt.Sprintf(`A comment written by "%s"`, comment.User.Username)
aboutUser = &comment.User aboutUser = &comment.User
footer = fmt.Sprintf(`
---
From: <a href="/u/%s">@%s</a>
%s`,
comment.User.Username, comment.User.Username,
markdown.Quotify(comment.Message),
)
} else { } else {
log.Error("/contact: couldn't produce table label for comment %d: %s", tableID, err) log.Error("/contact: couldn't produce table label for comment %d: %s", tableID, err)
} }

View File

@ -1,5 +1,11 @@
/* Custom CSS styles */ /* Custom CSS styles */
html {
/* With the fixed top nav bar, this works around anchor-links to make them appear
correctly BELOW the nav bar instead of overlapped underneath it. */
scroll-padding-top: 52px;
}
abbr { abbr {
cursor: help; cursor: help;
} }