Skip to content

fix(leaderboard): open external links in a new tab, add GitHub link and logo - #21

Merged
malteos merged 1 commit into
mainfrom
fix/leaderboard-links
Sep 22, 2026
Merged

malteos merged 1 commit into
mainfrom
fix/leaderboard-links

Conversation

@malteos

@malteos malteos commented Sep 22, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • External links open in a new tab. Plain Markdown links navigated the top frame, which browsers block when the app is embedded in the HF Space iframe. A new _ext_link() helper renders raw <a target="_blank" rel="noopener noreferrer"> anchors (Gradio's Markdown sanitizer keeps both attributes) and is used for every outbound link: the header row, the dataset-card Reference/License links, and the footer source link.
  • GitHub link added to the header row via GITHUB_URL.
  • CommonLID logo in the header. Light and dark SVGs live under src/commonlid/leaderboard/images/ (verified they ship in the wheel) and are inlined as base64 data URIs in a gr.HTML block next to a "Leaderboard" title, replacing the text-only H1. The light/dark swap goes through css_template with a nested .dark & selector: the Gradio 6 HTML component ignores inline <style> tags and wraps its CSS under the component id, so a plain .dark ... selector never matches the class Gradio toggles on <body>.

Test plan

  • pytest -k leaderboard (24 passed), ruff clean
  • Ran commonlid leaderboard serve --local-dir ./data/results and checked headless-Chrome screenshots: only the black logo in light mode, only the white logo with ?__theme=dark
  • uv build --wheel includes both SVGs
  • After merge: confirm header links open on the HF Space (installs from main)

…nd logo

Plain Markdown links in the Gradio header navigated the top frame, which
browsers block when the app is embedded in the HF Space iframe, so the
Website/Blog/Paper/Add-a-model links were dead on the Space.

- app.py: add `_ext_link()` rendering raw `<a target="_blank"
  rel="noopener noreferrer">` anchors (Gradio's Markdown sanitizer keeps
  both attributes) and use it for every external link: header row,
  dataset-card Reference/License links, and the footer source link.
- app.py: add a GitHub link (`GITHUB_URL`) to the header row.
- app.py: add the CommonLID logo (light + dark SVG under
  `leaderboard/images/`, shipped in the wheel) as a `gr.HTML` header next
  to a "Leaderboard" title, replacing the text-only H1. Both variants are
  inlined as base64 data URIs so no `allowed_paths` wiring is needed; the
  swap uses `css_template` with a nested `.dark &` selector because the
  HTML component ignores inline `<style>` tags and scopes its CSS under
  the component id.
- tests: assert the new-tab attributes on all header/footer links, the
  GitHub URL, and the light/dark logo swap rules.
@malteos
malteos merged commit 387f162 into main Sep 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant