Fork of patx/hglab.
tokenmess/hglab
Add bottom boarder to repo navlinks when active.
Commit 9c666c903ce3 · Harrison Erd · 2026-05-03 11:50 -0400
Comments
No comments yet.
Diff
diff --git a/app.py b/app.py
--- a/app.py
+++ b/app.py
@@ -1283,9 +1283,27 @@
"is_owner": user_owns_repo(user, repo),
"can_maintain": user_can_maintain_repo(user, repo),
"has_fork": bool(user and user_has_fork_for_target(user["id"], fork_target_id)),
+ "repo_active_tab": repo_active_tab(repo),
}
+def repo_active_tab(repo):
+ base_path = f"/{repo['owner_username']}/{repo['name']}"
+ current_path = request.path.rstrip("/")
+ if current_path == base_path:
+ return "overview"
+ for tab, suffix in (
+ ("source", "/src"),
+ ("commits", "/commits"),
+ ("issues", "/issues"),
+ ("pulls", "/pulls"),
+ ("settings", "/settings"),
+ ):
+ if current_path == base_path + suffix or current_path.startswith(base_path + suffix + "/"):
+ return tab
+ return ""
+
+
def quote_path(path):
return quote(path, safe="/")
diff --git a/static/styles.css b/static/styles.css
--- a/static/styles.css
+++ b/static/styles.css
@@ -45,6 +45,8 @@
.brand { color: #111; font-weight: 700; text-decoration: none; }
.nav form, .repo-tabs form, .inline-form { display: inline; }
.link-button { padding: 0; color: #0645ad; background: none; border: 0; text-decoration: underline; }
+.repo-tabs .repo-tab { padding-bottom: .2rem; border-bottom: 2px solid transparent; }
+.repo-tabs .repo-tab.active { color: #111; font-weight: 700; text-decoration: none; border-bottom-color: #111; }
.filters .active, .tabs .active { color: #111; font-weight: 700; text-decoration: none; }
.hero, .repo-tabs { margin-bottom: 1.5rem; }
.eyebrow, .muted, .empty, .nav-user, .repo-card small, .issue-list span, .commit-list span, .file-list span, .clean-list span, .file-kind { color: #666; }
diff --git a/templates/repo_nav.tpl b/templates/repo_nav.tpl
--- a/templates/repo_nav.tpl
+++ b/templates/repo_nav.tpl
@@ -1,9 +1,10 @@
+% active_tab = get("repo_active_tab", "")
<nav class="repo-tabs">
- <a href="/{{repo['owner_username']}}/{{repo['name']}}">Overview</a>
- <a href="/{{repo['owner_username']}}/{{repo['name']}}/src">Source</a>
- <a href="/{{repo['owner_username']}}/{{repo['name']}}/commits">Commits{{" (" + str(commit_count) + ")" if commit_count else ""}}</a>
- <a href="/{{repo['owner_username']}}/{{repo['name']}}/issues">Issues{{" (" + str(issue_counts["open"]) + ")" if issue_counts["open"] else ""}}</a>
- <a href="/{{repo['owner_username']}}/{{repo['name']}}/pulls">Pull requests{{" (" + str(pr_counts["open"]) + ")" if pr_counts["open"] else ""}}</a>
+ <a class="repo-tab {{'active' if active_tab == 'overview' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}">Overview</a>
+ <a class="repo-tab {{'active' if active_tab == 'source' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}/src">Source</a>
+ <a class="repo-tab {{'active' if active_tab == 'commits' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}/commits">Commits{{" (" + str(commit_count) + ")" if commit_count else ""}}</a>
+ <a class="repo-tab {{'active' if active_tab == 'issues' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}/issues">Issues{{" (" + str(issue_counts["open"]) + ")" if issue_counts["open"] else ""}}</a>
+ <a class="repo-tab {{'active' if active_tab == 'pulls' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}/pulls">Pull requests{{" (" + str(pr_counts["open"]) + ")" if pr_counts["open"] else ""}}</a>
% if user:
<form class="inline-form" method="post" action="/{{repo['owner_username']}}/{{repo['name']}}/star">
% if is_starred:
@@ -27,6 +28,6 @@
<a href="/login?next=/{{repo['owner_username']}}/{{repo['name']}}/fork">Fork</a>
% end
% if is_owner:
- <a href="/{{repo['owner_username']}}/{{repo['name']}}/settings">Settings</a>
+ <a class="repo-tab {{'active' if active_tab == 'settings' else ''}}" href="/{{repo['owner_username']}}/{{repo['name']}}/settings">Settings</a>
% end
</nav>