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))
|
||||
}
|
@ -1,2 +1,16 @@
|
||||
component ActivityFeed
|
||||
h1 Hello
|
||||
component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User)
|
||||
h1 Activity
|
||||
|
||||
.activities
|
||||
each entry in entries
|
||||
if entry.ObjectType == "Post"
|
||||
.activity
|
||||
ActivityPost(entry.Object().(*arn.Post), user)
|
||||
|
||||
component ActivityPost(post *arn.Post, user *arn.User)
|
||||
//- .activity-header.mountable
|
||||
//- a(href=post.Creator().Link())= post.Creator().Nick
|
||||
//- span commented on
|
||||
//- a(href=post.Parent().Link())= post.Parent().TitleByUser(user)
|
||||
|
||||
Postable(post.ToPostable(), user, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Parent().Link(), post.Parent().TitleByUser(user)), "")
|
11
pages/activity/activity.scarlet
Normal file
11
pages/activity/activity.scarlet
Normal file
@ -0,0 +1,11 @@
|
||||
.activities
|
||||
vertical
|
||||
width 100%
|
||||
max-width forum-width
|
||||
margin 0 auto
|
||||
|
||||
// .activity
|
||||
// margin-bottom 1rem
|
||||
|
||||
.activity-header
|
||||
font-size 0.9rem
|
Reference in New Issue
Block a user