mirror of
https://github.com/ShayManor/github-readme-stats.git
synced 2026-12-02 11:53:48 +05:30
feat(api): add endpoint for retrieving growth data for the dashboard
This commit is contained in:
@@ -466,6 +466,6 @@ export function renderAllWidgets(opts: {
|
|||||||
<rect width="${totalW}" height="${totalH}" rx="16" fill="${t.bg}"/>
|
<rect width="${totalW}" height="${totalH}" rx="16" fill="${t.bg}"/>
|
||||||
<rect x="0.5" y="0.5" width="${totalW-1}" height="${totalH-1}" rx="16" fill="none" stroke="${t.card_border}" stroke-width="1"/>
|
<rect x="0.5" y="0.5" width="${totalW-1}" height="${totalH-1}" rx="16" fill="none" stroke="${t.card_border}" stroke-width="1"/>
|
||||||
${header}${embedded}
|
${header}${embedded}
|
||||||
<text x="${totalW/2}" y="${totalH-8}" text-anchor="middle" font-family="${font}" font-size="9" fill="${t.text_secondary}" opacity="0.5">Generated with gh-stats</text>
|
<text x="${totalW/2}" y="${totalH-8}" text-anchor="middle" font-family="${font}" font-size="9" fill="${t.text_secondary}" opacity="0.5">Generated with gh-stats.com</text>
|
||||||
</svg>`
|
</svg>`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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]:
|
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.
|
"""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
|
(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
|
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
|
removed footer. The composite has its own attribution at the bottom
|
||||||
@@ -127,5 +127,5 @@ def compose_widget(
|
|||||||
{embedded}
|
{embedded}
|
||||||
<text x="{total_w // 2}" y="{total_h - 8}" text-anchor="middle"
|
<text x="{total_w // 2}" y="{total_h - 8}" text-anchor="middle"
|
||||||
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
||||||
font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats</text>
|
font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats.com</text>
|
||||||
</svg>'''
|
</svg>'''
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ def render_grade_widget(data: GradeData, theme_name: str = "dark", settings: dic
|
|||||||
stats_y = 100
|
stats_y = 100
|
||||||
tags_y = stats_y + 54
|
tags_y = stats_y + 54
|
||||||
tag_padding = 18 if tags_h > 24 else 14
|
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
|
# attribution. Matches the composite widget's footer convention so
|
||||||
# the standalone grade widget feels visually consistent when it's
|
# the standalone grade widget feels visually consistent when it's
|
||||||
# embedded on its own (the /api/<u>/grade.svg path).
|
# embedded on its own (the /api/<u>/grade.svg path).
|
||||||
@@ -182,6 +182,6 @@ def render_grade_widget(data: GradeData, theme_name: str = "dark", settings: dic
|
|||||||
<text data-gh-attribution="1" data-gh-h="{footer_h}"
|
<text data-gh-attribution="1" data-gh-h="{footer_h}"
|
||||||
x="190" y="{card_h - 8}" text-anchor="middle"
|
x="190" y="{card_h - 8}" text-anchor="middle"
|
||||||
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
||||||
font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats</text>'''
|
font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats.com</text>'''
|
||||||
|
|
||||||
return card_wrapper(inner, 380, card_h, t, "")
|
return card_wrapper(inner, 380, card_h, t, "")
|
||||||
|
|||||||
@@ -109,5 +109,5 @@ def render_languages_widget(languages: list[LanguageData], theme_name: str = "da
|
|||||||
<text data-gh-attribution="1" data-gh-h="{footer_h}"
|
<text data-gh-attribution="1" data-gh-h="{footer_h}"
|
||||||
x="190" y="{card_h - 36 - 8}" text-anchor="middle"
|
x="190" y="{card_h - 36 - 8}" text-anchor="middle"
|
||||||
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
font-family="-apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif"
|
||||||
font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats</text>'''
|
font-size="9" fill="{t["text_secondary"]}" opacity="0.5">Generated with gh-stats.com</text>'''
|
||||||
return card_wrapper(inner, 380, card_h, t, "Languages")
|
return card_wrapper(inner, 380, card_h, t, "Languages")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
"""Per-widget attribution behaves correctly in both contexts.
|
"""Per-widget attribution behaves correctly in both contexts.
|
||||||
|
|
||||||
Standalone widget SVGs (served at /api/<u>/<widget>.svg) must show the
|
Standalone widget SVGs (served at /api/<u>/<widget>.svg) must show the
|
||||||
"Generated with gh-stats" footer; the composite (served at /api/<u>)
|
"Generated with gh-stats.com" footer; the composite (served at /api/<u>)
|
||||||
must strip the per-widget footer and only show its own bottom one.
|
must strip the per-widget footer and only show its own bottom one.
|
||||||
"""
|
"""
|
||||||
from src.models import GradeData, LanguageData, TagData
|
from src.models import GradeData, LanguageData, TagData
|
||||||
@@ -30,13 +30,13 @@ def _languages_fixture() -> list[LanguageData]:
|
|||||||
|
|
||||||
def test_standalone_grade_widget_has_attribution():
|
def test_standalone_grade_widget_has_attribution():
|
||||||
svg = render_grade_widget(_grade_fixture(), theme_name="dark")
|
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
|
assert 'data-gh-attribution="1"' in svg
|
||||||
|
|
||||||
|
|
||||||
def test_standalone_languages_widget_has_attribution():
|
def test_standalone_languages_widget_has_attribution():
|
||||||
svg = render_languages_widget(_languages_fixture(), theme_name="dark")
|
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
|
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
|
# The composite has exactly ONE attribution (its own). The widget's
|
||||||
# footer attribution should be gone.
|
# 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.
|
# No leftover attribution markers leaked through.
|
||||||
assert "data-gh-attribution" not in composite
|
assert "data-gh-attribution" not in composite
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ def test_composite_strips_per_widget_attribution_from_languages():
|
|||||||
avatar_b64="",
|
avatar_b64="",
|
||||||
show_name=False,
|
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
|
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
|
# Each widget contributed an attribution; the composite contributes
|
||||||
# one of its own — total visible attributions must be exactly 1.
|
# 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():
|
def test_composite_reclaims_attribution_height():
|
||||||
|
|||||||
Reference in New Issue
Block a user