From 6a08e03a1a503b13ec0f14c736c31a397e688f88 Mon Sep 17 00:00:00 2001 From: Prithaj Nath Date: Thu, 23 May 2024 01:18:53 -0400 Subject: [PATCH 1/2] Add StackOverflow to list of social networks --- rendercv/data_models.py | 31 ++++++++++++++++++++++--------- tests/test_data_models.py | 5 +++++ 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/rendercv/data_models.py b/rendercv/data_models.py index a341658..9e78927 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -831,7 +831,13 @@ class SocialNetwork(RenderCVBaseModel): """This class is the data model of a social network.""" network: Literal[ - "LinkedIn", "GitHub", "Instagram", "Orcid", "Mastodon", "Twitter" + "LinkedIn", + "GitHub", + "Instagram", + "Orcid", + "Mastodon", + "Twitter", + "StackOverflow", ] = pydantic.Field( title="Social Network", description="The social network name.", @@ -871,6 +877,9 @@ class SocialNetwork(RenderCVBaseModel): # split domain and username dummy, username, domain = self.username.split("@") url = f"https://{domain}/@{username}" + elif self.network == "StackOverflow": + user_id, username = self.username.split("/") + url = f"https://stackoverflow.com/users/{user_id}/{username}" else: url_dictionary = { "LinkedIn": "https://linkedin.com/in/", @@ -983,18 +992,22 @@ class CurriculumVitae(RenderCVBaseModel): "Instagram": "\\faInstagram", "Mastodon": "\\faMastodon", "Orcid": "\\faOrcid", + "StackOverflow": "\\faStackOverflow", "Twitter": "\\faTwitter", } for social_network in self.social_networks: clean_url = social_network.url.replace("https://", "").rstrip("/") - connections.append( - { - "latex_icon": icon_dictionary[social_network.network], - "url": social_network.url, - "clean_url": clean_url, - "placeholder": social_network.username, - } - ) + connection = { + "latex_icon": icon_dictionary[social_network.network], + "url": social_network.url, + "clean_url": clean_url, + "placeholder": social_network.username, + } + + if social_network.network == "StackOverflow": + username = social_network.username.split("/")[1] + connection["placeholder"] = username + connections.append(connection) return connections diff --git a/tests/test_data_models.py b/tests/test_data_models.py index e30a1f1..a1708b4 100644 --- a/tests/test_data_models.py +++ b/tests/test_data_models.py @@ -426,6 +426,11 @@ def test_invalid_social_networks(network, username): ("Orcid", "myusername", "https://orcid.org/myusername"), ("Twitter", "myusername", "https://twitter.com/myusername"), ("Mastodon", "@myusername@test.org", "https://test.org/@myusername"), + ( + "StackOverflow", + "4567/myusername", + "https://stackoverflow.com/users/4567/myusername", + ), ], ) def test_social_network_url(network, username, expected_url): From c537cb28bfdea7eef615b8c9fb102b67276bf877 Mon Sep 17 00:00:00 2001 From: enqueueDequeue <53048965+enqueueDequeue@users.noreply.github.com> Date: Fri, 24 May 2024 20:08:22 -0500 Subject: [PATCH 2/2] Adds GitLab social network --- rendercv/data_models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rendercv/data_models.py b/rendercv/data_models.py index 9e78927..0c85a7a 100644 --- a/rendercv/data_models.py +++ b/rendercv/data_models.py @@ -833,6 +833,7 @@ class SocialNetwork(RenderCVBaseModel): network: Literal[ "LinkedIn", "GitHub", + "GitLab", "Instagram", "Orcid", "Mastodon", @@ -884,6 +885,7 @@ class SocialNetwork(RenderCVBaseModel): url_dictionary = { "LinkedIn": "https://linkedin.com/in/", "GitHub": "https://github.com/", + "GitLab": "https://gitlab.com/", "Instagram": "https://instagram.com/", "Orcid": "https://orcid.org/", "Twitter": "https://twitter.com/", @@ -989,6 +991,7 @@ class CurriculumVitae(RenderCVBaseModel): icon_dictionary = { "LinkedIn": "\\faLinkedinIn", "GitHub": "\\faGithub", + "GitLab": "\\faGitlab", "Instagram": "\\faInstagram", "Mastodon": "\\faMastodon", "Orcid": "\\faOrcid",