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 .post-author
Avatar(post.Author()) Avatar(post.Author())
.post-content .post-content
.p= post.Text() p!= aero.Markdown(post.Text())
.post-toolbar .post-toolbar
.spacer .spacer
.post-likes= len(post.Likes()) .post-likes= len(post.Likes())
a.post-tool.post-permalink.ajax(href="/posts/" + post.ID()) a.post-tool.post-permalink.ajax(href=post.Link(), title="Permalink")
svg.icon(viewBox="0 0 1792 1792") Icon("link")
a.post-link.side-note.title.ajax(href="/posts/" + post.ID())= post.Title() 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" "github.com/animenotifier/notify.moe/components"
) )
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 { func GetPostsByUser(ctx *aero.Context) string {
postLimit := 10
nick := ctx.Get("nick") nick := ctx.Get("nick")
user, err := arn.GetUserByNick(nick) user, err := arn.GetUserByNick(nick)
var postables []arn.Postable
if err != nil { if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err) return ctx.Error(http.StatusNotFound, "User not found", err)
} }
posts := user.Posts() posts := user.Posts()
arn.SortPostsLatestLast(posts) arn.SortPostsLatestLast(posts)
var postables []arn.Postable
if len(posts) >= postLimit { if len(posts) >= postLimit {
postables = make([]arn.Postable, postLimit, postLimit) posts = posts[:postLimit]
} else {
postables = make([]arn.Postable, len(posts), len(posts))
} }
postables = make([]arn.Postable, len(posts), len(posts))
for i, post := range posts { for i, post := range posts {
if i == postLimit {
break
}
postables[i] = arn.ToPostable(post) postables[i] = arn.ToPostable(post)
} }
return ctx.HTML(components.PostableList(postables)) 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 threads []*arn.Thread
var animeList *arn.AnimeList var animeList *arn.AnimeList
var posts []*arn.Post var posts []*arn.Post
aero.Parallel(func() { aero.Parallel(func() {
user = utils.GetUser(ctx) user = utils.GetUser(ctx)
}, func() { }, func() {
@ -39,12 +40,13 @@ func Profile(ctx *aero.Context, viewUser *arn.User) string {
if len(threads) > maxPosts { if len(threads) > maxPosts {
threads = threads[:maxPosts] threads = threads[:maxPosts]
} }
}, }, func() {
func() {
posts = viewUser.Posts() posts = viewUser.Posts()
if len(posts) > maxPosts { if len(posts) > maxPosts {
posts = posts[:maxPosts] posts = posts[:maxPosts]
} }
}) })
return ctx.HTML(components.Profile(viewUser, user, animeList, threads, posts)) 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 each thread in threads
ThreadLink(thread) ThreadLink(thread)
h3 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 if len(posts) == 0
p No posts on the forum. p No posts on the forum.
else else
@ -78,7 +78,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
.post-author .post-author
Avatar(post.Author()) Avatar(post.Author())
.post-content .post-content
.p= post.Text p!= aero.Markdown(post.Text)
.post-toolbar.active .post-toolbar.active
.spacer .spacer
.post-likes= len(post.Likes) .post-likes= len(post.Likes)