From bae8169bad91a26994a8c4f9793affdc6a2a029c Mon Sep 17 00:00:00 2001 From: Laura Hayes Date: Wed, 27 Nov 2024 23:19:47 +0100 Subject: [PATCH] Adding avatars as defult (#277) Co-authored-by: Nabil Freij --- .pre-commit-config.yaml | 2 +- docs/cards.rst | 1 - src/sunpy_sphinx_theme/cards.py | 7 ++++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70798112..36bc8b81 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: "--remove-unused-variable", ] - repo: https://github.com/PyCQA/docformatter - rev: v1.7.5 + rev: master hooks: - id: docformatter args: ["--make-summary-multi-line", "--pre-summary-newline", "-ri"] diff --git a/docs/cards.rst b/docs/cards.rst index 8651f89a..4819b1b9 100644 --- a/docs/cards.rst +++ b/docs/cards.rst @@ -18,7 +18,6 @@ Cards Stuart Mumford is the Python developer for the Daniel K. Inouye Solar Telescope Data Centre. He obtained a PhD in Numerical solar physics from Sheffield University in 2016, prior to his PhD he obtained a first class MPhys degree in Physics with Planetary and Space Physics from The University of Wales Aberystwyth, during which he spent 5 months studying at UNIS on Svalbard in the high arctic. .. custom-card:: Stuart Mumford and Sons - :img_name: _static/img/Stuart-Mumford.png :github: cadair :title: Lead Lead Lead Lead Lead Lead Developer :aff_name: Sheffield University diff --git a/src/sunpy_sphinx_theme/cards.py b/src/sunpy_sphinx_theme/cards.py index d19bd942..95735e7f 100644 --- a/src/sunpy_sphinx_theme/cards.py +++ b/src/sunpy_sphinx_theme/cards.py @@ -22,10 +22,15 @@ def visit_card_node(self, node) -> None: key = key.lower().replace(" ", "-") title = f"

{title}

" if len(title) > 0 else "" col_extra_class = "column-half" if title else "" + img_src = node.get("img_name") + # If there is no "img_name" given, we fallback to using the github avatar + # if a user handle is provided. If so, the image provided is actually the sunpy icon + if img_src == "sunpy_icon.svg" and node.get("github") is not None: + img_src = f"https://github.com/{node['github']}.png" body = f"""
{title}
- {node['name']} + {node['name']}

{node['name']}