Add appearance settings

This commit is contained in:
Ivan R. 2023-11-02 21:20:10 +05:00
parent 00dcd04eb7
commit 9d269ba79f
No known key found for this signature in database
GPG key ID: 56C7BAAE859B302C
9 changed files with 14 additions and 6 deletions

View file

@ -10,7 +10,6 @@ body {
linear-gradient(90deg, #1d1926 19px, transparent 1px) center, linear-gradient(90deg, #1d1926 19px, transparent 1px) center,
#7a7093; #7a7093;
background-size: 20px 20px; background-size: 20px 20px;
font-family: sans-serif;
font-size: 16px; font-size: 16px;
color: white; color: white;
} }

View file

@ -19,6 +19,8 @@ type Config struct {
SecureCookie bool `default:"true"` SecureCookie bool `default:"true"`
Title string `default:"Phoenix"` Title string `default:"Phoenix"`
// Any supported css value, embedded directly into every page.
FontFamily string `default:"sans-serif"`
} }
func GetConfig() (*Config, error) { func GetConfig() (*Config, error) {

View file

@ -31,7 +31,8 @@ Service settings can be set through environment variables.
Appearance settings: Appearance settings:
| Variable | Description | Default | | Variable | Description | Default |
| --- | --- | --- | | --- | --- | --- |
| P_TITLE | Website title | Phoenix | | P_TITLE | Website title | `Phoenix` |
| P_FONTFAMILY | The font used on the site. Inserted directly into css. | `sans-serif` |
## Docker-compose example ## Docker-compose example
```yml ```yml

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
{{template "head"}} {{template "head" .}}
<link rel="stylesheet" href="assets/css/auth.css" /> <link rel="stylesheet" href="assets/css/auth.css" />
</head> </head>
<body> <body>

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
{{template "head"}} {{template "head" .}}
<link rel="stylesheet" href="assets/css/error.css" /> <link rel="stylesheet" href="assets/css/error.css" />
</head> </head>
<body> <body>

View file

@ -8,4 +8,9 @@
<link rel="icon" type="image/png" href="/assets/favicons/favicon-32.png" sizes="32x32" /> <link rel="icon" type="image/png" href="/assets/favicons/favicon-32.png" sizes="32x32" />
<link rel="icon" type="image/svg+xml" href="/assets/favicons/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/assets/favicons/favicon.svg" />
<link rel="apple-touch-icon" href="/assets/favicons/favicon-180.png" /> <link rel="apple-touch-icon" href="/assets/favicons/favicon-180.png" />
<style>
body {
font-family: {{.FontFamily}};
}
</style>
{{end}} {{end}}

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
{{template "head"}} {{template "head" .}}
<link rel="stylesheet" href="assets/css/index.css" /> <link rel="stylesheet" href="assets/css/index.css" />
</head> </head>
<body> <body>

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
{{template "head"}} {{template "head" .}}
<link rel="stylesheet" href="assets/css/settings.css" /> <link rel="stylesheet" href="assets/css/settings.css" />
</head> </head>
<body> <body>

View file

@ -8,5 +8,6 @@ import (
// Fill in the necessary parameters from the settings and output html. // Fill in the necessary parameters from the settings and output html.
func Render(ctx *gin.Context, cfg *config.Config, status int, templatePath string, params map[string]any) { func Render(ctx *gin.Context, cfg *config.Config, status int, templatePath string, params map[string]any) {
params["WebsiteTitle"] = cfg.Title params["WebsiteTitle"] = cfg.Title
params["FontFamily"] = cfg.FontFamily
ctx.HTML(status, templatePath, params) ctx.HTML(status, templatePath, params)
} }