diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 10:32:28 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-24 10:32:28 +0200 |
| commit | c9f3bf46f0de09edb796e35f3dcff349febf75c9 (patch) | |
| tree | c1a0b98b484e4da557c1ab205dfff0d92ce8ac36 /internal/web/render.go | |
| parent | a865374755480a4aef2a6156afccdf08a91422ea (diff) | |
| download | lectio-c9f3bf46f0de09edb796e35f3dcff349febf75c9.tar.gz lectio-c9f3bf46f0de09edb796e35f3dcff349febf75c9.zip | |
dayinfo: show feast/day name + colour (modern niedziela + traditional missalemeum) in cli/tui/web; v0.5.0
Diffstat (limited to 'internal/web/render.go')
| -rw-r--r-- | internal/web/render.go | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/internal/web/render.go b/internal/web/render.go index 1afee1c..9e6280c 100644 --- a/internal/web/render.go +++ b/internal/web/render.go @@ -98,16 +98,45 @@ type ilLineView struct { // spans so theme CSS can restyle them; verse/paragraph text is escaped by // html/template. lang localises the version-column labels and each section // heading's part-label word (render.LocalizeHeading, brief ยง3b); the -// citation/verse text is never touched. -func RenderReadings(secs []liturgy.Section, versions []string, lectionary, display, lang string) template.HTML { +// citation/verse text is never touched. dayInfo is rendered once, ahead of +// every layout's own sections, as the day's celebration header (see +// renderDayInfo) -- never translated (source-language, like the readings/ +// citations), and simply omitted when the source carried none. +func RenderReadings(secs []liturgy.Section, versions []string, lectionary, display, lang string, dayInfo liturgy.DayInfo) template.HTML { + var body template.HTML switch display { case "vertical": - return renderTemplate("readings-vertical.html", buildColumnViews(secs, versions, lectionary, lang)) + body = renderTemplate("readings-vertical.html", buildColumnViews(secs, versions, lectionary, lang)) case "interlinear": - return renderTemplate("readings-interlinear.html", buildInterlinearViews(secs, versions, lectionary, lang)) + body = renderTemplate("readings-interlinear.html", buildInterlinearViews(secs, versions, lectionary, lang)) default: - return renderTemplate("readings.html", buildColumnViews(secs, versions, lectionary, lang)) + body = renderTemplate("readings.html", buildColumnViews(secs, versions, lectionary, lang)) } + return renderDayInfo(dayInfo) + body +} + +// renderDayInfo builds the "<p class="dayinfo">" header RenderReadings +// prepends to the reading pane: the celebration Name as its heading-role +// span, the temporal Season (if any) as its citation-role span. Reusing +// those two role classes (rather than inventing new ones) means every +// existing theme restyles it identically without a new CSS rule -- see +// base.css/docs/THEMES.md. Returns "" (the header is simply omitted, never +// an error) when the source yielded no DayInfo (info.Name == ""). +func renderDayInfo(info liturgy.DayInfo) template.HTML { + if info.Name == "" { + return "" + } + var b strings.Builder + b.WriteString(`<p class="dayinfo"><span class="heading">`) + b.WriteString(template.HTMLEscapeString(info.Name)) + b.WriteString(`</span>`) + if info.Season != "" { + b.WriteString(` <span class="citation">`) + b.WriteString(template.HTMLEscapeString(info.Season)) + b.WriteString(`</span>`) + } + b.WriteString(`</p>`) + return template.HTML(b.String()) } // renderTemplate executes the named embedded template with data, degrading |
