Skip to content

[REFACTOR] Report templates to files + unify chrome via base.html - #74

Merged
eleanorfrajka merged 6 commits into
mainfrom
rep/03-templates
Aug 14, 2026
Merged

[REFACTOR] Report templates to files + unify chrome via base.html#74
eleanorfrajka merged 6 commits into
mainfrom
rep/03-templates

Conversation

@eleanorfrajka

Copy link
Copy Markdown
Collaborator

Summary

Moves the six report page types from inline Jinja template strings to template files loaded through a shared FileSystemLoader, then factors the shared page chrome into a single base.html that every page extends. Along the way it reconciles CSS that had drifted across the six modules into one look, so the reports read as one system. The rendered HTML changes deliberately (the golden fixtures are re-baselined); the CLI, output filenames, and set of reports produced are unchanged.

What changed

Templates to files. The six inline constants (_INSTRUMENT_HTML_TEMPLATE, _STACK_HTML_TEMPLATE, _GRID_HTML_TEMPLATE, _HTML_TEMPLATE, _RECOVERY_TABLE_TEMPLATE, _ARRAY_HTML_TEMPLATE) are gone; each page is now reports/templates/<page>.html, loaded via reports/_env.py (render_template(name, /, **context), one FileSystemLoader environment, autoescape=True). This is what makes {% extends %} / {% include %} available. Templates are shipped as package data (reports/templates/*.html), verified present in a built wheel.

One base.html. All six pages {% extends "base.html" %}. The shared chrome — body column, masthead, meta-grid, section headings, jump-nav, history list, footer, and the @media print structural rules — lives once in base.html. Each page carries only its accent colour (via --accent / --accent-link) and genuinely page-specific rules.

Masthead is enforced, not copied. The masthead shell lives in base.html with blocks (masthead_title, masthead_type, masthead_sub, masthead_nav, masthead_meta, masthead_class); each page supplies only its values, so a page can no longer drift into a different header. recovery_table (a print-oriented form) uses the same shell via a .masthead-plain variant — a white card with dark text and no wordmark — instead of hand-rolling an <h1>/<h2> header; its title and coordinates now live in the masthead, using the canonical meta fields (Latitude, Longitude, Water depth, Deployment, Recovery, Duration) that the other pages use.

CSS reconciled to one look. The body column is unified to 1150px (spec §11 CONTENT_MAX_PX, which also keeps the figure-sizing USABLE_PX/OVERSAMPLE invariant intact), line-height:1.5 is uniform, and recovery_table drops its Times serif for the shared system-ui stack on screen (its print output keeps 9pt). The per-report masthead accent colours (instrument green, stack blue, grid purple, mooring/array navy) are preserved as the only per-page variant. Tightens the meta-grid so sparse headers pack left.

Configurable wordmark. The masthead carries a package wordmark (spec §15: accent-on-white pill, bottom-right) as a real <span class="wordmark">{{ package_name }}</span> element fed from parameters.PACKAGE_NAME via a Jinja global — not a hardcoded CSS content string — so the name is package-configurable and selectable text. Hidden on the .masthead-plain variant.

Output change (please review the golden diff)

This is not a pure refactor: the rendered report HTML changes on purpose. The re-baselined tests/fixtures/golden/dune2/* files are the record of exactly what moved — the 1150px column, the unified chrome values, the restructured masthead markup (.masthead-title / .masthead-type classes), and the wordmark. The A4 PDF path (reports/_pdf.py, WeasyPrint, injected print stylesheet) is untouched — body width there is still driven by @page, not the templates.

eleanorfrajka and others added 6 commits August 13, 2026 17:20
Add reports/templates/base.html holding the shared page chrome once (body,
masthead, meta-grid, h2, jump-nav, history list, footer, @media print). All six
page templates now {% extends %} it and carry only their accent colour (via
--accent/--accent-link) plus genuinely page-specific rules.

Reconcile drifted CSS to one look: body column unified to 1150px (spec §11
CONTENT_MAX_PX), line-height:1.5 everywhere, recovery_table dropped from Times
serif to the shared system-ui stack on screen (print keeps 9pt). Per-report
masthead accents (green/blue/purple/navy) preserved as the only per-page
variant. A4/print output unchanged (owned by reports/_pdf.py).

Golden re-baselined so the intended visual change is the reviewable diff.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@eleanorfrajka
eleanorfrajka merged commit 2822d7d into main Aug 14, 2026
5 checks passed
@eleanorfrajka
eleanorfrajka deleted the rep/03-templates branch August 14, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant