From cb01452c4498c5204a9f152b9e4703260e97aaae Mon Sep 17 00:00:00 2001 From: FM1337 Date: Sat, 24 Jun 2017 18:38:39 -0300 Subject: [PATCH 1/3] Updated dashboard to include following list --- pages/dashboard/dashboard.go | 11 ++++++++++- pages/dashboard/dashboard.pixy | 28 ++++++++++++++-------------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index 97cc72fe..4552a98c 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -9,6 +9,7 @@ import ( ) const maxPosts = 5 +const maxFollowing = 5 // Get dashboard. func Get(ctx *aero.Context) string { @@ -30,5 +31,13 @@ func Get(ctx *aero.Context) string { posts = posts[:maxPosts] } - return ctx.HTML(components.Dashboard(posts)) + userList, err := arn.DB.GetMany("User", user.Following[:maxFollowing]) + + if err != nil { + return ctx.Error(500, "Error fetching following", err) + } + + followingList := userList.([]*arn.User) + + return ctx.HTML(components.Dashboard(posts, followingList)) } diff --git a/pages/dashboard/dashboard.pixy b/pages/dashboard/dashboard.pixy index ab0d9c5d..7f2aa69f 100644 --- a/pages/dashboard/dashboard.pixy +++ b/pages/dashboard/dashboard.pixy @@ -1,6 +1,6 @@ -component Dashboard(posts []*arn.Post) +component Dashboard(posts []*arn.Post, followers []*arn.User) h2.page-title Dash - + .widgets .widget.mountable h3.widget-title Schedule @@ -10,7 +10,7 @@ component Dashboard(posts []*arn.Post) .widget-element-text Icon("calendar-o") span ... - + .widget.mountable h3.widget-title Forums @@ -19,7 +19,7 @@ component Dashboard(posts []*arn.Post) .widget-element-text Icon(arn.GetForumIcon(post.Thread().Tags[0])) span= post.Thread().Title - + .widget.mountable h3.widget-title Groups @@ -37,16 +37,16 @@ component Dashboard(posts []*arn.Post) .widget-element-text Icon("comment") span ... - + .widget.mountable h3.widget-title Contacts - for i := 1; i <= 5; i++ - .widget-element + each follower in followers + a.widget-element.ajax(href="/+" + follower.Nick) .widget-element-text Icon("address-card") - span ... - + span!= follower.Nick + .widget.mountable h3.widget-title Follow @@ -54,23 +54,23 @@ component Dashboard(posts []*arn.Post) .widget-element-text Icon("microphone") span Discord - + a.widget-element(href="https://www.facebook.com/animenotifier", target="_blank", rel="noopener") .widget-element-text Icon("facebook") span Facebook - + a.widget-element(href="https://twitter.com/animenotifier", target="_blank", rel="noopener") .widget-element-text Icon("twitter") span Twitter - + a.widget-element(href="https://plus.google.com/+AnimeReleaseNotifierOfficial", target="_blank", rel="noopener") .widget-element-text Icon("google-plus") span Google+ - + a.widget-element(href="https://github.com/animenotifier/notify.moe", target="_blank", rel="noopener") .widget-element-text Icon("github") - span GitHub \ No newline at end of file + span GitHub From 1cd798e947bfa6dac023183de1d9b4d31887284f Mon Sep 17 00:00:00 2001 From: FM1337 Date: Sat, 24 Jun 2017 18:57:36 -0300 Subject: [PATCH 2/3] Updated dashboard --- pages/dashboard/dashboard.go | 10 ++++++++-- pages/dashboard/dashboard.pixy | 15 ++++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index 4552a98c..48a36c05 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -31,10 +31,16 @@ func Get(ctx *aero.Context) string { posts = posts[:maxPosts] } - userList, err := arn.DB.GetMany("User", user.Following[:maxFollowing]) + followIDList := user.Following + + if len(followIDList) > maxFollowing { + followIDList = followIDList[:maxFollowing] + } + + userList, err := arn.DB.GetMany("User", followIDList) if err != nil { - return ctx.Error(500, "Error fetching following", err) + return ctx.Error(500, "Error fetching followers", err) } followingList := userList.([]*arn.User) diff --git a/pages/dashboard/dashboard.pixy b/pages/dashboard/dashboard.pixy index 7f2aa69f..2fb996bb 100644 --- a/pages/dashboard/dashboard.pixy +++ b/pages/dashboard/dashboard.pixy @@ -38,14 +38,15 @@ component Dashboard(posts []*arn.Post, followers []*arn.User) Icon("comment") span ... - .widget.mountable - h3.widget-title Contacts + if len(followers) > 0 + .widget.mountable + h3.widget-title Contacts - each follower in followers - a.widget-element.ajax(href="/+" + follower.Nick) - .widget-element-text - Icon("address-card") - span!= follower.Nick + each follower in followers + a.widget-element.ajax(href="/+" + follower.Nick) + .widget-element-text + Icon("address-card") + span= follower.Nick .widget.mountable h3.widget-title Follow From 1e89bfa5fb2d6256954dde96aa178c36670a09ff Mon Sep 17 00:00:00 2001 From: FM1337 Date: Sat, 24 Jun 2017 19:03:05 -0300 Subject: [PATCH 3/3] Updated dashboard following users terminology --- pages/dashboard/dashboard.go | 2 +- pages/dashboard/dashboard.pixy | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/dashboard/dashboard.go b/pages/dashboard/dashboard.go index 48a36c05..f37bbf1c 100644 --- a/pages/dashboard/dashboard.go +++ b/pages/dashboard/dashboard.go @@ -40,7 +40,7 @@ func Get(ctx *aero.Context) string { userList, err := arn.DB.GetMany("User", followIDList) if err != nil { - return ctx.Error(500, "Error fetching followers", err) + return ctx.Error(500, "Error fetching followed users", err) } followingList := userList.([]*arn.User) diff --git a/pages/dashboard/dashboard.pixy b/pages/dashboard/dashboard.pixy index 2fb996bb..7fee6c6f 100644 --- a/pages/dashboard/dashboard.pixy +++ b/pages/dashboard/dashboard.pixy @@ -1,4 +1,4 @@ -component Dashboard(posts []*arn.Post, followers []*arn.User) +component Dashboard(posts []*arn.Post, following []*arn.User) h2.page-title Dash .widgets @@ -38,15 +38,15 @@ component Dashboard(posts []*arn.Post, followers []*arn.User) Icon("comment") span ... - if len(followers) > 0 + if len(following) > 0 .widget.mountable h3.widget-title Contacts - each follower in followers - a.widget-element.ajax(href="/+" + follower.Nick) + each user in following + a.widget-element.ajax(href="/+" + user.Nick) .widget-element-text Icon("address-card") - span= follower.Nick + span= user.Nick .widget.mountable h3.widget-title Follow