diff --git a/mixins/Comments.pixy b/mixins/Comments.pixy index b2467572..35344b87 100644 --- a/mixins/Comments.pixy +++ b/mixins/Comments.pixy @@ -5,7 +5,7 @@ component Comments(parent arn.PostParent, user *arn.User) p.no-data.mountable No comments have been written yet. else each post in parent.Posts() - Postable(post.ToPostable(), user, "", "") + Postable(post, user, "", "") if user != nil if arn.IsLocked(parent) diff --git a/mixins/Postable.pixy b/mixins/Postable.pixy index e4ec4b91..49774a48 100644 --- a/mixins/Postable.pixy +++ b/mixins/Postable.pixy @@ -1,5 +1,5 @@ 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 Avatar(post.Creator()) @@ -7,35 +7,35 @@ component Postable(post arn.Postable, user *arn.User, headerContent string, high if 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 .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()) + 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()) Icon("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") 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 - .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.ID != post.Creator().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") 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") if user.Role == "admin" @@ -43,12 +43,12 @@ component Postable(post arn.Postable, user *arn.User, headerContent string, high Icon("edit") 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") if post.Type() != "Thread" 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") a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link") diff --git a/pages/activity/activity.pixy b/pages/activity/activity.pixy index 41313051..916ddc9e 100644 --- a/pages/activity/activity.pixy +++ b/pages/activity/activity.pixy @@ -13,4 +13,4 @@ component ActivityPost(post *arn.Post, user *arn.User) //- span commented on //- a(href=post.Parent().Link())= post.Parent().TitleByUser(user) - Postable(post.ToPostable(), user, fmt.Sprintf(`

%s

`, post.Parent().Link(), post.Parent().TitleByUser(user)), "") \ No newline at end of file + Postable(post, user, fmt.Sprintf(`

%s

`, post.Parent().Link(), post.Parent().TitleByUser(user)), "") \ No newline at end of file diff --git a/pages/post/post.pixy b/pages/post/post.pixy index 8b9fb987..889c363a 100644 --- a/pages/post/post.pixy +++ b/pages/post/post.pixy @@ -1,7 +1,7 @@ component Post(post *arn.Post, user *arn.User) .thread .posts - Postable(post.ToPostable(), user, "", "") + Postable(post, user, "", "") .side-note-container.mountable a.side-note(href=post.Parent().Link())= post.Parent().TitleByUser(user) diff --git a/pages/profile/posts.go b/pages/profile/posts.go index 0236decd..ffe877e1 100644 --- a/pages/profile/posts.go +++ b/pages/profile/posts.go @@ -23,18 +23,10 @@ func GetPostsByUser(ctx *aero.Context) string { posts := viewUser.Posts() arn.SortPostsLatestFirst(posts) - var postables []arn.Postable - if len(posts) >= postLimit { posts = posts[:postLimit] } - postables = make([]arn.Postable, len(posts)) - - for i, post := range posts { - postables[i] = arn.ToPostable(post) - } - - return ctx.HTML(components.LatestPosts(postables, viewUser, utils.GetUser(ctx), ctx.URI())) + return ctx.HTML(components.LatestPosts(arn.ToPostables(posts), viewUser, utils.GetUser(ctx), ctx.URI())) } diff --git a/pages/thread/thread.pixy b/pages/thread/thread.pixy index 7e55f2f2..9d960204 100644 --- a/pages/thread/thread.pixy +++ b/pages/thread/thread.pixy @@ -3,10 +3,10 @@ component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User) #thread.thread(data-id=thread.ID) .posts - Postable(thread.ToPostable(), user, "", thread.Creator().ID) + Postable(thread, user, "", thread.Creator().ID) each post in posts - Postable(post.ToPostable(), user, "", thread.Creator().ID) + Postable(post, user, "", thread.Creator().ID) //- Reply if user != nil