From 0fc470a8d588cac1a51cc4b3e1a2237dc56041c9 Mon Sep 17 00:00:00 2001 From: grm Date: Fri, 18 Sep 2026 14:32:22 +0300 Subject: Special pages: a gallery page of the blog's images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A page's kind says what it shows between its intro and outro: posts, as before, or something special. The first special kind is a gallery — every image in the files library as a masonry wall (CSS columns, no script), newest first, each linked to its full-size file. The page form lists the library's images with a Hide tick per picture; exclusions are stored (page_hidden_files) rather than inclusions so a new upload shows up without editing the page, and the design's own pictures — logo, favicon, header and background image — are never shown. Special pages keep the page chrome (menu, announcements, home, ordering) but hold no posts: the post forms skip them and a forced page id is refused. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/handlers_blog.go | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'internal/web/handlers_blog.go') diff --git a/internal/web/handlers_blog.go b/internal/web/handlers_blog.go index 55cec2e..006129c 100644 --- a/internal/web/handlers_blog.go +++ b/internal/web/handlers_blog.go @@ -107,6 +107,20 @@ func (s *Server) renderPage(w http.ResponseWriter, r *http.Request, page *store. s.serverError(w, err) return } + v["page"] = page + if !page.ShowNotices { + v["notices"] = noNotices + } + if page.Kind == store.PageKindGallery { // a special page: its images instead of posts + images, err := blogStore(r).GalleryImages(r.Context(), page.ID, themeFiles(v["theme"].(Theme))) + if err != nil { + s.serverError(w, err) + return + } + v["images"] = images + s.render(w, r, "blog/gallery.html", v) + return + } n, per := pageNum(r), v["theme"].(Theme).PostsPerPage posts, total, err := blogStore(r).PublishedPosts(r.Context(), page.ID, per, (n-1)*per) if err != nil { @@ -115,10 +129,7 @@ func (s *Server) renderPage(w http.ResponseWriter, r *http.Request, page *store. } last := (total + per - 1) / per fillExcerpts(v["theme"].(Theme), posts) - v["page"], v["posts"], v["pageNum"], v["lastPage"] = page, posts, n, last - if !page.ShowNotices { - v["notices"] = noNotices - } + v["posts"], v["pageNum"], v["lastPage"] = posts, n, last // The pager appends ?p=N to base: no trailing slash, which /{page} would not match. v["base"] = "/" + page.Slug if page.IsHome { -- cgit v1.2.3