package controllers import ( "bytes" "fmt" "git.readonly.ch/bouzoure/pop-camarades/helpers" "github.com/gofiber/fiber/v2" "github.com/yuin/goldmark" ) func SetColorMode(c *fiber.Ctx) error { colorMode := "light" if c.FormValue("color_mode") == "dark" { colorMode = "dark" } sess, err := helpers.GetSessionStore(c) if err != nil { return err } sess.Set("color-mode", colorMode) err = sess.Save() if err != nil { return err } return c.SendString(fmt.Sprintf( "New color mode: %s", colorMode, )) } func Licenses(c *fiber.Ctx) error { staticFS, err := helpers.GetEmbeddedFS("static") if err != nil { return err } source, err := staticFS.ReadFile("static/licenses.md") if err != nil { return err } var buf bytes.Buffer err = goldmark.Convert(source, &buf) if err != nil { return err } return c.Render("licenses", fiber.Map{ "PageTitle": "Licences", "Markdown": buf.String(), }) }