mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-29 09:15:33 +00:00
Briefansicht
This commit is contained in:
@@ -1,16 +1,27 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/Theodor-Springmann-Stiftung/lenz-web/xmlmodels"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
const DEFAULT_YEAR = 1765
|
||||
|
||||
func GetIndex(fiber *fiber.Ctx) error {
|
||||
func GetIndex(c *fiber.Ctx) error {
|
||||
return c.Redirect("/" + strconv.Itoa(DEFAULT_YEAR))
|
||||
}
|
||||
|
||||
func GetIndexYear(c *fiber.Ctx) error {
|
||||
lib := xmlmodels.Get()
|
||||
// Years
|
||||
years, yearmap := lib.Years()
|
||||
|
||||
return fiber.Render("/", map[string]any{"years": years, "yearmap": yearmap})
|
||||
y := c.Params(YEAR_PARAM)
|
||||
year, err := strconv.Atoi(y)
|
||||
if _, ok := yearmap[year]; (err != nil || !ok) && y != "all" {
|
||||
return c.SendStatus(fiber.StatusNotFound)
|
||||
}
|
||||
|
||||
return c.Render("/", map[string]any{"years": years, "yearmap": yearmap, "year": year, "all": y == "all"})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user