2017-11-18 11:37:29 +01:00

32 lines
658 B
Go

package companies
import (
"net/http"
"github.com/aerogo/aero"
"github.com/animenotifier/arn"
"github.com/animenotifier/notify.moe/components"
"github.com/animenotifier/notify.moe/utils"
)
const maxEntries = 12
// 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
})
if err != nil {
return ctx.Error(http.StatusInternalServerError, "Error fetching companies", err)
}
if len(companies) > maxEntries {
companies = companies[:maxEntries]
}
return ctx.HTML(components.Companies(companies, user))
}