Some Styling

This commit is contained in:
Simon Martens
2025-09-14 18:19:37 +02:00
parent 44c7258a50
commit 7fc3ee238c
19 changed files with 1778 additions and 452 deletions

View File

@@ -21,7 +21,8 @@ import (
// It is meant to be constructed once and then used as a singleton.
const (
IMG_PREFIX = "/img/"
IMG_PREFIX = "/img/"
PICTURES_PREFIX = "/static/pictures/"
EDITION_URL = "/edition/"
PRIVACY_URL = "/datenschutz/"
@@ -71,7 +72,7 @@ func NewKGPZ(config *providers.ConfigProvider) (*KGPZ, error) {
}
func (k *KGPZ) Pre(srv *fiber.App) error {
// Check if folder exists and if yes, serve image files from i
// Check if folder exists and if yes, serve image files from it
if _, err := os.Stat(k.Config.Config.ImgPath); err == nil {
fs := os.DirFS(k.Config.Config.ImgPath)
srv.Use(IMG_PREFIX, etag.New())
@@ -80,6 +81,16 @@ func (k *KGPZ) Pre(srv *fiber.App) error {
logging.Info("Image folder not found. Skipping image serving.")
}
// Serve newspaper pictures from pictures directory
if _, err := os.Stat("pictures"); err == nil {
picturesFS := os.DirFS("pictures")
srv.Use(PICTURES_PREFIX, etag.New())
srv.Use(PICTURES_PREFIX, helpers.StaticHandler(&picturesFS))
logging.Info("Serving newspaper pictures from pictures/ directory.")
} else {
logging.Info("Pictures folder not found. Skipping picture serving.")
}
return nil
}