Improved activity page
This commit is contained in:
@ -5,22 +5,24 @@ import (
|
||||
"github.com/animenotifier/notify.moe/arn"
|
||||
)
|
||||
|
||||
// Global activity page.
|
||||
func Global(ctx aero.Context) error {
|
||||
// Posts activity page.
|
||||
func Posts(ctx aero.Context) error {
|
||||
user := arn.GetUserFromContext(ctx)
|
||||
activities := fetchActivities(user, false)
|
||||
activities := fetchCreateActivities(user)
|
||||
return render(ctx, activities)
|
||||
}
|
||||
|
||||
// Followed activity page.
|
||||
func Followed(ctx aero.Context) error {
|
||||
// Watch activity page.
|
||||
func Watch(ctx aero.Context) error {
|
||||
user := arn.GetUserFromContext(ctx)
|
||||
activities := fetchActivities(user, true)
|
||||
activities := fetchConsumeActivities(user)
|
||||
return render(ctx, activities)
|
||||
}
|
||||
|
||||
// fetchActivities filters the activities by the given filters.
|
||||
func fetchActivities(user *arn.User, followedOnly bool) []arn.Activity {
|
||||
// fetchCreateActivities filters the activities by the given filters.
|
||||
func fetchCreateActivities(user *arn.User) []arn.Activity {
|
||||
followedOnly := user.Settings().Activity.ShowFollowedOnly
|
||||
|
||||
activities := arn.FilterActivityCreates(func(activity arn.Activity) bool {
|
||||
if followedOnly && user != nil && !user.IsFollowing(activity.GetCreatedBy()) {
|
||||
return false
|
||||
@ -43,3 +45,23 @@ func fetchActivities(user *arn.User, followedOnly bool) []arn.Activity {
|
||||
arn.SortActivitiesLatestFirst(activities)
|
||||
return activities
|
||||
}
|
||||
|
||||
// fetchConsumeActivities filters the consume activities by the given filters.
|
||||
func fetchConsumeActivities(user *arn.User) []arn.Activity {
|
||||
followedOnly := user.Settings().Activity.ShowFollowedOnly
|
||||
|
||||
activities := arn.FilterActivitiesConsumeAnime(func(activity arn.Activity) bool {
|
||||
if followedOnly && user != nil && !user.IsFollowing(activity.GetCreatedBy()) {
|
||||
return false
|
||||
}
|
||||
|
||||
if !activity.Creator().HasNick() {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
})
|
||||
|
||||
arn.SortActivitiesLatestFirst(activities)
|
||||
return activities
|
||||
}
|
||||
|
@ -2,8 +2,18 @@ component ActivityFeed(entries []arn.Activity, nextIndex int, user *arn.User)
|
||||
h1.page-title Activity
|
||||
|
||||
.tabs
|
||||
Tab("Global", "globe", "/activity")
|
||||
Tab("Followed", "user-plus", "/activity/followed")
|
||||
Tab("Posts", "comment", "/activity")
|
||||
Tab("Watch", "eye", "/activity/watch")
|
||||
|
||||
.corner-buttons(data-api="/api/settings/" + user.ID)
|
||||
if user.Settings().Activity.ShowFollowedOnly
|
||||
button.action(id="Activity.ShowFollowedOnly", data-action="disable", data-trigger="click", data-field="Activity.ShowFollowedOnly", title="Followed only")
|
||||
Icon("toggle-on")
|
||||
span Followed
|
||||
else
|
||||
button.action(id="Activity.ShowFollowedOnly", data-action="enable", data-trigger="click", data-field="Activity.ShowFollowedOnly", title="Followed only")
|
||||
Icon("toggle-off")
|
||||
span Followed
|
||||
|
||||
if len(entries) == 0
|
||||
p.no-data.mountable No activity here.
|
||||
@ -62,16 +72,28 @@ component Activity(activity arn.Activity, user *arn.User)
|
||||
//- ActivityConsumeAnimeText(activity.(*arn.ActivityConsumeAnime), user)
|
||||
|
||||
component ActivityConsumeAnime(activity *arn.ActivityConsumeAnime, user *arn.User)
|
||||
h1 TODO
|
||||
.activity.mountable.post-parent(id=fmt.Sprintf("activity-%s", activity.GetID()), data-type="consume-anime")
|
||||
.post-author
|
||||
Avatar(activity.Creator())
|
||||
|
||||
.post-box
|
||||
.post-header
|
||||
.post-header-info
|
||||
ActivityConsumeAnimeTitle(activity, user)
|
||||
|
||||
.post-date.utc-date(data-date=activity.GetCreated())
|
||||
|
||||
.post-content
|
||||
ActivityConsumeAnimeText(activity, user)
|
||||
|
||||
component ActivityConsumeAnimeText(activity *arn.ActivityConsumeAnime, user *arn.User)
|
||||
span watched
|
||||
component ActivityConsumeAnimeTitle(activity *arn.ActivityConsumeAnime, user *arn.User)
|
||||
a(href=activity.Anime().Link())= activity.Anime().TitleByUser(user)
|
||||
|
||||
component ActivityConsumeAnimeText(activity *arn.ActivityConsumeAnime, user *arn.User)
|
||||
if activity.ToEpisode > activity.FromEpisode
|
||||
span= fmt.Sprintf(" episodes %d - %d.", activity.FromEpisode, activity.ToEpisode)
|
||||
span= fmt.Sprintf("%s watched episodes %d - %d.", activity.Creator().Nick, activity.FromEpisode, activity.ToEpisode)
|
||||
else
|
||||
span= fmt.Sprintf(" episode %d.", activity.ToEpisode)
|
||||
span= fmt.Sprintf("%s watched episode %d.", activity.Creator().Nick, activity.ToEpisode)
|
||||
|
||||
component ActivityCreate(activity *arn.ActivityCreate, user *arn.User)
|
||||
Postable(activity.Postable(), user, false, true, "")
|
||||
|
Reference in New Issue
Block a user