34 lines
722 B
Go
Raw Normal View History

2017-06-24 19:07:45 +00:00
package embed
import (
"net/http"
"github.com/aerogo/aero"
2019-11-17 07:59:34 +00:00
"github.com/animenotifier/notify.moe/arn"
2017-06-24 19:07:45 +00:00
"github.com/animenotifier/notify.moe/components"
)
// Get anime list in the browser extension.
2019-06-01 04:55:49 +00:00
func Get(ctx aero.Context) error {
2019-11-17 07:59:34 +00:00
user := arn.GetUserFromContext(ctx)
2017-06-24 19:07:45 +00:00
if user == nil {
2019-06-01 04:55:49 +00:00
return ctx.HTML(components.Login("_blank"))
2017-06-24 19:07:45 +00:00
}
2018-11-15 03:42:10 +00:00
if !user.HasBasicInfo() {
2019-06-01 04:55:49 +00:00
return ctx.HTML(components.ExtensionEnterBasicInfo())
2018-11-15 03:42:10 +00:00
}
2017-06-24 19:07:45 +00:00
animeList := user.AnimeList()
if animeList == nil {
2018-07-07 03:42:00 +00:00
return ctx.Error(http.StatusNotFound, "Anime list not found")
2017-06-24 19:07:45 +00:00
}
2017-07-05 13:50:29 +00:00
watchingList := animeList.Watching()
2019-08-29 03:23:58 +00:00
watchingList.Sort(user.Settings().SortBy)
2017-06-24 19:07:45 +00:00
2019-06-01 04:55:49 +00:00
return ctx.HTML(components.BrowserExtension(watchingList, animeList.User(), user))
2017-06-24 19:07:45 +00:00
}