diff options
| author | Joe Mou <dev@mou.fo> | 2026-08-11 08:09:47 -0400 |
|---|---|---|
| committer | Joe Mou <dev@mou.fo> | 2026-08-11 08:13:58 -0400 |
| commit | 0be1fdd2635fbc49d7451d3711b5772e1e9990e2 (patch) | |
| tree | d317fae68cce476f57eb50eb33e2c6d21be8a765 /cgithub/views | |
| parent | 6240cf1c6b73b7ed34ff5816b53333382c229f5c (diff) | |
Add language percentages to repo pages
GitHub no longer server-renders the repository sidebar; its React UI
lazily fetches /:owner/:repo/_sidebar as JSON, which carries the
language breakdown (name, percentage, color). getGitHubLanguages() uses
that endpoint, and a new /api/:owner/:repo/languages fragment route
renders the bar and legend the same way refs and latest-commit already
work, so repo page loads still cost a single scrape.
The latest-commit placeholder loader in refs.js is generalized over
.placeholder[data-src] so both placeholders share it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'cgithub/views')
| -rw-r--r-- | cgithub/views/_languages.eta | 17 | ||||
| -rw-r--r-- | cgithub/views/_tree.eta | 2 | ||||
| -rw-r--r-- | cgithub/views/repo.eta | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/cgithub/views/_languages.eta b/cgithub/views/_languages.eta new file mode 100644 index 0000000..8aca447 --- /dev/null +++ b/cgithub/views/_languages.eta @@ -0,0 +1,17 @@ +<% if (it.languages.length > 0) { %> + <div class="languages box"> + <div class="language-bar"> + <% for (const lang of it.languages) { %> + <span style="width: <%= lang.percentage %>%; background: <%= lang.color ?? "#ededed" %>" title="<%= lang.name %> <%= lang.percentage %>%"></span> + <% } %> + </div> + <ul class="language-list"> + <% for (const lang of it.languages) { %> + <li> + <span class="language-dot" style="background: <%= lang.color ?? "#ededed" %>"></span> + <%= lang.name %> <span class="language-percentage"><%= lang.percentage %>%</span> + </li> + <% } %> + </ul> + </div> +<% } %> diff --git a/cgithub/views/_tree.eta b/cgithub/views/_tree.eta index a0ecfab..2eb445f 100644 --- a/cgithub/views/_tree.eta +++ b/cgithub/views/_tree.eta @@ -1,7 +1,7 @@ <%~ include("./_nav.eta", {...it, isTree: true}) %> <% const commitPath = it.path && it.path !== "/" ? it.path : ""; %> -<div class="latest-commit-placeholder box" data-src="/api/<%= it.repo.owner %>/<%= it.repo.name %>/latest-commit/<%= it.branch %>/<%= commitPath %>">Loading latest commit…</div> +<div class="placeholder box" data-src="/api/<%= it.repo.owner %>/<%= it.repo.name %>/latest-commit/<%= it.branch %>/<%= commitPath %>">Loading latest commit…</div> <table> <% for (const item of it.items) { %> diff --git a/cgithub/views/repo.eta b/cgithub/views/repo.eta index 683a9ad..9122594 100644 --- a/cgithub/views/repo.eta +++ b/cgithub/views/repo.eta @@ -29,4 +29,6 @@ </div> <% } %> +<div class="placeholder box" data-src="/api/<%= it.repo.owner %>/<%= it.repo.name %>/languages">Loading languages…</div> + <%~ include("./_tree", it) %> |
