Add web templates and handlers for home, embed card, and admin pages
This commit is contained in:
@@ -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,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user