This commit is contained in:
Jarmo Riikonen 2018-07-07 08:24:34 +03:00
parent 447186e7d3
commit 0af180ed5e
2 changed files with 7 additions and 10 deletions

View File

@ -33,14 +33,11 @@ func Get(ctx *aero.Context) string {
return ctx.Error(http.StatusNotFound, "Anime episodes not found", err)
}
episode, _ := animeEpisodes.Find(episodeNumber)
episode, episodeIndex := animeEpisodes.Find(episodeNumber)
if episode == nil {
return ctx.Error(http.StatusNotFound, "Anime episode not found", nil)
}
_, previousIndex := animeEpisodes.Find(episodeNumber - 1)
_, nextIndex := animeEpisodes.Find(episodeNumber + 1)
return ctx.HTML(components.AnimeEpisode(anime, episode, user, previousIndex, nextIndex))
return ctx.HTML(components.AnimeEpisode(anime, episode, user, episodeIndex))
}

View File

@ -1,4 +1,4 @@
component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.User, previousIndex int, nextIndex int)
component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.User, episodeIndex int)
h1
a(href=anime.Link())= anime.Title.ByUser(user)
@ -8,12 +8,12 @@ component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.Us
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
//- if previousIndex != -1
//- a.button(href=anime.Link() + "/episode/" + strconv.Itoa(anime.Episodes().Items[previousIndex].Number))
//- if episodeIndex > 0
//- a.button(href=anime.Link() + "/episode/" + strconv.Itoa(anime.Episodes().Items[episodeIndex - 1].Number))
//- Icon("chevron-left")
//- if nextIndex != -1
//- a.button(href=anime.Link() + "/episode/" + strconv.Itoa(anime.Episodes().Items[nextIndex].Number))
//- if episodeIndex < len(anime.Episodes().Items) - 1
//- a.button(href=anime.Link() + "/episode/" + strconv.Itoa(anime.Episodes().Items[episodeIndex + 1].Number))
//- Icon("chevron-right")
if episode.Title.Japanese != ""