27 lines
591 B
Go
27 lines
591 B
Go
package handlers_home
|
|
|
|
import (
|
|
"CatsOfMastodonBotGo/internal"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
type MainPageHandler struct{
|
|
AppContext *internal.AppContext
|
|
}
|
|
|
|
func NewMainPageHandler(appContext *internal.AppContext) *MainPageHandler {
|
|
return &MainPageHandler{
|
|
AppContext: appContext,
|
|
}
|
|
}
|
|
|
|
func (appContext *MainPageHandler) HomePageHandler(c *gin.Context) {
|
|
randomPost := appContext.AppContext.PostService.GetRandomPost()
|
|
|
|
c.HTML(200, "index.tmpl", gin.H{
|
|
"DisplayName": randomPost.Account.DisplayName,
|
|
"MediaAttachment": randomPost.Attachments[0],
|
|
"URL": randomPost.Url,
|
|
})
|
|
} |