From ac125593efe689fabd1e48a7023249c8973698b8 Mon Sep 17 00:00:00 2001 From: grm Date: Fri, 18 Sep 2026 11:22:25 +0300 Subject: 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 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/web_test.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'internal/web/web_test.go') 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) { -- cgit v1.2.3