mirror of
https://github.com/Theodor-Springmann-Stiftung/lenz-web.git
synced 2025-10-28 16:55:32 +00:00
Next/Prev stuff
This commit is contained in:
@@ -19,9 +19,10 @@ func GetLetter(c *fiber.Ctx) error {
|
||||
if meta == nil {
|
||||
return c.SendStatus(fiber.StatusNotFound)
|
||||
}
|
||||
np := lib.NextPrev(meta)
|
||||
|
||||
text := lib.Letters.Item(letter)
|
||||
tradition := lib.Traditions.Item(letter)
|
||||
|
||||
return c.Render("/brief/", map[string]any{"meta": meta, "text": text, "tradition": tradition})
|
||||
return c.Render("/brief/", map[string]any{"meta": meta, "text": text, "tradition": tradition, "next": np.Next, "prev": np.Prev})
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
const DEFAULT_YEAR = 1765
|
||||
|
||||
func GetIndex(c *fiber.Ctx) error {
|
||||
return c.Redirect("/" + strconv.Itoa(DEFAULT_YEAR))
|
||||
return c.Redirect(JAHRGAENGE_URL + "/" + strconv.Itoa(DEFAULT_YEAR))
|
||||
}
|
||||
|
||||
func GetIndexYear(c *fiber.Ctx) error {
|
||||
@@ -23,5 +23,5 @@ func GetIndexYear(c *fiber.Ctx) error {
|
||||
return c.SendStatus(fiber.StatusNotFound)
|
||||
}
|
||||
|
||||
return c.Render("/", map[string]any{"years": years, "yearmap": yearmap, "year": year, "all": y == "all"})
|
||||
return c.Render(JAHRGAENGE_URL+"/", map[string]any{"years": years, "yearmap": yearmap, "year": year, "all": y == "all"})
|
||||
}
|
||||
|
||||
@@ -9,14 +9,20 @@ import (
|
||||
"github.com/gofiber/fiber/v2/middleware/compress"
|
||||
)
|
||||
|
||||
const ASSETS_URL = "/assets"
|
||||
const INDEX_URL = "/"
|
||||
const ASSETS_URL = "/assets"
|
||||
const DATENSCHUTZ_URL = "/datenschutz"
|
||||
const JAHRGAENGE_URL = "/jahrgang"
|
||||
const ZITATION_URL = "/ausgabe/zitation"
|
||||
const EDITION_URL = "/ausgabe/edition"
|
||||
const KONTAKT_URL = "/kontakt"
|
||||
|
||||
var INDEX_YEAR_URL = JAHRGAENGE_URL + "/:" + YEAR_PARAM
|
||||
var LETTER_URL = "/brief/:" + LETTER_PARAM
|
||||
|
||||
const YEAR_PARAM = "year"
|
||||
const LETTER_PARAM = "letter"
|
||||
|
||||
var INDEX_YEAR_URL = "/:" + YEAR_PARAM
|
||||
var LETTER_URL = "/brief/:" + LETTER_PARAM
|
||||
|
||||
func Register(server server.Server, cfg config.Config) {
|
||||
server.Server.Use(ASSETS_URL, compress.New(compress.Config{
|
||||
Level: compress.LevelBestSpeed,
|
||||
@@ -25,6 +31,7 @@ func Register(server server.Server, cfg config.Config) {
|
||||
server.Server.Get(INDEX_URL, GetIndex)
|
||||
server.Server.Get(INDEX_YEAR_URL, GetIndexYear)
|
||||
server.Server.Get(LETTER_URL, GetLetter)
|
||||
server.Server.Get(DATENSCHUTZ_URL, Static(DATENSCHUTZ_URL+"/"))
|
||||
|
||||
// INFO: we map the webhook when a secret was provided
|
||||
if cfg.WebHookSecret != "" {
|
||||
|
||||
16
controllers/static.go
Normal file
16
controllers/static.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func Static(url string) fiber.Handler {
|
||||
if !strings.HasSuffix(url, "/") {
|
||||
url += "/"
|
||||
}
|
||||
return func(c *fiber.Ctx) error {
|
||||
return c.Render(url, map[string]any{})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user