Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion heart/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,13 @@ def _render_html(board: Board) -> str:
)
t_ = theme()
hero = t_.hero(BOARD_KEY, "Dashboard", _LEDE)
# The way back from the Pages board to the repository front door; owner
# from the declared config surface (REPO_OWNERS), so the segment drops
# out on a tenant whose config does not list this repo.
repo_name = PAGES_URL.rstrip("/").rsplit("/", 1)[-1]
gh_owner = REPO_OWNERS.get(repo_name)
github_link = (f' · <a href="https://github.com/{gh_owner}/{repo_name}'
'/blob/main/README.md">GitHub Page</a>' if gh_owner else "")
return f"""<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
Expand All @@ -1586,7 +1593,7 @@ def _render_html(board: Board) -> str:
{hero}
<p class="verdict {_VERDICT_TONE.get(board.verdict, '')}"><b>{word} · score
{board.score}</b><span class="muted">snapshot {_html.escape(board.ts)} ·
{age} · <a href="dashboard.md">markdown version</a></span></p>
{age} · <a href="dashboard.md">markdown version</a>{github_link}</span></p>
{stale_html}
{reasons_html}
<table class="recent board">{''.join(rows)}</table>
Expand Down
7 changes: 7 additions & 0 deletions tests/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ def test_html_is_self_contained():
red_reasons=["PyAutoLens: CI failure"]), fmt="html", now=FRESH_NOW)
assert out.lstrip().startswith("<!doctype html>")
assert "RED" in out
# The header links the markdown twin and the repository front door. The
# expected owner comes from the same declared config surface the renderer
# reads (the tenant firewall keeps org literals out of organ code).
assert '<a href="dashboard.md">markdown version</a>' in out
gh_owner = dashboard.REPO_OWNERS["PyAutoHeart"]
assert (f'<a href="https://github.com/{gh_owner}/PyAutoHeart/blob/main/'
'README.md">GitHub Page</a>') in out
# No external ASSETS (renders anywhere, loads nothing remote): no src=, no
# <link>, no fetches. Inline <script> is allowed — the one-tap 📋 copy
# buttons need the clipboard API — and outbound <a href> links are
Expand Down
Loading