From 90b7eea0dc54f64e61fd19c849bc57b868a85d24 Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Sat, 23 Nov 2024 16:45:39 -0800 Subject: [PATCH] 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. --- pkg/controller/admin/feedback.go | 16 +++------------- pkg/controller/index/contact.go | 10 ++++++++++ web/static/css/theme.css | 6 ++++++ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/pkg/controller/admin/feedback.go b/pkg/controller/admin/feedback.go index 39a17a3..d3baf70 100644 --- a/pkg/controller/admin/feedback.go +++ b/pkg/controller/admin/feedback.go @@ -137,19 +137,9 @@ func Feedback() http.HandlerFunc { } } case "comments": - // Get this comment. - comment, err := models.GetComment(fb.TableID) - if err != nil { - 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 - } - } + // Redirect to the comment redirector. + templates.Redirect(w, fmt.Sprintf("/go/comment?id=%d", fb.TableID)) + return case "forums": // Get this forum. forum, err := models.GetForum(fb.TableID) diff --git a/pkg/controller/index/contact.go b/pkg/controller/index/contact.go index 1e7d197..cef5f75 100644 --- a/pkg/controller/index/contact.go +++ b/pkg/controller/index/contact.go @@ -105,6 +105,16 @@ From: @%s if comment, err := models.GetComment(uint64(tableID)); err == nil { tableLabel = fmt.Sprintf(`A comment written by "%s"`, comment.User.Username) aboutUser = &comment.User + footer = fmt.Sprintf(` + +--- + +From: @%s + +%s`, + comment.User.Username, comment.User.Username, + markdown.Quotify(comment.Message), + ) } else { log.Error("/contact: couldn't produce table label for comment %d: %s", tableID, err) } diff --git a/web/static/css/theme.css b/web/static/css/theme.css index b50616f..3883965 100644 --- a/web/static/css/theme.css +++ b/web/static/css/theme.css @@ -1,5 +1,11 @@ /* 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 { cursor: help; }