aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Hergès <william@herges.fr>2025-09-06 22:40:59 +0200
committerWilliam Hergès <william@herges.fr>2025-09-06 22:40:59 +0200
commit8ae1115ba712209cb6b974e81a3a4c4745e36c94 (patch)
tree6bb54c05e1f1bcd3f39793d13867635f20da0c2a
parent6f6f10cedcbc46ef125bd067bc8d084d29c76afe (diff)
feat(config): customize font file path, extension and name
-rw-r--r--README.md14
-rw-r--r--config.schema.json177
-rw-r--r--custom_page.schema.json102
-rw-r--r--data.go6
-rw-r--r--main.go17
-rw-r--r--scss/main.scss8
-rw-r--r--templates/base/base.gohtml11
7 files changed, 32 insertions, 303 deletions
diff --git a/README.md b/README.md
index 955d364..9c8b469 100644
--- a/README.md
+++ b/README.md
@@ -14,30 +14,28 @@ You must have a `public` directory.
Everything located inside will be available at the path `/static/PATH` where `PATH` is the relative path inside the
`public` directory.
-You can change the font by adding a file named `font.woff2` inside the `public` directory.
-This font must be compressed by [Woff2](https://en.wikipedia.org/wiki/Web_Open_Font_Format).
-(You can compress them with the command `woff2_compress` available in the package `woff2` of many Linux distributions.)
-
### Main config
You can create a sample config with the flag `-generate-json-config` (which generates a JSON config) or with
`-generate-toml-config` (which generates a TOML config).
-A JSON schema is available for JSON configs.
The config does not depend on the markup language: a field `foo` will being named `foo` for JSON and TOML.
The TOML format is used in this section.
-The root is defining the background image, the description, the file's path to the legal pages, the path to
-the configs of custom pages and a list of all your ["rel-me"](https://microformats.org/wiki/rel-me) links.
+The root is defining the background image, the description, the file's path to the legal pages, the path to the custom
+font (you can remove this if you want to use `Raveo, Inter, Roboto` as default fonts), the path to the configs of custom
+pages and a list of all your ["rel-me"](https://microformats.org/wiki/rel-me) links.
(The "rel-me" links are required to
[verify a link on your Mastodon account](https://docs.joinmastodon.org/user/profile/#verification), for example.)
```toml
image = "wallpaper.webp"
description = "I am a beautiful description!"
legal = "legal.html"
+font = ""
custom_pages = ["custom.toml"]
rel_me_links = ["https://foo.example.org/@bar"]
```
-The path is relative to the execution of the binary.
+The path is relative to the execution of the binary, except for `image` and `font` which are relative to the `public`
+folder.
If you are using Docker, please use a static path.
The first section is defining who you are.
diff --git a/config.schema.json b/config.schema.json
deleted file mode 100644
index f2a2600..0000000
--- a/config.schema.json
+++ /dev/null
@@ -1,177 +0,0 @@
-{
- "type": "object",
- "properties": {
- "colors": {
- "type": "object",
- "properties": {
- "background": {
- "type": "object",
- "properties": {
- "angle": {
- "type": "integer",
- "format": "int32",
- "minimum": 0,
- "maximum": 359
- },
- "colors": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "color": {
- "type": "string"
- },
- "position": {
- "type": "integer",
- "format": "int32",
- "minimum": 0,
- "maximum": 100
- }
- },
- "additionalProperties": false,
- "required": [
- "color",
- "position"
- ]
- }
- },
- "type": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "type",
- "angle",
- "colors"
- ]
- },
- "buttons": {
- "type": "object",
- "properties": {
- "background": {
- "type": "string"
- },
- "background_hover": {
- "type": "string"
- },
- "text": {
- "type": "string"
- },
- "text_hover": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "text",
- "text_hover",
- "background",
- "background_hover"
- ]
- },
- "text": {
- "type": "string"
- },
- "tag_hover": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "background",
- "buttons",
- "text",
- "tag_hover"
- ]
- },
- "description": {
- "type": "string"
- },
- "image": {
- "type": "string"
- },
- "legal": {
- "type": "string",
- "additionalProperties": false
- },
- "links": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "content": {
- "type": "string"
- },
- "link": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "link",
- "content"
- ]
- }
- },
- "person": {
- "type": "object",
- "properties": {
- "image": {
- "type": "string"
- },
- "name": {
- "type": "string"
- },
- "pronouns": {
- "type": "string"
- },
- "tags": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "description": {
- "type": "string"
- },
- "name": {
- "type": "string"
- },
- "link": {
- "type": "string"
- }
- },
- "additionalProperties": false,
- "required": [
- "name",
- "description",
- "link"
- ]
- }
- }
- },
- "additionalProperties": false,
- "required": [
- "name",
- "pronouns",
- "image",
- "tags"
- ]
- },
- "custom_pages": {
- "type": "array"
- },
- "rel_me_links": {
- "type": "array"
- }
- },
- "additionalProperties": false,
- "required": [
- "image",
- "description",
- "person",
- "colors",
- "links",
- "legal"
- ]
-}
diff --git a/custom_page.schema.json b/custom_page.schema.json
deleted file mode 100644
index adb7fce..0000000
--- a/custom_page.schema.json
+++ /dev/null
@@ -1,102 +0,0 @@
-{
- "type": "object",
- "properties": {
- "title": {
- "type": "string"
- },
- "uri": {
- "type": "string"
- },
- "image": {
- "type": "string"
- },
- "description": {
- "type": "string"
- },
- "colors": {
- "type": "object",
- "properties": {
- "text": {
- "type": "string"
- },
- "tag_hover": {
- "type": "string"
- },
- "background": {
- "type": "object",
- "properties": {
- "type": {
- "type": "string"
- },
- "angle": {
- "type": "number"
- },
- "colors": {
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "color": {
- "type": "string"
- },
- "position": {
- "type": "number"
- }
- },
- "required": [
- "color",
- "position"
- ]
- }
- }
- },
- "required": [
- "type",
- "angle",
- "colors"
- ]
- },
- "buttons": {
- "type": "object",
- "properties": {
- "text": {
- "type": "string"
- },
- "text_hover": {
- "type": "string"
- },
- "background": {
- "type": "string"
- },
- "background_hover": {
- "type": "string"
- }
- },
- "required": [
- "text",
- "text_hover",
- "background",
- "background_hover"
- ]
- }
- },
- "required": [
- "text",
- "tag_hover",
- "background",
- "buttons"
- ]
- },
- "content": {
- "type": "string"
- }
- },
- "required": [
- "title",
- "uri",
- "image",
- "description",
- "colors",
- "content"
- ]
-} \ No newline at end of file
diff --git a/data.go b/data.go
index 7782b7b..fccaec3 100644
--- a/data.go
+++ b/data.go
@@ -3,13 +3,14 @@ package main
import (
"encoding/json"
"errors"
- "github.com/BurntSushi/toml"
- "github.com/anhgelus/golatt"
"html/template"
"os"
"regexp"
"strconv"
"strings"
+
+ "github.com/BurntSushi/toml"
+ "github.com/anhgelus/golatt"
)
var (
@@ -28,6 +29,7 @@ type Config struct {
Description string `json:"description" toml:"description"`
folder string
Legal string `json:"legal" toml:"legal"`
+ Font string `json:"font" toml:"font"`
RelMeLinks []string `json:"rel_me_links" toml:"rel_me_links"`
CustomPages []string `json:"custom_pages" toml:"custom_pages"`
Person *Person `json:"person" toml:"person"`
diff --git a/main.go b/main.go
index f2e7ab5..b0ba740 100644
--- a/main.go
+++ b/main.go
@@ -5,13 +5,14 @@ import (
"encoding/json"
"flag"
"fmt"
- "github.com/BurntSushi/toml"
- "github.com/anhgelus/golatt"
"html/template"
"log/slog"
"net/http"
"os"
"strings"
+
+ "github.com/BurntSushi/toml"
+ "github.com/anhgelus/golatt"
)
var (
@@ -117,15 +118,15 @@ func main() {
"Legal things",
"",
"Legal information about "+cfg.Person.Name+"'s Now page",
- &cfg).
- Handle()
+ &cfg,
+ ).Handle()
g.NewTemplate("tags",
"/tags",
"Tags",
"",
"Tags of "+cfg.Person.Name+"'s Now page",
- &cfg).
- Handle()
+ &cfg,
+ ).Handle()
for _, cp := range customPages {
slog.Info("Creating custom page...", "title", cp.Title, "uri", cp.URI)
@@ -134,8 +135,8 @@ func main() {
cp.Title,
cp.Image,
cp.Description,
- cp).
- Handle()
+ cp,
+ ).Handle()
}
g.NotFoundHandler = func(w http.ResponseWriter, r *http.Request) {
diff --git a/scss/main.scss b/scss/main.scss
index e3f1307..c877867 100644
--- a/scss/main.scss
+++ b/scss/main.scss
@@ -5,16 +5,12 @@
:root {
--text-color: #000;
font-size: 18px;
-}
-
-@font-face {
- font-family: "custom";
- src: url("/static/font.woff2");
+ --fonts: Raveo, Inter, Roboto; // default fonts
}
body {
--background-image: ;
- font-family: "custom", Raveo, Inter, Roboto, sans-serif;
+ font-family: var(--fonts), sans-serif;
background: #000;
background-size: cover;
color: var(--text-color);
diff --git a/templates/base/base.gohtml b/templates/base/base.gohtml
index 785bbaf..716b1ca 100644
--- a/templates/base/base.gohtml
+++ b/templates/base/base.gohtml
@@ -6,6 +6,17 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="shortcut icon" href="{{getStaticPath "logo.png"}}" type="image/png" />
<title>{{ .Title }}</title>
+ <style>
+ {{ if ne .Data.Font "" }}
+ @font-face {
+ font-family: "custom";
+ src: url("{{ getStaticPath .Data.Font }}");
+ }
+ body {
+ --fonts: "custom";
+ }
+ {{ end }}
+ </style>
<link rel="stylesheet" href="{{getAssetPath "styles.css"}}" />
{{template "opengraph-base" .SEO}}
{{ if .Data.IsCustomPage }}