diff --git a/pages/company/company.go b/pages/company/company.go new file mode 100644 index 00000000..b17311fa --- /dev/null +++ b/pages/company/company.go @@ -0,0 +1,21 @@ +package company + +import ( + "net/http" + + "github.com/aerogo/aero" + "github.com/animenotifier/arn" + "github.com/animenotifier/notify.moe/components" +) + +// Get company. +func Get(ctx *aero.Context) string { + id := ctx.Get("id") + company, err := arn.GetCompany(id) + + if err != nil { + return ctx.Error(http.StatusNotFound, "Company not found", err) + } + + return ctx.HTML(components.CompanyPage(company)) +} diff --git a/pages/company/company.pixy b/pages/company/company.pixy new file mode 100644 index 00000000..0f80e7f6 --- /dev/null +++ b/pages/company/company.pixy @@ -0,0 +1,2 @@ +component CompanyPage(company *arn.Company) + h1= company.Name.English \ No newline at end of file diff --git a/pages/index.go b/pages/index.go index a754b40b..33fed29b 100644 --- a/pages/index.go +++ b/pages/index.go @@ -13,6 +13,7 @@ import ( "github.com/animenotifier/notify.moe/pages/apiview" "github.com/animenotifier/notify.moe/pages/character" "github.com/animenotifier/notify.moe/pages/charge" + "github.com/animenotifier/notify.moe/pages/company" "github.com/animenotifier/notify.moe/pages/compare" "github.com/animenotifier/notify.moe/pages/database" "github.com/animenotifier/notify.moe/pages/editanime" @@ -92,6 +93,9 @@ func Configure(app *aero.Application) { // Characters l.Page("/character/:id", character.Get) + // Companies + l.Page("/company/:id", company.Get) + // Settings l.Page("/settings", settings.Get(components.SettingsPersonal)) l.Page("/settings/accounts", settings.Get(components.SettingsAccounts)) diff --git a/pages/users/users.go b/pages/users/users.go index 072cc55a..b087b39f 100644 --- a/pages/users/users.go +++ b/pages/users/users.go @@ -14,9 +14,15 @@ func Active(ctx *aero.Context) string { return user.IsActive() && user.HasAvatar() }) + followCount := map[*arn.User]int{} + + for _, user := range users { + followCount[user] = user.FollowersCount() + } + sort.Slice(users, func(i, j int) bool { - followersA := users[i].FollowersCount() - followersB := users[j].FollowersCount() + followersA := followCount[users[i]] + followersB := followCount[users[j]] if followersA == followersB { return users[i].Nick < users[j].Nick