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
10 changes: 10 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,16 @@ def build_report(data: bytes, source: str, show_names: bool) -> Response | tuple
return report_response(result, source, data, show_names)


@app.get("/favicon.svg")
def favicon():
"""Serve a browser-readable icon at a stable, directly inspectable URL."""
return send_file(
Path(__file__).parent / "assets" / "favicon.svg",
mimetype="image/svg+xml",
max_age=3600,
)


@app.get("/")
def index():
return landing_page()
Expand Down
1 change: 1 addition & 0 deletions assets/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/railstat-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion report_tool/templates/_theme.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{# Shared look: warm paper, light modular accents, light/dark tokens, and the theme switcher. Included in <head>. #}
<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2042%2034%22%20width%3D%2238%22%20height%3D%2232%22%3E%3Crect%20x%3D%223%22%20y%3D%2215%22%20width%3D%2217%22%20height%3D%2214%22%20rx%3D%222%22%20fill%3D%22%23c9937b%22%2F%3E%3Crect%20x%3D%2220%22%20y%3D%225%22%20width%3D%2217%22%20height%3D%2224%22%20rx%3D%222%22%20fill%3D%22%23a4bdc7%22%2F%3E%3Crect%20x%3D%2219%22%20y%3D%222%22%20width%3D%2219%22%20height%3D%224%22%20rx%3D%221%22%20fill%3D%22%23d5b36e%22%2F%3E%3Crect%20x%3D%2225%22%20y%3D%229%22%20width%3D%228%22%20height%3D%228%22%20rx%3D%221%22%20fill%3D%22%23faf9f5%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%2223%22%20width%3D%2234%22%20height%3D%226%22%20rx%3D%221%22%20fill%3D%22%238ba59a%22%2F%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2229%22%20r%3D%225%22%20fill%3D%22%2335433e%22%2F%3E%3Ccircle%20cx%3D%2223%22%20cy%3D%2229%22%20r%3D%225%22%20fill%3D%22%2335433e%22%2F%3E%3Ccircle%20cx%3D%2235%22%20cy%3D%2229%22%20r%3D%225%22%20fill%3D%22%2335433e%22%2F%3E%3C%2Fsvg%3E">
{% if request is defined %}
<link rel="icon" type="image/svg+xml" sizes="any" href="/favicon.svg?v=2">
{% else %}
<link rel="icon" type="image/svg+xml" sizes="any" href="data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2048%2048%22%3E%3Crect%20width%3D%2248%22%20height%3D%2248%22%20rx%3D%2210%22%20fill%3D%22%23faf9f5%22%2F%3E%3Cg%20transform%3D%22translate%283%207%29%22%3E%3Crect%20x%3D%223%22%20y%3D%2215%22%20width%3D%2217%22%20height%3D%2214%22%20rx%3D%222%22%20fill%3D%22%23c9937b%22%2F%3E%3Crect%20x%3D%2220%22%20y%3D%225%22%20width%3D%2217%22%20height%3D%2224%22%20rx%3D%222%22%20fill%3D%22%23a4bdc7%22%2F%3E%3Crect%20x%3D%2219%22%20y%3D%222%22%20width%3D%2219%22%20height%3D%224%22%20rx%3D%221%22%20fill%3D%22%23d5b36e%22%2F%3E%3Crect%20x%3D%2225%22%20y%3D%229%22%20width%3D%228%22%20height%3D%228%22%20rx%3D%221%22%20fill%3D%22%23faf9f5%22%2F%3E%3Crect%20x%3D%223%22%20y%3D%2223%22%20width%3D%2234%22%20height%3D%226%22%20rx%3D%221%22%20fill%3D%22%238ba59a%22%2F%3E%3Ccircle%20cx%3D%2210%22%20cy%3D%2229%22%20r%3D%225%22%20fill%3D%22%2335433e%22%2F%3E%3Ccircle%20cx%3D%2223%22%20cy%3D%2229%22%20r%3D%225%22%20fill%3D%22%2335433e%22%2F%3E%3Ccircle%20cx%3D%2235%22%20cy%3D%2229%22%20r%3D%225%22%20fill%3D%22%2335433e%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E">
{% endif %}
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap" rel="stylesheet">
Expand Down
16 changes: 16 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,19 @@ def test_too_large(client, monkeypatch):
response = upload(client, b"x" * 100)
assert response.status_code == 413
assert b"larger than" in response.data


def test_favicon_is_valid_svg():
import xml.etree.ElementTree as ET

response = app.test_client().get("/favicon.svg?v=2")
assert response.status_code == 200
assert response.mimetype == "image/svg+xml"
root = ET.fromstring(response.data)
assert root.tag == "{http://www.w3.org/2000/svg}svg"
assert root.attrib["viewBox"] == "0 0 48 48"


def test_landing_links_to_served_favicon():
response = app.test_client().get("/")
assert b'href="/favicon.svg?v=2"' in response.data
Loading