New dashboard idea (still not happy though)

This commit is contained in:
2016-11-22 12:34:59 +09:00
parent 4159525c25
commit 80506aa92e
18 changed files with 192 additions and 79 deletions

View File

@ -1,11 +1,28 @@
package dashboard
import (
"sort"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
)
const maxPosts = 6
// Get ...
func Get(ctx *aero.Context) string {
return ctx.HTML(components.Dashboard())
posts, err := arn.GetPosts()
if err != nil {
return ctx.Error(500, "Error fetching posts")
}
sort.Sort(sort.Reverse(posts))
if len(posts) > maxPosts {
posts = posts[:maxPosts]
}
return ctx.HTML(components.Dashboard(posts))
}