Saner file names

This commit is contained in:
Simon Martens
2024-12-21 11:15:03 +01:00
parent 977d7331d5
commit ff3ed74b5e
14 changed files with 19 additions and 23 deletions

View File

@@ -0,0 +1,30 @@
package controllers
import (
"strconv"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/app"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/logging"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/viewmodels"
"github.com/gofiber/fiber/v2"
)
func GetYear(kgpz *app.KGPZ) fiber.Handler {
return func(c *fiber.Ctx) error {
y := c.Params("year", strconv.Itoa(MINYEAR))
yi, err := strconv.Atoi(y)
if err != nil || yi < MINYEAR || yi > MAXYEAR {
logging.Debug("Jahr nicht gefunden: " + y)
return c.SendStatus(fiber.StatusNotFound)
}
view, err := viewmodels.YearView(y, kgpz.Library)
if err != nil {
logging.ErrorDebug(err, "Keine Ausgaben für das Jahr "+y)
return c.SendStatus(fiber.StatusNotFound)
}
return c.Render("/", fiber.Map{"model": view})
}
}