From 5460c49cfeaf1389c4a7e13e0824e87540632608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Rayapoull=C3=A9?= Date: Sat, 29 Sep 2018 14:02:25 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Added=20anime=20trailers=20page.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/anime/trailers.go | 25 ++++++++++++++++++++++++ pages/anime/trailers.pixy | 13 +++++++++++++ pages/anime/trailers.scarlet | 27 ++++++++++++++++++++++++++ pages/index/animeroutes/animeroutes.go | 1 + 4 files changed, 66 insertions(+) create mode 100644 pages/anime/trailers.go create mode 100644 pages/anime/trailers.pixy create mode 100644 pages/anime/trailers.scarlet diff --git a/pages/anime/trailers.go b/pages/anime/trailers.go new file mode 100644 index 000000000..3278114b2 --- /dev/null +++ b/pages/anime/trailers.go @@ -0,0 +1,25 @@ +package anime + +import ( + "net/http" + + "github.com/animenotifier/notify.moe/utils" + + "github.com/animenotifier/notify.moe/components" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" +) + +// Trailers Display the trailers of an anime. +func Trailers(ctx *aero.Context) string { + id := ctx.Get("id") + user := utils.GetUser(ctx) + anime, err := arn.GetAnime(id) + + if err != nil { + return ctx.Error(http.StatusNotFound, "Anime not found", err) + } + + return ctx.HTML(components.AnimeTrailers(anime, user)) +} diff --git a/pages/anime/trailers.pixy b/pages/anime/trailers.pixy new file mode 100644 index 000000000..a529d3a6e --- /dev/null +++ b/pages/anime/trailers.pixy @@ -0,0 +1,13 @@ +component AnimeTrailers(anime *arn.Anime, user *arn.User) + if anime.Trailers != nil && len(anime.Trailers) > 0 + .anime-section.mountable + h3.anime-section-name + a(href=anime.TrailersLink()) Trailers + + .trailers.anime-trailers + each trailer in anime.Trailers + if trailer.ServiceID != "" + .trailer.mountable(data-mountable-type="trailer") + .anime-trailer.video-container + //iframe.video(src="https://www.youtube.com/embed/" + trailer.ServiceID + "?showinfo=0", allowfullscreen) + ExternalMedia(trailer) \ No newline at end of file diff --git a/pages/anime/trailers.scarlet b/pages/anime/trailers.scarlet new file mode 100644 index 000000000..d6f06fd20 --- /dev/null +++ b/pages/anime/trailers.scarlet @@ -0,0 +1,27 @@ +.anime-trailers + vertical + .trailer + margin 1rem 0 + border-bottom-left-radius ui-element-border-radius !important + border-top-left-radius ui-element-border-radius !important + box-shadow shadow-light + min-height 200px + border-radius ui-element-border-radius + overflow hidden + + iframe + width 100% + +> +500px +.anime-trailers + horizontal-wrap + justify-content flex-start + +.trailer + max-width 200px + margin calc(content-padding / 2) + min-height 112px + height 112px + margin soundtrack-margin + margin-bottom media-bottom-margin \ No newline at end of file diff --git a/pages/index/animeroutes/animeroutes.go b/pages/index/animeroutes/animeroutes.go index 1136e5182..618440f25 100644 --- a/pages/index/animeroutes/animeroutes.go +++ b/pages/index/animeroutes/animeroutes.go @@ -15,6 +15,7 @@ func Register(l *layout.Layout) { l.Page("/anime/:id", anime.Get) l.Page("/anime/:id/episodes", anime.Episodes) l.Page("/anime/:id/characters", anime.Characters) + l.Page("/anime/:id/trailers", anime.Trailers) l.Page("/anime/:id/tracks", anime.Tracks) l.Page("/anime/:id/relations", anime.Relations) l.Page("/anime/:id/episode/:episode-number", episode.Get)