Added anime tabs
This commit is contained in:
parent
d50ba892e6
commit
02e89cd5e2
3
main.go
3
main.go
@ -77,6 +77,9 @@ func configure(app *aero.Application) *aero.Application {
|
|||||||
app.Ajax("/", home.Get)
|
app.Ajax("/", home.Get)
|
||||||
app.Ajax("/dashboard", dashboard.Get)
|
app.Ajax("/dashboard", dashboard.Get)
|
||||||
app.Ajax("/anime/:id", anime.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("/anime/:id/edit", editanime.Get)
|
||||||
app.Ajax("/api", apiview.Get)
|
app.Ajax("/api", apiview.Get)
|
||||||
app.Ajax("/best/anime", best.Get)
|
app.Ajax("/best/anime", best.Get)
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"github.com/animenotifier/notify.moe/utils"
|
"github.com/animenotifier/notify.moe/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
const maxEpisodes = 26
|
// const maxEpisodes = 26
|
||||||
const maxEpisodesLongSeries = 5
|
// const maxEpisodesLongSeries = 5
|
||||||
const maxDescriptionLength = 170
|
const maxDescriptionLength = 170
|
||||||
|
|
||||||
// Get anime page.
|
// Get anime page.
|
||||||
@ -24,24 +24,16 @@ func Get(ctx *aero.Context) string {
|
|||||||
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
return ctx.Error(http.StatusNotFound, "Anime not found", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
tracks, err := arn.FilterSoundTracks(func(track *arn.SoundTrack) bool {
|
// episodesReversed := false
|
||||||
return !track.IsDraft && len(track.Media) > 0 && arn.Contains(track.Tags, "anime:"+anime.ID)
|
|
||||||
})
|
|
||||||
|
|
||||||
if err != nil {
|
// if len(anime.Episodes().Items) > maxEpisodes {
|
||||||
return ctx.Error(http.StatusNotFound, "Error fetching soundtracks", err)
|
// episodesReversed = true
|
||||||
}
|
// anime.Episodes().Items = anime.Episodes().Items[len(anime.Episodes().Items)-maxEpisodesLongSeries:]
|
||||||
|
|
||||||
episodesReversed := false
|
// 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]
|
||||||
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]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Friends watching
|
// Friends watching
|
||||||
var friends []*arn.User
|
var friends []*arn.User
|
||||||
@ -108,5 +100,5 @@ func Get(ctx *aero.Context) string {
|
|||||||
|
|
||||||
ctx.Data = openGraph
|
ctx.Data = openGraph
|
||||||
|
|
||||||
return ctx.HTML(components.Anime(anime, friends, friendsAnimeListItems, tracks, user, episodesReversed))
|
return ctx.HTML(components.Anime(anime, friends, friendsAnimeListItems, user))
|
||||||
}
|
}
|
||||||
|
@ -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)
|
.anime-header(data-id=anime.ID)
|
||||||
if anime.Image.Small != ""
|
if anime.Image.Small != ""
|
||||||
.anime-image-container
|
.anime-image-container
|
||||||
@ -192,46 +194,6 @@ component Anime(anime *arn.Anime, friends []*arn.User, listItems map[*arn.User]*
|
|||||||
.anime-rating-category-name Dropped
|
.anime-rating-category-name Dropped
|
||||||
.anime-rating= anime.Popularity.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
|
//- h3.anime-section-name Reviews
|
||||||
//- p Coming soon.
|
//- p Coming soon.
|
||||||
|
|
||||||
|
6
pages/anime/animetabs.pixy
Normal file
6
pages/anime/animetabs.pixy
Normal file
@ -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")
|
22
pages/anime/characters.go
Normal file
22
pages/anime/characters.go
Normal file
@ -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))
|
||||||
|
}
|
8
pages/anime/characters.pixy
Normal file
8
pages/anime/characters.pixy
Normal file
@ -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())
|
23
pages/anime/episodes.go
Normal file
23
pages/anime/episodes.go
Normal file
@ -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))
|
||||||
|
}
|
27
pages/anime/episodes.pixy
Normal file
27
pages/anime/episodes.pixy
Normal file
@ -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
|
31
pages/anime/tracks.go
Normal file
31
pages/anime/tracks.go
Normal file
@ -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))
|
||||||
|
}
|
7
pages/anime/tracks.pixy
Normal file
7
pages/anime/tracks.pixy
Normal file
@ -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)
|
Loading…
Reference in New Issue
Block a user