Added activity feed

This commit is contained in:
2018-10-31 14:27:48 +09:00
parent 8e1578f2cb
commit 97c8f99499
14 changed files with 93 additions and 19 deletions

View 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))
}

View File

@ -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)), "")

View 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