32 lines
677 B
Go
Raw Normal View History

2017-07-22 13:04:54 +00:00
package home
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/pages/frontpage"
"github.com/animenotifier/notify.moe/utils"
)
2017-07-22 14:31:25 +00:00
// Get the anime list or the frontpage when logged out.
2017-07-22 13:04:54 +00:00
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil {
return frontpage.Get(ctx)
}
viewUser := user
animeList := viewUser.AnimeList()
if animeList == nil {
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
}
animeList.PrefetchAnime()
animeList.Sort()
2017-07-22 14:31:25 +00:00
return ctx.HTML(components.Home(animeList.Watching(), animeList.User(), user, "watching"))
2017-07-22 13:04:54 +00:00
}