API Cleanup
This commit is contained in:
31
pages/companies/companies.go
Normal file
31
pages/companies/companies.go
Normal file
@ -0,0 +1,31 @@
|
||||
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))
|
||||
}
|
0
pages/companies/companies.pixy
Normal file
0
pages/companies/companies.pixy
Normal file
Reference in New Issue
Block a user