mirror of https://github.com/eyhc1/rendercv.git
data_models: improve mastodon links
This commit is contained in:
parent
9331fe8f21
commit
905b7a360a
|
@ -821,8 +821,8 @@ class SocialNetwork(RenderCVBaseModel):
|
||||||
if network == "Mastodon":
|
if network == "Mastodon":
|
||||||
if not username.startswith("@"):
|
if not username.startswith("@"):
|
||||||
raise ValueError("Mastodon username should start with '@'!")
|
raise ValueError("Mastodon username should start with '@'!")
|
||||||
if username.count("@") > 2:
|
if username.count("@") != 2:
|
||||||
raise ValueError("Mastodon username should contain only two '@'!")
|
raise ValueError("Mastodon username should contain two '@'!")
|
||||||
|
|
||||||
return username
|
return username
|
||||||
|
|
||||||
|
@ -838,12 +838,16 @@ class SocialNetwork(RenderCVBaseModel):
|
||||||
@functools.cached_property
|
@functools.cached_property
|
||||||
def url(self) -> str:
|
def url(self) -> str:
|
||||||
"""Return the URL of the social network."""
|
"""Return the URL of the social network."""
|
||||||
|
if self.network == "Mastodon":
|
||||||
|
# split domain and username
|
||||||
|
dummy, username, domain = self.username.split("@")
|
||||||
|
url = f"https://{domain}/@{username}"
|
||||||
|
else:
|
||||||
url_dictionary = {
|
url_dictionary = {
|
||||||
"LinkedIn": "https://linkedin.com/in/",
|
"LinkedIn": "https://linkedin.com/in/",
|
||||||
"GitHub": "https://github.com/",
|
"GitHub": "https://github.com/",
|
||||||
"Instagram": "https://instagram.com/",
|
"Instagram": "https://instagram.com/",
|
||||||
"Orcid": "https://orcid.org/",
|
"Orcid": "https://orcid.org/",
|
||||||
"Mastodon": "https://mastodon.social/",
|
|
||||||
"Twitter": "https://twitter.com/",
|
"Twitter": "https://twitter.com/",
|
||||||
}
|
}
|
||||||
url = url_dictionary[self.network] + self.username
|
url = url_dictionary[self.network] + self.username
|
||||||
|
|
Loading…
Reference in New Issue