32 lines
652 B
Go
Raw Normal View History

2017-11-18 10:37:29 +00:00
package companies
import (
2017-11-19 01:04:37 +00:00
"sort"
2017-11-18 10:37:29 +00:00
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
2017-11-27 20:19:17 +00:00
const maxEntries = 24
2017-11-18 10:37:29 +00:00
// Get renders the companies page.
func Get(ctx *aero.Context) string {
user := utils.GetUser(ctx)
companies := arn.FilterCompanies(func(company *arn.Company) bool {
return !company.IsDraft
})
2017-11-19 01:04:37 +00:00
sort.Slice(companies, func(i, j int) bool {
return companies[i].Created > companies[j].Created
})
2017-11-18 10:37:29 +00:00
if len(companies) > maxEntries {
companies = companies[:maxEntries]
}
return ctx.HTML(components.Companies(companies, user))
}