Add web templates and handlers for home, embed card, and admin pages

This commit is contained in:
2025-05-18 12:23:00 +03:30
parent 0854387eb4
commit 7659cca37e
7 changed files with 657 additions and 7 deletions
+27
View File
@@ -0,0 +1,27 @@
package handlers
import (
"CatsOfMastodonBotGo/internal/services"
"github.com/gin-gonic/gin"
)
type EmbedCardHandler struct {
PostService services.PostService
}
var EmbedCardHandlerInstance *EmbedCardHandler
func InitEmbedCardHandler() {
EmbedCardHandlerInstance = &EmbedCardHandler{
PostService: *services.PostServiceInstance,
}
}
func (ps *EmbedCardHandler) GetEmbedCard(c *gin.Context) {
post := ps.PostService.GetRandomPost()
c.HTML(200, "home/embed.html", gin.H{
"postUrl": post.Url,
"imageUrl": post.Attachments[0].PreviewUrl,
})
}