From 0eccf41ff404029bd6f39f06b0a14f1643ddbdda Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 16 Jun 2026 22:34:54 +0300 Subject: wn0 batch preview-thumbnail rendering per page Each thumbnail on a preview page (page-N.html) used to be rendered by its own "template preview" call, paying the full source_template_file cost -- an "env -i bash" invocation -- per thumbnail. With MAXPREVIEWS thumbnails per page that was N template renders per page just for the grid. render_full_preview_page now builds the markup for ALL of a page's thumbnails in bash (build_preview_thumbnail / append_preview_thumbnail) and emits the whole grid in ONE render via a new previewpage.tmpl that takes the pre-built HTML through a context_raw "preview_thumbs" field -- the same pattern the stats filter galleries (camera.tmpl) already use. Per-thumbnail markup is byte-identical to the old preview.tmpl output: same structure, order, HTML escaping and seeded "slow" animation class. Header and footer stay as their own template calls, so a page now costs ~1 previewpage render + header/footer instead of N + chrome. The parallel job-pool integration and failure contract are unchanged: each preview page is still one background render job. Added the render_preview_thumbs_html field spec (hn0 dispatch pattern, context_raw kind), registered previewpage in the validate_template_dir required templates and in the required-context-vars test expectations, and pointed the four generation template-failure tests at previewpage.tmpl (generation no longer renders preview.tmpl). The standalone "template preview" engine unit tests keep exercising preview.tmpl, which still ships. Verified byte-identical output: generated the fixture album (including a spaces/special-char filename) twice with RANDOM_SEED=42 using the parent commit's bin/shuriken vs the new bin; every .html file is identical. just test, just shellcheck, just check-generated and git diff --check all pass. Co-Authored-By: Claude Opus 4.8 --- share/templates/default/previewpage.tmpl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 share/templates/default/previewpage.tmpl (limited to 'share') diff --git a/share/templates/default/previewpage.tmpl b/share/templates/default/previewpage.tmpl new file mode 100644 index 0000000..9f42f84 --- /dev/null +++ b/share/templates/default/previewpage.tmpl @@ -0,0 +1,14 @@ +# Preview-page thumbnail grid (task wn0). The album preview page (page-N.html) +# used to render EACH thumbnail with its own "template preview" call, paying the +# full source_template_file cost (an "env -i bash" invocation) per thumbnail. +# render_full_preview_page now pre-builds the markup for ALL of a page's +# thumbnails in bash (render_preview_thumbnail / build into one string) and hands +# the whole grid in through the raw context field render_preview_thumbs_html, so +# this template emits every thumbnail for the page in ONE render call instead of +# N. The per-thumbnail markup is byte-identical to the old preview.tmpl output +# (same structure, order +# and seeded animation classes). The surrounding header/footer still come from +# their own templates, which render_full_preview_page emits around this one. +cat <