From a2dad61a48af63db2fd00bee3f6ea487720d33bd Mon Sep 17 00:00:00 2001 From: Anhgelus Morhtuuzh Date: Fri, 3 Oct 2025 10:53:35 +0200 Subject: feat(backend): customize quotes --- backend/data.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'backend/data.go') 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 -- cgit v1.2.3