diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 11:57:45 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 11:57:45 +0200 |
| commit | feede51697be870ae183a95b513ef64f031dbd0f (patch) | |
| tree | 6700a80f996d2bba204c0452db2d2bbc16bff619 /internal/cli | |
| parent | 626f2275438a37e5cd2efb5964281b9bef5ce8cc (diff) | |
| download | lectio-feede51697be870ae183a95b513ef64f031dbd0f.tar.gz lectio-feede51697be870ae183a95b513ef64f031dbd0f.zip | |
feat(readings): compute the daily view offline (OF + EF)
Route readings.Load through the embedded calendar engine and lectionary
data instead of the niedziela/missalemeum scrapers. The daily view now
computes each day (calendar.Compute + caldata.Readings) and renders text
from the public-domain corpora, with citations resolved per corpus.
- bible.OFRef: normalise an English-canonical OF citation (drop sub-verse
letters, ";" -> ",") and renumber Psalms for the target Psalter
(Hebrew->Vulgate chapter for vul/grb/wuj; DRB title-fold verses for drb).
- liturgy.Section gains Ref (English-canonical lookup ref) alongside
Citation (sigla-dialect display); the loader fills both, resolveRef uses
Ref, headings/citation command show Citation.
- EffectiveVersions always drops "bt" (no offline corpus); the single
daily version defaults to vernacularVersion (reading corpus else Latin).
Scraper packages remain in the tree, unreferenced, pending removal.
Diffstat (limited to 'internal/cli')
| -rw-r--r-- | internal/cli/cli.go | 28 | ||||
| -rw-r--r-- | internal/cli/cli_test.go | 16 |
2 files changed, 15 insertions, 29 deletions
diff --git a/internal/cli/cli.go b/internal/cli/cli.go index f65774f..d671c91 100644 --- a/internal/cli/cli.go +++ b/internal/cli/cli.go @@ -396,19 +396,9 @@ func gospelCitation(sec liturgy.Section) string { // is parsed to canonical and re-rendered in the target dialect; a citation // whose book can't be parsed comes back in its source form unchanged. func dialectCitation(cfg config.Config, tbl *bible.BookTable, sec liturgy.Section) string { - raw := gospelCitation(sec) - if raw == "" || tbl == nil { - return raw - } - sourceLang := "pl" - if cfg.Lectionary == "traditional" { - sourceLang = cfg.TraditionalLang - } - canonical, ok := tbl.ParseRef(sourceLang, raw) - if !ok { - return raw - } - return tbl.FormatRef(cfg.SiglaLang(), canonical) + // The offline loader already rendered Citation in the reader's sigla dialect + // (see readings.citationForms), so the gospel reference is shown as-is. + return gospelCitation(sec) } // runExport handles --md/--pdf: load the day's readings and write them as @@ -425,8 +415,8 @@ func runExport(cfg config.Config, date, version string, all, refresh, asPDF bool fmt.Fprintln(stderr, "lectio: no readings found for", date) return 1 } - if vs := render.EffectiveVersions([]string{version}, cfg.Lectionary, cfg.Offline); len(vs) > 0 { - version = vs[0] + if version == "" || version == "bt" { + version = vernacularVersion(cfg) } var data []byte @@ -747,8 +737,12 @@ func fetchAndPrint(cfg config.Config, version, date string, all, raw bool, width return 1 } - if vs := render.EffectiveVersions([]string{version}, cfg.Lectionary, cfg.Offline); len(vs) > 0 { - version = vs[0] + // The single-version daily view renders lectio's own reading corpus (an + // explicit reading_version, else the vernacular that matches the UI + // language, else the complete Latin Vulgate -- the same choice -L makes), + // so the former "bt" niedziela default now maps to a real, offline corpus. + if version == "" || version == "bt" { + version = vernacularVersion(cfg) } w := resolveWidth(width, false, stdout) diff --git a/internal/cli/cli_test.go b/internal/cli/cli_test.go index b08ffba..0e90a04 100644 --- a/internal/cli/cli_test.go +++ b/internal/cli/cli_test.go @@ -200,23 +200,15 @@ func TestCleanPreferredOverUpdate(t *testing.T) { // banner for the default (non-raw) render, and is entirely absent from // --raw output, which stays text-only for piping. func TestDayInfoHeaderShown(t *testing.T) { - html, err := os.ReadFile("../liturgy/testdata/2026-07-22.html") - if err != nil { - t.Fatal(err) - } - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.Write(html) - })) - defer srv.Close() - liturgy.SetBaseURL(srv.URL + "/liturgia/%s/Ewangelia") - t.Setenv("XDG_CACHE_HOME", t.TempDir()) t.Setenv("XDG_CONFIG_HOME", t.TempDir()) + const name = "Saint Mary Magdalene" // universal sanctoral, authored in English + var out, errb bytes.Buffer if code := Run([]string{"2026-07-22"}, nil, &out, &errb); code != 0 { t.Fatalf("Run code=%d stderr=%q", code, errb.String()) } - if !strings.Contains(out.String(), "Święto św. Marii Magdaleny") { + if !strings.Contains(out.String(), name) { t.Errorf("stdout missing day-info header: %q", out.String()) } @@ -225,7 +217,7 @@ func TestDayInfoHeaderShown(t *testing.T) { if code := Run([]string{"2026-07-22", "-r"}, nil, &out, &errb); code != 0 { t.Fatalf("Run --raw code=%d stderr=%q", code, errb.String()) } - if strings.Contains(out.String(), "Święto św. Marii Magdaleny") { + if strings.Contains(out.String(), name) { t.Errorf("--raw stdout should omit the day-info header: %q", out.String()) } } |
