31 lines
689 B
Go
Raw Normal View History

2017-06-24 19:07:45 +00:00
package embed
import (
"net/http"
"github.com/aerogo/aero"
2017-06-29 21:27:21 +00:00
"github.com/animenotifier/arn"
2017-06-24 19:07:45 +00:00
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
// Get anime list in the browser extension.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil {
2017-06-25 16:10:42 +00:00
return utils.AllowEmbed(ctx, ctx.HTML(components.Login()))
2017-06-24 19:07:45 +00:00
}
animeList := user.AnimeList()
if animeList == nil {
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
}
2017-06-29 06:32:46 +00:00
animeList.Sort()
2017-06-29 21:27:21 +00:00
watchingList := animeList.SplitByStatus()[arn.AnimeListStatusWatching]
2017-06-24 19:07:45 +00:00
2017-06-29 21:27:21 +00:00
return utils.AllowEmbed(ctx, ctx.HTML(components.AnimeList(watchingList, user)))
2017-06-24 19:07:45 +00:00
}