aboutsummaryrefslogtreecommitdiffstats
path: root/internal/web/web_test.go
diff options
context:
space:
mode:
authorgrm <grm@eyesin.space>2026-09-18 11:22:25 +0300
committergrm <grm@eyesin.space>2026-09-18 11:22:25 +0300
commitac125593efe689fabd1e48a7023249c8973698b8 (patch)
treed7ee62adfd2260427383093ddf9956b2ef672598 /internal/web/web_test.go
parentad30b38759dc222a7137598559998acbd0c06740 (diff)
downloadblogspace-ac125593efe689fabd1e48a7023249c8973698b8.tar.gz
blogspace-ac125593efe689fabd1e48a7023249c8973698b8.tar.bz2
blogspace-ac125593efe689fabd1e48a7023249c8973698b8.zip
Add switches to keep announcements off a page or off post pages
Announcements showed on every public page. Now each page has a "Show announcements on this page" checkbox (pages.show_notices, on by default) that covers the page and its posts, and the Design tab's Content section has "Show announcements on post pages" (theme.post_notices, on by default) for bloggers who want notices only on listings, not while reading a post. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A
Diffstat (limited to 'internal/web/web_test.go')
-rw-r--r--internal/web/web_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/web/web_test.go b/internal/web/web_test.go
index a7c189f..34ec057 100644
--- a/internal/web/web_test.go
+++ b/internal/web/web_test.go
@@ -138,6 +138,22 @@ func TestThemeNormalizeAndCSS(t *testing.T) {
}
}
+// Announcements on post pages are on by default (the look blogs had before
+// the switch) and, like every checkbox, off when the box is unticked; stored
+// themes from before the option get the default too.
+func TestPostNotices(t *testing.T) {
+ if !DefaultTheme().PostNotices || !ParseTheme([]byte(`{"show_dates":false}`)).PostNotices {
+ t.Error("post notices should default to on")
+ }
+ th := ThemeFromForm(DefaultTheme(), url.Values{"post_notices": {"on"}})
+ if !th.PostNotices {
+ t.Errorf("ticked: %+v", th)
+ }
+ if th = ThemeFromForm(th, url.Values{"show_dates": {"on"}}); th.PostNotices {
+ t.Errorf("unticked: %+v", th)
+ }
+}
+
// The rule under titles is a body class blog.css draws from, coloured by the
// theme CSS; the tag hash is a plain flag the templates read.
func TestTitleRuleAndTagHash(t *testing.T) {