New genre overview
This commit is contained in:
33
pages/threads/threads.go
Normal file
33
pages/threads/threads.go
Normal file
@ -0,0 +1,33 @@
|
||||
package threads
|
||||
|
||||
import (
|
||||
"sort"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
)
|
||||
|
||||
// Get ...
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
thread, err := arn.GetThread(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Text("Thread not found")
|
||||
}
|
||||
|
||||
thread.Author, _ = arn.GetUser(thread.AuthorID)
|
||||
|
||||
replies, filterErr := arn.FilterPosts(func(post *arn.Post) bool {
|
||||
return post.ThreadID == thread.ID
|
||||
})
|
||||
|
||||
sort.Sort(replies)
|
||||
|
||||
if filterErr != nil {
|
||||
return ctx.Text("Error fetching thread replies")
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Thread(thread, replies))
|
||||
}
|
@ -1,16 +1,15 @@
|
||||
component Thread(thread *arn.Thread)
|
||||
component Thread(thread *arn.Thread, posts []*arn.Post)
|
||||
.thread
|
||||
h2.thread-title= thread.Title
|
||||
|
||||
.posts
|
||||
Post(thread.ToPostable(), nil, "Threads", "Thread", thread.AuthorID)
|
||||
//- +renderMessage(thread, user, "Threads", thread.author.ID)
|
||||
Post(thread.ToPostable(), nil, "Threads", "Thread", thread.Author.ID)
|
||||
|
||||
//- each post in posts
|
||||
//- +renderMessage(post, user, "Posts", thread.author.ID)
|
||||
each post in posts
|
||||
Post(post.ToPostable(), nil, "Posts", "Post", thread.Author.ID)
|
||||
|
||||
component Post(post arn.Postable, viewUser *arn.User, postType string, postTypeSingular string, highlightAuthorID string)
|
||||
.post(class=[]string{"", "special-post"}[post.Author().ID == highlightAuthorID])
|
||||
.post(data-highlight=post.Author().ID == highlightAuthorID)
|
||||
.post-author
|
||||
Avatar(post.Author())
|
||||
|
||||
|
Reference in New Issue
Block a user