Seperated global and followed activity feed
This commit is contained in:
@ -9,11 +9,33 @@ import (
|
||||
|
||||
const maxActivitiesPerPage = 40
|
||||
|
||||
// Get activity page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
// Global activity page.
|
||||
func Global(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
activities := fetchActivities(user, false)
|
||||
return ctx.HTML(components.ActivityFeed(activities, user))
|
||||
}
|
||||
|
||||
// Followed activity page.
|
||||
func Followed(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
activities := fetchActivities(user, true)
|
||||
return ctx.HTML(components.ActivityFeed(activities, user))
|
||||
}
|
||||
|
||||
// fetchActivities filters the activities by the given filters.
|
||||
func fetchActivities(user *arn.User, followedOnly bool) []arn.Activity {
|
||||
var followedUserIDs []string
|
||||
|
||||
if followedOnly && user != nil {
|
||||
followedUserIDs = user.Follows().Items
|
||||
}
|
||||
|
||||
activities := arn.FilterActivities(func(activity arn.Activity) bool {
|
||||
if followedOnly && !arn.Contains(followedUserIDs, activity.GetCreatedBy()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if activity.Type() == "ActivityCreate" {
|
||||
obj := activity.(*arn.ActivityCreate).Object()
|
||||
|
||||
@ -21,8 +43,8 @@ func Get(ctx *aero.Context) string {
|
||||
return false
|
||||
}
|
||||
|
||||
draft, isDraftable := obj.(arn.HasDraft)
|
||||
return !isDraftable || !draft.IsDraft
|
||||
draft, isDraftable := obj.(arn.Draftable)
|
||||
return !isDraftable || !draft.GetIsDraft()
|
||||
}
|
||||
|
||||
if activity.Type() == "ActivityConsumeAnime" {
|
||||
@ -38,5 +60,5 @@ func Get(ctx *aero.Context) string {
|
||||
activities = activities[:maxActivitiesPerPage]
|
||||
}
|
||||
|
||||
return ctx.HTML(components.ActivityFeed(activities, user))
|
||||
return activities
|
||||
}
|
||||
|
@ -1,12 +1,25 @@
|
||||
component ActivityFeed(entries []arn.Activity, user *arn.User)
|
||||
h1 Activity
|
||||
h1.page-title Activity
|
||||
|
||||
.tabs
|
||||
Tab("Global", "globe", "/activity")
|
||||
Tab("Followed", "user-plus", "/activity/followed")
|
||||
|
||||
.activities
|
||||
each entry in entries
|
||||
Activity(entry, user)
|
||||
if len(entries) == 0
|
||||
p.no-data.mountable No activity here.
|
||||
else
|
||||
each entry in entries
|
||||
Activity(entry, user)
|
||||
|
||||
#load-new-activities(data-count="0")
|
||||
.buttons
|
||||
button.page-main-action.action(data-action="reloadContent", data-trigger="click")
|
||||
Icon("refresh")
|
||||
span#load-new-activities-text 0 new activities
|
||||
|
||||
component Activity(activity arn.Activity, user *arn.User)
|
||||
.activity.post-parent(id=fmt.Sprintf("activity-%s", activity.GetID()))
|
||||
.activity.post-parent.mountable(id=fmt.Sprintf("activity-%s", activity.GetID()))
|
||||
.post-author
|
||||
Avatar(activity.Creator())
|
||||
.post-content
|
||||
@ -29,19 +42,23 @@ component ActivityConsumeAnimeTitle(activity *arn.ActivityConsumeAnime, user *ar
|
||||
|
||||
component ActivityConsumeAnimeText(activity *arn.ActivityConsumeAnime, user *arn.User)
|
||||
if activity.ToEpisode > activity.FromEpisode
|
||||
em= fmt.Sprintf("watched episodes %d - %d", activity.FromEpisode, activity.ToEpisode)
|
||||
em.actvity-text-consume-anime= fmt.Sprintf("watched episodes %d - %d", activity.FromEpisode, activity.ToEpisode)
|
||||
else
|
||||
em= fmt.Sprintf("watched episode %d", activity.ToEpisode)
|
||||
em.actvity-text-consume-anime= fmt.Sprintf("watched episode %d", activity.ToEpisode)
|
||||
|
||||
component ActivityCreateTitle(activity *arn.ActivityCreate, user *arn.User)
|
||||
if activity.ObjectType == "Post"
|
||||
a(href=activity.Postable().Parent().Link())= activity.Postable().Parent().TitleByUser(user)
|
||||
else if activity.ObjectType == "Thread"
|
||||
a(href=activity.Postable().Link())= activity.Postable().TitleByUser(user)
|
||||
else if activity.ObjectType == "AMV" || activity.ObjectType == "SoundTrack" || activity.ObjectType == "Quote"
|
||||
a(href=activity.Object().(arn.PostParent).Link())= activity.Object().(arn.PostParent).TitleByUser(user)
|
||||
|
||||
component ActivityCreateText(activity *arn.ActivityCreate, user *arn.User)
|
||||
if activity.ObjectType == "Post" || activity.ObjectType == "Thread"
|
||||
div!= activity.Postable().HTML()
|
||||
else
|
||||
em.actvity-text-create= "new " + strings.ToLower(activity.ObjectType)
|
||||
|
||||
//- component ActivityFeed(entries []*arn.EditLogEntry, user *arn.User)
|
||||
//- h1 Activity
|
||||
|
@ -14,4 +14,11 @@
|
||||
flex 1
|
||||
|
||||
.activity-date
|
||||
color hsla(text-color-h, text-color-s, text-color-l, 0.5)
|
||||
color hsla(text-color-h, text-color-s, text-color-l, 0.5)
|
||||
|
||||
.actvity-text-create
|
||||
opacity 0.8
|
||||
|
||||
#load-new-activities
|
||||
[data-count="0"]
|
||||
display none
|
@ -7,7 +7,7 @@ component Forum(tag string, threads []*arn.Thread, threadsPerPage int)
|
||||
ThreadList(threads)
|
||||
|
||||
.buttons
|
||||
button#new-thread.action(data-action="load", data-trigger="click", data-url="/new/thread")
|
||||
button#new-thread.page-main-action.action(data-action="load", data-trigger="click", data-url="/new/thread")
|
||||
Icon("plus")
|
||||
span New thread
|
||||
//- if len(threads) == threadsPerPage
|
||||
|
@ -1,13 +1,13 @@
|
||||
.forum
|
||||
vertical
|
||||
align-items center
|
||||
|
||||
|
||||
.thread-link
|
||||
width 100%
|
||||
max-width forum-width
|
||||
|
||||
> 1250px
|
||||
#new-thread
|
||||
.page-main-action
|
||||
position fixed
|
||||
right content-padding
|
||||
bottom content-padding
|
||||
|
@ -20,7 +20,8 @@ func Register(l *layout.Layout) {
|
||||
l.Page("/login", login.Get)
|
||||
|
||||
// Activity
|
||||
l.Page("/activity", activity.Get)
|
||||
l.Page("/activity", activity.Global)
|
||||
l.Page("/activity/followed", activity.Followed)
|
||||
|
||||
// Calendar
|
||||
l.Page("/calendar", calendar.Get)
|
||||
|
Reference in New Issue
Block a user