Skip to content

Commit

Permalink
generate urls in python side
Browse files Browse the repository at this point in the history
  • Loading branch information
sinaatalay committed Sep 16, 2023
1 parent 9bacd5c commit fc376d4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
16 changes: 16 additions & 0 deletions rendercv/data_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion rendercv/templates/components/classic/header.tex.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 *))
Expand Down
12 changes: 6 additions & 6 deletions rendercv/templates/components/classic/header_connections.tex.j2
Original file line number Diff line number Diff line change
@@ -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 *))

0 comments on commit fc376d4

Please sign in to comment.