Started working on new activity feed
This commit is contained in:
parent
8e1196cd98
commit
d86eb966c9
@ -2,7 +2,6 @@ package activity
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/aerogo/aero"
|
"github.com/aerogo/aero"
|
||||||
"github.com/animenotifier/arn"
|
|
||||||
"github.com/animenotifier/notify.moe/components"
|
"github.com/animenotifier/notify.moe/components"
|
||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
@ -13,33 +12,26 @@ const maxActivitiesPerPage = 40
|
|||||||
func Get(ctx *aero.Context) string {
|
func Get(ctx *aero.Context) string {
|
||||||
user := utils.GetUser(ctx)
|
user := utils.GetUser(ctx)
|
||||||
|
|
||||||
// posts := arn.AllPosts()
|
// entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
|
||||||
// arn.SortPostsLatestFirst(posts)
|
// if entry.Action != "create" {
|
||||||
|
// return false
|
||||||
|
// }
|
||||||
|
|
||||||
// posts := arn.FilterPosts(func(post *arn.Post) bool {
|
// obj := entry.Object()
|
||||||
// return post.
|
|
||||||
|
// if obj == nil {
|
||||||
|
// return false
|
||||||
|
// }
|
||||||
|
|
||||||
|
// _, isPostable := obj.(arn.Postable)
|
||||||
|
// return isPostable
|
||||||
// })
|
// })
|
||||||
|
|
||||||
entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
|
// arn.SortEditLogEntriesLatestFirst(entries)
|
||||||
if entry.Action != "create" {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
obj := entry.Object()
|
// if len(entries) > maxActivitiesPerPage {
|
||||||
|
// entries = entries[:maxActivitiesPerPage]
|
||||||
|
// }
|
||||||
|
|
||||||
if obj == nil {
|
return ctx.HTML(components.ActivityFeed(nil, user))
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
_, isPostable := obj.(arn.Postable)
|
|
||||||
return isPostable
|
|
||||||
})
|
|
||||||
|
|
||||||
arn.SortEditLogEntriesLatestFirst(entries)
|
|
||||||
|
|
||||||
if len(entries) > maxActivitiesPerPage {
|
|
||||||
entries = entries[:maxActivitiesPerPage]
|
|
||||||
}
|
|
||||||
|
|
||||||
return ctx.HTML(components.ActivityFeed(entries, user))
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,22 @@
|
|||||||
component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User)
|
component ActivityFeed(entries []*arn.Activity, user *arn.User)
|
||||||
h1 Activity
|
h1 Activity
|
||||||
|
|
||||||
.activities
|
.activities
|
||||||
each entry in entries
|
each entry in entries
|
||||||
ActivityPost(entry.Object().(arn.Postable), user)
|
Activity(entry, user)
|
||||||
|
|
||||||
component ActivityPost(post arn.Postable, user *arn.User)
|
component Activity(activity *arn.Activity, user *arn.User)
|
||||||
if post.Parent() != nil
|
h1= activity.Text()
|
||||||
Postable(post, user, false, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Parent().Link(), html.EscapeString(post.Parent().TitleByUser(user))), "")
|
|
||||||
else
|
//- component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User)
|
||||||
Postable(post, user, false, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Link(), html.EscapeString(post.TitleByUser(user))), "")
|
//- h1 Activity
|
||||||
|
|
||||||
|
//- .activities
|
||||||
|
//- each entry in entries
|
||||||
|
//- ActivityPost(entry.Object().(arn.Postable), user)
|
||||||
|
|
||||||
|
//- component ActivityPost(post arn.Postable, user *arn.User)
|
||||||
|
//- if post.Parent() != nil
|
||||||
|
//- Postable(post, user, false, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Parent().Link(), html.EscapeString(post.Parent().TitleByUser(user))), "")
|
||||||
|
//- else
|
||||||
|
//- Postable(post, user, false, fmt.Sprintf(`<p class="activity-header"><a href="%s">%s</a></p>`, post.Link(), html.EscapeString(post.TitleByUser(user))), "")
|
Loading…
Reference in New Issue
Block a user