Implemented new frontpage

This commit is contained in:
2017-09-22 17:23:22 +02:00
parent 9c900ec01b
commit 4ce0bed52c
7 changed files with 70 additions and 30 deletions

View File

@ -95,4 +95,4 @@
display none !important
.fill-screen
min-height calc(100vh - nav-height - content-padding * 2 - 1rem - 43px - 23px)
min-height calc(100vh - content-padding * 2 - 1rem - 43px - 23px)

39
pages/home/animelist.go Normal file
View File

@ -0,0 +1,39 @@
package home
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/pages/frontpage"
"github.com/animenotifier/notify.moe/utils"
)
// FilterByStatus returns a handler for the given anime list item status.
func FilterByStatus(status string) aero.Handle {
return func(ctx *aero.Context) string {
user := utils.GetUser(ctx)
if user == nil {
return frontpage.Get(ctx)
}
return AnimeList(ctx, user, status)
}
}
// AnimeList sends the anime list with the given status for given user.
func AnimeList(ctx *aero.Context, user *arn.User, status string) string {
viewUser := user
animeList := viewUser.AnimeList()
if animeList == nil {
return ctx.Error(http.StatusNotFound, "Anime list not found", nil)
}
animeList.PrefetchAnime()
animeList.Sort()
return ctx.HTML(components.Home(animeList.FilterStatus(status), viewUser, user, status))
}

View File

@ -1,10 +1,9 @@
package home
import (
"net/http"
"github.com/animenotifier/arn"
"github.com/aerogo/aero"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/pages/frontpage"
"github.com/animenotifier/notify.moe/utils"
)
@ -17,15 +16,5 @@ func Get(ctx *aero.Context) string {
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()
return ctx.HTML(components.Home(animeList.Watching(), animeList.User(), user, "watching"))
return AnimeList(ctx, user, arn.AnimeListStatusWatching)
}