aboutsummaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2025-10-03 10:53:35 +0200
committerAnhgelus Morhtuuzh <william@herges.fr>2025-10-03 10:53:35 +0200
commita2dad61a48af63db2fd00bee3f6ea487720d33bd (patch)
tree641c686472c5748369884fa8a6097f874ab78146 /backend
parent620b03459751a17632f6165b289206dc6d86ed7c (diff)
feat(backend): customize quotes
Diffstat (limited to 'backend')
-rw-r--r--backend/config.go13
-rw-r--r--backend/data.go9
-rw-r--r--backend/templates/base.html6
3 files changed, 19 insertions, 9 deletions
diff --git a/backend/config.go b/backend/config.go
index c5a44ef..b1fcbd8 100644
--- a/backend/config.go
+++ b/backend/config.go
@@ -18,12 +18,13 @@ type Logo struct {
}
type Config struct {
- Domain string `toml:"domain"`
- Name string `toml:"name"`
- Description string `toml:"description"`
- Links []Link `toml:"links"`
- Logo Logo `toml:"logo"`
- LogFolder string `toml:"log_folder"`
+ Domain string `toml:"domain"`
+ Name string `toml:"name"`
+ Description string `toml:"description"`
+ Links []Link `toml:"links"`
+ Logo Logo `toml:"logo"`
+ LogFolder string `toml:"log_folder"`
+ Quotes []string `toml:"quotes"`
}
func (c *Config) DefaultValues() {
diff --git a/backend/data.go b/backend/data.go
index 9c30c6b..e841669 100644
--- a/backend/data.go
+++ b/backend/data.go
@@ -3,6 +3,7 @@ package backend
import (
"fmt"
"html/template"
+ "math/rand"
"net/http"
"regexp"
"strings"
@@ -26,6 +27,7 @@ type data struct {
Name string
Links []Link
Logo *Logo
+ Quote string
}
func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string, custom dataUsable) {
@@ -45,6 +47,13 @@ func (d *data) handleGeneric(w http.ResponseWriter, r *http.Request, name string
if d.Logo == nil {
d.Logo = &cfg.Logo
}
+ if d.Quote == "" {
+ if cfg.Quotes == nil {
+ d.Quote = "Une citation"
+ } else {
+ d.Quote = cfg.Quotes[rand.Intn(len(cfg.Quotes))]
+ }
+ }
if d.URL == "" {
if !strings.HasPrefix(r.URL.Path, "/") {
r.URL.Path = "/" + r.URL.Path
diff --git a/backend/templates/base.html b/backend/templates/base.html
index bef493f..8d8567a 100644
--- a/backend/templates/base.html
+++ b/backend/templates/base.html
@@ -38,8 +38,8 @@
{{ end }}
<footer>
<p>&copy; 2025 - Anhgelus Morthuuzh</p>
- <p>«&thinsp;Une citation&thinsp;»</p>
- <p><a href="">Mentions légales</a></p>
+ <p>«&thinsp;{{ .Quote }}&thinsp;»</p>
+ <p><a href="">Mentions légales</a>, <a href="https://git.anhgelus.world/anhgelus/small-web">Code source</a></p>
</footer>
</body>
-</html> \ No newline at end of file
+</html>