Added season filters
This commit is contained in:
parent
1cedabb47b
commit
cff76bc696
@ -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
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
@ -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
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user