2023-09-08 19:08:13 +00:00
|
|
|
import tomllib
|
|
|
|
|
2022-11-04 18:49:31 +00:00
|
|
|
from pydantic import BaseModel
|
|
|
|
|
2023-09-08 19:08:13 +00:00
|
|
|
from .settings import SETTINGS
|
|
|
|
from .webdav import WebDAV
|
|
|
|
|
2022-11-04 18:49:31 +00:00
|
|
|
|
2022-11-15 22:17:32 +00:00
|
|
|
class User(BaseModel):
|
|
|
|
name: str
|
|
|
|
password: str
|
|
|
|
|
|
|
|
|
2023-09-21 11:49:28 +00:00
|
|
|
class Puzzle(BaseModel):
|
|
|
|
# Titel
|
2023-09-26 22:23:23 +00:00
|
|
|
# TODO penner neue Route GET /user/title
|
2023-09-21 11:49:28 +00:00
|
|
|
title: str
|
|
|
|
|
|
|
|
# Lösungswort
|
|
|
|
solution: str
|
2023-09-07 16:44:44 +00:00
|
|
|
|
2023-09-14 23:38:35 +00:00
|
|
|
# Tag, an dem der Kalender startet
|
|
|
|
# TODO penner
|
2023-09-20 16:14:58 +00:00
|
|
|
begin_day: int = 1
|
2023-09-14 23:38:35 +00:00
|
|
|
|
|
|
|
# Monat, in dem der Kalender startet
|
2023-09-08 10:23:43 +00:00
|
|
|
# TODO penner
|
2023-09-20 16:14:58 +00:00
|
|
|
begin_month: int = 12
|
2023-09-07 16:44:44 +00:00
|
|
|
|
2023-09-20 16:14:58 +00:00
|
|
|
# Kalender so viele Tage nach der letzten Türöffnung schließen
|
2023-09-08 10:23:43 +00:00
|
|
|
# TODO penner
|
2023-09-20 16:14:58 +00:00
|
|
|
close_after: int = 90
|
2023-09-07 19:34:11 +00:00
|
|
|
|
|
|
|
|
2023-09-21 11:49:28 +00:00
|
|
|
class TTFont(BaseModel):
|
|
|
|
# Dateiname (in "/files")
|
|
|
|
file: str
|
2023-09-12 20:45:57 +00:00
|
|
|
|
2023-09-21 11:49:28 +00:00
|
|
|
# Schriftgröße für den Font
|
|
|
|
size: int = 50
|
2023-09-07 16:44:44 +00:00
|
|
|
|
2023-09-07 21:05:00 +00:00
|
|
|
|
2023-09-21 11:49:28 +00:00
|
|
|
class Image(BaseModel):
|
|
|
|
# Quadrat, Seitenlänge in px
|
|
|
|
# TODO penner
|
|
|
|
size: int = 1000
|
|
|
|
|
|
|
|
# Rand in px, wo keine Buchstaben untergebracht werden
|
|
|
|
# TODO penner
|
|
|
|
border: int = 60
|
|
|
|
|
|
|
|
# Schriftarten
|
|
|
|
# TODO
|
|
|
|
fonts: list[TTFont]
|
2023-09-07 21:05:00 +00:00
|
|
|
|
2023-09-07 16:44:44 +00:00
|
|
|
|
2022-11-04 18:49:31 +00:00
|
|
|
class Config(BaseModel):
|
2022-11-15 22:17:32 +00:00
|
|
|
admin: User
|
2022-11-18 01:39:05 +00:00
|
|
|
puzzle: Puzzle
|
2023-09-21 11:49:28 +00:00
|
|
|
image: Image
|
|
|
|
|
|
|
|
# Kalenderdefinition
|
|
|
|
calendar: str = "default.toml"
|
|
|
|
|
|
|
|
# Serverseitiger zusätzlicher "random" seed
|
|
|
|
random_seed: str = ""
|
2023-09-08 19:08:13 +00:00
|
|
|
|
2023-09-26 22:23:23 +00:00
|
|
|
# Fußzeile der Seite
|
|
|
|
footer: str = (
|
|
|
|
'<strong>Advent22</strong> by <a href="//www.lenaisten.de">Lenaisten e.V.</a>'
|
|
|
|
)
|
|
|
|
|
2023-09-08 19:53:35 +00:00
|
|
|
|
2023-09-14 23:38:35 +00:00
|
|
|
async def get_config() -> Config:
|
2023-09-08 19:53:35 +00:00
|
|
|
"""
|
|
|
|
Globale Konfiguration lesen
|
|
|
|
"""
|
|
|
|
|
2023-09-10 02:59:57 +00:00
|
|
|
txt = await WebDAV.read_str(path=SETTINGS.webdav.config_filename)
|
2023-09-08 19:53:35 +00:00
|
|
|
return Config.model_validate(tomllib.loads(txt))
|