From a0ce551198bfeb35417e3c6bb73e42f163ec2c43 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 8 Aug 2021 15:10:21 -0700 Subject: [PATCH] www/index- add a third column for most starred packages --- pkg/db/package.go | 9 +++++++++ pkg/handler/index.go | 1 + www/index.hbs | 15 +++++++++++++++ www/theme.css | 2 +- 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/pkg/db/package.go b/pkg/db/package.go index d009c0d..a2e8114 100644 --- a/pkg/db/package.go +++ b/pkg/db/package.go @@ -85,6 +85,15 @@ func (v Package) GetLatest(n int) []*Package { return res } +func (v Package) TopStarred(n int) []*Package { + arr := dbstorage.ScanAll(v.b().Or("star_count", "desc").Lm(int64(n)), Package{}) + res := []*Package{} + for _, item := range arr { + res = append(res, item.(*Package)) + } + return res +} + // // diff --git a/pkg/handler/index.go b/pkg/handler/index.go index 2540599..5d2299b 100644 --- a/pkg/handler/index.go +++ b/pkg/handler/index.go @@ -12,6 +12,7 @@ func Index(w http.ResponseWriter, r *http.Request) { "aquila_version": etc.Version, "latest_packages": db.Package{}.GetLatest(25), "latest_versions": db.Version{}.GetLatest(25), + "top_starred": db.Package{}.TopStarred(25), }) } diff --git a/www/index.hbs b/www/index.hbs index 7040349..f44577c 100644 --- a/www/index.hbs +++ b/www/index.hbs @@ -18,6 +18,21 @@ {{/each}} +
+

Most Starred

+ {{#each top_starred}} +
+
+

+ + {{this.StarCount}} +

+
{{#if this.license}}{{this.license}}{{else}}No{{/if}} License
+
{{this.description}} 
+
+
+ {{/each}} +

Latest Updates

{{#each latest_versions}} diff --git a/www/theme.css b/www/theme.css index 0251976..a05ac4d 100644 --- a/www/theme.css +++ b/www/theme.css @@ -30,7 +30,7 @@ table.left tr td { } .home-cols { display: grid; - grid-template-columns: 50% 50%; + grid-template-columns: 33% 33% 33%; } .home-cols > div { margin-right: 1em;