add location to the heading

This commit is contained in:
Sina Atalay 2023-10-07 17:59:13 +02:00
parent 41af11638d
commit 7e47e0bd94
2 changed files with 36 additions and 11 deletions

View File

@ -81,7 +81,7 @@ def check_spelling(sentence: str) -> str:
r"\-+", " ", modifiedSentence r"\-+", " ", modifiedSentence
) # replace hyphens with spaces ) # replace hyphens with spaces
modifiedSentence = re.sub( modifiedSentence = re.sub(
"[^a-z\s\-']", "", modifiedSentence r"[^a-z\s\-']", "", modifiedSentence
) # remove all the special characters ) # remove all the special characters
words = modifiedSentence.split() # split sentence into a list of words words = modifiedSentence.split() # split sentence into a list of words
misspelled = spell.unknown(words) # find misspelled words misspelled = spell.unknown(words) # find misspelled words
@ -777,14 +777,14 @@ class SocialNetwork(BaseModel):
class Connection(BaseModel): class Connection(BaseModel):
"""This class stores a connection/communication information. r"""This class stores a connection/communication information.
Warning: Warning:
This class isn't designed for users to use, but it is used by RenderCV to make This class isn't designed for users to use, but it is used by RenderCV to make
the $\LaTeX$ templating easier. the $\LaTeX$ templating easier.
""" """
name: Literal["LinkedIn", "GitHub", "Instagram", "phone", "email", "website"] name: Literal["LinkedIn", "GitHub", "Instagram", "phone", "email", "website", "location"]
value: str value: str
@computed_field @computed_field
@ -802,6 +802,8 @@ class Connection(BaseModel):
url = f"{self.value}" url = f"{self.value}"
elif self.name == "phone": elif self.name == "phone":
url = f"{self.value}" url = f"{self.value}"
elif self.name == "location":
url = None
else: else:
raise RuntimeError(f'"{self.name}" is not a valid connection!"') raise RuntimeError(f'"{self.name}" is not a valid connection!"')
@ -945,6 +947,8 @@ class CurriculumVitae(BaseModel):
@cached_property @cached_property
def connections(self) -> list[str]: def connections(self) -> list[str]:
connections = [] connections = []
if self.location is not None:
connections.append(Connection(name="location", value=self.location))
if self.phone is not None: if self.phone is not None:
connections.append(Connection(name="phone", value=self.phone)) connections.append(Connection(name="phone", value=self.phone))
if self.email is not None: if self.email is not None:
@ -1015,8 +1019,9 @@ class CurriculumVitae(BaseModel):
# Find the corresponding custom section and get its entries: # Find the corresponding custom section and get its entries:
if self.custom_sections is None: if self.custom_sections is None:
raise ValueError( raise ValueError(
f'"{section_name}" is not a valid section name. Please fix the' f'"{section_name}" is not a valid section name. Please create a'
" section_order field." " custom section with this name or delete it from the section"
" order."
) )
else: else:
for custom_section in self.custom_sections: for custom_section in self.custom_sections:

View File

@ -1,8 +1,28 @@
((# Each macro in here is a link with an icon for header. #)) ((# Each macro in here is a link with an icon for header. #))
((* macro LinkedIn(username, url) *))\href{<<url>>}{{\small\faLinkedinIn}\hspace{0.13cm}<<username>>}((* endmacro *)) ((* macro LinkedIn(username, url) -*))
((* macro GitHub(username, url) *))\href{<<url>>}{{\small\faGithub}\hspace{0.13cm}<<username>>}((* endmacro *)) \mbox{\href{<<url>>}{{\small\faLinkedinIn}\hspace{0.13cm}<<username>>}}
((* macro Instagram(username, url) *))\href{}{{\small\faInstagram}\hspace{0.13cm}<<username>>}((* endmacro *)) ((*- endmacro *))
((* macro phone(number, url) *))\href{<<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 *))
((* macro GitHub(username, url) -*))
\mbox{\href{<<url>>}{{\small\faGithub}\hspace{0.13cm}<<username>>}}
((*- endmacro *))
((* macro Instagram(username, url) -*))
\mbox{\href{}{{\small\faInstagram}\hspace{0.13cm}<<username>>}}
((*- endmacro *))
((* macro phone(number, url) -*))
\mbox{{\footnotesize\faPhone*}\hspace{0.13cm}<<number|replace("tel:", "")|replace("-"," ")>>}
((*- endmacro *))
((* macro email(email, url) -*))
\mbox{\href{<<url>>}{{\small\faEnvelope[regular]}\hspace{0.13cm}<<email>>}}
((*- endmacro *))
((* macro website(url, dummy) -*))
\mbox{\href{<<url>>}{{\small\faLink}\hspace{0.13cm}<<url|replace("https://","")|replace("/","")>>}}
((*- endmacro *))
((* macro location(location, url) -*))
\mbox{{\small\faMapMarker*}\hspace{0.13cm}<<location>>}
((*- endmacro *))