first image \o/

This commit is contained in:
Niko Abeler 2023-07-08 14:32:20 +02:00
parent a90bcaaa2d
commit e9e17ed263
3 changed files with 12 additions and 7 deletions

View File

@ -26,7 +26,7 @@ func NewWebApp(
indexHandler := NewIndexHandler(entryService) indexHandler := NewIndexHandler(entryService)
listHandler := NewListHandler(entryService) listHandler := NewListHandler(entryService)
entryHandler := NewEntryHandler(entryService, typeRegistry) entryHandler := NewEntryHandler(entryService, typeRegistry)
mediaHandler := NewMediaHandler(entryService) mediaHandler := NewMediaHandler(binService)
rssHandler := NewRSSHandler(entryService) rssHandler := NewRSSHandler(entryService)
loginHandler := NewLoginHandler(authorService) loginHandler := NewLoginHandler(authorService)
editorListHandler := NewEditorListHandler(typeRegistry) editorListHandler := NewEditorListHandler(typeRegistry)
@ -47,7 +47,7 @@ func NewWebApp(
app.Get("/", indexHandler.Handle) app.Get("/", indexHandler.Handle)
app.Get("/lists/:list/", listHandler.Handle) app.Get("/lists/:list/", listHandler.Handle)
// Media // Media
app.Get("/media/*filepath", mediaHandler.Handle) app.Get("/media/:id", mediaHandler.Handle)
// RSS // RSS
app.Get("/index.xml", rssHandler.Handle) app.Get("/index.xml", rssHandler.Handle)
// Posts // Posts

View File

@ -7,13 +7,18 @@ import (
) )
type MediaHandler struct { type MediaHandler struct {
entrySvc *app.EntryService binaryService *app.BinaryService
} }
func NewMediaHandler(entryService *app.EntryService) *MediaHandler { func NewMediaHandler(binaryService *app.BinaryService) *MediaHandler {
return &MediaHandler{entrySvc: entryService} return &MediaHandler{binaryService: binaryService}
} }
func (h *MediaHandler) Handle(c *fiber.Ctx) error { func (h *MediaHandler) Handle(c *fiber.Ctx) error {
return c.SendString("Hello, Media!") id := c.Params("id")
binary, err := h.binaryService.FindById(id)
if err != nil {
return err
}
return c.Send(binary.Data)
} }

View File

@ -2,7 +2,7 @@
{{define "main"}} {{define "main"}}
{{.MetaData.ImageId}} <img src="/media/{{.MetaData.ImageId}}">
<p> <p>
{{.Content}} {{.Content}}