diff options
| author | Łukasz <lukasz@arcofasiagroup.com> | 2026-07-23 12:28:09 +0200 |
|---|---|---|
| committer | Łukasz <lukasz@arcofasiagroup.com> | 2026-07-23 12:28:09 +0200 |
| commit | 71da73c4a8c01595118c196db5b8a37611f672ec (patch) | |
| tree | d7d7f6ea469839fd7c83a9494bb156789ad6d749 /docs/superpowers/plans | |
| parent | fd5f75e4080ee1c6c17a70414349eea8ea1903d2 (diff) | |
| download | lectio-71da73c4a8c01595118c196db5b8a37611f672ec.tar.gz lectio-71da73c4a8c01595118c196db5b8a37611f672ec.zip | |
Spec+plan: traditional lectionary (missalemeum) + per-part config
- config: lectionary=new|traditional, traditional_lang=pl|en, and
commented-out [parts.new]/[parts.traditional] per-part toggles (parsed
as a map: a part shows unless explicitly false).
- traditional source: missalemeum API (en/pl only; no Latin) mapped to
the shared []Section; scripture parts get the version-compare via their
citation + embedded vul, prayers are vernacular-only.
- new internal/tradlit package + Load router by lectionary; plan addendum
A with the tradlit task and amendments to Section/config/Load/render/cli.
Diffstat (limited to 'docs/superpowers/plans')
| -rw-r--r-- | docs/superpowers/plans/2026-07-23-lectio-go-rewrite.md | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/docs/superpowers/plans/2026-07-23-lectio-go-rewrite.md b/docs/superpowers/plans/2026-07-23-lectio-go-rewrite.md index 84e5c32..b4a82d2 100644 --- a/docs/superpowers/plans/2026-07-23-lectio-go-rewrite.md +++ b/docs/superpowers/plans/2026-07-23-lectio-go-rewrite.md @@ -1371,6 +1371,146 @@ git add -A && git commit -m "docs: README; finalize build" --- +## Addendum A: Traditional lectionary (missalemeum) + +Adds `lectionary = new|traditional`. Traditional propers come from the +missalemeum API. Integrates via the shared `[]Section` type. Do these after the +base plan (or interleave: A1–A2 before Task 11). + +### Amendment to Task 7 (Section type) + +Add a `PartID string` field to `Section`: +```go +type Section struct { + Heading, Subtitle, Citation, PartID string + Paragraphs [][]string +} +``` +In modern `Parse`, set `PartID` from the heading: map `1. czytanie`→`pierwsze_czytanie` +(or `drugie_czytanie` for a second `1. czytanie` occurrence), `Psalm`→`psalm`, +`Aklamacja`→`aklamacja`, `Ewangelia`→`ewangelia`. + +### Amendment to Task 10 (config) + +Add fields and `PartShown`; extend the embedded seed with the commented +`lectionary`, `traditional_lang`, and `[parts.*]` blocks from the spec. +```go +type Config struct { + SchemaVersion int `toml:"schema_version"` + Lectionary string `toml:"lectionary"` + TraditionalLang string `toml:"traditional_lang"` + Versions []string `toml:"versions"` + DefaultVersion string `toml:"default_version"` + Width int `toml:"width"` + All bool `toml:"all"` + Offline bool `toml:"offline"` + Parts map[string]map[string]bool `toml:"parts"` +} + +// PartShown reports whether a part renders: true unless explicitly set false. +func (c Config) PartShown(lectionary, partID string) bool { + if m, ok := c.Parts[lectionary]; ok { + if v, ok := m[partID]; ok { + return v + } + } + return true +} +``` +Defaults: `Lectionary="new"`, `TraditionalLang="pl"`. Validate `Lectionary` ∈ +{new,traditional}, `TraditionalLang` ∈ {pl,en}. Add a `TestPartShown` (empty → +all true; `{new:{psalm:false}}` → psalm false, ewangelia true). + +### Amendment to Tasks 8–9 (Load router) + +`Load(cfg config.Config, opts Options) ([]Section, error)`: if +`cfg.Lectionary=="traditional"`, delegate to `tradlit.Load(opts.Date, +cfg.TraditionalLang)` (offline: `tradlit.LoadOffline`); else the modern path. +Then filter: `sections = keep(s for s where cfg.PartShown(cfg.Lectionary, s.PartID))`, +unless `opts.GospelOnly`, which keeps only `ewangelia`/`evangelium`. Traditional +cache lives under `traditional/{date}.json`; harvest writes `sigla-traditional.tsv`. + +### Task A1: internal/tradlit — fetch + parse missalemeum propers + +**Files:** Create `internal/tradlit/tradlit.go`, `internal/tradlit/parse_test.go`, +`internal/tradlit/testdata/2026-07-22.json` (save `curl -s https://www.missalemeum.com/en/api/v5/proper/2026-07-22`). + +**Interfaces:** +- Consumes: `liturgy.Section`. +- Produces: `tradlit.Parse(jsonBody []byte) ([]liturgy.Section, error)`; + `tradlit.Load(date, lang string) ([]liturgy.Section, error)`. + +- [ ] **Step 1: Save fixture + write the failing test** + +```bash +mkdir -p internal/tradlit/testdata +curl -s -A 'Mozilla/5.0' https://www.missalemeum.com/en/api/v5/proper/2026-07-22 \ + > internal/tradlit/testdata/2026-07-22.json +``` + +`internal/tradlit/parse_test.go`: +```go +package tradlit + +import ( + "os" + "testing" +) + +func TestParse(t *testing.T) { + body, _ := os.ReadFile("testdata/2026-07-22.json") + secs, err := Parse(body) + if err != nil { + t.Fatal(err) + } + var gospel, epistle bool + for _, s := range secs { + if s.PartID == "evangelium" { + gospel = true + if s.Citation != "Luke 7:36-50" { + t.Errorf("gospel citation = %q", s.Citation) + } + if len(s.Paragraphs) == 0 { + t.Error("gospel has no vernacular text") + } + } + if s.PartID == "lectio" { + epistle = true + } + } + if !gospel || !epistle { + t.Errorf("missing parts: gospel=%v epistle=%v", gospel, epistle) + } +} +``` + +- [ ] **Step 2: Run test, verify it fails** + +Run: `go test ./internal/tradlit/` — Expected: FAIL. + +- [ ] **Step 3: Implement tradlit.go** + +Unmarshal `[]struct{ Info struct{Title string} `json:"info"`; Sections []struct{ ID, Label string; Body [][]string } }`. For each section: `PartID = strings.ToLower(ID)`, `Heading = Label`, join `Body[0]` into `Paragraphs`, and extract the citation from the first `*...*` marker in the body text (`regexp.MustCompile(`\*([^*\n]+)\*`)`). Skip empty/administrative sections. `Load` fetches `https://www.missalemeum.com/{lang}/api/v5/proper/{date}` with the User-Agent and calls `Parse`; a 404 means "no propers for this date". The citation is already kjv-style (e.g. `Luke 7:36-50`, `Ps 44:2`), so `bible.Lookup` consumes it directly; psalm citations are Vulgate-numbered (1962 Missal) — feed the version lookup as-is for `vul/grb/wuj`; `drb` psalms may sit a verse off (same known limitation as the modern mode, no extra handling). + +- [ ] **Step 4: Run tests, verify pass** + +Run: `go test ./internal/tradlit/` — Expected: PASS. + +- [ ] **Step 5: Commit** + +```bash +git add internal/tradlit && git commit -m "tradlit: missalemeum 1962 propers -> sections" +``` + +### Amendment to Task 11 (render) and Task 12 (cli) + +`render.GatherVersion`: for a traditional section, the vernacular source column is +`sec.Paragraphs` (used for the `pl` role / when a part has no citation); the four +bible versions use `sec.Citation` when present. A prayer part (no citation) +renders vernacular only, with a one-line note that Latin is unavailable. `cli`: +add global `--lectionary`/`--lang` flags overriding config; everything else is +unchanged because both sources yield `[]Section`. + ## Self-Review Notes - Spec coverage: two binaries (T1,12,13,15-via-14), embedded corpora (T1,4), lookup (T4,5), aliases incl. `J`→John (T3), citation conversion + psalm systems (T2,6), fetch/parse (T7,8), cache HTML+JSON (T8), sigla harvest + offline (T9), config incl. `offline` (T10), render + dedup + pl→wuj (T11), subcommands (T12), colored reader TUI (T13), Makefile/cross/README (T1,14). All spec sections map to a task. |
