package views
import (
"fmt"
"github.com/dominicf2001/comfychan/internal/database"
"github.com/dominicf2001/comfychan/internal/util"
"github.com/dominicf2001/comfychan/web/views/shared"
"strconv"
)
templ PostAdminDialog(post database.Post) {
{{ elPostId := fmt.Sprintf("post-%d", post.Id) }}
}
templ PostOriginal(post database.Post, thread database.Thread) {
[close]
File:
{ post.MediaPath }
{ util.FormatPostFileInfo(util.GetPostFileInfo(post.MediaPath)) }
@templ.Raw(util.EnrichPost(post.Body))
}
templ PostReply(post database.Post, threadContext ThreadContext) {
{{ elPostId := fmt.Sprintf("post-%d", post.Id) }}
if post.MediaPath != "" {
[close]
File:
{ post.MediaPath }
{ util.FormatPostFileInfo(util.GetPostFileInfo(post.MediaPath)) }
}
@templ.Raw(util.EnrichPost(post.Body))
if post.Banned {
(USER WAS BANNED FOR THIS POST)
}
@PostAdminDialog(post)
}
templ Posts(posts []database.Post, thread database.Thread, threadContext ThreadContext) {
@PostOriginal(posts[0], thread)
for _, post := range (posts[1:]) {
@PostReply(post, threadContext)
}
}
type ThreadContext struct {
IsAdmin bool
}
templ ThreadActionBar(thread database.Thread, pos string) {
}
templ Thread(board database.Board, thread database.Thread, posts []database.Post, threadContext ThreadContext) {
@shared.Layout() {
@BoardHeader(board)
if !thread.Locked {
@shared.NewPostForm(board, fmt.Sprintf("/%s/threads/%d", board.Slug, thread.Id), false)
}
@ThreadActionBar(thread, "top")
@Posts(posts, thread, threadContext)
@ThreadActionBar(thread, "bottom")
}
}