From 7526bed07661264cd50b5c8c59e874d03dbca94e Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 22 Jun 2017 17:33:41 +0200 Subject: [PATCH 1/4] Fixed typo --- pages/profile/posts.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pages/profile/posts.go b/pages/profile/posts.go index ea60c93e..ce54991c 100644 --- a/pages/profile/posts.go +++ b/pages/profile/posts.go @@ -10,7 +10,7 @@ import ( const postLimit = 10 -// GetPostsbyUser shows all forum posts of a particular user. +// GetPostsByUser shows all forum posts of a particular user. func GetPostsByUser(ctx *aero.Context) string { nick := ctx.Get("nick") user, err := arn.GetUserByNick(nick) @@ -31,9 +31,7 @@ func GetPostsByUser(ctx *aero.Context) string { postables = make([]arn.Postable, len(posts), len(posts)) for i, post := range posts { - postables[i] = arn.ToPostable(post) - } return ctx.HTML(components.PostableList(postables)) From 711f7f20a1689ad70226222065e5f7fe6177a92a Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 22 Jun 2017 17:42:17 +0200 Subject: [PATCH 2/4] Fixed order of posts --- pages/profile/posts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/profile/posts.go b/pages/profile/posts.go index ce54991c..df2e71d9 100644 --- a/pages/profile/posts.go +++ b/pages/profile/posts.go @@ -20,7 +20,7 @@ func GetPostsByUser(ctx *aero.Context) string { } posts := user.Posts() - arn.SortPostsLatestLast(posts) + arn.SortPostsLatestFirst(posts) var postables []arn.Postable From dd7355a45d33087848e5cc49ec383750af815184 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 22 Jun 2017 17:49:32 +0200 Subject: [PATCH 3/4] Added sorting to posts on the profile --- pages/profile/profile.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pages/profile/profile.go b/pages/profile/profile.go index 185d41a7..9e660b42 100644 --- a/pages/profile/profile.go +++ b/pages/profile/profile.go @@ -42,6 +42,7 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string { } }, func() { posts = viewUser.Posts() + arn.SortPostsLatestFirst(posts) if len(posts) > maxPosts { posts = posts[:maxPosts] From e652e6655f6ac37281dc2f506fb4bc41d4bb6250 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 22 Jun 2017 18:04:14 +0200 Subject: [PATCH 4/4] Improved composability --- mixins/PostableList.pixy | 4 +++- pages/profile/posts.go | 2 +- pages/profile/posts.pixy | 6 ++++++ 3 files changed, 10 insertions(+), 2 deletions(-) create mode 100644 pages/profile/posts.pixy diff --git a/mixins/PostableList.pixy b/mixins/PostableList.pixy index ce6f4c10..93855fcd 100644 --- a/mixins/PostableList.pixy +++ b/mixins/PostableList.pixy @@ -1,16 +1,18 @@ component PostableList(postables []arn.Postable) - h2.thread-title= len(postables), " latest posts by ", postables[0].Author().Nick .thread .posts each post in postables .post .post-author Avatar(post.Author()) + .post-content p!= aero.Markdown(post.Text()) + .post-toolbar .spacer .post-likes= len(post.Likes()) a.post-tool.post-permalink.ajax(href=post.Link(), title="Permalink") Icon("link") + a.post-link.side-note.ajax(href=post.Link())= post.Title() diff --git a/pages/profile/posts.go b/pages/profile/posts.go index df2e71d9..9f91239a 100644 --- a/pages/profile/posts.go +++ b/pages/profile/posts.go @@ -34,6 +34,6 @@ func GetPostsByUser(ctx *aero.Context) string { postables[i] = arn.ToPostable(post) } - return ctx.HTML(components.PostableList(postables)) + return ctx.HTML(components.LatestPosts(postables, user)) } diff --git a/pages/profile/posts.pixy b/pages/profile/posts.pixy new file mode 100644 index 00000000..5d18a568 --- /dev/null +++ b/pages/profile/posts.pixy @@ -0,0 +1,6 @@ +component LatestPosts(postables []arn.Postable, viewUser *arn.User) + if len(postables) > 0 + h2.thread-title= len(postables), " latest posts by ", postables[0].Author().Nick + PostableList(postables) + else + p= viewUser.Nick + " hasn't written any posts yet." \ No newline at end of file