Started working on episode pages
This commit is contained in:
43
pages/episode/episode.go
Normal file
43
pages/episode/episode.go
Normal file
@ -0,0 +1,43 @@
|
||||
package episode
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// Get renders the anime episode.
|
||||
func Get(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
id := ctx.Get("id")
|
||||
episodeNumber, err := ctx.GetInt("episode-number")
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusBadRequest, "Episode is not a number", err)
|
||||
}
|
||||
|
||||
// Get anime
|
||||
anime, err := arn.GetAnime(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
||||
}
|
||||
|
||||
// Get anime episodes
|
||||
animeEpisodes, err := arn.GetAnimeEpisodes(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Anime episodes not found", err)
|
||||
}
|
||||
|
||||
episode := animeEpisodes.Find(episodeNumber)
|
||||
|
||||
if episode == nil {
|
||||
return ctx.Error(http.StatusNotFound, "Anime episode not found", nil)
|
||||
}
|
||||
|
||||
return ctx.HTML(components.AnimeEpisode(anime, episode, user))
|
||||
}
|
9
pages/episode/episode.pixy
Normal file
9
pages/episode/episode.pixy
Normal file
@ -0,0 +1,9 @@
|
||||
component AnimeEpisode(anime *arn.Anime, episode *arn.AnimeEpisode, user *arn.User)
|
||||
h1= episode.Title.Japanese
|
||||
p
|
||||
a.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||
img(src=anime.Image("medium"), alt=anime.Title.ByUser(user))
|
||||
|
||||
if validator.IsValidDate(episode.AiringDate.Start)
|
||||
.utc-airing-date(data-start-date=episode.AiringDate.Start, data-end-date=episode.AiringDate.End, data-episode-number=episode.Number)= episode.AiringDate.StartDateHuman()
|
||||
|
Reference in New Issue
Block a user