From 8a2c7de8ca5f39e78d6eae3e9dfb6cd1ab6a8bb0 Mon Sep 17 00:00:00 2001 From: codegirl-007 Date: Thu, 27 Aug 2026 16:21:38 +0000 Subject: [PATCH] Add post permalinks (#8) Reviewed-on: https://git.codegirl007.com/codegirl007/plumber/pulls/8 Co-authored-by: codegirl-007 --- internal/web/posts_test.go | 6 ++++++ static/app.css | 5 +++++ templates/partials/_post.html | 3 +++ 3 files changed, 14 insertions(+) diff --git a/internal/web/posts_test.go b/internal/web/posts_test.go index 1b63317..b61b1fb 100644 --- a/internal/web/posts_test.go +++ b/internal/web/posts_test.go @@ -462,6 +462,9 @@ func TestQuestionPageRendersNestedPostControls(t *testing.T) { `data-submit-button`, `action="/posts/` + root.ID + `/edit"`, `action="/posts/` + homeownerReply.ID + `/edit"`, + `href="/questions/` + root.ID + `#post-` + root.ID + `"`, + `href="/questions/` + root.ID + `#post-` + homeownerReply.ID + `"`, + `href="/questions/` + root.ID + `#post-` + adminReply.ID + `"`, `>The model number is 123A.`, `removeAttribute('open')`, } { @@ -469,6 +472,9 @@ func TestQuestionPageRendersNestedPostControls(t *testing.T) { t.Fatalf("question page missing %q: %s", want, body) } } + if got := strings.Count(body, ">Permalink"); got != 3 { + t.Fatalf("question page rendered %d permalinks, want 3: %s", got, body) + } if strings.Contains(body, `action="/posts/`+adminReply.ID+`/edit"`) { t.Fatalf("homeowner can edit admin reply: %s", body) } diff --git a/static/app.css b/static/app.css index c5fa9f7..54f5e22 100644 --- a/static/app.css +++ b/static/app.css @@ -749,6 +749,11 @@ input:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible, .vote-btn: .post-form-actions .btn { flex: 1 1 10rem; } +.post-permalink { + display: inline-flex; + align-items: center; +} + .post-hide { margin: 0; } diff --git a/templates/partials/_post.html b/templates/partials/_post.html index 95e1c26..3f6fe63 100644 --- a/templates/partials/_post.html +++ b/templates/partials/_post.html @@ -33,6 +33,9 @@ {{end}} + Permalink {{if and (not .Post.ParentID) (isAdmin .User)}}