29 lines
461 B
Go
Raw Normal View History

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