Added activity feed
This commit is contained in:
34
pages/activity/activity.go
Normal file
34
pages/activity/activity.go
Normal file
@ -0,0 +1,34 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
const maxActivitiesPerPage = 40
|
||||
|
||||
// Get activity page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
// posts := arn.AllPosts()
|
||||
// arn.SortPostsLatestFirst(posts)
|
||||
|
||||
// posts := arn.FilterPosts(func(post *arn.Post) bool {
|
||||
// return post.
|
||||
// })
|
||||
|
||||
entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
|
||||
return entry.Action == "create" && entry.ObjectType == "Post" && entry.Object() != nil
|
||||
})
|
||||
|
||||
arn.SortEditLogEntriesLatestFirst(entries)
|
||||
|
||||
if len(entries) > maxActivitiesPerPage {
|
||||
entries = entries[:maxActivitiesPerPage]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.ActivityFeed(entries, user))
|
||||
}
|
Reference in New Issue
Block a user