From 3df105b94321b9870a4ce5a4b590e8f50870c6d8 Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Mon, 23 Oct 2023 18:26:57 +0200 Subject: [PATCH] add Orcid support --- rendercv/data_model.py | 23 +++++++++---------- .../components/header_connections.tex.j2 | 4 ++++ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/rendercv/data_model.py b/rendercv/data_model.py index 958ed23..040f645 100644 --- a/rendercv/data_model.py +++ b/rendercv/data_model.py @@ -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": diff --git a/rendercv/templates/classic/components/header_connections.tex.j2 b/rendercv/templates/classic/components/header_connections.tex.j2 index 0da8719..b51bf41 100644 --- a/rendercv/templates/classic/components/header_connections.tex.j2 +++ b/rendercv/templates/classic/components/header_connections.tex.j2 @@ -11,6 +11,10 @@ \mbox{\href{<>}{{\small\faInstagram}\hspace{0.13cm}<>}} ((*- endmacro *)) +((* macro Orcid(username, url) -*)) +\mbox{\href{<>}{{\small\faOrcid}\hspace{0.13cm}<>}} +((*- endmacro *)) + ((* macro phone(number, url) -*)) \mbox{\href{<>}{{\footnotesize\faPhone*}\hspace{0.13cm}<>}} ((*- endmacro *))