Basic Briefansicht + parsing

This commit is contained in:
Simon Martens
2025-04-01 18:07:57 +02:00
parent 0e2c6360bf
commit 31d40c1ce1
13 changed files with 107 additions and 55 deletions

View File

@@ -1,27 +1,12 @@
package controllers
import (
"strconv"
"github.com/Theodor-Springmann-Stiftung/lenz-web/xmlmodels"
"github.com/gofiber/fiber/v2"
"strconv"
)
const DEFAULT_YEAR = 1765
func GetIndex(c *fiber.Ctx) error {
return c.Redirect(JAHRGAENGE_URL + "/" + strconv.Itoa(DEFAULT_YEAR))
}
func GetIndexYear(c *fiber.Ctx) error {
lib := xmlmodels.Get()
years, yearmap := lib.Years()
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(JAHRGAENGE_URL+"/", map[string]any{"years": years, "yearmap": yearmap, "year": year, "all": y == "all"})
return c.Redirect(LETTERS_URL + "?year=" + strconv.Itoa(DEFAULT_YEAR))
}