From 7dfaa85a7adca0bed52067362ac889210e035c02 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 6 Dec 2018 14:13:49 +0900 Subject: [PATCH] Sequels page is now linked on profiles --- pages/explore/explore.pixy | 4 -- pages/explore/explorerelations/relations.pixy | 2 +- pages/explore/explorerelations/sequels.go | 11 +++++- pages/index/exploreroutes/exploreroutes.go | 2 - pages/index/userroutes/userroutes.go | 4 +- pages/profile/old.pixy | 37 ------------------- pages/profile/profile.pixy | 9 ++++- utils/routetests/All.go | 1 - 8 files changed, 21 insertions(+), 49 deletions(-) delete mode 100644 pages/profile/old.pixy diff --git a/pages/explore/explore.pixy b/pages/explore/explore.pixy index 75f36265..6ef926a6 100644 --- a/pages/explore/explore.pixy +++ b/pages/explore/explore.pixy @@ -19,10 +19,6 @@ component ExploreAnime(animes []*arn.Anime, year string, season string, status s a.button(href="/genres", title="View genres") RawIcon("clone") - if user != nil - a.button(href="/explore/sequels", title="View sequels of my completed anime") - RawIcon("forward") - a.button(href="/explore/color/any/anime", title="View colors") RawIcon("paint-brush") diff --git a/pages/explore/explorerelations/relations.pixy b/pages/explore/explorerelations/relations.pixy index 1faf32b3..eb2a3803 100644 --- a/pages/explore/explorerelations/relations.pixy +++ b/pages/explore/explorerelations/relations.pixy @@ -1,4 +1,4 @@ -component ExploreAnimeSequels(entries []*utils.AnimeWithRelatedAnime, user *arn.User) +component ExploreAnimeSequels(entries []*utils.AnimeWithRelatedAnime, viewUser *arn.User, user *arn.User) h1 Sequels of my completed anime .explore-anime diff --git a/pages/explore/explorerelations/sequels.go b/pages/explore/explorerelations/sequels.go index 271dd62a..a43eee18 100644 --- a/pages/explore/explorerelations/sequels.go +++ b/pages/explore/explorerelations/sequels.go @@ -13,13 +13,20 @@ import ( // Sequels ... func Sequels(ctx *aero.Context) string { + nick := ctx.Get("nick") user := utils.GetUser(ctx) if user == nil { return ctx.Error(http.StatusUnauthorized, "Not logged in") } - animeList := user.AnimeList() + viewUser, err := arn.GetUserByNick(nick) + + if err != nil { + return ctx.Error(http.StatusNotFound, "User not found", err) + } + + animeList := viewUser.AnimeList() sequels := []*utils.AnimeWithRelatedAnime{} for anime := range arn.StreamAnime() { @@ -56,5 +63,5 @@ func Sequels(ctx *aero.Context) string { return aScore > bScore }) - return ctx.HTML(components.ExploreAnimeSequels(sequels, user)) + return ctx.HTML(components.ExploreAnimeSequels(sequels, viewUser, user)) } diff --git a/pages/index/exploreroutes/exploreroutes.go b/pages/index/exploreroutes/exploreroutes.go index 2cc7f250..065e1dbb 100644 --- a/pages/index/exploreroutes/exploreroutes.go +++ b/pages/index/exploreroutes/exploreroutes.go @@ -4,7 +4,6 @@ import ( "github.com/aerogo/layout" "github.com/animenotifier/notify.moe/pages/explore" "github.com/animenotifier/notify.moe/pages/explore/explorecolor" - "github.com/animenotifier/notify.moe/pages/explore/explorerelations" "github.com/animenotifier/notify.moe/pages/explore/halloffame" ) @@ -15,6 +14,5 @@ func Register(l *layout.Layout) { l.Page("/explore/anime/:year/:season/:status/:type", explore.Filter) l.Page("/explore/color/:color/anime", explorecolor.AnimeByAverageColor) l.Page("/explore/color/:color/anime/from/:index", explorecolor.AnimeByAverageColor) - l.Page("/explore/sequels", explorerelations.Sequels) l.Page("/halloffame", halloffame.Get) } diff --git a/pages/index/userroutes/userroutes.go b/pages/index/userroutes/userroutes.go index 60709854..476e849b 100644 --- a/pages/index/userroutes/userroutes.go +++ b/pages/index/userroutes/userroutes.go @@ -6,6 +6,7 @@ import ( "github.com/animenotifier/notify.moe/pages/animelist" "github.com/animenotifier/notify.moe/pages/animelistitem" "github.com/animenotifier/notify.moe/pages/compare" + "github.com/animenotifier/notify.moe/pages/explore/explorerelations" "github.com/animenotifier/notify.moe/pages/notifications" "github.com/animenotifier/notify.moe/pages/profile" "github.com/animenotifier/notify.moe/pages/recommended" @@ -31,7 +32,8 @@ func Register(l *layout.Layout) { // l.Page("/user/:nick/stats", profile.GetStatsByUser) // l.Page("/user/:nick/followers", profile.GetFollowers) l.Page("/user/:nick/animelist/anime/:id", animelistitem.Get) - l.Page("/user/:nick/recommended/anime", recommended.Anime) + l.Page("/user/:nick/anime/recommended", recommended.Anime) + l.Page("/user/:nick/anime/sequels", explorerelations.Sequels) l.Page("/user/:nick/notifications", notifications.ByUser) l.Page("/user/:nick/edit", user.Edit) diff --git a/pages/profile/old.pixy b/pages/profile/old.pixy deleted file mode 100644 index 9bb326d5..00000000 --- a/pages/profile/old.pixy +++ /dev/null @@ -1,37 +0,0 @@ -//- component ProfileTabs(viewUser *arn.User, uri string) -//- .tabs.mountable.never-unmount -//- Tab("Anime", "th", "/+" + viewUser.Nick) -//- Tab("Characters", "child", "/+" + viewUser.Nick + "/characters/liked") -//- Tab("Forum", "comment", "/+" + viewUser.Nick + "/forum/threads") -//- Tab("Tracks", "music", "/+" + viewUser.Nick + "/soundtracks/liked") -//- Tab("Quotes", "quote-left", "/+" + viewUser.Nick + "/quotes/liked") -//- Tab("Stats", "area-chart", "/+" + viewUser.Nick + "/stats") -//- Tab("Followers", "users", "/+" + viewUser.Nick + "/followers") - -//- if strings.Contains(uri, "/soundtracks") -//- .tabs -//- Tab("Liked", "heart", "/+" + viewUser.Nick + "/soundtracks/liked") -//- Tab("Added", "plus", "/+" + viewUser.Nick + "/soundtracks/added") - -//- if strings.Contains(uri, "/quotes") -//- .tabs -//- Tab("Liked", "heart", "/+" + viewUser.Nick + "/quotes/liked") -//- Tab("Added", "plus", "/+" + viewUser.Nick + "/quotes/added") - -//- Anime shelf -//- if len(animeList.Items) == 0 -//- p.no-data.mountable= viewUser.Nick + " hasn't added any anime yet." -//- else -//- .profile-watching-list.mountable -//- each item in animeList.Items -//- if item.Status == arn.AnimeListStatusWatching || item.Status == arn.AnimeListStatusCompleted -//- a.profile-watching-list-item.tip(href=item.Anime().Link(), aria-label=item.Anime().Title.ByUser(user) + " (" + fmt.Sprint(item.Episodes) + " / " + arn.EpisodesToString(item.Anime().EpisodeCount) + ")") -//- img.profile-watching-list-item-image.lazy(data-src=item.Anime().ImageLink("small"), data-webp="true", data-color=item.Anime().AverageColor(), alt=item.Anime().Title.ByUser(user), importance="high") - -//- Footer -//- .footer -//- .buttons -//- if user != nil && (user.Role == "admin" || user.Role == "editor") -//- a.button.profile-action(href="/api/user/" + viewUser.ID, target="_blank", rel="noopener") -//- Icon("search-plus") -//- span JSON \ No newline at end of file diff --git a/pages/profile/profile.pixy b/pages/profile/profile.pixy index 8e7876f8..e2e6e132 100644 --- a/pages/profile/profile.pixy +++ b/pages/profile/profile.pixy @@ -176,12 +176,19 @@ component ProfileHead(viewUser *arn.User, animeList *arn.AnimeList, user *arn.Us a.profile-tag.tip.mountable.never-unmount.show-more(href="/compare/animelist/" + user.Nick + "/" + viewUser.Nick, aria-label="Compare", data-mountable-type="header") RawIcon("exchange") - a.profile-tag.tip.mountable.never-unmount.show-more(href="/+" + viewUser.Nick + "/recommended/anime", aria-label="Recommendations", data-mountable-type="header") + a.profile-tag.tip.mountable.never-unmount.show-more(href="/+" + viewUser.Nick + "/anime/recommended", aria-label="Recommendations", data-mountable-type="header") RawIcon("archive") + a.profile-tag.tip.mountable.never-unmount.show-more(href="/+" + viewUser.Nick + "/anime/sequels", aria-label="Sequels", data-mountable-type="header") + RawIcon("forward") + if user != nil && (user.Role == "editor" || user.Role == "admin") a.profile-tag.tip.mountable.never-unmount.show-more(href="/+" + viewUser.Nick + "/log", aria-label="Log", data-mountable-type="header") RawIcon("list") + + if user != nil && user.Role == "admin" + a.profile-tag.tip.mountable.never-unmount.show-more(href="/api/user/" + viewUser.ID, aria-label="API", target="_blank", rel="noopener", data-mountable-type="header") + RawIcon("search-plus") .profile-actions if user != nil && user.ID != viewUser.ID diff --git a/utils/routetests/All.go b/utils/routetests/All.go index 114da85f..2f2d2ca7 100644 --- a/utils/routetests/All.go +++ b/utils/routetests/All.go @@ -463,7 +463,6 @@ var routeTests = map[string][]string{ "/admin/purchases": nil, "/admin/registrations": nil, "/admin/payments": nil, - "/explore/sequels": nil, "/editor/anilist": nil, "/editor/shoboi": nil, "/dark-flame-master": nil,