63 lines
2.7 KiB
Plaintext
Raw Normal View History

2018-11-05 10:05:36 +00:00
component Postable(post arn.Postable, user *arn.User, includeReplies bool, headerContent string, highlightAuthorID string)
2018-11-15 11:19:40 +00:00
.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())
2018-11-05 10:05:36 +00:00
.post-parent
.post-author
Avatar(post.Creator())
.post-content(data-highlight=post.Creator().ID == highlightAuthorID)
if headerContent != ""
div!= headerContent
div(id="render-" + post.GetID())!= post.HTML()
if user != nil && user.ID == post.Creator().ID
.post-edit-interface
2018-11-15 11:19:40 +00:00
if post.TypeName() == "Thread"
2018-11-05 10:05:36 +00:00
input.post-title-input.hidden(id="title-" + post.GetID(), value=post.TitleByUser(user), type="text", placeholder="Thread title")
2018-11-05 11:57:37 +00:00
2018-11-05 10:05:36 +00:00
textarea.post-text-input.hidden(id="source-" + post.GetID())= post.GetText()
2018-11-05 11:57:37 +00:00
2018-11-05 10:05:36 +00:00
.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
2018-11-05 04:19:42 +00:00
2018-11-05 10:05:36 +00:00
.post-date.utc-date.no-tip(data-date=post.GetCreated())
.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")
2018-11-05 11:57:37 +00:00
a.post-tool.post-reply.tip.action(data-post-id=post.GetID(), aria-label="Reply", data-action="reply", data-trigger="click")
2018-11-05 10:05:36 +00:00
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")
2018-11-15 11:19:40 +00:00
if post.TypeName() != "Thread"
2018-11-05 10:05:36 +00:00
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")
2018-11-05 11:57:37 +00:00
.replies(id="replies-" + post.GetID())
2018-11-05 10:05:36 +00:00
if includeReplies
each reply in post.Posts()
Postable(reply, user, true, "", highlightAuthorID)