diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 20:46:17 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-23 20:46:17 +0200 |
| commit | 0b47572bc0addc5f59ebac3e70278ea435097565 (patch) | |
| tree | a04a3a3afb2c074b2f714f396506dc5bb4f5cbca /internal/readings | |
| parent | 734eb4f3aec4e3c10064c7af4bd8e33c64ad07a7 (diff) | |
| download | lectio-0b47572bc0addc5f59ebac3e70278ea435097565.tar.gz lectio-0b47572bc0addc5f59ebac3e70278ea435097565.zip | |
web: theme control boxes, one default version, drop search bar; traditional drops pl + all=readings-only
Diffstat (limited to 'internal/readings')
| -rw-r--r-- | internal/readings/readings.go | 26 | ||||
| -rw-r--r-- | internal/readings/readings_test.go | 23 |
2 files changed, 47 insertions, 2 deletions
diff --git a/internal/readings/readings.go b/internal/readings/readings.go index 886c1eb..82d2fb9 100644 --- a/internal/readings/readings.go +++ b/internal/readings/readings.go @@ -6,6 +6,7 @@ package readings import ( "fmt" + "strings" "github.com/lukaszkasprzak/lectio/internal/config" "github.com/lukaszkasprzak/lectio/internal/liturgy" @@ -56,8 +57,12 @@ func Load(cfg config.Config, opts Options) ([]liturgy.Section, error) { } // filterParts keeps only the gospel when !all (PartID "ewangelia" modern or -// "evangelium" traditional), otherwise keeps sections cfg.PartShown allows -// (a section with an empty PartID is always kept). Pure and network-free. +// "evangelium" traditional). When all and the lectionary is traditional, it +// keeps only the scripture readings (isTraditionalReading) -- dropping +// Introit/Kolekta/Graduale/Offertorium/Sekreta/Prefacja/Komunia/Pokomunia +// and any commemoration, none of which are readings; the "new" lectionary +// path is unchanged, keeping sections cfg.PartShown allows (a section with +// an empty PartID is always kept). Pure and network-free. func filterParts(secs []liturgy.Section, cfg config.Config, all bool) []liturgy.Section { var out []liturgy.Section for _, s := range secs { @@ -67,9 +72,26 @@ func filterParts(secs []liturgy.Section, cfg config.Config, all bool) []liturgy. } continue } + if cfg.Lectionary == "traditional" { + if isTraditionalReading(s.PartID) { + out = append(out, s) + } + continue + } if s.PartID == "" || cfg.PartShown(cfg.Lectionary, s.PartID) { out = append(out, s) } } return out } + +// isTraditionalReading reports whether partID (a lowercased missalemeum +// section id) is a scripture reading -- the gospel, or an epistle/lesson -- +// rather than Introit/Kolekta/Graduale/Offertorium/Sekreta/Prefacja/ +// Komunia/Pokomunia or a commemoration. +func isTraditionalReading(partID string) bool { + return partID == "evangelium" || + strings.HasPrefix(partID, "lectio") || + strings.HasPrefix(partID, "epistola") || + strings.HasPrefix(partID, "prophetia") +} diff --git a/internal/readings/readings_test.go b/internal/readings/readings_test.go index fd355ff..20df5e0 100644 --- a/internal/readings/readings_test.go +++ b/internal/readings/readings_test.go @@ -55,6 +55,29 @@ func TestFilterPartsAll(t *testing.T) { } } +func TestFilterPartsTraditionalAllReadingsOnly(t *testing.T) { + secs := []liturgy.Section{ + {PartID: "introitus", Heading: "Introit"}, + {PartID: "oratio", Heading: "Kolekta"}, + {PartID: "lectio", Heading: "Lekcja"}, + {PartID: "graduale", Heading: "GraduaĆ"}, + {PartID: "evangelium", Heading: "Ewangelia"}, + {PartID: "offertorium", Heading: "Ofiarowanie"}, + {PartID: "secreta", Heading: "Sekreta"}, + {PartID: "communio", Heading: "Komunia"}, + {PartID: "postcommunio", Heading: "Pokomunia"}, + } + cfg := config.Config{Lectionary: "traditional"} + got := filterParts(secs, cfg, true) + + if len(got) != 2 { + t.Fatalf("got %d sections, want 2: %+v", len(got), got) + } + if got[0].PartID != "lectio" || got[1].PartID != "evangelium" { + t.Errorf("got %+v, want [lectio evangelium] in order", got) + } +} + func TestLoadModernRoutes(t *testing.T) { html, err := os.ReadFile("../liturgy/testdata/2026-07-22.html") if err != nil { |
