[REFACTOR] Report templates to files + unify chrome via base.html - #74
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 singlebase.htmlthat 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 nowreports/templates/<page>.html, loaded viareports/_env.py(render_template(name, /, **context), oneFileSystemLoaderenvironment,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 printstructural rules — lives once inbase.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.htmlwith 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-plainvariant — 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-sizingUSABLE_PX/OVERSAMPLEinvariant intact),line-height:1.5is uniform, andrecovery_tabledrops 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 fromparameters.PACKAGE_NAMEvia a Jinja global — not a hardcoded CSScontentstring — so the name is package-configurable and selectable text. Hidden on the.masthead-plainvariant.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-typeclasses), 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.