This commit is contained in:
Simon Martens
2025-09-28 11:59:58 +02:00
parent adc45f2212
commit e8855a6c3c
13 changed files with 1478 additions and 198 deletions

View File

@@ -4,6 +4,7 @@ import (
"strings"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/helpers/logging"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/providers/geonames"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/viewmodels"
"github.com/Theodor-Springmann-Stiftung/kgpz_web/xmlmodels"
"github.com/gofiber/fiber/v2"
@@ -13,13 +14,13 @@ const (
DEFAULT_PLACE = ""
)
func GetPlace(kgpz *xmlmodels.Library) fiber.Handler {
func GetPlace(kgpz *xmlmodels.Library, geonamesProvider *geonames.GeonamesProvider) fiber.Handler {
return func(c *fiber.Ctx) error {
placeID := c.Params("place", DEFAULT_PLACE)
placeID = strings.ToLower(placeID)
// Get places data using view model
places := viewmodels.PlacesView(placeID, kgpz)
places := viewmodels.PlacesView(placeID, kgpz, geonamesProvider)
// If no places found at all, return 404
if len(places.Places) == 0 {
@@ -48,13 +49,13 @@ func GetPlace(kgpz *xmlmodels.Library) fiber.Handler {
}
}
func GetPlaceFragment(kgpz *xmlmodels.Library) fiber.Handler {
func GetPlaceFragment(kgpz *xmlmodels.Library, geonamesProvider *geonames.GeonamesProvider) fiber.Handler {
return func(c *fiber.Ctx) error {
placeID := c.Params("place", DEFAULT_PLACE)
placeID = strings.ToLower(placeID)
// Get places data using view model
places := viewmodels.PlacesView(placeID, kgpz)
places := viewmodels.PlacesView(placeID, kgpz, geonamesProvider)
// If no places found at all, return 404
if len(places.Places) == 0 {