34 lines
722 B
Go
Raw Normal View History

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