From f66088e5d61e0cb538f4349a00eb30e594e87b01 Mon Sep 17 00:00:00 2001 From: shay Date: Wed, 27 May 2026 10:21:32 -0700 Subject: [PATCH] feat(api): add endpoint for retrieving growth data for the dashboard --- generator/frontend/src/lib/renderWidgets.ts | 2 +- generator/src/widgets/composite.py | 4 ++-- generator/src/widgets/grade.py | 4 ++-- generator/src/widgets/languages.py | 2 +- generator/tests/test_attribution.py | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/generator/frontend/src/lib/renderWidgets.ts b/generator/frontend/src/lib/renderWidgets.ts index 9aa8cc6..326fb27 100644 --- a/generator/frontend/src/lib/renderWidgets.ts +++ b/generator/frontend/src/lib/renderWidgets.ts @@ -466,6 +466,6 @@ export function renderAllWidgets(opts: { ${header}${embedded} - Generated with gh-stats + Generated with gh-stats.com ` } diff --git a/generator/src/widgets/composite.py b/generator/src/widgets/composite.py index 4687330..b8636e7 100644 --- a/generator/src/widgets/composite.py +++ b/generator/src/widgets/composite.py @@ -15,7 +15,7 @@ _ATTRIBUTION_H_RE = re.compile(r'\bdata-gh-h="(\d+)"') def _extract_inner(svg: str, widget_key: str) -> tuple[str, int]: """Extract the inner content from a widget SVG and rewrite IDs to be unique. - Also strips any per-widget "Generated with gh-stats" attribution text + Also strips any per-widget "Generated with gh-stats.com" attribution text (marked with data-gh-attribution="1") and shrinks the reported height by data-gh-h so the composite doesn't reserve empty space for the removed footer. The composite has its own attribution at the bottom @@ -127,5 +127,5 @@ def compose_widget( {embedded} Generated with gh-stats + font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats.com ''' diff --git a/generator/src/widgets/grade.py b/generator/src/widgets/grade.py index 74c89d3..216d804 100644 --- a/generator/src/widgets/grade.py +++ b/generator/src/widgets/grade.py @@ -128,7 +128,7 @@ def render_grade_widget(data: GradeData, theme_name: str = "dark", settings: dic stats_y = 100 tags_y = stats_y + 54 tag_padding = 18 if tags_h > 24 else 14 - # Reserve space at the bottom for the "Generated with gh-stats" + # Reserve space at the bottom for the "Generated with gh-stats.com" # attribution. Matches the composite widget's footer convention so # the standalone grade widget feels visually consistent when it's # embedded on its own (the /api//grade.svg path). @@ -182,6 +182,6 @@ def render_grade_widget(data: GradeData, theme_name: str = "dark", settings: dic Generated with gh-stats''' + font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats.com''' return card_wrapper(inner, 380, card_h, t, "") diff --git a/generator/src/widgets/languages.py b/generator/src/widgets/languages.py index 01c8070..401a82a 100644 --- a/generator/src/widgets/languages.py +++ b/generator/src/widgets/languages.py @@ -109,5 +109,5 @@ def render_languages_widget(languages: list[LanguageData], theme_name: str = "da Generated with gh-stats''' + font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats.com''' return card_wrapper(inner, 380, card_h, t, "Languages") diff --git a/generator/tests/test_attribution.py b/generator/tests/test_attribution.py index a783767..95fb085 100644 --- a/generator/tests/test_attribution.py +++ b/generator/tests/test_attribution.py @@ -1,7 +1,7 @@ """Per-widget attribution behaves correctly in both contexts. Standalone widget SVGs (served at /api//.svg) must show the -"Generated with gh-stats" footer; the composite (served at /api/) +"Generated with gh-stats.com" footer; the composite (served at /api/) must strip the per-widget footer and only show its own bottom one. """ from src.models import GradeData, LanguageData, TagData @@ -30,13 +30,13 @@ def _languages_fixture() -> list[LanguageData]: def test_standalone_grade_widget_has_attribution(): svg = render_grade_widget(_grade_fixture(), theme_name="dark") - assert "Generated with gh-stats" in svg + assert "Generated with gh-stats.com" in svg assert 'data-gh-attribution="1"' in svg def test_standalone_languages_widget_has_attribution(): svg = render_languages_widget(_languages_fixture(), theme_name="dark") - assert "Generated with gh-stats" in svg + assert "Generated with gh-stats.com" in svg assert 'data-gh-attribution="1"' in svg @@ -55,7 +55,7 @@ def test_composite_strips_per_widget_attribution_from_grade(): ) # The composite has exactly ONE attribution (its own). The widget's # footer attribution should be gone. - assert composite.count("Generated with gh-stats") == 1 + assert composite.count("Generated with gh-stats.com") == 1 # No leftover attribution markers leaked through. assert "data-gh-attribution" not in composite @@ -70,7 +70,7 @@ def test_composite_strips_per_widget_attribution_from_languages(): avatar_b64="", show_name=False, ) - assert composite.count("Generated with gh-stats") == 1 + assert composite.count("Generated with gh-stats.com") == 1 assert "data-gh-attribution" not in composite @@ -89,7 +89,7 @@ def test_composite_strips_attribution_from_multiple_widgets(): ) # Each widget contributed an attribution; the composite contributes # one of its own — total visible attributions must be exactly 1. - assert composite.count("Generated with gh-stats") == 1 + assert composite.count("Generated with gh-stats.com") == 1 def test_composite_reclaims_attribution_height():