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,27 @@
package controllers
import (
"strings"
"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"
)
const (
DEFAULT_AGENT = "a"
)
func GetAgents(kgpz *app.KGPZ) fiber.Handler {
return func(c *fiber.Ctx) error {
a := c.Params("letterorid", DEFAULT_AGENT)
a = strings.ToLower(a)
agents := viewmodels.AgentsView(a, kgpz.Library)
if len(agents.Agents) == 0 {
logging.Error(nil, "No agents found for letter or id: "+a)
return c.SendStatus(fiber.StatusNotFound)
}
return c.Render("/akteure/", fiber.Map{"model": fiber.Map{"agents": agents, "search": a}, "title": "Akteure"})
}
}