From 586668381132653d102806813a04a5b824651148 Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Thu, 1 Nov 2018 14:45:16 +0900 Subject: [PATCH] Added anime comments --- pages/anime/anime.pixy | 1 + pages/anime/comments.go | 24 ++++++++++++++++++++++++ pages/anime/comments.pixy | 12 ++++++++++++ pages/anime/comments.scarlet | 7 +++++++ pages/anime/episodes.go | 1 - pages/index/animeroutes/animeroutes.go | 1 + utils/routetests/All.go | 2 +- 7 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 pages/anime/comments.go create mode 100644 pages/anime/comments.pixy create mode 100644 pages/anime/comments.scarlet diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index 97d5f942..f55803a8 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -30,6 +30,7 @@ component AnimeMainColumn(anime *arn.Anime, listItem *arn.AnimeListItem, tracks AnimeTracks(anime, tracks, user, false) AnimeAMVs(anime, amvs, amvAppearances, user) AnimeEpisodes(anime, episodes, user, false) + AnimeComments(anime, user, false) component AnimeSideColumn(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) AnimeTrailer(anime) diff --git a/pages/anime/comments.go b/pages/anime/comments.go new file mode 100644 index 00000000..d9006f66 --- /dev/null +++ b/pages/anime/comments.go @@ -0,0 +1,24 @@ +package anime + +import ( + "net/http" + + "github.com/animenotifier/notify.moe/components" + "github.com/animenotifier/notify.moe/utils" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" +) + +// Comments ... +func Comments(ctx *aero.Context) string { + user := utils.GetUser(ctx) + id := ctx.Get("id") + anime, err := arn.GetAnime(id) + + if err != nil { + return ctx.Error(http.StatusNotFound, "Anime not found", err) + } + + return ctx.HTML(components.AnimeComments(anime, user, true)) +} diff --git a/pages/anime/comments.pixy b/pages/anime/comments.pixy new file mode 100644 index 00000000..6f16549f --- /dev/null +++ b/pages/anime/comments.pixy @@ -0,0 +1,12 @@ +component AnimeComments(anime *arn.Anime, user *arn.User, standAlonePage bool) + if standAlonePage + h1.mountable + a(href=anime.Link())= anime.Title.ByUser(user) + + section.anime-section.mountable + if !standAlonePage + h3.anime-section-name + a(href=anime.Link() + "/comments") Comments + + .anime-comments(data-standalone-page=standAlonePage) + Comments(anime, user) \ No newline at end of file diff --git a/pages/anime/comments.scarlet b/pages/anime/comments.scarlet new file mode 100644 index 00000000..7a31f440 --- /dev/null +++ b/pages/anime/comments.scarlet @@ -0,0 +1,7 @@ +.anime-comments + [data-standalone-page="false"] + margin-top 1rem + + .thread + max-width 600px + justify-content flex-start \ No newline at end of file diff --git a/pages/anime/episodes.go b/pages/anime/episodes.go index cdbd5b81..15c8da43 100644 --- a/pages/anime/episodes.go +++ b/pages/anime/episodes.go @@ -14,7 +14,6 @@ import ( func Episodes(ctx *aero.Context) string { user := utils.GetUser(ctx) id := ctx.Get("id") - anime, err := arn.GetAnime(id) if err != nil { diff --git a/pages/index/animeroutes/animeroutes.go b/pages/index/animeroutes/animeroutes.go index 1136e518..42fb8447 100644 --- a/pages/index/animeroutes/animeroutes.go +++ b/pages/index/animeroutes/animeroutes.go @@ -17,6 +17,7 @@ func Register(l *layout.Layout) { l.Page("/anime/:id/characters", anime.Characters) l.Page("/anime/:id/tracks", anime.Tracks) l.Page("/anime/:id/relations", anime.Relations) + l.Page("/anime/:id/comments", anime.Comments) l.Page("/anime/:id/episode/:episode-number", episode.Get) // Anime redirects diff --git a/utils/routetests/All.go b/utils/routetests/All.go index ae7b3d67..73fd9e1c 100644 --- a/utils/routetests/All.go +++ b/utils/routetests/All.go @@ -465,7 +465,7 @@ var routeTests = map[string][]string{ "/settings/apps": nil, "/settings/avatar": nil, "/settings/formatting": nil, - "/settings/pro": nil, + "/settings/extras": nil, "/shop": nil, "/shop/history": nil, "/support": nil,