aboutsummaryrefslogtreecommitdiff
path: root/internal/config/config.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config/config.go')
-rw-r--r--internal/config/config.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 9c3c3cd..c15b5a0 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -11,6 +11,7 @@ import (
"fmt"
"os"
"path/filepath"
+ "strings"
"github.com/pelletier/go-toml/v2"
)
@@ -30,6 +31,26 @@ var validVersions = map[string]bool{
"drb": true,
}
+// validDisplays are the lectio-web reading-pane layouts.
+var validDisplays = map[string]bool{
+ "horizontal": true,
+ "vertical": true,
+ "interlinear": true,
+}
+
+// NormalizeDisplay lower-cases display and falls back to "horizontal" when
+// it is not one of validDisplays -- the same lenient style as the rest of
+// lectio-web's config fields (no error, just a safe default). Exported so
+// internal/web can apply the identical normalization to an explicit
+// ?display= query override, keeping the valid set in this one place.
+func NormalizeDisplay(display string) string {
+ d := strings.ToLower(display)
+ if !validDisplays[d] {
+ return "horizontal"
+ }
+ return d
+}
+
// Config holds lectio's user-configurable settings.
type Config struct {
SchemaVersion int `toml:"schema_version"`
@@ -42,6 +63,7 @@ type Config struct {
Offline bool `toml:"offline"`
WebTheme string `toml:"web_theme"`
WebPort int `toml:"web_port"`
+ WebDisplay string `toml:"web_display"`
Parts map[string]map[string]bool `toml:"parts"`
}
@@ -69,6 +91,7 @@ func Default() Config {
Offline: false,
WebTheme: "transfiguration",
WebPort: 0,
+ WebDisplay: "horizontal",
Parts: nil,
}
}
@@ -134,6 +157,7 @@ func Load() (Config, error) {
fmt.Fprintf(os.Stderr, "lectio: warning: invalid config at %s: %v; using defaults\n", path, err)
return def, nil
}
+ cfg.WebDisplay = NormalizeDisplay(cfg.WebDisplay)
if err := validate(cfg); err != nil {
return Config{}, err