Improved episode overview for long series
This commit is contained in:
@ -9,6 +9,9 @@ import (
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
const maxEpisodes = 26
|
||||
const maxEpisodesLongSeries = 5
|
||||
|
||||
// Get anime page.
|
||||
func Get(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
@ -25,5 +28,16 @@ func Get(ctx *aero.Context) string {
|
||||
return ctx.Error(http.StatusNotFound, "Error fetching soundtracks", err)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Anime(anime, tracks, user))
|
||||
episodesReversed := false
|
||||
|
||||
if len(anime.Episodes) > maxEpisodes {
|
||||
episodesReversed = true
|
||||
anime.Episodes = anime.Episodes[len(anime.Episodes)-maxEpisodesLongSeries-1:]
|
||||
|
||||
for i, j := 0, len(anime.Episodes)-1; i < j; i, j = i+1, j-1 {
|
||||
anime.Episodes[i], anime.Episodes[j] = anime.Episodes[j], anime.Episodes[i]
|
||||
}
|
||||
}
|
||||
|
||||
return ctx.HTML(components.Anime(anime, tracks, user, episodesReversed))
|
||||
}
|
||||
|
Reference in New Issue
Block a user