Browse Source

Added custom CSS support

master
Patrick Gaskin 6 months ago
parent
commit
2deff0e170
Signed by: geek1011 GPG Key ID: A2FD79F68A2AB707
2 changed files with 12 additions and 2 deletions
  1. +4
    -2
      config.go
  2. +8
    -0
      render.go

+ 4
- 2
config.go View File

@ -66,6 +66,8 @@ func (c Config) Filtered(authProvider, authUser string) Config {
type DashboardSettings struct {
// Title is a custom page title to use.
Title string `toml:"title"`
// CustomCSS is added to the page.
CustomCSS string `toml:"custom_css"`
}
func (d DashboardSettings) Validate() error {
@ -225,14 +227,14 @@ func (a AuthProviderJWT) KeyFunc() (jwt.Keyfunc, error) {
case *jwt.SigningMethodRSA, *jwt.SigningMethodRSAPSS:
k, err := jwt.ParseRSAPublicKeyFromPEM([]byte(secret))
if err != nil {
return nil, fmt.Errorf("error parsing RSA public key from provided PEM: %w", err)
return nil, fmt.Errorf("error parsing RSA public key %#v from provided PEM: %w", secret, err)
}
return jwt.KnownKeyfunc(sm, k), nil
case *jwt.SigningMethodECDSA:
k, err := jwt.ParseECPublicKeyFromPEM([]byte(secret))
if err != nil {
return nil, fmt.Errorf("error parsing ECDSA public key from provided PEM: %w", err)
return nil, fmt.Errorf("error parsing ECDSA public key %#v from provided PEM: %w", secret, err)
}
return jwt.KnownKeyfunc(sm, k), nil

+ 8
- 0
render.go View File

@ -27,6 +27,9 @@ var tmpl = template.Must(template.New("").Funcs(template.FuncMap{
"rawurl": func(v interface{}) template.URL {
return template.URL(fmt.Sprint(v))
},
"rawcss": func(v interface{}) template.CSS {
return template.CSS(fmt.Sprint(v))
},
}).Parse(`<!DOCTYPE html>
<html lang="en">
<head>
@ -193,6 +196,11 @@ var tmpl = template.Must(template.New("").Funcs(template.FuncMap{
right: 4px;
}
</style>
{{with .Config.Dashboard.CustomCSS}}
<style>
{{rawcss .}}
</style>
{{end}}
</head>
<body>
<main class="content">

Loading…
Cancel
Save