diff options
Diffstat (limited to 'backend/data.go')
| -rw-r--r-- | backend/data.go | 9 |
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 |
