33 lines
685 B
Go
Raw Normal View History

2017-06-19 20:16:01 +00:00
package animelist
import (
"net/http"
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
// Get anime list.
func Get(ctx *aero.Context) string {
nick := ctx.Get("nick")
viewUser, err := arn.GetUserByNick(nick)
if err != nil {
return ctx.Error(http.StatusNotFound, "User not found", err)
}
animeList := viewUser.AnimeList()
if animeList == nil {
2017-06-24 19:07:45 +00:00
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
2017-06-19 20:16:01 +00:00
}
sort.Slice(animeList.Items, func(i, j int) bool {
return animeList.Items[i].FinalRating() < animeList.Items[j].FinalRating()
})
return ctx.HTML(components.AnimeList(animeList))
}