cerca

lean forum software (pmc local branch)
Log | Files | Refs | README | LICENSE

commit 1e8561e2e2794fb62c9d81659e13715c5b28a35d
parent c5266f64c942b1ae43ef056213214723cbc3d71d
Author: cblgh <cblgh@cblgh.org>
Date:   Tue, 18 Oct 2022 16:21:49 +0200

defaults tweakin and logo riffing

Diffstat:
Mdefaults/defaults.go | 2+-
Mdefaults/sample-config.toml | 13+++----------
Adefaults/sample-logo.html | 17+++++++++++++++++
Ddefaults/sample-logo.svg | 7-------
Mhtml/head.html | 6++++--
Mserver/server.go | 8+++++++-
Mtypes/types.go | 7-------
7 files changed, 32 insertions(+), 28 deletions(-)

diff --git a/defaults/defaults.go b/defaults/defaults.go @@ -7,7 +7,7 @@ import ( //go:embed sample-about.md var DEFAULT_ABOUT string -//go:embed sample-logo.svg +//go:embed sample-logo.html var DEFAULT_LOGO string //go:embed sample-rules.md diff --git a/defaults/sample-config.toml b/defaults/sample-config.toml @@ -1,17 +1,10 @@ [general] name = "" -link = "" -conduct_url = "" -language = "" - -[theme] -background = "" -foreground = "" -links = "" +conduct_url = "" # optional + recommended: if omitted, the checkboxes in registration relating to CoC will be hidden +language = "" # Swedish, English [documents] -logo = "logo.svg" +logo = "logo.html" about = "about.md" rules = "rules.md" verification_explanation = "verification-instructions.md" -custom_css = "" diff --git a/defaults/sample-logo.html b/defaults/sample-logo.html @@ -0,0 +1,17 @@ +<!-- here's how to have an svg logo --> +<svg aria-hidden="true" style="margin-bottom: 0;" width="48" height="48" fill="black" stroke="none" viewBox="60 60 200 200" xmlns="http://www.w3.org/2000/svg"> +<g> +<path d="M185,65 A60,60 0 0,0 125,125 L185,125 Z M125,245 A60,60 0 0,0 185,185 L125,185 Z M95,125 A30,30 0 0,1 125,155 A30,30 0 0,1 95,185 A30,30 0 0,1 65,155 A30,30 0 0,1 95,125 Z M155,125 A30,30 0 0,1 185,155 A30,30 0 0,1 155,185 A30,30 0 0,1 125,155 A30,30 0 0,1 155,125 Z M215,125 A30,30 0 0,1 245,155 A30,30 0 0,1 215,185 A30,30 0 0,1 185,155 A30,30 0 0,1 215,125 "/> +<path d="M125,65 A60,60 0 0,1 185,125 L125,125 Z M185,245 A60,60 0 0,1 125,185 L185,185 Z M65,65 A60,60 0 0,1 125,125 L65,125 Z M65,245 A60,60 0 0,0 125,185 L65,185 Z M245,65 A60,60 0 0,0 185,125 L245,125 Z M245,245 A60,60 0 0,1 185,185 L245,185 Z"/> +</g> +</svg> +--> + +<!-- here's how to have a png logo +it's important with the path starting with /assets/, and that the loaded asset is inside dir <cercaroot>/html/assets +<img src="/assets/merveilles.png"> +--> + +<!-- here's how to have an emoji logo +<h1>🍵</h1> +--> diff --git a/defaults/sample-logo.svg b/defaults/sample-logo.svg @@ -1,6 +0,0 @@ -<svg width="30" height="30" fill="black" stroke="none" viewBox="60 60 200 200" xmlns="http://www.w3.org/2000/svg"> - <g> - <path d="M185,65 A60,60 0 0,0 125,125 L185,125 Z M125,245 A60,60 0 0,0 185,185 L125,185 Z M95,125 A30,30 0 0,1 125,155 A30,30 0 0,1 95,185 A30,30 0 0,1 65,155 A30,30 0 0,1 95,125 Z M155,125 A30,30 0 0,1 185,155 A30,30 0 0,1 155,185 A30,30 0 0,1 125,155 A30,30 0 0,1 155,125 Z M215,125 A30,30 0 0,1 245,155 A30,30 0 0,1 215,185 A30,30 0 0,1 185,155 A30,30 0 0,1 215,125 "/> - <path d="M125,65 A60,60 0 0,1 185,125 L125,125 Z M185,245 A60,60 0 0,1 125,185 L185,185 Z M65,65 A60,60 0 0,1 125,125 L65,125 Z M65,245 A60,60 0 0,0 125,185 L65,185 Z M245,65 A60,60 0 0,0 185,125 L245,125 Z M245,245 A60,60 0 0,1 185,185 L245,185 Z"/> - </g> -</svg> -\ No newline at end of file diff --git a/html/head.html b/html/head.html @@ -117,7 +117,6 @@ } header > a { - background-image: url('/assets/merveilles.png'); background-size: 100%; background-repeat: no-repeat; display: inline-block; @@ -158,7 +157,7 @@ } </style> - <!-- <link href="/assets/style.css" rel="stylesheet"> --> + <link href="/assets/theme.css" rel="stylesheet"> <link rel="icon" href="/assets/favicon.png"> <!-- <link rel="icon" href="/assets/favicon.svg" type="image/svg+xml"> --> @@ -184,12 +183,15 @@ <body> <header> <a style="margin-bottom: 0; height: 48px;" href="/" aria-label='{{ "AriaHome" | translate }}'> + {{ dumpLogo }} + <!-- <svg aria-hidden="true" style="margin-bottom: 0;" width="48" height="48" fill="black" stroke="none" viewBox="60 60 200 200" xmlns="http://www.w3.org/2000/svg"> <g> <path d="M185,65 A60,60 0 0,0 125,125 L185,125 Z M125,245 A60,60 0 0,0 185,185 L125,185 Z M95,125 A30,30 0 0,1 125,155 A30,30 0 0,1 95,185 A30,30 0 0,1 65,155 A30,30 0 0,1 95,125 Z M155,125 A30,30 0 0,1 185,155 A30,30 0 0,1 155,185 A30,30 0 0,1 125,155 A30,30 0 0,1 155,125 Z M215,125 A30,30 0 0,1 245,155 A30,30 0 0,1 215,185 A30,30 0 0,1 185,155 A30,30 0 0,1 215,125 "/> <path d="M125,65 A60,60 0 0,1 185,125 L125,125 Z M185,245 A60,60 0 0,1 125,185 L185,185 Z M65,65 A60,60 0 0,1 125,125 L65,125 Z M65,245 A60,60 0 0,0 125,185 L65,185 Z M245,65 A60,60 0 0,0 185,125 L245,125 Z M245,245 A60,60 0 0,1 185,185 L245,185 Z"/> </g> </svg> + --> </a> <nav> <ul type="menu"> diff --git a/server/server.go b/server/server.go @@ -134,9 +134,15 @@ func (h RequestHandler) IsLoggedIn(req *http.Request) (bool, int) { return true, userid } +// establish closure over config + translator so that it's present in templates during render func generateTemplates(config types.Config, translator i18n.Translator) (*template.Template, error) { - // establish closure over translator so that it's present in templates during render + // only read logo contents once when generating + logo, err := os.ReadFile(config.Documents.LogoPath) + util.Check(err, "generate-template: dump logo") templateFuncs := template.FuncMap{ + "dumpLogo": func() template.HTML { + return template.HTML(logo) + }, "formatDateTime": func(t time.Time) string { return t.Format("2006-01-02 15:04:05") }, diff --git a/types/types.go b/types/types.go @@ -12,18 +12,11 @@ type Config struct { Language string `json:"language"` } `json:"general"` - Theme struct { - Background string `json:"background"` - Foreground string `json:"foreground"` - Links string `json:"links"` - } `json:"theme"` - Documents struct { LogoPath string `json:"logo"` AboutPath string `json:"about"` RegisterRulesPath string `json:"rules"` VerificationExplanationPath string `json:"verification_explanation"` - CustomCSSPath string `json:"custom_css"` } `json:"documents"` }