Forum improvements

This commit is contained in:
2017-06-26 15:17:53 +02:00
parent d197fb30fb
commit 8c19f0be72
10 changed files with 67 additions and 24 deletions

View File

@ -1,7 +1,3 @@
.anime-list-item-view
textarea
height 10rem
.anime-list-item-view-image
max-width 55px
margin-bottom 1rem

View File

@ -79,7 +79,7 @@ component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList,
.post-author
Avatar(post.Author())
.post-content
div!= aero.Markdown(post.Text)
div!= post.HTML()
.post-toolbar.active
.spacer
.post-likes= len(post.Likes)

View File

@ -1,29 +1,59 @@
package threads
import (
"strings"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get thread.
func Get(ctx *aero.Context) string {
id := ctx.Get("id")
thread, err := arn.GetThread(id)
user := utils.GetUser(ctx)
if err != nil {
return ctx.Error(404, "Thread not found", err)
}
replies, filterErr := arn.FilterPosts(func(post *arn.Post) bool {
post.Text = strings.Replace(post.Text, "http://", "https://", -1)
return post.ThreadID == thread.ID
})
arn.SortPostsLatestLast(replies)
for i := 0; i < 7; i++ {
replies = append(replies, replies...)
}
println(len(replies))
// Pre-render markdown
// flow.Parallel(func() {
// for _, reply := range replies[0:256] {
// reply.HTML()
// }
// }, func() {
// for _, reply := range replies[256:512] {
// reply.HTML()
// }
// }, func() {
// for _, reply := range replies[512:768] {
// reply.HTML()
// }
// }, func() {
// for _, reply := range replies[768:1024] {
// reply.HTML()
// }
// })
if filterErr != nil {
return ctx.Error(500, "Error fetching thread replies", err)
}
return ctx.HTML(components.Thread(thread, replies))
return ctx.HTML(components.Thread(thread, replies, user))
}

View File

@ -1,4 +1,4 @@
component Thread(thread *arn.Thread, posts []*arn.Post)
component Thread(thread *arn.Thread, posts []*arn.Post, user *arn.User)
h2.thread-title= thread.Title
.thread
@ -7,3 +7,12 @@ component Thread(thread *arn.Thread, posts []*arn.Post)
each post in posts
Postable(post.ToPostable(), thread.Author().ID)
// Reply
if user != nil
.post.mountable
.post-author
Avatar(user)
.post-content
textarea(id="new-reply", placeholder="Reply...")