56 lines
2.5 KiB
Plaintext
Raw Normal View History

2018-10-31 05:27:48 +00:00
component Postable(post arn.Postable, user *arn.User, headerContent string, highlightAuthorID string)
2018-11-01 08:05:55 +00:00
.post.mountable(id=strings.ToLower(post.Type()) + "-" + fmt.Sprint(post.GetID()), data-highlight=post.Creator().ID == highlightAuthorID, data-pro=post.Creator().IsPro(), data-api="/api/" + strings.ToLower(post.Type()) + "/" + post.GetID())
.post-author
2018-04-08 10:01:18 +00:00
Avatar(post.Creator())
2017-06-22 17:38:01 +00:00
.post-content
2018-10-31 05:27:48 +00:00
if headerContent != ""
div!= headerContent
2018-11-01 08:05:55 +00:00
div(id="render-" + post.GetID())!= 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"
2018-11-01 08:05:55 +00:00
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())
2017-07-06 17:33:58 +00:00
Icon("save")
span Save
2017-07-06 14:54:10 +00:00
2018-11-01 08:05:55 +00:00
a.button.post-cancel-edit.action(data-action="editPost", data-trigger="click", data-id=post.GetID())
2017-07-06 17:33:58 +00:00
Icon("close")
span Cancel
2017-07-07 15:16:40 +00:00
2018-11-01 08:05:55 +00:00
.post-date.utc-date.no-tip(data-date=post.GetCreated())
2017-06-22 17:38:01 +00:00
2018-11-01 08:05:55 +00:00
.post-toolbar(id="toolbar-" + post.GetID())
.spacer
2018-11-01 08:05:55 +00:00
.post-likes.tip(id="likes-" + post.GetID(), aria-label=stringutils.Plural(post.CountLikes(), "like"))= "+" + strconv.Itoa(post.CountLikes())
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-11-01 08:05:55 +00:00
a.post-tool.post-unlike.tip.action(id="unlike-" + post.GetID(), 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-11-01 08:05:55 +00:00
a.post-tool.post-like.tip.action(id="like-" + post.GetID(), aria-label="Like", data-action="like", data-trigger="click")
2017-07-12 18:37:34 +00:00
Icon("thumbs-up")
if user.Role == "admin"
a.post-tool.post-edit.tip(href=post.Link() + "/edit", aria-label="Edit")
Icon("edit")
2017-06-22 17:38:01 +00:00
2018-04-08 10:01:18 +00:00
if user.ID == post.Creator().ID
2018-11-01 08:05:55 +00:00
a.post-tool.post-edit.tip.action(data-action="editPost", data-trigger="click", data-id=post.GetID(), 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-11-01 08:05:55 +00:00
a.post-tool.post-delete.tip.action(data-action="deletePost", data-trigger="click", data-id=post.GetID(), aria-label="Delete")
Icon("trash")
2018-11-05 04:19:42 +00:00
a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link")
Icon("link")