Removed Postable proxies

This commit is contained in:
Eduard Urbach 2018-11-01 17:05:55 +09:00
parent ae1bd6846d
commit 4779b492ec
6 changed files with 20 additions and 28 deletions

View File

@ -5,7 +5,7 @@ component Comments(parent arn.PostParent, user *arn.User)
p.no-data.mountable No comments have been written yet. p.no-data.mountable No comments have been written yet.
else else
each post in parent.Posts() each post in parent.Posts()
Postable(post.ToPostable(), user, "", "") Postable(post, user, "", "")
if user != nil if user != nil
if arn.IsLocked(parent) if arn.IsLocked(parent)

View File

@ -1,5 +1,5 @@
component Postable(post arn.Postable, user *arn.User, headerContent string, highlightAuthorID string) component Postable(post arn.Postable, user *arn.User, headerContent string, highlightAuthorID string)
.post.mountable(id=strings.ToLower(post.Type()) + "-" + fmt.Sprint(post.ID()), data-highlight=post.Creator().ID == highlightAuthorID, data-pro=post.Creator().IsPro(), data-api="/api/" + strings.ToLower(post.Type()) + "/" + post.ID()) .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 .post-author
Avatar(post.Creator()) Avatar(post.Creator())
@ -7,35 +7,35 @@ component Postable(post arn.Postable, user *arn.User, headerContent string, high
if headerContent != "" if headerContent != ""
div!= headerContent div!= headerContent
div(id="render-" + post.ID())!= post.HTML() div(id="render-" + post.GetID())!= post.HTML()
if user != nil && user.ID == post.Creator().ID if user != nil && user.ID == post.Creator().ID
.post-edit-interface .post-edit-interface
if post.Type() == "Thread" if post.Type() == "Thread"
input.post-title-input.hidden(id="title-" + post.ID(), value=post.Title(), type="text", placeholder="Thread title") 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.ID())= post.Text() textarea.post-text-input.hidden(id="source-" + post.GetID())= post.GetText()
.buttons.hidden(id="edit-toolbar-" + post.ID()) .buttons.hidden(id="edit-toolbar-" + post.GetID())
a.button.post-save.action(data-action="savePost", data-trigger="click", data-id=post.ID()) a.button.post-save.action(data-action="savePost", data-trigger="click", data-id=post.GetID())
Icon("save") Icon("save")
span Save span Save
a.button.post-cancel-edit.action(data-action="editPost", data-trigger="click", data-id=post.ID()) a.button.post-cancel-edit.action(data-action="editPost", data-trigger="click", data-id=post.GetID())
Icon("close") Icon("close")
span Cancel span Cancel
.post-date.utc-date.no-tip(data-date=post.Created()) .post-date.utc-date.no-tip(data-date=post.GetCreated())
.post-toolbar(id="toolbar-" + post.ID()) .post-toolbar(id="toolbar-" + post.GetID())
.spacer .spacer
.post-likes.tip(id="likes-" + post.ID(), aria-label=stringutils.Plural(len(post.Likes()), "like"))= "+" + strconv.Itoa(len(post.Likes())) .post-likes.tip(id="likes-" + post.GetID(), aria-label=stringutils.Plural(post.CountLikes(), "like"))= "+" + strconv.Itoa(post.CountLikes())
if user != nil if user != nil
if user.ID != post.Creator().ID if user.ID != post.Creator().ID
if post.LikedBy(user.ID) if post.LikedBy(user.ID)
a.post-tool.post-unlike.tip.action(id="unlike-" + post.ID(), aria-label="Unlike", data-action="unlike", data-trigger="click") a.post-tool.post-unlike.tip.action(id="unlike-" + post.GetID(), aria-label="Unlike", data-action="unlike", data-trigger="click")
Icon("thumbs-down") Icon("thumbs-down")
else else
a.post-tool.post-like.tip.action(id="like-" + post.ID(), aria-label="Like", data-action="like", data-trigger="click") a.post-tool.post-like.tip.action(id="like-" + post.GetID(), aria-label="Like", data-action="like", data-trigger="click")
Icon("thumbs-up") Icon("thumbs-up")
if user.Role == "admin" if user.Role == "admin"
@ -43,12 +43,12 @@ component Postable(post arn.Postable, user *arn.User, headerContent string, high
Icon("edit") Icon("edit")
if user.ID == post.Creator().ID if user.ID == post.Creator().ID
a.post-tool.post-edit.tip.action(data-action="editPost", data-trigger="click", data-id=post.ID(), aria-label="Edit") a.post-tool.post-edit.tip.action(data-action="editPost", data-trigger="click", data-id=post.GetID(), aria-label="Edit")
Icon("pencil") Icon("pencil")
if post.Type() != "Thread" if post.Type() != "Thread"
if user != nil && (user.Role == "admin" || user.Role == "editor") 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.ID(), aria-label="Delete") a.post-tool.post-delete.tip.action(data-action="deletePost", data-trigger="click", data-id=post.GetID(), aria-label="Delete")
Icon("trash") Icon("trash")
a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link") a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link")

View File

@ -13,4 +13,4 @@ component ActivityPost(post *arn.Post, user *arn.User)
//- span commented on //- span commented on
//- a(href=post.Parent().Link())= post.Parent().TitleByUser(user) //- a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
Postable(post.ToPostable(), user, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Parent().Link(), post.Parent().TitleByUser(user)), "") Postable(post, user, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Parent().Link(), post.Parent().TitleByUser(user)), "")

View File

@ -1,7 +1,7 @@
component Post(post *arn.Post, user *arn.User) component Post(post *arn.Post, user *arn.User)
.thread .thread
.posts .posts
Postable(post.ToPostable(), user, "", "") Postable(post, user, "", "")
.side-note-container.mountable .side-note-container.mountable
a.side-note(href=post.Parent().Link())= post.Parent().TitleByUser(user) a.side-note(href=post.Parent().Link())= post.Parent().TitleByUser(user)

View File

@ -23,18 +23,10 @@ func GetPostsByUser(ctx *aero.Context) string {
posts := viewUser.Posts() posts := viewUser.Posts()
arn.SortPostsLatestFirst(posts) arn.SortPostsLatestFirst(posts)
var postables []arn.Postable
if len(posts) >= postLimit { if len(posts) >= postLimit {
posts = posts[:postLimit] posts = posts[:postLimit]
} }
postables = make([]arn.Postable, len(posts)) return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, utils.GetUser(ctx), ctx.URI()))
for i, post := range posts {
postables[i] = arn.ToPostable(post)
}
return ctx.HTML(components.LatestPosts(postables, viewUser, utils.GetUser(ctx), ctx.URI()))
} }

View File

@ -3,10 +3,10 @@ component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User)
#thread.thread(data-id=thread.ID) #thread.thread(data-id=thread.ID)
.posts .posts
Postable(thread.ToPostable(), user, "", thread.Creator().ID) Postable(thread, user, "", thread.Creator().ID)
each post in posts each post in posts
Postable(post.ToPostable(), user, "", thread.Creator().ID) Postable(post, user, "", thread.Creator().ID)
//- Reply //- Reply
if user != nil if user != nil