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
··· 410 } 411 412 type ProfileCard struct { 413 - UserDid string 414 - UserHandle string 415 - FollowStatus db.FollowStatus 416 - FollowersCount int 417 - FollowingCount int 418 - Punchcard *db.Punchcard 419 - Profile *db.Profile 420 - Active string 421 } 422 423 - func (p *ProfileCard) GetTabs() [][]string { 424 - tabs := [][]string{ 425 - {"overview", "overview", "square-chart-gantt"}, 426 - {"repos", "repos", "book-marked"}, 427 - {"starred", "starred", "star"}, 428 } 429 430 return tabs ··· 468 return p.executeProfile("user/starred", w, params) 469 } 470 471 type FollowCard struct { 472 UserDid string 473 FollowStatus db.FollowStatus 474 - FollowersCount int 475 - FollowingCount int 476 Profile *db.Profile 477 } 478
··· 410 } 411 412 type ProfileCard struct { 413 + UserDid string 414 + UserHandle string 415 + FollowStatus db.FollowStatus 416 + Punchcard *db.Punchcard 417 + Profile *db.Profile 418 + Stats ProfileStats 419 + Active string 420 + } 421 + 422 + type ProfileStats struct { 423 + RepoCount int64 424 + StarredCount int64 425 + StringCount int64 426 + FollowersCount int64 427 + FollowingCount int64 428 } 429 430 + func (p *ProfileCard) GetTabs() [][]any { 431 + tabs := [][]any{ 432 + {"overview", "overview", "square-chart-gantt", nil}, 433 + {"repos", "repos", "book-marked", p.Stats.RepoCount}, 434 + {"starred", "starred", "star", p.Stats.StarredCount}, 435 + {"strings", "strings", "line-squiggle", p.Stats.StringCount}, 436 } 437 438 return tabs ··· 476 return p.executeProfile("user/starred", w, params) 477 } 478 479 + type ProfileStringsParams struct { 480 + LoggedInUser *oauth.User 481 + Strings []db.String 482 + Card *ProfileCard 483 + Active string 484 + } 485 + 486 + func (p *Pages) ProfileStrings(w io.Writer, params ProfileStringsParams) error { 487 + params.Active = "strings" 488 + return p.executeProfile("user/strings", w, params) 489 + } 490 + 491 type FollowCard struct { 492 UserDid string 493 FollowStatus db.FollowStatus 494 + FollowersCount int64 495 + FollowingCount int64 496 Profile *db.Profile 497 } 498
+2 -7
appview/pages/repoinfo/repoinfo.go
··· 78 func (r RepoInfo) TabMetadata() map[string]any { 79 meta := make(map[string]any) 80 81 - if r.Stats.PullCount.Open > 0 { 82 - meta["pulls"] = r.Stats.PullCount.Open 83 - } 84 - 85 - if r.Stats.IssueCount.Open > 0 { 86 - meta["issues"] = r.Stats.IssueCount.Open 87 - } 88 89 // more stuff? 90
··· 78 func (r RepoInfo) TabMetadata() map[string]any { 79 meta := make(map[string]any) 80 81 + meta["pulls"] = r.Stats.PullCount.Open 82 + meta["issues"] = r.Stats.IssueCount.Open 83 84 // more stuff? 85
+4 -4
appview/pages/templates/layouts/profilebase.html
··· 9 10 {{ define "content" }} 11 {{ template "profileTabs" . }} 12 - <section class="bg-white dark:bg-gray-800 p-6 rounded w-full dark:text-white"> 13 <div class="grid grid-cols-1 md:grid-cols-11 gap-4"> 14 <div class="md:col-span-3 order-1 md:order-1"> 15 <div class="flex flex-col gap-4"> ··· 32 {{ $key := index $item 0 }} 33 {{ $value := index $item 1 }} 34 {{ $icon := index $item 2 }} 35 - {{ $meta := index $tabmeta $key }} 36 <a 37 href="?tab={{ $value }}" 38 class="relative -mr-px group no-underline hover:no-underline" ··· 48 <span class="flex items-center justify-center"> 49 {{ i $icon "w-4 h-4 mr-2" }} 50 {{ $key }} 51 - {{ if not (isNil $meta) }} 52 - <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span> 53 {{ end }} 54 </span> 55 </div>
··· 9 10 {{ define "content" }} 11 {{ template "profileTabs" . }} 12 + <section class="bg-white dark:bg-gray-800 p-6 rounded w-full dark:text-white drop-shadow-sm"> 13 <div class="grid grid-cols-1 md:grid-cols-11 gap-4"> 14 <div class="md:col-span-3 order-1 md:order-1"> 15 <div class="flex flex-col gap-4"> ··· 32 {{ $key := index $item 0 }} 33 {{ $value := index $item 1 }} 34 {{ $icon := index $item 2 }} 35 + {{ $meta := index $item 3 }} 36 <a 37 href="?tab={{ $value }}" 38 class="relative -mr-px group no-underline hover:no-underline" ··· 48 <span class="flex items-center justify-center"> 49 {{ i $icon "w-4 h-4 mr-2" }} 50 {{ $key }} 51 + {{ if $meta }} 52 + <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span> 53 {{ end }} 54 </span> 55 </div>
+2 -2
appview/pages/templates/layouts/repobase.html
··· 71 <span class="flex items-center justify-center"> 72 {{ i $icon "w-4 h-4 mr-2" }} 73 {{ $key }} 74 - {{ if not (isNil $meta) }} 75 - <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span> 76 {{ end }} 77 </span> 78 </div>
··· 71 <span class="flex items-center justify-center"> 72 {{ i $icon "w-4 h-4 mr-2" }} 73 {{ $key }} 74 + {{ if $meta }} 75 + <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span> 76 {{ end }} 77 </span> 78 </div>
+2 -2
appview/pages/templates/user/fragments/profileCard.html
··· 92 {{ with $root }} 93 <div class="flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full text-sm"> 94 <span class="flex-shrink-0">{{ i "users" "size-4" }}</span> 95 - <span id="followers"><a href="/{{ $userIdent }}?tab=followers">{{ .FollowersCount }} followers</a></span> 96 <span class="select-none after:content-['·']"></span> 97 - <span id="following"><a href="/{{ $userIdent }}?tab=following">{{ .FollowingCount }} following</a></span> 98 </div> 99 {{ end }} 100 {{ end }}
··· 92 {{ with $root }} 93 <div class="flex items-center gap-2 my-2 overflow-hidden text-ellipsis whitespace-nowrap max-w-full text-sm"> 94 <span class="flex-shrink-0">{{ i "users" "size-4" }}</span> 95 + <span id="followers"><a href="/{{ $userIdent }}?tab=followers">{{ .Stats.FollowersCount }} followers</a></span> 96 <span class="select-none after:content-['·']"></span> 97 + <span id="following"><a href="/{{ $userIdent }}?tab=following">{{ .Stats.FollowingCount }} following</a></span> 98 </div> 99 {{ end }} 100 {{ end }}