36 lines
880 B
Go
Raw Normal View History

2017-06-24 21:07:45 +02:00
package embed
import (
"net/http"
"github.com/aerogo/aero"
"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 {
return utils.AllowEmbed(ctx, ctx.HTML(components.Login("_blank")))
2017-06-24 21:07:45 +02:00
}
2017-11-27 16:18:29 +01:00
// Extension is enabled as long as the site isn't finished yet.
// ---
// if !user.IsPro() && user.TimeSinceRegistered() > 14*24*time.Hour {
// return utils.AllowEmbed(ctx, ctx.HTML(components.EmbedProNotice(user)))
// }
2017-10-09 08:18:28 +02:00
2017-06-24 21:07:45 +02:00
animeList := user.AnimeList()
if animeList == nil {
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
}
2017-07-05 15:50:29 +02:00
watchingList := animeList.Watching()
2017-07-01 13:45:23 +02:00
watchingList.Sort()
2017-06-24 21:07:45 +02:00
2017-06-30 23:52:42 +02:00
return utils.AllowEmbed(ctx, ctx.HTML(components.AnimeList(watchingList, animeList.User(), user)))
2017-06-24 21:07:45 +02:00
}