aboutsummaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/caldata/caldata_test.go27
-rw-r--r--internal/caldata/readings.go43
-rw-r--r--internal/caldata/roman-calendar.ini13
3 files changed, 52 insertions, 31 deletions
diff --git a/internal/caldata/caldata_test.go b/internal/caldata/caldata_test.go
index 0d6616e..12aa765 100644
--- a/internal/caldata/caldata_test.go
+++ b/internal/caldata/caldata_test.go
@@ -33,13 +33,16 @@ func TestUniversalLoads(t *testing.T) {
func TestUniversalSanctoralReadings(t *testing.T) {
l := Universal()
- // A feast/solemnity or a PROPER-reading memorial carries its own inline Mass
- // (imported from catholic-resources.org) rather than falling back to the ferial.
- want := map[string][2]string{ // slug -> {reading.first substr, reading.gospel substr}
- "barnabas-the-apostle": {"Acts 11", "Matthew 10:7-13"},
+ // A feast/solemnity or a PROPER-reading memorial carries its own inline Mass.
+ // Partial-proper memorials keep ONLY the strictly-proper part (the resolver
+ // fills the rest from the ferial): the Guardian Angels a proper gospel, St
+ // Barnabas a proper first reading, Our Lady of Sorrows a proper gospel.
+ want := map[string][2]string{ // slug -> {reading.first substr, reading.gospel substr; "" = absent}
"assumption-of-the-blessed-virgin-mary": {"Revelation 11", "Luke 1:39-56"},
- "our-lady-of-sorrows": {"Hebrews 5", "John 19:25-27"},
"all-saints": {"Revelation 7", "Matthew 5:1-12"},
+ "barnabas-the-apostle": {"Acts 11", ""},
+ "guardian-angels": {"", "Matthew 18:1-5"},
+ "our-lady-of-sorrows": {"", "John 19:25-27"},
}
for slug, w := range want {
rc, ok := l.Cels[slug]
@@ -47,11 +50,15 @@ func TestUniversalSanctoralReadings(t *testing.T) {
t.Errorf("missing %q", slug)
continue
}
- if got := rc.Fields["reading.first"]; !strings.Contains(got, w[0]) {
- t.Errorf("%s: reading.first = %q, want containing %q", slug, got, w[0])
- }
- if got := rc.Fields["reading.gospel"]; !strings.Contains(got, w[1]) {
- t.Errorf("%s: reading.gospel = %q, want containing %q", slug, got, w[1])
+ for i, part := range []string{"reading.first", "reading.gospel"} {
+ got := rc.Fields[part]
+ if w[i] == "" {
+ if got != "" {
+ t.Errorf("%s: %s = %q, want absent (ferial)", slug, part, got)
+ }
+ } else if !strings.Contains(got, w[i]) {
+ t.Errorf("%s: %s = %q, want containing %q", slug, part, got, w[i])
+ }
}
}
}
diff --git a/internal/caldata/readings.go b/internal/caldata/readings.go
index 49109f5..1b87b7a 100644
--- a/internal/caldata/readings.go
+++ b/internal/caldata/readings.go
@@ -1,11 +1,25 @@
package caldata
import (
+ "sort"
"time"
"github.com/lukaszkasprzak/lectio/internal/calendar"
)
+var partOrder = map[string]int{"first": 0, "psalm": 1, "second": 2, "acclamation": 3, "gospel": 4}
+
+// ofFerial returns the day's Ordinary-Form ferial (weekday) readings, or nil.
+func ofFerial(sel calendar.Selection, date time.Time, day calendar.LiturgicalDay) []calendar.Reading {
+ if day.WeekdayCycle == "" || date.Weekday() == time.Sunday {
+ return nil
+ }
+ if temp := calendar.Compute(date, sel, nil); temp.Observed.Layer == "temporal" {
+ return TemporalReadings("new", temp.Observed.Slug+"-"+day.WeekdayCycle)
+ }
+ return nil
+}
+
// Readings resolves a day's Mass readings: the observed celebration's inline
// propers, else the temporal lectionary for its slug, else -- for an EF
// weekday with no proper Mass -- the preceding Sunday's Mass (the 1962 rule
@@ -17,6 +31,24 @@ func Readings(sel calendar.Selection, layers []calendar.Layer, date time.Time, d
rs = append(rs, m.Readings...)
}
if len(rs) > 0 {
+ // OF: a memorial with only a PROPER gospel (or only a proper first) takes
+ // the missing reading from the day's ferial -- e.g. the Guardian Angels are
+ // the ferial first reading + their proper gospel (Matt 18), and St Barnabas
+ // is his proper first (Acts 11) + the ferial gospel. A fully-proper feast
+ // (first AND gospel present) is left untouched.
+ have := map[string]bool{}
+ for _, r := range rs {
+ have[r.Part] = true
+ }
+ if sel.Form != "old" && !(have["first"] && have["gospel"]) {
+ for _, fr := range ofFerial(sel, date, day) {
+ if p := fr.Part; !have[p] && (p == "first" || p == "psalm" || p == "gospel") {
+ rs = append(rs, fr)
+ have[p] = true
+ }
+ }
+ sort.SliceStable(rs, func(i, j int) bool { return partOrder[rs[i].Part] < partOrder[rs[j].Part] })
+ }
return rs
}
// temporal table: EF by bare slug; OF by slug+cycle. Sundays & solemnities
@@ -39,14 +71,9 @@ func Readings(sel calendar.Selection, layers []calendar.Layer, date time.Time, d
}
// OF: a sanctoral memorial / optional memorial with no proper readings of its
// own reads the FERIAL (weekday) readings of the day -- the ordinary OF rule.
- // Compute the pure temporal (no sanctoral) to get the day's ferial slug.
- if sel.Form != "old" && day.Observed.Layer != "temporal" &&
- day.WeekdayCycle != "" && date.Weekday() != time.Sunday {
- temp := calendar.Compute(date, sel, nil)
- if temp.Observed.Layer == "temporal" {
- if r := TemporalReadings("new", temp.Observed.Slug+"-"+day.WeekdayCycle); len(r) > 0 {
- return r
- }
+ if sel.Form != "old" && day.Observed.Layer != "temporal" {
+ if r := ofFerial(sel, date, day); len(r) > 0 {
+ return r
}
}
// EF: a green-season weekday with no proper Mass repeats the preceding Sunday.
diff --git a/internal/caldata/roman-calendar.ini b/internal/caldata/roman-calendar.ini
index ccffa64..f82224f 100644
--- a/internal/caldata/roman-calendar.ini
+++ b/internal/caldata/roman-calendar.ini
@@ -492,8 +492,6 @@ class = saint
colour = white
name.en = Saint Joseph the Worker
name.la = S. Ioseph Opificis
-reading.first = Genesis 1:26-2:3
-reading.psalm = Psalms 90:2,3-4,12-13,14+16
reading.gospel = Matthew 13:54-58
[athanasius-bishop-and-doctor]
@@ -698,7 +696,6 @@ name.pl = św. Barnaby, apostoła
name.la = S. Barnabae, apostoli
reading.first = The Acts 11:21b-26;13:1-3
reading.psalm = Psalms 98:1,2-3ab,3cd-4,5-6
-reading.gospel = Matthew 10:7-13
[anthony-of-padua-priest-and-doctor]
date = 06-13
@@ -901,8 +898,6 @@ colour = white
name.en = Saint Mary Magdalene
name.pl = św. Marii Magdaleny
name.la = S. Mariae Magdalenae
-reading.first = Song of Solomon 3:1-4b
-reading.psalm = Psalms 63:2,3-4,5-6,8-9
reading.gospel = John 20:1-2,11-18
[birgitta-religious]
@@ -953,8 +948,6 @@ colour = red
name.en = Saint Martha
name.pl = św. Marty, Marii i Łazarza
name.la = S. Marthae
-reading.first = 1 John 4:7-16
-reading.psalm = Psalms 34:2-3,4-5,6-7,8-9,10-11
reading.gospel = John 11:19-27
[peter-chrysologus-bishop-and-doctor]
@@ -1224,8 +1217,6 @@ colour = red
name.en = The Beheading of Saint John the Baptist, martyr
name.pl = męczeństwa św. Jana Chrzciciela
name.la = In Passione S. Ioannis Baptistae, martyris
-reading.first = Jeremiah 1:17-19
-reading.psalm = Psalms 71:1-2,3-4a,5-6ab,15ab+17
reading.gospel = Mark 6:17-29
[gregory-the-great-pope-and-doctor]
@@ -1294,8 +1285,6 @@ colour = white
name.en = Our Lady of Sorrows
name.pl = Najświętszej Maryi Panny Bolesnej
name.la = B. Mariae Virginis Perdolentis
-reading.first = Hebrews 5:7-9
-reading.psalm = Psalms 31:2-3b,3cd-4,5-6,15-16,20
reading.gospel = John 19:25-27
[saints-cornelius-pope-and-cyprian-bishop-martyrs]
@@ -1423,8 +1412,6 @@ colour = white
name.en = Guardian Angels
name.pl = świętych Aniołów Stróżów
name.la = Ss. Angelorum Custodum
-reading.first = Exodus 23:20-23
-reading.psalm = Psalms 91:1-2,3-4ab,4c-6,10-11
reading.gospel = Matthew 18:1-5,10
[francis-of-assisi]