Episode restrictions

This commit is contained in:
Eduard Urbach 2017-12-03 17:21:58 +01:00
parent cd9dfd85e1
commit 96b1e2d6d2
3 changed files with 12 additions and 9 deletions

View File

@ -28,7 +28,7 @@ component AnimeMainColumn(anime *arn.Anime, tracks []*arn.SoundTrack, episodes [
AnimeCharacters(anime) AnimeCharacters(anime)
AnimeRelations(anime, user) AnimeRelations(anime, user)
AnimeTracks(anime, tracks) AnimeTracks(anime, tracks)
AnimeEpisodes(episodes) AnimeEpisodes(episodes, user)
component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User)
AnimeTrailer(anime) AnimeTrailer(anime)

View File

@ -4,6 +4,7 @@ import (
"net/http" "net/http"
"github.com/animenotifier/notify.moe/components" "github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/arn" "github.com/animenotifier/arn"
@ -11,6 +12,7 @@ import (
// Episodes ... // Episodes ...
func Episodes(ctx *aero.Context) string { func Episodes(ctx *aero.Context) string {
user := utils.GetUser(ctx)
id := ctx.Get("id") id := ctx.Get("id")
anime, err := arn.GetAnime(id) anime, err := arn.GetAnime(id)
@ -19,5 +21,5 @@ func Episodes(ctx *aero.Context) string {
return ctx.Error(http.StatusNotFound, "Anime not found", err) return ctx.Error(http.StatusNotFound, "Anime not found", err)
} }
return ctx.HTML(components.AnimeEpisodes(anime.Episodes().Items)) return ctx.HTML(components.AnimeEpisodes(anime.Episodes().Items, user))
} }

View File

@ -1,4 +1,4 @@
component AnimeEpisodes(episodes []*arn.AnimeEpisode) component AnimeEpisodes(episodes []*arn.AnimeEpisode, user *arn.User)
if len(episodes) > 0 if len(episodes) > 0
.anime-section.mountable .anime-section.mountable
h3.anime-section-name Episodes h3.anime-section-name Episodes
@ -14,6 +14,7 @@ component AnimeEpisodes(episodes []*arn.AnimeEpisode)
Japanese(episode.Title.Japanese) Japanese(episode.Title.Japanese)
else else
span - span -
if user != nil && user.Location.CountryName != "Japan"
td.episode-actions td.episode-actions
for name, link := range episode.Links for name, link := range episode.Links
a(href=link, target="_blank", rel="noopener", title="Watch episode " + toString(episode.Number) + " on " + name) a(href=link, target="_blank", rel="noopener", title="Watch episode " + toString(episode.Number) + " on " + name)