mirror of https://github.com/eyhc1/rendercv.git
Merge pull request #77 from prithajnath/prithajnath/add_stackoverflow_support
add StackOverflow to the list of social networks
This commit is contained in:
commit
17f7854b7d
|
@ -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(
|
||||
{
|
||||
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
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue