Sequels page is now linked on profiles

This commit is contained in:
Eduard Urbach 2018-12-06 14:13:49 +09:00
parent 566b8f83cf
commit 7dfaa85a7a
8 changed files with 21 additions and 49 deletions

View File

@ -19,10 +19,6 @@ component ExploreAnime(animes []*arn.Anime, year string, season string, status s
a.button(href="/genres", title="View genres") a.button(href="/genres", title="View genres")
RawIcon("clone") 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") a.button(href="/explore/color/any/anime", title="View colors")
RawIcon("paint-brush") RawIcon("paint-brush")

View File

@ -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 h1 Sequels of my completed anime
.explore-anime .explore-anime

View File

@ -13,13 +13,20 @@ import (
// Sequels ... // Sequels ...
func Sequels(ctx *aero.Context) string { func Sequels(ctx *aero.Context) string {
nick := ctx.Get("nick")
user := utils.GetUser(ctx) user := utils.GetUser(ctx)
if user == nil { if user == nil {
return ctx.Error(http.StatusUnauthorized, "Not logged in") 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{} sequels := []*utils.AnimeWithRelatedAnime{}
for anime := range arn.StreamAnime() { for anime := range arn.StreamAnime() {
@ -56,5 +63,5 @@ func Sequels(ctx *aero.Context) string {
return aScore > bScore return aScore > bScore
}) })
return ctx.HTML(components.ExploreAnimeSequels(sequels, user)) return ctx.HTML(components.ExploreAnimeSequels(sequels, viewUser, user))
} }

View File

@ -4,7 +4,6 @@ import (
"github.com/aerogo/layout" "github.com/aerogo/layout"
"github.com/animenotifier/notify.moe/pages/explore" "github.com/animenotifier/notify.moe/pages/explore"
"github.com/animenotifier/notify.moe/pages/explore/explorecolor" "github.com/animenotifier/notify.moe/pages/explore/explorecolor"
"github.com/animenotifier/notify.moe/pages/explore/explorerelations"
"github.com/animenotifier/notify.moe/pages/explore/halloffame" "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/anime/:year/:season/:status/:type", explore.Filter)
l.Page("/explore/color/:color/anime", explorecolor.AnimeByAverageColor) l.Page("/explore/color/:color/anime", explorecolor.AnimeByAverageColor)
l.Page("/explore/color/:color/anime/from/:index", explorecolor.AnimeByAverageColor) l.Page("/explore/color/:color/anime/from/:index", explorecolor.AnimeByAverageColor)
l.Page("/explore/sequels", explorerelations.Sequels)
l.Page("/halloffame", halloffame.Get) l.Page("/halloffame", halloffame.Get)
} }

View File

@ -6,6 +6,7 @@ import (
"github.com/animenotifier/notify.moe/pages/animelist" "github.com/animenotifier/notify.moe/pages/animelist"
"github.com/animenotifier/notify.moe/pages/animelistitem" "github.com/animenotifier/notify.moe/pages/animelistitem"
"github.com/animenotifier/notify.moe/pages/compare" "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/notifications"
"github.com/animenotifier/notify.moe/pages/profile" "github.com/animenotifier/notify.moe/pages/profile"
"github.com/animenotifier/notify.moe/pages/recommended" "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/stats", profile.GetStatsByUser)
// l.Page("/user/:nick/followers", profile.GetFollowers) // l.Page("/user/:nick/followers", profile.GetFollowers)
l.Page("/user/:nick/animelist/anime/:id", animelistitem.Get) 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/notifications", notifications.ByUser)
l.Page("/user/:nick/edit", user.Edit) l.Page("/user/:nick/edit", user.Edit)

View File

@ -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

View File

@ -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") 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") 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") 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") 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") a.profile-tag.tip.mountable.never-unmount.show-more(href="/+" + viewUser.Nick + "/log", aria-label="Log", data-mountable-type="header")
RawIcon("list") 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 .profile-actions
if user != nil && user.ID != viewUser.ID if user != nil && user.ID != viewUser.ID

View File

@ -463,7 +463,6 @@ var routeTests = map[string][]string{
"/admin/purchases": nil, "/admin/purchases": nil,
"/admin/registrations": nil, "/admin/registrations": nil,
"/admin/payments": nil, "/admin/payments": nil,
"/explore/sequels": nil,
"/editor/anilist": nil, "/editor/anilist": nil,
"/editor/shoboi": nil, "/editor/shoboi": nil,
"/dark-flame-master": nil, "/dark-flame-master": nil,