Show sequels of completed anime
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
component ExploreAnime(animeList []*arn.Anime, year string, status string, typ string, user *arn.User)
|
||||
component ExploreAnime(animes []*arn.Anime, year string, status string, typ string, user *arn.User)
|
||||
#filter-root(data-url="/explore/anime")
|
||||
ExploreFilters(year, status, typ, false)
|
||||
|
||||
@ -7,6 +7,10 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ s
|
||||
button.action(data-trigger="click", data-action="hideAddedAnime", title="Hide anime in my collection")
|
||||
RawIcon("eye-slash")
|
||||
|
||||
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")
|
||||
|
||||
@ -16,10 +20,10 @@ component ExploreAnime(animeList []*arn.Anime, year string, status string, typ s
|
||||
h1.page-title Explore
|
||||
|
||||
.explore-anime
|
||||
if len(animeList) == 0
|
||||
if len(animes) == 0
|
||||
p.no-data.mountable No anime found using the above filters.
|
||||
else
|
||||
AnimeGrid(animeList, user)
|
||||
AnimeGrid(animes, user)
|
||||
|
||||
component ExploreFilters(year string, status string, typ string, advancedFilters bool)
|
||||
.explore-filters
|
||||
|
8
pages/explore/explorerelations/relations.pixy
Normal file
8
pages/explore/explorerelations/relations.pixy
Normal file
@ -0,0 +1,8 @@
|
||||
component ExploreAnimeSequels(entries []*utils.AnimeWithRelatedAnime, user *arn.User)
|
||||
h1 Sequels of my completed anime
|
||||
|
||||
.explore-anime
|
||||
if len(entries) == 0
|
||||
p.no-data.mountable No sequels found for the anime you completed.
|
||||
else
|
||||
AnimeGridWithRelation(entries, user)
|
57
pages/explore/explorerelations/sequels.go
Normal file
57
pages/explore/explorerelations/sequels.go
Normal file
@ -0,0 +1,57 @@
|
||||
package explorerelations
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
"github.com/animenotifier/arn"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Sequels ...
|
||||
func Sequels(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
|
||||
if user == nil {
|
||||
return ctx.Error(http.StatusUnauthorized, "Not logged in", nil)
|
||||
}
|
||||
|
||||
animeList := user.AnimeList()
|
||||
sequels := []*utils.AnimeWithRelatedAnime{}
|
||||
|
||||
for anime := range arn.StreamAnime() {
|
||||
if animeList.Contains(anime.ID) {
|
||||
continue
|
||||
}
|
||||
|
||||
prequels := anime.Prequels()
|
||||
|
||||
for _, prequel := range prequels {
|
||||
item := animeList.Find(prequel.ID)
|
||||
|
||||
if item != nil && item.Status == arn.AnimeListStatusCompleted {
|
||||
sequels = append(sequels, &utils.AnimeWithRelatedAnime{
|
||||
Anime: anime,
|
||||
Related: prequel,
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(sequels, func(i, j int) bool {
|
||||
aScore := sequels[i].Anime.Score()
|
||||
bScore := sequels[j].Anime.Score()
|
||||
|
||||
if aScore == bScore {
|
||||
return sequels[i].Anime.Title.Canonical < sequels[j].Anime.Title.Canonical
|
||||
}
|
||||
|
||||
return aScore > bScore
|
||||
})
|
||||
|
||||
return ctx.HTML(components.ExploreAnimeSequels(sequels, user))
|
||||
}
|
Reference in New Issue
Block a user