From dd13e4b73a105ee416b6cfd8eb19b217622c0031 Mon Sep 17 00:00:00 2001 From: grm Date: Sat, 12 Sep 2026 12:33:57 +0300 Subject: Add announcements: blog-wide notices on every page and post A blog can have any number of announcements ("sections" in the schema): a book club's next meeting, this month's pick, a holiday closure. Each has a placement (above or below the posts, or under the menu when the menu is a left sidebar), a look (highlighted, warning, plain), an order, and an on/off switch so recurring notices can be kept around while hidden. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/templates/dashboard/overview.html | 2 +- internal/web/templates/dashboard/section_form.html | 32 ++++++++++++++++++++++ internal/web/templates/dashboard/sections.html | 29 ++++++++++++++++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 internal/web/templates/dashboard/section_form.html create mode 100644 internal/web/templates/dashboard/sections.html (limited to 'internal/web/templates/dashboard') diff --git a/internal/web/templates/dashboard/overview.html b/internal/web/templates/dashboard/overview.html index 0ec72e6..fbe49f9 100644 --- a/internal/web/templates/dashboard/overview.html +++ b/internal/web/templates/dashboard/overview.html @@ -7,7 +7,7 @@

Pages

diff --git a/internal/web/templates/dashboard/section_form.html b/internal/web/templates/dashboard/section_form.html new file mode 100644 index 0000000..9d4529c --- /dev/null +++ b/internal/web/templates/dashboard/section_form.html @@ -0,0 +1,32 @@ +{{define "title"}}{{if .Data.section.ID}}Edit announcement{{else}}New announcement{{end}} · {{.Blog.Title}}{{end}} +{{define "content"}} +{{$s := .Data.section}} +
+

{{if $s.ID}}Edit announcement{{else}}New announcement{{end}}

+
+ + +
+ + +
+

The sidebar spot only exists when the menu is a sidebar (see Design); otherwise a sidebar announcement is shown above the posts.

+ + {{template "editor" (dict "name" "body" "value" $s.BodyMD "rows" 10 "tall" false "upload" (print "/b/" .Blog.Subdomain "/images/upload") "csrf" .CSRF)}} + +

+ + View blog ↗ + Back to announcements +

+
+
+{{end}} diff --git a/internal/web/templates/dashboard/sections.html b/internal/web/templates/dashboard/sections.html new file mode 100644 index 0000000..d2fade7 --- /dev/null +++ b/internal/web/templates/dashboard/sections.html @@ -0,0 +1,29 @@ +{{define "title"}}Announcements · {{.Blog.Title}}{{end}} +{{define "content"}} +{{$u := print "/b/" .Blog.Subdomain "/announcements"}} +
+

Announcements

+ +

Notices shown on every page and post of your blog — the next meeting, this month's book, a holiday closure. Hide one instead of deleting it if you will need it again.

+
+
+{{if .Data.sections}} + + + {{range .Data.sections}} + + + + + + {{end}} +
OrderAnnouncementWhereLook
+
+
+
{{if .Title}}{{.Title}}{{else}}(untitled){{end}}{{if not .Enabled}}hidden{{end}}{{if eq .Placement "above"}}Above the posts{{else if eq .Placement "below"}}Below the posts{{else}}Sidebar{{end}}{{if eq .Style "note"}}Highlighted{{else if eq .Style "warning"}}Warning{{else}}Plain{{end}} +
+ delete +
+{{else}}

No announcements yet. Write the first one.

{{end}} +
+{{end}} -- cgit v1.2.3