aboutsummaryrefslogtreecommitdiff
path: root/internal/render/render.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 15:00:17 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-23 15:00:17 +0200
commitaa6c9dad764089a3f0e287b5f90937e97dde3921 (patch)
tree213f7f56bf3c5ca1db82f0eee7c482886fa9ce43 /internal/render/render.go
parent66a17fda33e44e9022d6724f850323f754715259 (diff)
downloadlectio-aa6c9dad764089a3f0e287b5f90937e97dde3921.tar.gz
lectio-aa6c9dad764089a3f0e287b5f90937e97dde3921.zip
web: horizontal/vertical/interlinear display modes + web_display config
Adds a display-layout option to lectio-web alongside the existing colour themes: - config: WebDisplay field (toml web_display), default "horizontal", normalized on load via the new exported config.NormalizeDisplay (unknown -> "horizontal", same lenient style as the other web_* fields). - render: extracts the citation/ToEnglishRef resolution shared by GatherVersion into an unexported resolveRef helper (GatherVersion's signature/behavior unchanged) and adds GatherVerses(version, sec, lectionary) returning raw bible.Verse structs plus a versified flag, for column/interlinear alignment. - web/render: RenderReadings gains a display parameter. "horizontal" is the original stacked layout, byte-for-byte the same code path as before. "vertical" reuses the same per-version column data in a .display-vertical/.vcol grid (the CLI compare view, browser-side). "interlinear" maps versions through render.OfflineVersions' pl->wuj substitution (pl has no verse numbers), gathers GatherVerses per version, and interleaves them by chapter:verse into .ilverse/.illine blocks (ordered union of keys, first versified version's order first). - server: adds a display <select> to the top bar wired into the existing #controls HTMX form; a resolveQuery(cfg, r) helper replaces the duplicated date/lectionary/all/versions(+now display) resolution in indexHandler and readingsHandler. - fold-in from the B2 review: indexHandler now populates indexData.Lookup via a shared renderLookup(ref, versions) helper (also used by lookupHandler), so a bookmarked "/?ref=...&v=..." link shows its lookup result instead of an empty pane. - base.css: layout-only rules for the two new modes (no colours; themes stay colour-only). go test ./..., go vet ./..., gofmt clean; go build ./cmd/lectio-web ok.
Diffstat (limited to 'internal/render/render.go')
-rw-r--r--internal/render/render.go69
1 files changed, 52 insertions, 17 deletions
diff --git a/internal/render/render.go b/internal/render/render.go
index 2807272..b8d778c 100644
--- a/internal/render/render.go
+++ b/internal/render/render.go
@@ -55,23 +55,9 @@ func GatherVersion(version string, sec liturgy.Section, lectionary string) (labe
return label, gatherPL(sec)
}
- citation := sec.Citation
- if citation == "" {
- if c, err := liturgy.ExtractCitation(sec.Heading); err == nil {
- citation = c
- }
- }
- if citation == "" {
- return label, []string{"(brak odwołania)"}
- }
-
- ref := citation
- if lectionary == "new" {
- r, err := bible.ToEnglishRef(citation, system(version))
- if err != nil {
- return label, []string{fmt.Sprintf("(brak odwołania: %v)", err)}
- }
- ref = r
+ ref, err := resolveRef(version, sec, lectionary)
+ if err != nil {
+ return label, []string{err.Error()}
}
verses, missing := bible.Lookup(version, ref)
@@ -89,6 +75,55 @@ func GatherVersion(version string, sec liturgy.Section, lectionary string) (labe
return label, blocks
}
+// resolveRef resolves a non-"pl" version's bible.Lookup reference for sec:
+// sec.Citation (or, failing that, the citation extracted from sec.Heading),
+// converted to English/kjv-style via bible.ToEnglishRef when
+// lectionary=="new" (a "traditional" citation is already English-style and
+// used as-is). Shared by GatherVersion and GatherVerses so both apply the
+// exact same resolution.
+func resolveRef(version string, sec liturgy.Section, lectionary string) (string, error) {
+ citation := sec.Citation
+ if citation == "" {
+ if c, err := liturgy.ExtractCitation(sec.Heading); err == nil {
+ citation = c
+ }
+ }
+ if citation == "" {
+ return "", fmt.Errorf("(brak odwołania)")
+ }
+
+ if lectionary != "new" {
+ return citation, nil
+ }
+ ref, err := bible.ToEnglishRef(citation, system(version))
+ if err != nil {
+ return "", fmt.Errorf("(brak odwołania: %w)", err)
+ }
+ return ref, nil
+}
+
+// GatherVerses returns one version's verses for a section as raw bible.Verse
+// structs (for column/interlinear alignment). versified is false for "pl"
+// (paragraph text, no verse numbers) and on any resolution/lookup failure --
+// callers fall back to GatherVersion's string blocks for those.
+func GatherVerses(version string, sec liturgy.Section, lectionary string) (label string, verses []bible.Verse, versified bool) {
+ label = versionLabels[version]
+ if version == "pl" {
+ return label, nil, false
+ }
+
+ ref, err := resolveRef(version, sec, lectionary)
+ if err != nil {
+ return label, nil, false
+ }
+
+ verses, _ = bible.Lookup(version, ref)
+ if len(verses) == 0 {
+ return label, nil, false
+ }
+ return label, verses, true
+}
+
// gatherPL returns the section's paragraphs, one block per paragraph, with
// the liturgical incipit ("Słowa Ewangelii według ...") dropped and repeated
// blocks (a responsorial psalm's refrain) deduped to their first occurrence.