Fixed mistakes

This commit is contained in:
FM1337 2017-06-22 12:03:43 -03:00
parent ad7bc381ac
commit f6e5b6da08
4 changed files with 22 additions and 21 deletions

View File

@ -7,10 +7,10 @@ component PostableList(postables []arn.Postable)
.post-author
Avatar(post.Author())
.post-content
.p= post.Text()
p!= aero.Markdown(post.Text())
.post-toolbar
.spacer
.post-likes= len(post.Likes())
a.post-tool.post-permalink.ajax(href="/posts/" + post.ID())
svg.icon(viewBox="0 0 1792 1792")
a.post-tool.post-permalink.ajax(href=post.Link(), title="Permalink")
Icon("link")
a.post-link.side-note.title.ajax(href="/posts/" + post.ID())= post.Title()

View File

@ -8,32 +8,31 @@ import (
"github.com/animenotifier/notify.moe/components"
)
const postLimit = 10
// GetPostsbyUser shows all forum posts of a particular user.
func GetPostsByUser(ctx *aero.Context) string {
postLimit := 10
nick := ctx.Get("nick")
user, err := arn.GetUserByNick(nick)
var postables []arn.Postable
if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err)
}
posts := user.Posts()
arn.SortPostsLatestLast(posts)
var postables []arn.Postable
if len(posts) >= postLimit {
postables = make([]arn.Postable, postLimit, postLimit)
} else {
postables = make([]arn.Postable, len(posts), len(posts))
posts = posts[:postLimit]
}
postables = make([]arn.Postable, len(posts), len(posts))
for i, post := range posts {
if i == postLimit {
break
}
postables[i] = arn.ToPostable(post)
}
return ctx.HTML(components.PostableList(postables))

View File

@ -27,6 +27,7 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
var threads []*arn.Thread
var animeList *arn.AnimeList
var posts []*arn.Post
aero.Parallel(func() {
user = utils.GetUser(ctx)
}, func() {
@ -39,13 +40,14 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
if len(threads) > maxPosts {
threads = threads[:maxPosts]
}
},
func() {
posts = viewUser.Posts()
if len(posts) > maxPosts {
posts = posts[:maxPosts]
}
})
}, func() {
posts = viewUser.Posts()
if len(posts) > maxPosts {
posts = posts[:maxPosts]
}
})
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts))
}

View File

@ -69,7 +69,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
each thread in threads
ThreadLink(thread)
h3
a.ajax(href="/+" + viewUser.Nick + "/posts", title="View all Posts") Posts
a.ajax(href="/+" + viewUser.Nick + "/posts", title="View all posts") Posts
if len(posts) == 0
p No posts on the forum.
else
@ -78,7 +78,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
.post-author
Avatar(post.Author())
.post-content
.p= post.Text
p!= aero.Markdown(post.Text)
.post-toolbar.active
.spacer
.post-likes= len(post.Likes)