feat(social): supports rel-me links

This commit is contained in:
Anhgelus Morhtuuzh 2025-05-19 23:55:02 +02:00
parent cf36d7daa9
commit d7598a843e
No known key found for this signature in database
GPG key ID: CAD341EFA92DDDE5
5 changed files with 14 additions and 12 deletions

View file

@ -21,18 +21,21 @@ This font must be compressed by [Woff2](https://en.wikipedia.org/wiki/Web_Open_F
### 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.
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 and the path to
the configs of custom pages.
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 "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"
custom_pages = ["custom.toml"]
rel_me_links = ["https://foo.example.org/@bar"]
```
The path is relative to the execution of the binary.
If you are using Docker, please use a static path.

View file

@ -160,6 +160,9 @@
},
"custom_pages": {
"type": "array"
},
"rel_me_links": {
"type": "array"
}
},
"additionalProperties": false,

10
data.go
View file

@ -11,15 +11,6 @@ import (
"strings"
)
const (
TitleContentType = "title"
SubtitleContentType = "subtitle"
ParagraphContentType = "paragraph"
ListContentType = "list"
OrderedListContentType = "ordered_list"
ButtonsContentType = "links"
)
type ConfigData interface {
GetTextColor() template.CSS
GetBackground() template.CSS
@ -34,6 +25,7 @@ type Config struct {
Color *Color `json:"colors" toml:"colors"`
Links []*Link `json:"links" toml:"links"`
Legal string `json:"legal" toml:"legal"`
RelMeLinks []string `json:"rel_me_links" toml:"rel_me_links"`
CustomPages []string `json:"custom_pages" toml:"custom_pages"`
}

View file

@ -174,6 +174,7 @@ func generateConfigFile(isToml bool) {
},
Legal: "legal.html",
CustomPages: []string{"custom.json"},
RelMeLinks: []string{"https://foo.example.org/@bar"},
}
var b []byte
var err error

View file

@ -13,6 +13,9 @@
.links { {{ .Data.Color.Button.GetBackground }}{{ .Data.Color.Button.GetTextColor }} }
</style>
{{ end }}
{{ range .Data.RelMeLinks }}
<link rel="me" href="{{ . }}" />
{{ end }}
</head>
<body style="{{ .Data.GetBackgroundImage }}{{ .Data.GetTextColor }}">
<div class="center">