mirror of https://github.com/eyhc1/rendercv.git
generate urls in python side
This commit is contained in:
parent
9abd3c9de1
commit
c9cefcf748
|
@ -680,6 +680,22 @@ class Connection(BaseModel):
|
|||
name: Literal["LinkedIn", "GitHub", "Instagram", "phone", "email", "website"]
|
||||
value: str
|
||||
|
||||
@computed_field
|
||||
@cached_property
|
||||
def url(self) -> HttpUrl:
|
||||
if self.name == "LinkedIn":
|
||||
url = f"https://www.linkedin.com/in/{self.value}"
|
||||
elif self.name == "GitHub":
|
||||
url = f"https:www.github.com/{self.value}"
|
||||
elif self.name == "Instagram":
|
||||
url = f"https://www.instagram.com/{self.value}"
|
||||
elif self.name == "email":
|
||||
url = f"mailto:{self.value}"
|
||||
elif self.name == "website":
|
||||
url = self.value
|
||||
else:
|
||||
raise RuntimeError(f'"{self.name}" is not a valid connection!"')
|
||||
|
||||
|
||||
class Section(BaseModel):
|
||||
"""This class stores a section information."""
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
\normalsize
|
||||
((* for connection in connections *))
|
||||
<<print_connections[connection.name|replace(" ", "")](connection.value)>>
|
||||
<<print_connections[connection.name|replace(" ", "")](connection.value, connection.url)>>
|
||||
((* if not loop.last *))
|
||||
\hspace{0.5cm}
|
||||
((* endif *))
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
((# Each macro in here is a link with an icon for header. #))
|
||||
((* macro LinkedIn(username) *))\href{https://www.linkedin.com/in/<<username>>}{{\small\faLinkedinIn}\hspace{0.13cm}<<username>>}((* endmacro *))
|
||||
((* macro GitHub(username) *))\href{https://www.github.com/<<username>>}{{\small\faGithub}\hspace{0.13cm}<<username>>}((* endmacro *))
|
||||
((* macro Instagram(username) *))\href{https://www.instagram.com/<<username>>}{{\small\faInstagram}\hspace{0.13cm}<<username>>}((* endmacro *))
|
||||
((* macro phone(number) *)){\footnotesize\faPhone*}\hspace{0.13cm}<<number|replace("tel:", "")|replace("-"," ")>>((* endmacro *))
|
||||
((* macro email(email) *))\href{mailto:<<email>>}{{\small\faEnvelope[regular]}\hspace{0.13cm}<<email>>}((* endmacro *))
|
||||
((* macro website(url) *))\href{<<url>>}{{\small\faLink}\hspace{0.13cm}<<url|replace("https://","")|replace("/","")>>}((* endmacro *))
|
||||
((* macro LinkedIn(username, url) *))\href{<<url>>}{{\small\faLinkedinIn}\hspace{0.13cm}<<username>>}((* endmacro *))
|
||||
((* macro GitHub(username, url) *))\href{<<url>>}{{\small\faGithub}\hspace{0.13cm}<<username>>}((* endmacro *))
|
||||
((* macro Instagram(username, url) *))\href{}{{\small\faInstagram}\hspace{0.13cm}<<username>>}((* endmacro *))
|
||||
((* macro phone(number, url) *)){\footnotesize\faPhone*}\hspace{0.13cm}<<number|replace("tel:", "")|replace("-"," ")>>((* endmacro *))
|
||||
((* macro email(email, url) *))\href{<<url>>}{{\small\faEnvelope[regular]}\hspace{0.13cm}<<email>>}((* endmacro *))
|
||||
((* macro website(url, dummy) *))\href{<<url>>}{{\small\faLink}\hspace{0.13cm}<<url|replace("https://","")|replace("/","")>>}((* endmacro *))
|
||||
|
||||
|
|
Loading…
Reference in New Issue