diff --git a/pages/calendar/calendar.go b/pages/calendar/calendar.go index 9f4b3242..2847cac6 100644 --- a/pages/calendar/calendar.go +++ b/pages/calendar/calendar.go @@ -55,7 +55,7 @@ func Get(ctx *aero.Context) string { } for _, episode := range animeEpisodes.Items { - if !validate.Date(episode.AiringDate.Start) { + if !validate.DateTime(episode.AiringDate.Start) { continue } diff --git a/pages/editor/editor.pixy b/pages/editor/editor.pixy index ce52d875..2c39204c 100644 --- a/pages/editor/editor.pixy +++ b/pages/editor/editor.pixy @@ -83,5 +83,5 @@ component EditorTabs(url string, user *arn.User) if strings.Contains(url, "/editor/anime/") || strings.Contains(url, "/editor/mal/diff/anime") .editor-filters #filter-root(data-url=url) - ExploreFilters(user.Settings().Editor.Filter.Year, user.Settings().Editor.Filter.Status, user.Settings().Editor.Filter.Type, true) + ExploreFilters(user.Settings().Editor.Filter.Year, user.Settings().Editor.Filter.Season, user.Settings().Editor.Filter.Status, user.Settings().Editor.Filter.Type, true) \ No newline at end of file diff --git a/pages/editor/filteranime/utils.go b/pages/editor/filteranime/utils.go index 5d51f43f..63a3e272 100644 --- a/pages/editor/filteranime/utils.go +++ b/pages/editor/filteranime/utils.go @@ -25,7 +25,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.Anime) bool, s // Determine URL url := strings.TrimPrefix(ctx.URI(), "/_") urlParts := strings.Split(url, "/") - urlParts = urlParts[:len(urlParts)-3] + urlParts = urlParts[:len(urlParts)-4] url = strings.Join(urlParts, "/") return ctx.HTML(components.AnimeEditorListFull( @@ -43,6 +43,7 @@ func editorList(ctx *aero.Context, title string, filter func(*arn.Anime) bool, s func filterAnime(ctx *aero.Context, user *arn.User, filter func(*arn.Anime) bool) ([]*arn.Anime, int) { year := ctx.Get("year") status := ctx.Get("status") + season := ctx.Get("season") typ := ctx.Get("type") if year == "any" { @@ -53,12 +54,17 @@ func filterAnime(ctx *aero.Context, user *arn.User, filter func(*arn.Anime) bool status = "" } + if season == "any" { + season = "" + } + if typ == "any" { typ = "" } settings := user.Settings() settings.Editor.Filter.Year = year + settings.Editor.Filter.Season = season settings.Editor.Filter.Status = status settings.Editor.Filter.Type = typ settings.Save() @@ -69,6 +75,10 @@ func filterAnime(ctx *aero.Context, user *arn.User, filter func(*arn.Anime) bool return false } + if season != "" && anime.Season() != season { + return false + } + if status != "" && anime.Status != status { return false } diff --git a/pages/editor/mal.go b/pages/editor/mal.go index d812fa24..a1605712 100644 --- a/pages/editor/mal.go +++ b/pages/editor/mal.go @@ -19,12 +19,17 @@ func CompareMAL(ctx *aero.Context) string { user := utils.GetUser(ctx) year := ctx.Get("year") status := ctx.Get("status") + season := ctx.Get("season") typ := ctx.Get("type") if year == "any" { year = "" } + if season == "any" { + season = "" + } + if status == "any" { status = "" } @@ -35,6 +40,7 @@ func CompareMAL(ctx *aero.Context) string { settings := user.Settings() settings.Editor.Filter.Year = year + settings.Editor.Filter.Season = season settings.Editor.Filter.Status = status settings.Editor.Filter.Type = typ settings.Save() @@ -48,6 +54,10 @@ func CompareMAL(ctx *aero.Context) string { return false } + if season != "" && anime.Season() != season { + return false + } + if typ != "" && anime.Type != typ { return false } diff --git a/pages/explore/explore.go b/pages/explore/explore.go index 9a847f9a..f8a943a8 100644 --- a/pages/explore/explore.go +++ b/pages/explore/explore.go @@ -10,46 +10,75 @@ import ( "github.com/animenotifier/notify.moe/utils" ) -// Get ... -func Get(ctx *aero.Context) string { - year := strconv.Itoa(time.Now().Year()) - status := "current" - typ := "tv" - results := filterAnime(year, status, typ) - user := utils.GetUser(ctx) - - return ctx.HTML(components.ExploreAnime(results, year, status, typ, user)) -} - // Filter ... func Filter(ctx *aero.Context) string { year := ctx.Get("year") + season := ctx.Get("season") status := ctx.Get("status") typ := ctx.Get("type") user := utils.GetUser(ctx) + now := time.Now() - results := filterAnime(year, status, typ) + if year == "" { + year = strconv.Itoa(now.Year()) + } - return ctx.HTML(components.ExploreAnime(results, year, status, typ, user)) + if season == "" { + season = arn.DateToSeason(now) + } + + if status == "" { + status = "current" + } + + if typ == "" { + typ = "tv" + } + + results := filterAnime(year, season, status, typ) + + if year == "any" { + year = "" + } + + if season == "any" { + season = "" + } + + if status == "any" { + status = "" + } + + if typ == "any" { + typ = "" + } + + return ctx.HTML(components.ExploreAnime(results, year, season, status, typ, user)) } -func filterAnime(year, status, typ string) []*arn.Anime { +func filterAnime(year, season, status, typ string) []*arn.Anime { var results []*arn.Anime for anime := range arn.StreamAnime() { - if len(anime.StartDate) < 4 { + if year != "any" { + if len(anime.StartDate) < 4 { + continue + } + + if anime.StartDate[:4] != year { + continue + } + } + + if status != "any" && anime.Status != status { continue } - if anime.StartDate[:4] != year { + if season != "any" && anime.Season() != season { continue } - if anime.Status != status { - continue - } - - if anime.Type != typ { + if (typ != "any" || anime.Type == "music" || anime.Type == "tba") && anime.Type != typ { continue } diff --git a/pages/explore/explore.pixy b/pages/explore/explore.pixy index 508062ed..1adf1353 100644 --- a/pages/explore/explore.pixy +++ b/pages/explore/explore.pixy @@ -1,6 +1,6 @@ -component ExploreAnime(animes []*arn.Anime, year string, status string, typ string, user *arn.User) +component ExploreAnime(animes []*arn.Anime, year string, season string, status string, typ string, user *arn.User) #filter-root(data-url="/explore/anime") - ExploreFilters(year, status, typ, false) + ExploreFilters(year, season, status, typ, false) .corner-buttons-hide-on-mobile if user != nil @@ -28,35 +28,50 @@ component ExploreAnime(animes []*arn.Anime, year string, status string, typ stri else AnimeGrid(animes, user) -component ExploreFilters(year string, status string, typ string, advancedFilters bool) +component ExploreFilters(year string, season string, status string, typ string, advancedFilters bool) .explore-filters - select#filter-year.action(value=year, data-action="filterAnime", data-trigger="change") - if advancedFilters - option(value="") + .filter-select-container + select#filter-year.filter-select.action(value=year, data-action="filterAnime", data-trigger="change") + if advancedFilters + option.option-any(value="") Any - for year := time.Now().Year()+1; year >= 1951; year-- - option(value=year)= year + for year := time.Now().Year()+1; year >= 1951; year-- + option(value=year)= year + + .filter-label Year - select#filter-status.action(value=status, data-action="filterAnime", data-trigger="change") - if advancedFilters - option(value="") + .filter-select-container + select#filter-season.filter-select.action(value=season, data-action="filterAnime", data-trigger="change") + option.option-any(value="") Any + option(value="winter") Winter + option(value="spring") Spring + option(value="summer") Summer + option(value="autumn") Autumn - option(value="current") Current - option(value="upcoming") Upcoming - option(value="finished") Finished + .filter-label Season - if advancedFilters - option(value="tba") TBA + .filter-select-container + select#filter-status.filter-select.action(value=status, data-action="filterAnime", data-trigger="change") + option.option-any(value="") Any + option(value="current") Current + option(value="upcoming") Upcoming + option(value="finished") Finished - select#filter-type.action(value=typ, data-action="filterAnime", data-trigger="change") - if advancedFilters - option(value="") - - option(value="tv") TV - option(value="movie") Movie - option(value="ova") OVA - option(value="ona") ONA - option(value="special") Special + if advancedFilters + option(value="tba") TBA + + .filter-label Status - if advancedFilters - option(value="music") Music \ No newline at end of file + .filter-select-container + select#filter-type.filter-select.action(value=typ, data-action="filterAnime", data-trigger="change") + option.option-any(value="") Any + option(value="tv") TV + option(value="movie") Movie + option(value="ova") OVA + option(value="ona") ONA + option(value="special") Special + + if advancedFilters + option(value="music") Music + + .filter-label Type \ No newline at end of file diff --git a/pages/explore/explore.scarlet b/pages/explore/explore.scarlet index bec9e47a..d50d37ee 100644 --- a/pages/explore/explore.scarlet +++ b/pages/explore/explore.scarlet @@ -3,17 +3,32 @@ justify-content center margin-bottom calc(content-padding / 2) - select - margin 0.05rem - .explore-anime margin-top calc(content-padding / 2) +.option-any + color reverse-light-hover-color + +.filter-select-container + vertical + justify-content center + +.filter-select + margin 0.05rem + +.filter-label + opacity 0.5 + font-size 0.7rem + text-align center + #filter-year width 80px +#filter-season + width 90px + #filter-status - width 120px + width 110px #filter-type width 80px \ No newline at end of file diff --git a/pages/explore/halloffame/halloffame.pixy b/pages/explore/halloffame/halloffame.pixy index c9326fdc..842b130e 100644 --- a/pages/explore/halloffame/halloffame.pixy +++ b/pages/explore/halloffame/halloffame.pixy @@ -7,7 +7,7 @@ component HallOfFame(entries []*utils.HallOfFameEntry, user *arn.User) .hall-of-fame-entry .hall-of-fame-anime AnimeImageLink(entry.Anime, "large", user) - a.hall-of-fame-footer(href="/explore/anime/" + strconv.Itoa(entry.Year) + "/finished/tv", title="Best TV series " + strconv.Itoa(entry.Year)) + a.hall-of-fame-footer(href="/explore/anime/" + strconv.Itoa(entry.Year) + "/any/finished/tv", title="Best TV series " + strconv.Itoa(entry.Year)) .hall-of-fame-trophy Icon("trophy") .hall-of-fame-year= entry.Year \ No newline at end of file diff --git a/pages/index.go b/pages/index.go index f491f260..4eb308d5 100644 --- a/pages/index.go +++ b/pages/index.go @@ -80,8 +80,8 @@ func Configure(app *aero.Application) { // Main menu l.Page("/", home.Get) - l.Page("/explore", explore.Get) - l.Page("/explore/anime/:year/:status/:type", explore.Filter) + l.Page("/explore", explore.Filter) + l.Page("/explore/anime/:year/:season/:status/:type", explore.Filter) l.Page("/explore/color/:color/anime", explorecolor.AnimeByAverageColor) l.Page("/explore/color/:color/anime/from/:index", explorecolor.AnimeByAverageColor) l.Page("/explore/sequels", explorerelations.Sequels) @@ -267,7 +267,7 @@ func Configure(app *aero.Application) { // Editor links can be filtered by year, status and type editorFilterable := func(route string, handler func(ctx *aero.Context) string) { - l.Page(route+"/:year/:status/:type", handler) + l.Page(route+"/:year/:season/:status/:type", handler) } // Editor - Anime diff --git a/scripts/Actions/Explore.ts b/scripts/Actions/Explore.ts index ddb32242..271901a5 100644 --- a/scripts/Actions/Explore.ts +++ b/scripts/Actions/Explore.ts @@ -6,6 +6,7 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { let root = document.getElementById("filter-root") let elementYear = document.getElementById("filter-year") as HTMLSelectElement + let elementSeason = document.getElementById("filter-season") as HTMLSelectElement let elementStatus = document.getElementById("filter-status") as HTMLSelectElement let elementType = document.getElementById("filter-type") as HTMLSelectElement @@ -17,10 +18,11 @@ export function filterAnime(arn: AnimeNotifier, input: HTMLInputElement) { } let year = elementYear.value || "any" + let season = elementSeason.value || "any" let status = elementStatus.value || "any" let type = elementType.value || "any" - arn.diff(`${root.dataset.url}/${year}/${status}/${type}`) + arn.diff(`${root.dataset.url}/${year}/${season}/${status}/${type}`) } // Hides anime that are already in your list.