diff options
| author | grm <grm@eyesin.space> | 2026-09-18 14:32:22 +0300 |
|---|---|---|
| committer | grm <grm@eyesin.space> | 2026-09-18 14:32:22 +0300 |
| commit | 0fc470a8d588cac1a51cc4b3e1a2237dc56041c9 (patch) | |
| tree | f4cde97479977d46046bc18953a1d0ecc3686165 /internal/web/handlers_blog.go | |
| parent | a2b2574538c30278f4edd8e6b2704a176a7750a2 (diff) | |
| download | blogspace-0fc470a8d588cac1a51cc4b3e1a2237dc56041c9.tar.gz blogspace-0fc470a8d588cac1a51cc4b3e1a2237dc56041c9.tar.bz2 blogspace-0fc470a8d588cac1a51cc4b3e1a2237dc56041c9.zip | |
Special pages: a gallery page of the blog's images
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A
Diffstat (limited to 'internal/web/handlers_blog.go')
| -rw-r--r-- | internal/web/handlers_blog.go | 19 |
1 files changed, 15 insertions, 4 deletions
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 { |
