diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:50:31 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:50:31 +0200 |
| commit | 7b220084cf3951c8cde0582efdfcf628afc64336 (patch) | |
| tree | e74bae03c61b62479ef4f68b046e3345618933c8 /internal/config/config.go | |
| parent | feede51697be870ae183a95b513ef64f031dbd0f (diff) | |
| download | lectio-7b220084cf3951c8cde0582efdfcf628afc64336.tar.gz lectio-7b220084cf3951c8cde0582efdfcf628afc64336.zip | |
refactor: remove the niedziela/missalemeum scrapers, bt, traditional_lang
The daily view now computes entirely offline (previous commit), so retire the
network path and everything that served it:
- Delete internal/tradlit (missalemeum) and the niedziela scraper from
internal/liturgy (fetch/store/parse + fixtures); keep Section, DayInfo and
ExtractCitation.
- Remove the "bt" version everywhere (render gatherBT + branches, config,
i18n, web form, TUI) and bible.ToEnglishRef (Polish citation converter).
A legacy config carrying "bt" migrates to "wuj" on load (config.migrateBT).
- Remove the traditional_lang config field and the -g/--lang flag from all
three binaries.
- Drop the now-dead flags -R/--refresh, -o/--offline, -u/--update,
-C/--clean and the harvest/clean commands.
- New defaults: versions = wuj,vul,grb,drb; default_version = vul.
Update the README (offline-by-design, no harvest/update), help text, and
stale niedziela/bt doc comments. Tests updated for the offline reality;
go test ./... and go vet ./... are clean, all three binaries build and run
offline (OF + EF, compare, web).
Diffstat (limited to 'internal/config/config.go')
| -rw-r--r-- | internal/config/config.go | 137 |
1 files changed, 84 insertions, 53 deletions
diff --git a/internal/config/config.go b/internal/config/config.go index a9e00d1..31e9078 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -32,9 +32,8 @@ const configHeader = `# lectio configuration (INI). Full-line comments only (# o # # Allowed values: # lectionary new | traditional (new = modern OF; traditional = 1962 EF) -# traditional_lang pl | en (vernacular for traditional propers) -# versions any of: bt, wuj, vul, grb, drb (comma list; bt = Biblia TysiÄ…clecia) -# default_version bt | wuj | vul | grb | drb +# versions any of: wuj, vul, grb, drb (comma list) +# default_version wuj | vul | grb | drb # width integer; 0 = detect terminal width # all true | false (all readings, or just the gospel) # offline true | false (never fetch; cache/sigla only) @@ -46,7 +45,7 @@ const configHeader = `# lectio configuration (INI). Full-line comments only (# o # web_port integer; 0 = try 1099, then any free port # web_display horizontal | vertical | interlinear # web_mono true | false (monospace reading face in the web UI) -# web_versions any of: bt, wuj, vul, grb, drb (comma list); empty = just default_version +# web_versions any of: wuj, vul, grb, drb (comma list); empty = just default_version # pager shell command, e.g. less -R; empty = off # use calendar layers to stack over the universal calendar: names of # ~/.config/lectio/calendars/<name>.ini files (comma list, order = precedence) @@ -65,17 +64,18 @@ const configHeader = `# lectio configuration (INI). Full-line comments only (# o // -v/--version output (lectio, lectio-ui, lectio-web). const Version = "0.44.0" -// validVersions are the five scripture versions lectio understands. +// validVersions are the scripture versions lectio understands. All are +// embedded corpora; the former "bt" (the niedziela.pl modern scrape) is gone +// and a legacy config carrying it is migrated to "wuj" on load (see Load). var validVersions = map[string]bool{ - "bt": true, "wuj": true, "vul": true, "grb": true, "drb": true, } -// ValidVersion reports whether v is one of the five scripture versions -// lectio understands (bt, wuj, vul, grb, drb). +// ValidVersion reports whether v is one of the scripture versions lectio +// understands (wuj, vul, grb, drb). func ValidVersion(v string) bool { return validVersions[v] } @@ -150,25 +150,24 @@ func NormalizeSiglaStyle(s string) string { // Config holds lectio's user-configurable settings. The toml tags are used only // by the one-shot config.toml -> config.ini migration; the live format is INI. 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"` - UILanguage string `toml:"ui_language"` - ReadingLang string `toml:"reading_lang"` - ReadingVersion string `toml:"reading_version"` - SiglaStyle string `toml:"sigla_style"` - WebTheme string `toml:"web_theme"` - WebPort int `toml:"web_port"` - WebDisplay string `toml:"web_display"` - WebMono bool `toml:"web_mono"` - WebVersions []string `toml:"web_versions"` - Pager string `toml:"pager"` - Parts map[string]map[string]bool `toml:"parts"` + SchemaVersion int `toml:"schema_version"` + Lectionary string `toml:"lectionary"` + Versions []string `toml:"versions"` + DefaultVersion string `toml:"default_version"` + Width int `toml:"width"` + All bool `toml:"all"` + Offline bool `toml:"offline"` + UILanguage string `toml:"ui_language"` + ReadingLang string `toml:"reading_lang"` + ReadingVersion string `toml:"reading_version"` + SiglaStyle string `toml:"sigla_style"` + WebTheme string `toml:"web_theme"` + WebPort int `toml:"web_port"` + WebDisplay string `toml:"web_display"` + WebMono bool `toml:"web_mono"` + WebVersions []string `toml:"web_versions"` + Pager string `toml:"pager"` + Parts map[string]map[string]bool `toml:"parts"` // Computed-calendar placement options (INI [calendar] section; INI-only). CalEpiphany string `toml:"-"` @@ -257,23 +256,22 @@ func (c Config) Selection() calendar.Selection { // is found and as the base that a partial config file overrides. func Default() Config { return Config{ - SchemaVersion: 1, - Lectionary: "new", - TraditionalLang: "pl", - Versions: []string{"bt", "wuj", "vul", "grb", "drb"}, - DefaultVersion: "bt", - Width: 0, - All: false, - Offline: false, - UILanguage: "en", - SiglaStyle: "auto", - WebTheme: "transfiguration", - WebPort: 0, - WebDisplay: "horizontal", - WebMono: false, - WebVersions: nil, - Pager: "", - Parts: nil, + SchemaVersion: 1, + Lectionary: "new", + Versions: []string{"wuj", "vul", "grb", "drb"}, + DefaultVersion: "vul", + Width: 0, + All: false, + Offline: false, + UILanguage: "en", + SiglaStyle: "auto", + WebTheme: "transfiguration", + WebPort: 0, + WebDisplay: "horizontal", + WebMono: false, + WebVersions: nil, + Pager: "", + Parts: nil, } } @@ -471,6 +469,45 @@ func normalize(cfg *Config) { cfg.WebDisplay = NormalizeDisplay(cfg.WebDisplay) cfg.UILanguage = NormalizeUILanguage(cfg.UILanguage) cfg.SiglaStyle = NormalizeSiglaStyle(cfg.SiglaStyle) + migrateBT(cfg) +} + +// migrateBT rewrites a legacy "bt" version (the retired niedziela.pl scrape, +// which had no embedded corpus) to "wuj" wherever a saved config still carries +// it, so an existing config keeps loading after bt was removed. In a version +// list "bt" becomes "wuj" only when "wuj" is not already present; otherwise it +// is dropped, so no list gains a duplicate column. +func migrateBT(cfg *Config) { + if cfg.DefaultVersion == "bt" { + cfg.DefaultVersion = "wuj" + } + cfg.Versions = migrateBTList(cfg.Versions) + cfg.WebVersions = migrateBTList(cfg.WebVersions) +} + +func migrateBTList(versions []string) []string { + if len(versions) == 0 { + return versions + } + hasWuj := false + for _, v := range versions { + if v == "wuj" { + hasWuj = true + break + } + } + out := make([]string, 0, len(versions)) + for _, v := range versions { + if v != "bt" { + out = append(out, v) + continue + } + if !hasWuj { + out = append(out, "wuj") + hasWuj = true + } + } + return out } // readINI parses INI bytes into a Config over Default(). Absent keys keep the @@ -520,8 +557,6 @@ func applyScalar(cfg *Config, key, val string) { cfg.SchemaVersion = atoiOr(val, cfg.SchemaVersion) case "lectionary": cfg.Lectionary = val - case "traditional_lang": - cfg.TraditionalLang = val case "versions": cfg.Versions = ini.List(val) case "default_version": @@ -569,20 +604,17 @@ func validate(cfg Config) error { if cfg.Lectionary != "new" && cfg.Lectionary != "traditional" { return fmt.Errorf("config: invalid lectionary %q (must be \"new\" or \"traditional\")", cfg.Lectionary) } - if cfg.TraditionalLang != "pl" && cfg.TraditionalLang != "en" { - return fmt.Errorf("config: invalid traditional_lang %q (must be \"pl\" or \"en\")", cfg.TraditionalLang) - } for _, v := range cfg.Versions { if !validVersions[v] { - return fmt.Errorf("config: invalid version %q in versions (must be one of bt, wuj, vul, grb, drb)", v) + return fmt.Errorf("config: invalid version %q in versions (must be one of wuj, vul, grb, drb)", v) } } if !validVersions[cfg.DefaultVersion] { - return fmt.Errorf("config: invalid default_version %q (must be one of bt, wuj, vul, grb, drb)", cfg.DefaultVersion) + return fmt.Errorf("config: invalid default_version %q (must be one of wuj, vul, grb, drb)", cfg.DefaultVersion) } for _, v := range cfg.WebVersions { if !validVersions[v] { - return fmt.Errorf("config: invalid version %q in web_versions (must be one of bt, wuj, vul, grb, drb)", v) + return fmt.Errorf("config: invalid version %q in web_versions (must be one of wuj, vul, grb, drb)", v) } } return nil @@ -613,7 +645,6 @@ func renderConfigINI(cfg Config) []byte { b.WriteString("\n") fmt.Fprintf(&b, "schema_version = %d\n", cfg.SchemaVersion) fmt.Fprintf(&b, "lectionary = %s\n", cfg.Lectionary) - fmt.Fprintf(&b, "traditional_lang = %s\n", cfg.TraditionalLang) fmt.Fprintf(&b, "versions = %s\n", strings.Join(cfg.Versions, ", ")) fmt.Fprintf(&b, "default_version = %s\n", cfg.DefaultVersion) fmt.Fprintf(&b, "width = %d\n", cfg.Width) |
