Skip to content

Commit

Permalink
www/index- add a third column for most starred packages
Browse files Browse the repository at this point in the history
  • Loading branch information
nektro committed Aug 8, 2021
1 parent eba01f5 commit a0ce551
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pkg/db/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

//
//

Expand Down
1 change: 1 addition & 0 deletions pkg/handler/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
}

Expand Down
15 changes: 15 additions & 0 deletions www/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@
</div>
{{/each}}
</div>
<div>
<h3>Most Starred</h3>
{{#each top_starred}}
<div class="terminal-card">
<div>
<h3 style="margin-bottom: 0;">
<a class="link-as-text" href="{{get_user_path this.Owner}}/{{this.name}}"></a>
<span><i class="star icon"></i> {{this.StarCount}}</span>
</h3>
<div><i class="balance scale icon"></i> {{#if this.license}}{{this.license}}{{else}}No{{/if}} License</div>
<div>{{this.description}}&nbsp;</div>
</div>
</div>
{{/each}}
</div>
<div>
<h3>Latest Updates</h3>
{{#each latest_versions}}
Expand Down
2 changes: 1 addition & 1 deletion www/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a0ce551

Please sign in to comment.