2019-08-30 01:02:22 +00:00
|
|
|
component Postable(post arn.Postable, user *arn.User, includeReplies bool, showParent bool, highlightAuthorID string)
|
|
|
|
.post.mountable(id=fmt.Sprintf("%s-%s", strings.ToLower(post.TypeName()), post.GetID()), data-pro=post.Creator().IsPro(), data-api=fmt.Sprintf("/api/%s/%s", strings.ToLower(post.TypeName()), post.GetID()))
|
2018-11-05 10:05:36 +00:00
|
|
|
.post-parent
|
|
|
|
.post-author
|
|
|
|
Avatar(post.Creator())
|
|
|
|
|
2019-08-30 02:42:46 +00:00
|
|
|
.post-box(data-highlight=post.Creator().ID == highlightAuthorID)
|
2019-06-09 00:52:13 +00:00
|
|
|
.post-header
|
2019-08-30 02:42:46 +00:00
|
|
|
.post-header-info
|
2019-06-09 00:52:13 +00:00
|
|
|
a(href=post.Creator().Link())= post.Creator().Nick
|
2019-08-30 02:42:46 +00:00
|
|
|
|
2019-08-30 01:02:22 +00:00
|
|
|
if showParent
|
|
|
|
if post.GetParentType() == "User"
|
|
|
|
if post.GetParentID() != post.Creator().ID
|
|
|
|
span to
|
|
|
|
a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
|
|
|
|
else if post.GetParentType() != ""
|
|
|
|
span in
|
|
|
|
a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
|
2019-06-09 03:06:01 +00:00
|
|
|
|
|
|
|
if user != nil
|
|
|
|
if user.ID == post.Creator().ID
|
2019-08-30 02:42:46 +00:00
|
|
|
button.post-action.post-header-action.tip.action(data-action="editPost", data-trigger="click", data-id=post.GetID(), aria-label="Edit")
|
2019-06-09 03:06:01 +00:00
|
|
|
RawIcon("pencil")
|
|
|
|
|
|
|
|
if post.TypeName() != "Thread"
|
|
|
|
if user != nil && (user.Role == "admin" || user.Role == "editor")
|
2019-08-30 02:42:46 +00:00
|
|
|
button.post-action.post-header-action.tip.action(data-action="deletePost", data-trigger="click", data-id=post.GetID(), aria-label="Delete")
|
2019-06-09 03:06:01 +00:00
|
|
|
RawIcon("trash")
|
|
|
|
|
2019-08-30 02:42:46 +00:00
|
|
|
a.post-action.post-header-action.tip(href=post.Link(), aria-label="Link")
|
2019-06-09 03:06:01 +00:00
|
|
|
RawIcon("link")
|
|
|
|
|
2019-06-09 00:52:13 +00:00
|
|
|
.post-date.utc-date(data-date=post.GetCreated())
|
|
|
|
|
2019-08-30 02:42:46 +00:00
|
|
|
.post-content(id="render-" + post.GetID())!= post.HTML()
|
2018-11-05 10:05:36 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2019-08-31 07:52:42 +00:00
|
|
|
textarea.post-text-input.hidden(id="source-" + post.GetID(), maxlength=limits.DefaultTextAreaMaxLength)= 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
|
|
|
|
|
2019-08-30 02:42:46 +00:00
|
|
|
.post-toolbar
|
|
|
|
if user != nil
|
|
|
|
button.post-action.post-toolbar-action.tip.action(data-post-id=post.GetID(), aria-label="Reply", data-action="reply", data-trigger="click")
|
|
|
|
Icon("reply")
|
|
|
|
span= post.CountPosts()
|
|
|
|
|
|
|
|
if user != nil && post.LikedBy(user.ID)
|
|
|
|
button.post-action.post-toolbar-action.tip.action(id="unlike-" + post.GetID(), aria-label="Unlike", data-action="unlike", data-trigger="click", data-like="true")
|
|
|
|
Icon("heart")
|
|
|
|
span= post.CountLikes()
|
|
|
|
else
|
|
|
|
button.post-action.post-toolbar-action.tip.action(id="like-" + post.GetID(), aria-label="Like", data-action="like", data-trigger="click", data-like="false")
|
|
|
|
Icon("heart-o")
|
|
|
|
span= post.CountLikes()
|
|
|
|
|
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()
|
2019-08-30 01:02:22 +00:00
|
|
|
Postable(reply, user, true, false, highlightAuthorID)
|