2017-07-06 14:54:10 +00:00
component Postable(post arn.Postable, user *arn.User, highlightAuthorID string)
2018-04-08 10:01:18 +00:00
.post.mountable(id=strings.ToLower(post.Type()) + "-" + toString(post.ID()), data-highlight=post.Creator().ID == highlightAuthorID, data-pro=post.Creator().IsPro(), data-api="/api/" + strings.ToLower(post.Type()) + "/" + post.ID())
2016-11-22 03:34:59 +00:00
.post-author
2018-04-08 10:01:18 +00:00
Avatar(post.Creator())
2017-06-22 17:38:01 +00:00
2016-11-22 03:34:59 +00:00
//- if post.recipient && post.recipient.ID !== post.author.ID
//- a.user.post-recipient(href="/+" + post.recipient.nick, title=post.recipient.nick)
//- img.user-image(src=post.recipient.avatar ? (post.recipient.avatar + "?s=100&r=x&d=mm") : "/images/elements/no-gravatar.svg", alt=post.recipient.nick)
.post-content
2017-06-26 13:17:53 +00:00
div(id="render-" + post.ID())!= post.HTML()
2017-06-22 17:38:01 +00:00
2018-04-08 10:01:18 +00:00
if user != nil && user.ID == post.Creator().ID
2017-07-06 17:33:58 +00:00
.post-edit-interface
if post.Type() == "Thread"
input.post-title-input.hidden(id="title-" + post.ID(), value=post.Title(), type="text", placeholder="Thread title")
textarea.post-text-input.hidden(id="source-" + post.ID())= post.Text()
.buttons.hidden(id="edit-toolbar-" + post.ID())
a.button.post-save.action(data-action="savePost", data-trigger="click", data-id=post.ID())
Icon("save")
span Save
2017-07-06 14:54:10 +00:00
2017-07-06 17:33:58 +00:00
a.button.post-cancel-edit.action(data-action="editPost", data-trigger="click", data-id=post.ID())
Icon("close")
span Cancel
2017-07-07 15:16:40 +00:00
2018-04-18 14:27:08 +00:00
.post-date.utc-date.no-tip(data-date=post.Created())
2017-06-22 17:38:01 +00:00
2016-11-22 03:34:59 +00:00
.post-toolbar(id="toolbar-" + post.ID())
.spacer
2018-04-18 13:07:46 +00:00
.post-likes.tip(id="likes-" + post.ID(), aria-label=arn.Plural(len(post.Likes()), "like"))= "+" + strconv.Itoa(len(post.Likes()))
2017-06-22 17:38:01 +00:00
2017-07-06 14:54:10 +00:00
if user != nil
2018-04-08 10:01:18 +00:00
if user.ID != post.Creator().ID
2017-07-08 21:27:24 +00:00
if post.LikedBy(user.ID)
2018-04-18 13:07:46 +00:00
a.post-tool.post-unlike.tip.action(id="unlike-" + post.ID(), aria-label="Unlike", data-action="unlike", data-trigger="click")
2017-07-12 18:37:34 +00:00
Icon("thumbs-down")
2017-07-08 21:27:24 +00:00
else
2018-04-18 13:07:46 +00:00
a.post-tool.post-like.tip.action(id="like-" + post.ID(), aria-label="Like", data-action="like", data-trigger="click")
2017-07-12 18:37:34 +00:00
Icon("thumbs-up")
2017-06-22 17:38:01 +00:00
2018-04-08 10:01:18 +00:00
if user.ID == post.Creator().ID
2018-04-18 13:07:46 +00:00
a.post-tool.post-edit.tip.action(data-action="editPost", data-trigger="click", data-id=post.ID(), aria-label="Edit")
2017-07-12 18:37:34 +00:00
Icon("pencil")
2017-06-22 17:38:01 +00:00
2016-12-06 03:36:31 +00:00
if post.Type() != "Thread"
2017-11-25 13:31:15 +00:00
if user != nil && (user.Role == "admin" || user.Role == "editor")
2018-04-18 13:07:46 +00:00
a.post-tool.post-delete.tip.action(data-action="deletePost", data-trigger="click", data-id=post.ID(), aria-label="Delete")
2017-11-24 22:55:29 +00:00
Icon("trash")
2017-11-25 13:31:15 +00:00
2018-04-18 13:07:46 +00:00
a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link")
2017-07-12 18:37:34 +00:00
Icon("link")
2017-06-22 17:38:01 +00:00
2016-11-22 03:34:59 +00:00
//- if type === "Messages" && user && (user.ID === post.authorId || user.ID === post.recipientId)
//- a.post-tool.post-delete(onclick=`if(confirm("Do you really want to delete this ${typeSingular.toLowerCase()} from ${post.author.nick}?")) $.delete${typeSingular}("${post.ID}")`, title="Delete")
2017-06-22 17:38:01 +00:00
//- i.fa.fa-trash.fa-fw