From d86eb966c93fae6fbe467de712ec9d111b888b43 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 12 Nov 2018 07:48:16 +0900 Subject: [PATCH] Started working on new activity feed --- pages/activity/activity.go | 42 +++++++++++++++--------------------- pages/activity/activity.pixy | 24 +++++++++++++++------ 2 files changed, 34 insertions(+), 32 deletions(-) diff --git a/pages/activity/activity.go b/pages/activity/activity.go index d180b14b..26617880 100644 --- a/pages/activity/activity.go +++ b/pages/activity/activity.go @@ -2,7 +2,6 @@ package activity import ( "github.com/aerogo/aero" - "github.com/animenotifier/arn" "github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/utils" ) @@ -13,33 +12,26 @@ const maxActivitiesPerPage = 40 func Get(ctx *aero.Context) string { user := utils.GetUser(ctx) - // posts := arn.AllPosts() - // arn.SortPostsLatestFirst(posts) + // entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool { + // if entry.Action != "create" { + // return false + // } - // posts := arn.FilterPosts(func(post *arn.Post) bool { - // return post. + // obj := entry.Object() + + // if obj == nil { + // return false + // } + + // _, isPostable := obj.(arn.Postable) + // return isPostable // }) - entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool { - if entry.Action != "create" { - return false - } + // arn.SortEditLogEntriesLatestFirst(entries) - obj := entry.Object() + // if len(entries) > maxActivitiesPerPage { + // entries = entries[:maxActivitiesPerPage] + // } - if obj == nil { - 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)) + return ctx.HTML(components.ActivityFeed(nil, user)) } diff --git a/pages/activity/activity.pixy b/pages/activity/activity.pixy index 81f04fe0..01f4b616 100644 --- a/pages/activity/activity.pixy +++ b/pages/activity/activity.pixy @@ -1,12 +1,22 @@ -component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User) +component ActivityFeed(entries []*arn.Activity, user *arn.User) h1 Activity .activities each entry in entries - ActivityPost(entry.Object().(arn.Postable), user) + Activity(entry, user) -component ActivityPost(post arn.Postable, user *arn.User) - if post.Parent() != nil - Postable(post, user, false, fmt.Sprintf(`

%s

`, post.Parent().Link(), html.EscapeString(post.Parent().TitleByUser(user))), "") - else - Postable(post, user, false, fmt.Sprintf(`

%s

`, post.Link(), html.EscapeString(post.TitleByUser(user))), "") \ No newline at end of file +component Activity(activity *arn.Activity, user *arn.User) + h1= activity.Text() + +//- component ActivityFeed(entries []*arn.EditLogEntry, user *arn.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(`

%s

`, post.Parent().Link(), html.EscapeString(post.Parent().TitleByUser(user))), "") +//- else +//- Postable(post, user, false, fmt.Sprintf(`

%s

`, post.Link(), html.EscapeString(post.TitleByUser(user))), "") \ No newline at end of file