Monorepo for Tangled
0

Configure Feed

Select the types of activity you want to include in your feed.

appview/pages: add scaleFmt to print counts >1k better

Signed-off-by: oppiliappan <me@oppi.li>

authored by

oppiliappan and committed by
Tangled
(May 23, 2026, 2:17 PM +0300) 06da90da b51ba4e6

+38 -14
+24
appview/pages/funcmap.go
··· 178 178 s = append(s, values...) 179 179 return s 180 180 }, 181 + // scale numerics over 1000 to 1k 182 + "scaleFmt": func(n any) string { 183 + var v float64 184 + switch x := n.(type) { 185 + case int: 186 + v = float64(x) 187 + case int32: 188 + v = float64(x) 189 + case int64: 190 + v = float64(x) 191 + case float64: 192 + v = x 193 + default: 194 + return fmt.Sprintf("%v", n) 195 + } 196 + if v < 1000 { 197 + return fmt.Sprintf("%d", int(v)) 198 + } 199 + k := v / 1000 200 + if k < 10 { 201 + return fmt.Sprintf("%.1fk", k) 202 + } 203 + return fmt.Sprintf("%dk", int(k)) 204 + }, 181 205 "commaFmt": humanize.Comma, 182 206 "plural": english.Plural, 183 207 "relTimeFmt": humanize.Time,
+2 -2
appview/pages/templates/fragments/starBtn.html
··· 31 31 class="btn-group-item" 32 32 title="Starred by" 33 33 > 34 - {{ .StarCount }} 34 + {{ scaleFmt .StarCount }} 35 35 </a> 36 36 {{ else }} 37 37 <span class="btn-group-item cursor-default"> 38 - {{ .StarCount }} 38 + {{ scaleFmt .StarCount }} 39 39 </span> 40 40 {{ end }} 41 41 </div>
+1 -1
appview/pages/templates/layouts/profilebase.html
··· 91 91 {{ i $icon "w-4 h-4 mr-2" }} 92 92 {{ $key }} 93 93 {{ if $meta }} 94 - <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span> 94 + <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ scaleFmt $meta }}</span> 95 95 {{ end }} 96 96 </span> 97 97 </div>
+2 -2
appview/pages/templates/layouts/repobase.html
··· 47 47 {{ i $icon "w-4 h-4 mr-2" }} 48 48 {{ $key }} 49 49 {{ if $meta }} 50 - <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ $meta }}</span> 50 + <span class="bg-gray-200 dark:bg-gray-700 rounded py-1/2 px-1 text-sm ml-1">{{ scaleFmt $meta }}</span> 51 51 {{ end }} 52 52 </span> 53 53 </div> ··· 132 132 class="btn-group-item" 133 133 title="Forked by" 134 134 > 135 - {{ .RepoInfo.Stats.ForkCount }} 135 + {{ scaleFmt .RepoInfo.Stats.ForkCount }} 136 136 </a> 137 137 </div> 138 138 {{ template "repo/fragments/feedDropdown" . }}
+2 -2
appview/pages/templates/repo/issues/issues.html
··· 15 15 "Key" "open" 16 16 "Value" "open" 17 17 "Icon" "circle-dot" 18 - "Meta" (string .RepoInfo.Stats.IssueCount.Open)) }} 18 + "Meta" (scaleFmt .RepoInfo.Stats.IssueCount.Open)) }} 19 19 {{ $closed := 20 20 (dict 21 21 "Key" "closed" 22 22 "Value" "closed" 23 23 "Icon" "ban" 24 - "Meta" (string .RepoInfo.Stats.IssueCount.Closed)) }} 24 + "Meta" (scaleFmt .RepoInfo.Stats.IssueCount.Closed)) }} 25 25 {{ $values := list $open $closed }} 26 26 27 27 <div class="grid gap-2 grid-cols-[auto_1fr_auto] grid-row-2">
+3 -3
appview/pages/templates/repo/pulls/pulls.html
··· 14 14 "Key" "open" 15 15 "Value" "open" 16 16 "Icon" "git-pull-request" 17 - "Meta" (string .RepoInfo.Stats.PullCount.Open)) }} 17 + "Meta" (scaleFmt .RepoInfo.Stats.PullCount.Open)) }} 18 18 {{ $merged := 19 19 (dict 20 20 "Key" "merged" 21 21 "Value" "merged" 22 22 "Icon" "git-merge" 23 - "Meta" (string .RepoInfo.Stats.PullCount.Merged)) }} 23 + "Meta" (scaleFmt .RepoInfo.Stats.PullCount.Merged)) }} 24 24 {{ $closed := 25 25 (dict 26 26 "Key" "closed" 27 27 "Value" "closed" 28 28 "Icon" "ban" 29 - "Meta" (string .RepoInfo.Stats.PullCount.Closed)) }} 29 + "Meta" (scaleFmt .RepoInfo.Stats.PullCount.Closed)) }} 30 30 {{ $values := list $open $merged $closed }} 31 31 <div class="grid gap-2 grid-cols-[auto_1fr_auto] grid-row-2"> 32 32 <form id="search-form" class="flex relative col-span-3 sm:col-span-1 sm:col-start-2" method="GET">
+4 -4
appview/pages/templates/user/fragments/repoCard.html
··· 62 62 {{ with .StarCount }} 63 63 <div class="flex gap-1 items-center text-sm"> 64 64 {{ i "star" "w-3 h-3 fill-current" }} 65 - <span>{{ . }}</span> 65 + <span>{{ scaleFmt . }}</span> 66 66 </div> 67 67 {{ end }} 68 68 {{ with .ForkCount }} 69 69 <div class="flex gap-1 items-center text-sm"> 70 70 {{ i "git-fork" "w-3 h-3" }} 71 - <span>{{ . }}</span> 71 + <span>{{ scaleFmt . }}</span> 72 72 </div> 73 73 {{ end }} 74 74 {{ with .IssueCount.Open }} 75 75 <div class="flex gap-1 items-center text-sm"> 76 76 {{ i "circle-dot" "w-3 h-3" }} 77 - <span>{{ . }}</span> 77 + <span>{{ scaleFmt . }}</span> 78 78 </div> 79 79 {{ end }} 80 80 {{ with .PullCount.Open }} 81 81 <div class="flex gap-1 items-center text-sm"> 82 82 {{ i "git-pull-request" "w-3 h-3" }} 83 - <span>{{ . }}</span> 83 + <span>{{ scaleFmt . }}</span> 84 84 </div> 85 85 {{ end }} 86 86 </div>