aboutsummaryrefslogtreecommitdiff
path: root/internal/render/render.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 12:52:13 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-28 12:52:13 +0200
commit44472bbe31475a3c672ae003d928d7caffb4b50a (patch)
treee74bae03c61b62479ef4f68b046e3345618933c8 /internal/render/render.go
parent626f2275438a37e5cd2efb5964281b9bef5ce8cc (diff)
parent7b220084cf3951c8cde0582efdfcf628afc64336 (diff)
downloadlectio-44472bbe31475a3c672ae003d928d7caffb4b50a.tar.gz
lectio-44472bbe31475a3c672ae003d928d7caffb4b50a.zip
Merge branch 'of-offline-migration': offline daily view, remove scrapers
Diffstat (limited to 'internal/render/render.go')
-rw-r--r--internal/render/render.go96
1 files changed, 32 insertions, 64 deletions
diff --git a/internal/render/render.go b/internal/render/render.go
index 6cdb939..c744aac 100644
--- a/internal/render/render.go
+++ b/internal/render/render.go
@@ -99,22 +99,17 @@ func system(version string) string {
return "vulgate"
}
-const incipit = "Słowa Ewangelii"
-
// GatherVersion returns (label, blocks) for one version of one reading
-// section. Each block is a paragraph (Polish) or a verse line (bible
-// versions); on any failure the blocks hold a single short note instead.
+// section. Each block is a verse line; on any failure the blocks hold a single
+// short note instead.
//
-// lectionary selects how sec.Citation is read: "new" (modern/niedziela.pl)
-// citations are Polish and go through bible.ToEnglishRef; "traditional"
-// (missalemeum) citations are already English kjv-style and are used as-is.
-// lang selects the UI chrome language the label comes from (see
-// internal/i18n); it never affects the verse text/citation itself.
+// lectionary selects how sec.Ref is renumbered: "new" (Ordinary Form) refs are
+// modern-numbered and go through bible.OFRef for the target Psalter;
+// "traditional" (1962) refs are already Vulgate-numbered and used as-is. lang
+// selects the UI chrome language the label comes from (see internal/i18n); it
+// never affects the verse text/citation itself.
func GatherVersion(version string, sec liturgy.Section, lectionary, lang string) (label string, blocks []string) {
label = versionLabel(version, lang)
- if version == "bt" {
- return label, gatherBT(sec)
- }
ref, err := resolveRef(version, sec, lectionary, lang)
if err != nil {
@@ -146,7 +141,12 @@ func GatherVersion(version string, sec liturgy.Section, lectionary, lang string)
// it never affects which reference is resolved.
func resolveRef(version string, sec liturgy.Section, lectionary, lang string) (string, error) {
ui := i18n.Get(lang)
- citation := sec.Citation
+ // Ref is the English-canonical lookup reference; fall back to the display
+ // citation (or the one embedded in the heading) for sections that carry none.
+ citation := sec.Ref
+ if citation == "" {
+ citation = sec.Citation
+ }
if citation == "" {
if c, err := liturgy.ExtractCitation(sec.Heading); err == nil {
citation = c
@@ -157,25 +157,20 @@ func resolveRef(version string, sec liturgy.Section, lectionary, lang string) (s
}
if lectionary != "new" {
- return citation, nil
+ return citation, nil // Extraordinary Form: already Vulgate-numbered
}
- ref, err := bible.ToEnglishRef(citation, system(version))
- if err != nil {
- return "", fmt.Errorf(ui.NoReferenceErr, err)
- }
- return ref, nil
+ // Ordinary Form: the citation is lectio's English-canonical, modern-numbered
+ // form; renumber only the Psalms for the target corpus's Psalter.
+ return bible.OFRef(citation, system(version)), nil
}
// GatherVerses returns one version's verses for a section as raw bible.Verse
-// structs (for column/interlinear alignment). versified is false for "bt"
-// (paragraph text, no verse numbers) and on any resolution/lookup failure --
-// callers fall back to GatherVersion's string blocks for those. lang selects
-// the UI chrome language the label comes from, same as GatherVersion.
+// structs (for column/interlinear alignment). versified is false on any
+// resolution/lookup failure -- callers fall back to GatherVersion's string
+// blocks for those. lang selects the UI chrome language the label comes from,
+// same as GatherVersion.
func GatherVerses(version string, sec liturgy.Section, lectionary, lang string) (label string, verses []bible.Verse, versified bool) {
label = versionLabel(version, lang)
- if version == "bt" {
- return label, nil, false
- }
ref, err := resolveRef(version, sec, lectionary, lang)
if err != nil {
@@ -189,35 +184,10 @@ func GatherVerses(version string, sec liturgy.Section, lectionary, lang string)
return label, verses, true
}
-// gatherBT 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.
-func gatherBT(sec liturgy.Section) []string {
- var blocks []string
- for _, p := range sec.Paragraphs {
- b := strings.Join(p, " ")
- if strings.HasPrefix(b, incipit) {
- continue
- }
- blocks = append(blocks, b)
- }
-
- seen := map[string]bool{}
- deduped := make([]string, 0, len(blocks))
- for _, b := range blocks {
- if seen[b] {
- continue
- }
- seen[b] = true
- deduped = append(deduped, b)
- }
- return deduped
-}
-
-// OfflineVersions drops "bt" (which needs the network fetch of the liturgy
-// page) from versions. If "bt" was present but "wuj" (the Polish-language
-// bible version) was not, "wuj" takes bt's place, so the offline set still
-// carries a Polish column.
+// OfflineVersions maps a legacy "bt" version (the retired niedziela.pl scrape,
+// which has no embedded corpus) to "wuj", or drops it when "wuj" is already
+// present so the set keeps a single Polish column. Config load migrates bt out
+// (see config.migrateBT), so this only guards versions passed in directly.
func OfflineVersions(versions []string) []string {
hadWuj := false
for _, v := range versions {
@@ -242,16 +212,14 @@ func OfflineVersions(versions []string) []string {
}
// EffectiveVersions is the version set actually loadable for a request: "bt"
-// (the niedziela.pl modern scrape) is dropped -- substituting "wuj" if it was
-// the only Polish column, via OfflineVersions -- whenever the scrape is
-// unavailable: offline (never fetch) OR the traditional lectionary
-// (missalemeum, which has no niedziela.pl scrape). Shared by cli, tui and web
-// so all three binaries treat traditional/offline versions identically.
+// (the former niedziela.pl modern scrape) has no embedded corpus, so it is
+// always dropped -- substituting "wuj" if it was the only Polish column, via
+// OfflineVersions. Every reading is now rendered offline from an embedded
+// corpus, so the swap is unconditional; the lectionary and offline arguments
+// are retained for caller compatibility but no longer change the result.
+// Shared by cli, tui and web so all three binaries agree on the version set.
func EffectiveVersions(versions []string, lectionary string, offline bool) []string {
- if offline || lectionary == "traditional" {
- return OfflineVersions(versions)
- }
- return versions
+ return OfflineVersions(versions)
}
// Compare lays the versions of one reading section out as parallel columns,