Repository navigation
fix(leaderboard): open external links in a new tab, add GitHub link and logo - #21
Merged
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_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_URL.src/commonlid/leaderboard/images/(verified they ship in the wheel) and are inlined as base64 data URIs in agr.HTMLblock next to a "Leaderboard" title, replacing the text-only H1. The light/dark swap goes throughcss_templatewith 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 cleancommonlid leaderboard serve --local-dir ./data/resultsand checked headless-Chrome screenshots: only the black logo in light mode, only the white logo with?__theme=darkuv build --wheelincludes both SVGsmain)