From d0601f06c080a8eb8d781fdd0e3338cd7ed42690 Mon Sep 17 00:00:00 2001 From: grm Date: Thu, 17 Sep 2026 16:42:15 +0300 Subject: Add post summaries, featured images and a page outro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Recreating gizmolab.net as a blog showed three things the design system could not express, all of them ordinary blog features: - Listings can show a summary and a "Read more" link instead of the whole post (theme.list_style). The summary is the source up to ; without the marker a Markdown post is cut at a block boundary after 70 words (never inside a code fence) and an HTML post is shown whole, since cutting hand-written markup blind would leave tags open. Computed at render time (Post.Excerpt/HasMore), nothing new is stored. - A post can carry a featured image (posts.image, a library file that is unset when the file is deleted): a thumbnail floated beside the entry on listings, and on the post page above or below the text, or not at all, as theme.post_image says. The picker is the design page's imagepick; its library panel moves out of design.html into partials/imagelib.html so both forms share it — which also removes a stale pickAction call the design form's click handler would have hit. - A page can have a closing text after its posts (pages.outro_md/html), in the intro's format: the per-page counterpart of the blog-wide "after the posts" module, for a home page that ends in a site map or a widget. The editor partial takes formatof to share another editor's Format row, and its upload field is now _file so two editors fit in one form. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01Sd8UPWrvyYCLj97JexNw3A --- internal/web/templates/blog/page.html | 3 +- internal/web/templates/blog/post.html | 3 + internal/web/templates/dashboard/design.html | 76 +++++-------------------- internal/web/templates/dashboard/page_form.html | 2 + internal/web/templates/dashboard/post_form.html | 2 + internal/web/templates/partials/editor.html | 11 ++-- internal/web/templates/partials/imagelib.html | 72 +++++++++++++++++++++++ internal/web/templates/partials/imagepick.html | 13 +++-- internal/web/templates/partials/mdhelp.html | 2 +- internal/web/templates/partials/postlist.html | 6 +- 10 files changed, 115 insertions(+), 75 deletions(-) create mode 100644 internal/web/templates/partials/imagelib.html (limited to 'internal/web/templates') diff --git a/internal/web/templates/blog/page.html b/internal/web/templates/blog/page.html index 99403ef..6f833f8 100644 --- a/internal/web/templates/blog/page.html +++ b/internal/web/templates/blog/page.html @@ -2,5 +2,6 @@ {{define "content"}} {{if not .Data.page.IsHome}}

{{.Data.page.Title}}

{{end}} {{if .Data.page.IntroHTML}}
{{html .Data.page.IntroHTML}}
{{end}} -{{if or .Data.posts .Data.page.IntroHTML}}{{template "postlist" .}}{{else}}

{{t "Nothing here yet."}}

{{end}} +{{if or .Data.posts .Data.page.IntroHTML .Data.page.OutroHTML}}{{template "postlist" .}}{{else}}

{{t "Nothing here yet."}}

{{end}} +{{if .Data.page.OutroHTML}}
{{html .Data.page.OutroHTML}}
{{end}} {{end}} diff --git a/internal/web/templates/blog/post.html b/internal/web/templates/blog/post.html index a3b0375..10d4c3a 100644 --- a/internal/web/templates/blog/post.html +++ b/internal/web/templates/blog/post.html @@ -4,6 +4,9 @@

{{.Data.post.Title}}

{{template "posttags" .Data.post.Tags}} + {{$img := .Data.post.Image}}{{$place := .Data.theme.PostImage}} + {{if and $img (eq $place "top")}}

{{end}}
{{html .Data.post.BodyHTML}}
+ {{if and $img (eq $place "bottom")}}

{{end}} {{end}} diff --git a/internal/web/templates/dashboard/design.html b/internal/web/templates/dashboard/design.html index 261eb69..71597e8 100644 --- a/internal/web/templates/dashboard/design.html +++ b/internal/web/templates/dashboard/design.html @@ -181,6 +181,18 @@ {{range .Data.perPage}}{{end}} +
+ + +
+

{{t "A summary is the post up to a line with , or its first paragraphs. A post's featured image is picked on the post form and shown as a thumbnail on listings."}}

{{t "Around the posts"}}

{{t "Your own HTML before and after the posts — an intro box, a newsletter form, a badge…"}}

{{template "arealist" (dict "area" "above" "root" .)}} @@ -260,19 +272,8 @@ -{{/* The library panel: filled by the script from /files?kind=image as JSON, one page at a time. */}} - +{{/* The library panel behind the image pickers (partials/imagelib.html). */}} +{{template "imagelib" (dict "sub" $sub "count" .Data.imageCount)}} {{end}} diff --git a/internal/web/templates/dashboard/page_form.html b/internal/web/templates/dashboard/page_form.html index 4754c91..18b0a86 100644 --- a/internal/web/templates/dashboard/page_form.html +++ b/internal/web/templates/dashboard/page_form.html @@ -9,6 +9,8 @@ {{template "editor" (dict "name" "intro" "value" .Data.page.IntroMD "format" .Data.page.Format "rows" 8 "tall" false "upload" (print "/b/" .Blog.Subdomain "/files/upload") "preview" (print "/b/" .Blog.Subdomain "/preview") "csrf" .CSRF)}} + + {{template "editor" (dict "name" "outro" "value" .Data.page.OutroMD "format" .Data.page.Format "formatof" "intro" "rows" 8 "tall" false "upload" (print "/b/" .Blog.Subdomain "/files/upload") "preview" (print "/b/" .Blog.Subdomain "/preview") "csrf" .CSRF)}}

diff --git a/internal/web/templates/dashboard/post_form.html b/internal/web/templates/dashboard/post_form.html index 70cddcc..9bd7624 100644 --- a/internal/web/templates/dashboard/post_form.html +++ b/internal/web/templates/dashboard/post_form.html @@ -39,6 +39,7 @@ {{template "editor" (dict "name" "body" "value" .Data.post.BodyMD "format" .Data.post.Format "rows" 24 "tall" true "upload" (print "/b/" .Blog.Subdomain "/files/upload") "preview" (print "/b/" .Blog.Subdomain "/preview") "csrf" .CSRF)}} + {{template "imagepick" (dict "name" "image" "current" .Data.post.Image "sub" .Blog.Subdomain "images" .Data.images "names" .Data.imageNames "label" (t "Featured image") "hint" (t "Optional. A thumbnail on listings, and on the post page where the Design tab puts it."))}}

@@ -47,4 +48,5 @@

+{{template "imagelib" (dict "sub" .Blog.Subdomain "count" .Data.imageCount)}} {{end}} diff --git a/internal/web/templates/partials/editor.html b/internal/web/templates/partials/editor.html index a0f8c7f..cfc5642 100644 --- a/internal/web/templates/partials/editor.html +++ b/internal/web/templates/partials/editor.html @@ -1,10 +1,13 @@ +{{/* A second editor in the same form (a page's outro) shares the first one's + Format row: pass "formatof" with that editor's name and no radios are + rendered, the script watches the other row instead. */}} {{define "editor"}}
-

+{{if not .formatof}}

{{t "Format"}}: {{t "Put on your blog exactly as written — embeds and scripts all work. An unclosed tag can break the page around it, so check your blog after saving."}} -

+

{{end}}