diff options
| author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2025-11-01 18:34:04 +0100 |
|---|---|---|
| committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2025-11-01 18:34:04 +0100 |
| commit | c6f77e08b8a26ec740f3121edbb7a9d06c04ce20 (patch) | |
| tree | 7155f98f89a8d7ba310416ca13170b3af172a509 /templates/base.qtpl | |
| parent | 49fc8733129028ff4a3537b9eb20f548f0e3e9e6 (diff) | |
| download | cerrado-c6f77e08b8a26ec740f3121edbb7a9d06c04ce20.tar.gz cerrado-c6f77e08b8a26ec740f3121edbb7a9d06c04ce20.tar.bz2 cerrado-c6f77e08b8a26ec740f3121edbb7a9d06c04ce20.zip | |
feat: Add session variable
This will allow the css to be refreshed once the server is restarted.
This allows the admin to update the theme configuration and have it
reflected in the browser.
Diffstat (limited to 'templates/base.qtpl')
| -rw-r--r-- | templates/base.qtpl | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/templates/base.qtpl b/templates/base.qtpl index 1dddb57..6ff3d53 100644 --- a/templates/base.qtpl +++ b/templates/base.qtpl @@ -1,11 +1,28 @@ This is a base page template. All the other template pages implement this interface. {% import "context" %} +{% import "crypto/rand" %} +{% import "encoding/hex" %} {% import "strconv" %} {% import "time" %} -{% code +{% code + var Slug = "" + var Session = "" + + func init() { + Session = hex.EncodeToString(generateSmallTimeID()) +} + +func generateSmallTimeID() []byte { + b := make([]byte, 4) + _, err := rand.Read(b) + if err != nil { + panic(err) + } + return b +} %} {% interface @@ -58,9 +75,9 @@ Page prints a page implementing Page interface. <head> <meta charset="utf-8"> <link rel="icon" href="data:,"> - <title>{%= p.Title(ctx) %}</title> + <title>{%= p.Title(ctx) %}</title> <link rel="stylesheet" href="/static/main{%s Slug %}.css"> - <link rel="stylesheet" href="/static/theme{%s Slug %}.css"> + <link rel="stylesheet" href="/static/theme.{%s Session %}{%s Slug %}.css"> <html data-bs-theme="dark"> <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> <meta name="viewport" content="width=device-width, initial-scale=1" /> |
