diff --git a/main.go b/main.go index b1f9b3bb..5d5d9f89 100644 --- a/main.go +++ b/main.go @@ -77,6 +77,9 @@ func configure(app *aero.Application) *aero.Application { app.Ajax("/", home.Get) app.Ajax("/dashboard", dashboard.Get) app.Ajax("/anime/:id", anime.Get) + app.Ajax("/anime/:id/episodes", anime.Episodes) + app.Ajax("/anime/:id/characters", anime.Characters) + app.Ajax("/anime/:id/tracks", anime.Tracks) app.Ajax("/anime/:id/edit", editanime.Get) app.Ajax("/api", apiview.Get) app.Ajax("/best/anime", best.Get) diff --git a/pages/anime/anime.go b/pages/anime/anime.go index 308a09c0..0277f053 100644 --- a/pages/anime/anime.go +++ b/pages/anime/anime.go @@ -10,8 +10,8 @@ import ( "github.com/animenotifier/notify.moe/utils" ) -const maxEpisodes = 26 -const maxEpisodesLongSeries = 5 +// const maxEpisodes = 26 +// const maxEpisodesLongSeries = 5 const maxDescriptionLength = 170 // Get anime page. @@ -24,24 +24,16 @@ func Get(ctx *aero.Context) string { return ctx.Error(http.StatusNotFound, "Anime not found", err) } - tracks, err := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool { - return !track.IsDraft && len(track.Media) > 0 && arn.Contains(track.Tags, "anime:"+anime.ID) - }) + // episodesReversed := false - if err != nil { - return ctx.Error(http.StatusNotFound, "Error fetching soundtracks", err) - } + // if len(anime.Episodes().Items) > maxEpisodes { + // episodesReversed = true + // anime.Episodes().Items = anime.Episodes().Items[len(anime.Episodes().Items)-maxEpisodesLongSeries:] - episodesReversed := false - - if len(anime.Episodes().Items) > maxEpisodes { - episodesReversed = true - anime.Episodes().Items = anime.Episodes().Items[len(anime.Episodes().Items)-maxEpisodesLongSeries:] - - for i, j := 0, len(anime.Episodes().Items)-1; i < j; i, j = i+1, j-1 { - anime.Episodes().Items[i], anime.Episodes().Items[j] = anime.Episodes().Items[j], anime.Episodes().Items[i] - } - } + // for i, j := 0, len(anime.Episodes().Items)-1; i < j; i, j = i+1, j-1 { + // anime.Episodes().Items[i], anime.Episodes().Items[j] = anime.Episodes().Items[j], anime.Episodes().Items[i] + // } + // } // Friends watching var friends []*arn.User @@ -108,5 +100,5 @@ func Get(ctx *aero.Context) string { ctx.Data = openGraph - return ctx.HTML(components.Anime(anime, friends, friendsAnimeListItems, tracks, user, episodesReversed)) + return ctx.HTML(components.Anime(anime, friends, friendsAnimeListItems, user)) } diff --git a/pages/anime/anime.pixy b/pages/anime/anime.pixy index ec72f8c6..8a4469e7 100644 --- a/pages/anime/anime.pixy +++ b/pages/anime/anime.pixy @@ -1,4 +1,6 @@ -component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, tracks []*arn.SoundTrack, user *arn.User, episodesReversed bool) +component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*arn.AnimeListItem, user *arn.User) + AnimeTabs(anime) + .anime-header(data-id=anime.ID) if anime.Image.Small != "" .anime-image-container @@ -191,47 +193,7 @@ component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]* .anime-rating-category .anime-rating-category-name Dropped .anime-rating= anime.Popularity.Dropped - - if len(tracks) > 0 - h3.anime-section-name Tracks - .sound-tracks - each track in tracks - SoundTrack(track) - - if anime.Characters() != nil && len(anime.Characters().Items) > 0 - h3.anime-section-name Characters - .characters - each character in anime.Characters().Items - if character.Character() != nil - Character(character.Character()) - - if len(anime.Episodes().Items) > 0 - if episodesReversed - h3.anime-section-name Latest episodes - else - h3.anime-section-name Episodes - table.episodes - tbody - each episode in anime.Episodes().Items - tr.episode - td.episode-number - if episode.Number != -1 - span= episode.Number - td.episode-title - if episode.Title.Japanese != "" - 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 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 - td.episode-airing-date-start + //- h3.anime-section-name Reviews //- p Coming soon. diff --git a/pages/anime/animetabs.pixy b/pages/anime/animetabs.pixy new file mode 100644 index 00000000..8fa01e18 --- /dev/null +++ b/pages/anime/animetabs.pixy @@ -0,0 +1,6 @@ +component AnimeTabs(anime *arn.Anime) + .tabs + Tab("Anime", "tv", anime.Link()) + Tab("Episodes", "list-ol", anime.Link() + "/episodes") + Tab("Characters", "male", anime.Link() + "/characters") + Tab("Tracks", "music", anime.Link() + "/tracks") \ No newline at end of file diff --git a/pages/anime/characters.go b/pages/anime/characters.go new file mode 100644 index 00000000..e03b8462 --- /dev/null +++ b/pages/anime/characters.go @@ -0,0 +1,22 @@ +package anime + +import ( + "net/http" + + "github.com/animenotifier/notify.moe/components" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" +) + +// Characters ... +func Characters(ctx *aero.Context) string { + 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.AnimeCharacters(anime)) +} diff --git a/pages/anime/characters.pixy b/pages/anime/characters.pixy new file mode 100644 index 00000000..0dcfc24c --- /dev/null +++ b/pages/anime/characters.pixy @@ -0,0 +1,8 @@ +component AnimeCharacters(anime *arn.Anime) + AnimeTabs(anime) + + h3.anime-section-name Characters + .characters + each character in anime.Characters().Items + if character.Character() != nil + Character(character.Character()) \ No newline at end of file diff --git a/pages/anime/episodes.go b/pages/anime/episodes.go new file mode 100644 index 00000000..fe2b097d --- /dev/null +++ b/pages/anime/episodes.go @@ -0,0 +1,23 @@ +package anime + +import ( + "net/http" + + "github.com/animenotifier/notify.moe/components" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" +) + +// Episodes ... +func Episodes(ctx *aero.Context) string { + 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.AnimeEpisodes(anime)) +} diff --git a/pages/anime/episodes.pixy b/pages/anime/episodes.pixy new file mode 100644 index 00000000..9adafd61 --- /dev/null +++ b/pages/anime/episodes.pixy @@ -0,0 +1,27 @@ +component AnimeEpisodes(anime *arn.Anime) + AnimeTabs(anime) + + h3.anime-section-name Episodes + + table.episodes + tbody + each episode in anime.Episodes().Items + tr.episode + td.episode-number + if episode.Number != -1 + span= episode.Number + td.episode-title + if episode.Title.Japanese != "" + 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 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 + td.episode-airing-date-start \ No newline at end of file diff --git a/pages/anime/tracks.go b/pages/anime/tracks.go new file mode 100644 index 00000000..c82a1f95 --- /dev/null +++ b/pages/anime/tracks.go @@ -0,0 +1,31 @@ +package anime + +import ( + "net/http" + + "github.com/animenotifier/notify.moe/components" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" +) + +// Tracks ... +func Tracks(ctx *aero.Context) string { + id := ctx.Get("id") + + anime, err := arn.GetAnime(id) + + if err != nil { + return ctx.Error(http.StatusNotFound, "Anime not found", err) + } + + tracks, err := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool { + return !track.IsDraft && len(track.Media) > 0 && arn.Contains(track.Tags, "anime:"+anime.ID) + }) + + if err != nil { + return ctx.Error(http.StatusNotFound, "Error fetching soundtracks", err) + } + + return ctx.HTML(components.AnimeTracks(anime, tracks)) +} diff --git a/pages/anime/tracks.pixy b/pages/anime/tracks.pixy new file mode 100644 index 00000000..f1a7bea2 --- /dev/null +++ b/pages/anime/tracks.pixy @@ -0,0 +1,7 @@ +component AnimeTracks(anime *arn.Anime, tracks []*arn.SoundTrack) + AnimeTabs(anime) + + h3.anime-section-name Tracks + .sound-tracks + each track in tracks + SoundTrack(track) \ No newline at end of file