From e74253df9619869349b5eee2d872d02e5f8a2f00 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Mon, 5 Nov 2018 13:19:42 +0900 Subject: [PATCH] Show threads in activity view --- mixins/Postable.pixy | 10 +++------- pages/activity/activity.go | 18 +++++++++++++++++- pages/activity/activity.pixy | 17 +++++++---------- 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/mixins/Postable.pixy b/mixins/Postable.pixy index 49774a48..8db831f0 100644 --- a/mixins/Postable.pixy +++ b/mixins/Postable.pixy @@ -50,10 +50,6 @@ component Postable(post arn.Postable, user *arn.User, headerContent string, high if user != nil && (user.Role == "admin" || user.Role == "editor") a.post-tool.post-delete.tip.action(data-action="deletePost", data-trigger="click", data-id=post.GetID(), aria-label="Delete") Icon("trash") - - a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link") - Icon("link") - - //- if type === "Messages" && user && (user.ID === post.authorId || user.ID === post.recipientId) - //- a.post-tool.post-delete(onclick=`if(confirm("Do you really want to delete this ${typeSingular.toLowerCase()} from ${post.author.nick}?")) $.delete${typeSingular}("${post.ID}")`, title="Delete") - //- i.fa.fa-trash.fa-fw + + a.post-tool.post-permalink.tip(href=post.Link(), aria-label="Link") + Icon("link") diff --git a/pages/activity/activity.go b/pages/activity/activity.go index 6f510e68..88969ace 100644 --- a/pages/activity/activity.go +++ b/pages/activity/activity.go @@ -21,7 +21,23 @@ func Get(ctx *aero.Context) string { // }) entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool { - return entry.Action == "create" && entry.ObjectType == "Post" && entry.Object() != nil + if entry.Action != "create" { + return false + } + + obj := entry.Object() + + if obj == nil { + return false + } + + _, isPostable := obj.(arn.Postable) + + if !isPostable { + return false + } + + return true }) arn.SortEditLogEntriesLatestFirst(entries) diff --git a/pages/activity/activity.pixy b/pages/activity/activity.pixy index df7c2c95..b46c950e 100644 --- a/pages/activity/activity.pixy +++ b/pages/activity/activity.pixy @@ -3,14 +3,11 @@ component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User) .activities each entry in entries - if entry.ObjectType == "Post" - .activity - ActivityPost(entry.Object().(*arn.Post), user) + .activity + ActivityPost(entry.Object().(arn.Postable), 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, user, fmt.Sprintf(`

%s

`, post.Parent().Link(), html.EscapeString(post.Parent().TitleByUser(user))), "") \ No newline at end of file +component ActivityPost(post arn.Postable, user *arn.User) + if post.Parent() != nil + Postable(post, user, fmt.Sprintf(`

%s

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

%s

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