add Orcid support

This commit is contained in:
Sina Atalay 2023-10-23 18:26:57 +02:00
parent 571260f2dd
commit 3df105b943
2 changed files with 15 additions and 12 deletions

View File

@ -934,7 +934,7 @@ class SocialNetwork(BaseModel):
Currently, only LinkedIn, Github, and Instagram are supported.
"""
network: Literal["LinkedIn", "GitHub", "Instagram"] = Field(
network: Literal["LinkedIn", "GitHub", "Instagram", "Orcid"] = Field(
title="Social Network",
description="The social network name.",
)
@ -953,20 +953,17 @@ class Connection(BaseModel):
"""
name: Literal[
"LinkedIn", "GitHub", "Instagram", "phone", "email", "website", "location"
"LinkedIn",
"GitHub",
"Instagram",
"Orcid",
"phone",
"email",
"website",
"location",
]
value: str
@field_validator("value")
@classmethod
def check_type_of_value(cls, value: str) -> str:
if not re.search(r"[^\d\-+]", str(value)):
# If there is nothing other than digits, hyphens, and plus signs, then it is
# a phone number
value = "tel:" + value
return value
@computed_field
@cached_property
def url(self) -> Optional[HttpUrl | str]:
@ -976,6 +973,8 @@ class Connection(BaseModel):
url = f"https://www.github.com/{self.value}"
elif self.name == "Instagram":
url = f"https://www.instagram.com/{self.value}"
elif self.name == "Orcid":
url = f"https://orcid.org/{self.value}"
elif self.name == "email":
url = f"mailto:{self.value}"
elif self.name == "website":

View File

@ -11,6 +11,10 @@
\mbox{\href{<<url>>}{{\small\faInstagram}\hspace{0.13cm}<<username>>}}
((*- endmacro *))
((* macro Orcid(username, url) -*))
\mbox{\href{<<url>>}{{\small\faOrcid}\hspace{0.13cm}<<username>>}}
((*- endmacro *))
((* macro phone(number, url) -*))
\mbox{\href{<<url|replace("-","")>>}{{\footnotesize\faPhone*}\hspace{0.13cm}<<number|replace("tel:", "")|replace("-"," ")>>}}
((*- endmacro *))