Merge pull request #174 from Amatrelan/arrows

Episode left and right arrow #153
This commit is contained in:
Eduard Urbach 2018-07-07 15:35:02 +09:00 committed by GitHub
commit ec9bd057ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -33,11 +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")
}
return ctx.HTML(components.AnimeEpisode(anime, episode, user))
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)
component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.User, episodeIndex int)
h1
a(href=anime.Link())= anime.Title.ByUser(user)
@ -8,6 +8,14 @@ component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.Us
h3.episode-view-number= "Episode " + strconv.Itoa(episode.Number)
//- if episodeIndex > 0
//- a.button(href=anime.Link() + "/episode/" + strconv.Itoa(anime.Episodes().Items[episodeIndex - 1].Number))
//- Icon("chevron-left")
//- 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 != ""
.episode-view-title
Japanese(episode.Title.Japanese)