Started working on status filter
This commit is contained in:
parent
3df506b274
commit
44803adc2d
7
main.go
7
main.go
@ -76,7 +76,12 @@ func configure(app *aero.Application) *aero.Application {
|
||||
app.Ajax("/user/:nick/posts", profile.GetPostsByUser)
|
||||
app.Ajax("/user/:nick/tracks", profile.GetSoundTracksByUser)
|
||||
app.Ajax("/user/:nick/animelist", animelist.Get)
|
||||
app.Ajax("/user/:nick/animelist/:id", animelistitem.Get)
|
||||
app.Ajax("/user/:nick/animelist/watching", animelist.FilterByStatus(arn.AnimeListStatusWatching))
|
||||
app.Ajax("/user/:nick/animelist/completed", animelist.FilterByStatus(arn.AnimeListStatusCompleted))
|
||||
app.Ajax("/user/:nick/animelist/planned", animelist.FilterByStatus(arn.AnimeListStatusPlanned))
|
||||
app.Ajax("/user/:nick/animelist/hold", animelist.FilterByStatus(arn.AnimeListStatusHold))
|
||||
app.Ajax("/user/:nick/animelist/dropped", animelist.FilterByStatus(arn.AnimeListStatusDropped))
|
||||
app.Ajax("/user/:nick/animelist/anime/:id", animelistitem.Get)
|
||||
app.Ajax("/new/thread", newthread.Get)
|
||||
app.Ajax("/new/soundtrack", newsoundtrack.Get)
|
||||
app.Ajax("/settings", settings.Get)
|
||||
|
@ -27,7 +27,7 @@ component Anime(anime *arn.Anime, tracks []*arn.SoundTrack, user *arn.User, epis
|
||||
span Edit anime
|
||||
|
||||
if user.AnimeList().Contains(anime.ID)
|
||||
a.button.ajax(href="/+" + user.Nick + "/animelist/" + anime.ID)
|
||||
a.button.ajax(href="/+" + user.Nick + "/animelist/anime/" + anime.ID)
|
||||
Icon("pencil")
|
||||
span Edit in collection
|
||||
else
|
||||
|
46
pages/animelist/status.go
Normal file
46
pages/animelist/status.go
Normal file
@ -0,0 +1,46 @@
|
||||
package animelist
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// FilterByStatus returns a handler for the given anime list item status.
|
||||
func FilterByStatus(status string) aero.Handle {
|
||||
return func(ctx *aero.Context) string {
|
||||
user := utils.GetUser(ctx)
|
||||
list, response := statusList(ctx, status)
|
||||
|
||||
if response != "" {
|
||||
return response
|
||||
}
|
||||
|
||||
return ctx.HTML(components.AnimeListFilteredByStatus(list, list.User(), user))
|
||||
}
|
||||
}
|
||||
|
||||
// statusList handles the request for an anime list with a given status.
|
||||
func statusList(ctx *aero.Context, status string) (*arn.AnimeList, string) {
|
||||
nick := ctx.Get("nick")
|
||||
viewUser, err := arn.GetUserByNick(nick)
|
||||
|
||||
if err != nil {
|
||||
return nil, ctx.Error(http.StatusNotFound, "User not found", err)
|
||||
}
|
||||
|
||||
animeList := viewUser.AnimeList()
|
||||
|
||||
if animeList == nil {
|
||||
return nil, ctx.Error(http.StatusNotFound, "Anime list not found", nil)
|
||||
}
|
||||
|
||||
watchingList := animeList.FilterStatus(status)
|
||||
watchingList.PrefetchAnime()
|
||||
watchingList.Sort()
|
||||
|
||||
return watchingList, ""
|
||||
}
|
8
pages/animelist/watching.pixy
Normal file
8
pages/animelist/watching.pixy
Normal file
@ -0,0 +1,8 @@
|
||||
component AnimeListFilteredByStatus(animeList *arn.AnimeList, viewUser *arn.User, user *arn.User)
|
||||
ProfileHeader(viewUser, user)
|
||||
|
||||
if len(animeList.Items) == 0
|
||||
p.no-data.mountable= viewUser.Nick + " hasn't added any anime to this list yet."
|
||||
else
|
||||
.anime-list-container
|
||||
AnimeList(animeList, viewUser, user)
|
@ -68,6 +68,30 @@ component ProfileNavigation(viewUser *arn.User)
|
||||
Icon("music")
|
||||
span.tab-text Tracks
|
||||
|
||||
StatusTabs("/+" + viewUser.Nick + "/animelist")
|
||||
|
||||
component StatusTabs(urlPrefix string)
|
||||
.buttons.tabs
|
||||
a.button.tab.action(href=urlPrefix + "/watching", data-action="diff", data-trigger="click")
|
||||
Icon("play")
|
||||
span.tab-text Watching
|
||||
|
||||
a.button.tab.action(href=urlPrefix + "/completed", data-action="diff", data-trigger="click")
|
||||
Icon("check")
|
||||
span.tab-text Completed
|
||||
|
||||
a.button.tab.action(href=urlPrefix + "/planned", data-action="diff", data-trigger="click")
|
||||
Icon("forward")
|
||||
span.tab-text Planned
|
||||
|
||||
a.button.tab.action(href=urlPrefix + "/hold", data-action="diff", data-trigger="click")
|
||||
Icon("pause")
|
||||
span.tab-text On Hold
|
||||
|
||||
a.button.tab.action(href=urlPrefix + "/dropped", data-action="diff", data-trigger="click")
|
||||
Icon("stop")
|
||||
span.tab-text Dropped
|
||||
|
||||
component Profile(viewUser *arn.User, user *arn.User, animeList *arn.AnimeList, threads []*arn.Thread, posts []*arn.Post, tracks []*arn.SoundTrack)
|
||||
ProfileHeader(viewUser, user)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user