Simplify anime list routing

This commit is contained in:
Eduard Urbach 2019-08-28 11:50:26 +09:00
parent fb41b7947d
commit 5551dd176e
Signed by: akyoto
GPG Key ID: C874F672B1AF20C0
2 changed files with 7 additions and 18 deletions

View File

@ -18,12 +18,11 @@ const (
animePerScroll = 40 animePerScroll = 40
) )
// FilterByStatus returns a handler for the given anime list item status. // Filter filters a user's anime list item by the status.
func FilterByStatus(status string) aero.Handler { func Filter(ctx aero.Context) error {
return func(ctx aero.Context) error { user := utils.GetUser(ctx)
user := utils.GetUser(ctx) status := ctx.Get("status")
return AnimeList(ctx, user, status) return AnimeList(ctx, user, status)
}
} }
// AnimeList renders the anime list items. // AnimeList renders the anime list items.

View File

@ -2,7 +2,6 @@ package userroutes
import ( import (
"github.com/aerogo/aero" "github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/arn"
"github.com/animenotifier/notify.moe/pages/animelist" "github.com/animenotifier/notify.moe/pages/animelist"
"github.com/animenotifier/notify.moe/pages/animelistitem" "github.com/animenotifier/notify.moe/pages/animelistitem"
"github.com/animenotifier/notify.moe/pages/compare" "github.com/animenotifier/notify.moe/pages/compare"
@ -40,17 +39,8 @@ func Register(app *aero.Application) {
page.Get(app, "/user/:nick/edit", user.Edit) page.Get(app, "/user/:nick/edit", user.Edit)
// Anime list // Anime list
page.Get(app, "/user/:nick/animelist/watching", animelist.FilterByStatus(arn.AnimeListStatusWatching)) page.Get(app, "/user/:nick/animelist/:status", animelist.Filter)
page.Get(app, "/user/:nick/animelist/completed", animelist.FilterByStatus(arn.AnimeListStatusCompleted)) page.Get(app, "/user/:nick/animelist/:status/from/:index", animelist.Filter)
page.Get(app, "/user/:nick/animelist/planned", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
page.Get(app, "/user/:nick/animelist/hold", animelist.FilterByStatus(arn.AnimeListStatusHold))
page.Get(app, "/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
page.Get(app, "/user/:nick/animelist/watching/from/:index", animelist.FilterByStatus(arn.AnimeListStatusWatching))
page.Get(app, "/user/:nick/animelist/completed/from/:index", animelist.FilterByStatus(arn.AnimeListStatusCompleted))
page.Get(app, "/user/:nick/animelist/planned/from/:index", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
page.Get(app, "/user/:nick/animelist/hold/from/:index", animelist.FilterByStatus(arn.AnimeListStatusHold))
page.Get(app, "/user/:nick/animelist/dropped/from/:index", animelist.FilterByStatus(arn.AnimeListStatusDropped))
// Redirects // Redirects
page.Get(app, "/animelist/watching", animelist.Redirect) page.Get(app, "/animelist/watching", animelist.Redirect)