From 96b1e2d6d2a967cec230b2c23f7b41821beb044a Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Sun, 3 Dec 2017 17:21:58 +0100 Subject: [PATCH] Episode restrictions --- pages/anime/anime.pixy | 2 +- pages/anime/episodes.go | 4 +++- pages/anime/episodes.pixy | 15 ++++++++------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index c5960f58..0d544ed1 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -28,7 +28,7 @@ component AnimeMainColumn(anime *arn.Anime, tracks []*arn.SoundTrack, episodes [ AnimeCharacters(anime) AnimeRelations(anime, user) 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) AnimeTrailer(anime) diff --git a/pages/anime/episodes.go b/pages/anime/episodes.go index 901d3b75..d4da8e38 100644 --- a/pages/anime/episodes.go +++ b/pages/anime/episodes.go @@ -4,6 +4,7 @@ import ( "net/http" "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" "github.com/aerogo/aero" "github.com/animenotifier/arn" @@ -11,6 +12,7 @@ import ( // Episodes ... func Episodes(ctx *aero.Context) string { + user := utils.GetUser(ctx) id := ctx.Get("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.HTML(components.AnimeEpisodes(anime.Episodes().Items)) + return ctx.HTML(components.AnimeEpisodes(anime.Episodes().Items, user)) } diff --git a/pages/anime/episodes.pixy b/pages/anime/episodes.pixy index 5b149e8b..9f8dabd3 100644 --- a/pages/anime/episodes.pixy +++ b/pages/anime/episodes.pixy @@ -1,4 +1,4 @@ -component AnimeEpisodes(episodes []*arn.AnimeEpisode) +component AnimeEpisodes(episodes []*arn.AnimeEpisode, user *arn.User) if len(episodes) > 0 .anime-section.mountable h3.anime-section-name Episodes @@ -14,12 +14,13 @@ component AnimeEpisodes(episodes []*arn.AnimeEpisode) Japanese(episode.Title.Japanese) else span - - td.episode-actions - for name, link := range episode.Links - a(href=link, target="_blank", rel="noopener", title="Watch episode " + toString(episode.Number) + " on " + name) - RawIcon("eye") - //- a(href="https://translate.google.com/#ja/en/" + episode.Title.Japanese, target="_blank", rel="noopener") - //- RawIcon("google") + if user != nil && user.Location.CountryName != "Japan" + td.episode-actions + for name, link := range episode.Links + a(href=link, target="_blank", rel="noopener", title="Watch episode " + toString(episode.Number) + " on " + name) + RawIcon("eye") + //- a(href="https://translate.google.com/#ja/en/" + episode.Title.Japanese, target="_blank", rel="noopener") + //- RawIcon("google") if validator.IsValidDate(episode.AiringDate.Start) td.episode-airing-date-start.utc-airing-date(data-start-date=episode.AiringDate.Start, data-end-date=episode.AiringDate.End, data-episode-number=episode.Number)= episode.AiringDate.StartDateHuman() else