aboutsummaryrefslogtreecommitdiff
path: root/backend/data.go
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/data.go
parent620b03459751a17632f6165b289206dc6d86ed7c (diff)
feat(backend): customize quotes
Diffstat (limited to 'backend/data.go')
-rw-r--r--backend/data.go9
1 files changed, 9 insertions, 0 deletions
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