32 lines
695 B
Go
Raw Normal View History

2017-06-19 20:16:01 +00:00
package animelist
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
2017-06-25 12:58:27 +00:00
"github.com/animenotifier/notify.moe/utils"
2017-06-19 20:16:01 +00:00
)
// Get anime list.
func Get(ctx *aero.Context) string {
nick := ctx.Get("nick")
2017-06-25 12:58:27 +00:00
user := utils.GetUser(ctx)
2017-06-19 20:16:01 +00:00
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
}
2017-06-29 06:32:46 +00:00
animeList.Sort()
2017-06-19 20:16:01 +00:00
2017-07-22 13:04:54 +00:00
return ctx.HTML(components.ProfileAnimeLists(animeList.SplitByStatus(), animeList.User(), user, ctx.URI()))
2017-06-19 20:16:01 +00:00
}