Added season filters
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
.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
|
@ -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
|
@ -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
|
Reference in New Issue
Block a user