appview/pages: add metadata to profile tabs #543

merged
opened by oppi.li targeting master from push-mvmrzuxwmzvs
Changed files
+45 -30
appview
pages
repoinfo
templates
+35 -15
appview/pages/pages.go
···
}
type ProfileCard struct {
-
UserDid string
-
UserHandle string
-
FollowStatus db.FollowStatus
-
FollowersCount int
-
FollowingCount int
-
Punchcard *db.Punchcard
-
Profile *db.Profile
-
Active string
+
UserDid string
+
UserHandle string
+
FollowStatus db.FollowStatus
+
Punchcard *db.Punchcard
+
Profile *db.Profile
+
Stats ProfileStats
+
Active string
+
}
+
+
type ProfileStats struct {
+
RepoCount int64
+
StarredCount int64
+
StringCount int64
+
FollowersCount int64
+
FollowingCount int64
}
-
func (p *ProfileCard) GetTabs() [][]string {
-
tabs := [][]string{
-
{"overview", "overview", "square-chart-gantt"},
-
{"repos", "repos", "book-marked"},
-
{"starred", "starred", "star"},
+
func (p *ProfileCard) GetTabs() [][]any {
+
tabs := [][]any{
+
{"overview", "overview", "square-chart-gantt", nil},
+
{"repos", "repos", "book-marked", p.Stats.RepoCount},
+
{"starred", "starred", "star", p.Stats.StarredCount},
+
{"strings", "strings", "line-squiggle", p.Stats.StringCount},
}
return tabs
···
return p.executeProfile("user/starred", w, params)
}
+
type ProfileStringsParams struct {
+
LoggedInUser *oauth.User
+
Strings []db.String
+
Card *ProfileCard
+
Active string
+
}
+
+
func (p *Pages) ProfileStrings(w io.Writer, params ProfileStringsParams) error {
+
params.Active = "strings"
+
return p.executeProfile("user/strings", w, params)
+
}
+
type FollowCard struct {
UserDid string
FollowStatus db.FollowStatus
-
FollowersCount int
-
FollowingCount int
+
FollowersCount int64
+
FollowingCount int64
Profile *db.Profile
}
+2 -7
appview/pages/repoinfo/repoinfo.go
···
func (r RepoInfo) TabMetadata() map[string]any {
meta := make(map[string]any)
-
if r.Stats.PullCount.Open > 0 {
-
meta["pulls"] = r.Stats.PullCount.Open
-
}
-
-
if r.Stats.IssueCount.Open > 0 {
-
meta["issues"] = r.Stats.IssueCount.Open
-
}
+
meta["pulls"] = r.Stats.PullCount.Open
+
meta["issues"] = r.Stats.IssueCount.Open
// more stuff?
+4 -4
appview/pages/templates/layouts/profilebase.html
···
{{ define "content" }}
{{ template "profileTabs" . }}
-
<section class="bg-white dark:bg-gray-800 p-6 rounded w-full dark:text-white">
+
<section class="bg-white dark:bg-gray-800 p-6 rounded w-full dark:text-white drop-shadow-sm">
<div class="grid grid-cols-1 md:grid-cols-11 gap-4">
<div class="md:col-span-3 order-1 md:order-1">
<div class="flex flex-col gap-4">
···
{{ $key := index $item 0 }}
{{ $value := index $item 1 }}
{{ $icon := index $item 2 }}
-
{{ $meta := index $tabmeta $key }}
+
{{ $meta := index $item 3 }}
<a
href="?tab={{ $value }}"
class="relative -mr-px group no-underline hover:no-underline"
···
<span class="flex items-center justify-center">
{{ i $icon "w-4 h-4 mr-2" }}
{{ $key }}
-
{{ if not (isNil $meta) }}
-
<span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span>
+
{{ if $meta }}
+
<span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span>
{{ end }}
</span>
</div>
+2 -2
appview/pages/templates/layouts/repobase.html
···
<span class="flex items-center justify-center">
{{ i $icon "w-4 h-4 mr-2" }}
{{ $key }}
-
{{ if not (isNil $meta) }}
-
<span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span>
+
{{ if $meta }}
+
<span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span>
{{ end }}
</span>
</div>
+2 -2
appview/pages/templates/user/fragments/profileCard.html
···
{{ with $root }}
<div class="flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full text-sm">
<span class="flex-shrink-0">{{ i "users" "size-4" }}</span>
-
<span id="followers"><a href="/{{ $userIdent }}?tab=followers">{{ .FollowersCount }} followers</a></span>
+
<span id="followers"><a href="/{{ $userIdent }}?tab=followers">{{ .Stats.FollowersCount }} followers</a></span>
<span class="select-none after:content-['·']"></span>
-
<span id="following"><a href="/{{ $userIdent }}?tab=following">{{ .FollowingCount }} following</a></span>
+
<span id="following"><a href="/{{ $userIdent }}?tab=following">{{ .Stats.FollowingCount }} following</a></span>
</div>
{{ end }}
{{ end }}