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