2023-07-06 20:16:52 +00:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
|
|
|
"owl-blogs/app"
|
|
|
|
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type EditorListHandler struct {
|
|
|
|
registry *app.EntryTypeRegistry
|
|
|
|
}
|
|
|
|
|
|
|
|
type EditorListContext struct {
|
|
|
|
Types []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewEditorListHandler(registry *app.EntryTypeRegistry) *EditorListHandler {
|
|
|
|
return &EditorListHandler{
|
|
|
|
registry: registry,
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *EditorListHandler) Handle(c *fiber.Ctx) error {
|
|
|
|
c.Set(fiber.HeaderContentType, fiber.MIMETextHTML)
|
|
|
|
|
|
|
|
types := h.registry.Types()
|
|
|
|
typeNames := []string{}
|
|
|
|
|
|
|
|
for _, t := range types {
|
|
|
|
name, _ := h.registry.TypeName(t)
|
|
|
|
typeNames = append(typeNames, name)
|
|
|
|
}
|
|
|
|
|
2023-07-08 12:28:15 +00:00
|
|
|
return RenderTemplate(c, "views/editor_list", &EditorListContext{Types: typeNames})
|
2023-07-06 20:16:52 +00:00
|
|
|
}
|