From dde8343978f768dd400776bc6a2d5af14697c2b7 Mon Sep 17 00:00:00 2001
From: barnold
Date: Sun, 9 Oct 2022 14:22:40 +0100
Subject: [PATCH] Local override for configuration...
Look for a local .yml file and apply it if present.
---
.gitignore | 1 +
lib/MyApp.pm | 4 ++++
my_app.yml | 6 ++++++
templates/book/about.html.ep | 6 ++++--
4 files changed, 15 insertions(+), 2 deletions(-)
create mode 100644 .gitignore
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..8e6314b
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+local-override.yml
diff --git a/lib/MyApp.pm b/lib/MyApp.pm
index c0461f8..0b47124 100644
--- a/lib/MyApp.pm
+++ b/lib/MyApp.pm
@@ -75,6 +75,10 @@ sub startup ($self) {
# Set a "secret" for signing cookies, preventing "Your secret
# passphrase needs to be changed" in the log, using my_app.yml.
my $config = $self->plugin('NotYAMLConfig');
+ # Apply local overrides, if any.
+ if (-e $self->home->child('local-override.yml')) {
+ $config = $self->plugin('NotYAMLConfig', { file => 'local-override.yml' });
+ }
$self->secrets([ $config->{secrets} ]);
# Add home-made helper(s).
diff --git a/my_app.yml b/my_app.yml
index 8817473..8163638 100644
--- a/my_app.yml
+++ b/my_app.yml
@@ -3,3 +3,9 @@ secrets:
- 197b9b0060f3285c0909d83598e54f9ec0602151
default-rows-per-page: 12
maximum-rows-per-page: 100
+
+# Copy these to local-override.yml, uncomment and set to your liking,
+# then the about page will invite email.
+#email-address: webmaster@example.com?Subject=Awesome site!
+#email-name: webmaster@example.com
+
diff --git a/templates/book/about.html.ep b/templates/book/about.html.ep
index 76a8a29..f908ad5 100644
--- a/templates/book/about.html.ep
+++ b/templates/book/about.html.ep
@@ -43,9 +43,11 @@ or "Name like" on the authors page). Other non-authors are
"Anonymous" and "Unknown".
+% if (config->{'email-address'}) {
-Comments and questions welcome
-at barnold@tilde.club.
+Comments and questions are welcome at
+<%= config->{'email-name'} %>.
+% }