mirror of https://github.com/eyhc1/rendercv.git
WIP: start on mastodon
This commit is contained in:
parent
6e34ff524d
commit
1169a76654
|
@ -1036,7 +1036,7 @@ class SocialNetwork(BaseModel):
|
||||||
Currently, only LinkedIn, Github, and Instagram are supported.
|
Currently, only LinkedIn, Github, and Instagram are supported.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
network: Literal["LinkedIn", "GitHub", "Instagram", "Orcid"] = Field(
|
network: Literal["LinkedIn", "GitHub", "Instagram", "Orcid", "Mastodon"] = Field(
|
||||||
title="Social Network",
|
title="Social Network",
|
||||||
description="The social network name.",
|
description="The social network name.",
|
||||||
)
|
)
|
||||||
|
@ -1059,6 +1059,7 @@ class Connection(BaseModel):
|
||||||
"GitHub",
|
"GitHub",
|
||||||
"Instagram",
|
"Instagram",
|
||||||
"Orcid",
|
"Orcid",
|
||||||
|
"Mastodon",
|
||||||
"phone",
|
"phone",
|
||||||
"email",
|
"email",
|
||||||
"website",
|
"website",
|
||||||
|
@ -1066,6 +1067,21 @@ class Connection(BaseModel):
|
||||||
]
|
]
|
||||||
value: str
|
value: str
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def MastodonUname2Url(uname: str) ->Optional[HttpUrl]:
|
||||||
|
"""From a Mastodon-style "user@domain.example" returns profile url."""
|
||||||
|
|
||||||
|
# The closest thing to a formal spec of Mastodon usernames
|
||||||
|
# where these regular expressions from a (reference?)
|
||||||
|
# implementation
|
||||||
|
#
|
||||||
|
# https://github.com/mastodon/mastodon/blob/852123867768e23410af5bd07ac0327bead0d9b2/app/models/account.rb#L68
|
||||||
|
#
|
||||||
|
# SERNAME_RE = /[a-z0-9_]+([a-z0-9_.-]+[a-z0-9_]+)?/i
|
||||||
|
# MENTION_RE = %r{(?<![=/[:word:]])@((#{USERNAME_RE})(?:@[[:word:].-]+[[:word:]]+)?)}i
|
||||||
|
# URL_PREFIX_RE = %r{\Ahttp(s?)://[^/]+}
|
||||||
|
|
||||||
|
|
||||||
@computed_field
|
@computed_field
|
||||||
@cached_property
|
@cached_property
|
||||||
def url(self) -> Optional[HttpUrl | str]:
|
def url(self) -> Optional[HttpUrl | str]:
|
||||||
|
@ -1077,6 +1093,8 @@ class Connection(BaseModel):
|
||||||
url = f"https://www.instagram.com/{self.value}"
|
url = f"https://www.instagram.com/{self.value}"
|
||||||
elif self.name == "Orcid":
|
elif self.name == "Orcid":
|
||||||
url = f"https://orcid.org/{self.value}"
|
url = f"https://orcid.org/{self.value}"
|
||||||
|
elif self.name == "Mastodon":
|
||||||
|
url = MastodonUname2Url(self.value)
|
||||||
elif self.name == "email":
|
elif self.name == "email":
|
||||||
url = f"mailto:{self.value}"
|
url = f"mailto:{self.value}"
|
||||||
elif self.name == "website":
|
elif self.name == "website":
|
||||||
|
|
|
@ -1532,7 +1532,8 @@
|
||||||
"LinkedIn",
|
"LinkedIn",
|
||||||
"GitHub",
|
"GitHub",
|
||||||
"Instagram",
|
"Instagram",
|
||||||
"Orcid"
|
"Orcid",
|
||||||
|
"Mastodon"
|
||||||
],
|
],
|
||||||
"title": "Social Network",
|
"title": "Social Network",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
|
Loading…
Reference in New Issue