64 lines
2.7 KiB
Plaintext

component Postable(post arn.Postable, user *arn.User, includeReplies bool, highlightAuthorID string)
.post.mountable(id=strings.ToLower(post.TypeName()) + "-" + fmt.Sprint(post.GetID()), data-pro=post.Creator().IsPro(), data-api="/api/" + strings.ToLower(post.TypeName()) + "/" + post.GetID())
.post-parent
.post-author
Avatar(post.Creator())
.post-content(data-highlight=post.Creator().ID == highlightAuthorID)
.post-header
.post-creator
a(href=post.Creator().Link())= post.Creator().Nick
.post-date.utc-date(data-date=post.GetCreated())
div(id="render-" + post.GetID())!= post.HTML()
if user != nil && user.ID == post.Creator().ID
.post-edit-interface
if post.TypeName() == "Thread"
input.post-title-input.hidden(id="title-" + post.GetID(), value=post.TitleByUser(user), type="text", placeholder="Thread title")
textarea.post-text-input.hidden(id="source-" + post.GetID())= post.GetText()
.buttons.hidden(id="edit-toolbar-" + post.GetID())
a.button.post-save.action(data-action="savePost", data-trigger="click", data-id=post.GetID())
Icon("save")
span Save
a.button.post-cancel-edit.action(data-action="editPost", data-trigger="click", data-id=post.GetID())
Icon("close")
span Cancel
.post-toolbar(id="toolbar-" + post.GetID())
.spacer
.post-likes.tip(id="likes-" + post.GetID(), aria-label=stringutils.Plural(post.CountLikes(), "like"))= "+" + strconv.Itoa(post.CountLikes())
if user != nil
if user.ID != post.Creator().ID
if post.LikedBy(user.ID)
a.post-tool.post-unlike.tip.action(id="unlike-" + post.GetID(), aria-label="Unlike", data-action="unlike", data-trigger="click")
Icon("thumbs-down")
else
a.post-tool.post-like.tip.action(id="like-" + post.GetID(), aria-label="Like", data-action="like", data-trigger="click")
Icon("thumbs-up")
a.post-tool.post-reply.tip.action(data-post-id=post.GetID(), aria-label="Reply", data-action="reply", data-trigger="click")
Icon("reply")
if user.ID == post.Creator().ID
a.post-tool.post-edit.tip.action(data-action="editPost", data-trigger="click", data-id=post.GetID(), aria-label="Edit")
Icon("pencil")
if post.TypeName() != "Thread"
if user != nil && (user.Role == "admin" || user.Role == "editor")
a.post-tool.post-delete.tip.action(data-action="deletePost", data-trigger="click", data-id=post.GetID(), aria-label="Delete")
Icon("trash")
a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link")
Icon("link")
.replies(id="replies-" + post.GetID())
if includeReplies
each reply in post.Posts()
Postable(reply, user, true, highlightAuthorID)