29 lines
461 B
Go
Raw Normal View History

2016-11-19 23:54:31 +09:00
package dashboard
import (
"sort"
2016-11-19 23:54:31 +09:00
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
2016-11-19 23:54:31 +09:00
"github.com/animenotifier/notify.moe/components"
)
const maxPosts = 6
2016-11-19 23:54:31 +09:00
// Get ...
func Get(ctx *aero.Context) string {
posts, err := arn.GetPosts()
if err != nil {
2016-11-23 14:26:59 +09: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 23:54:31 +09:00
}