Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added US Formatting and new template #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions yaml_resume/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@
THEMES = {
"classic": "optional",
"material": "mandatory",
"modern": "optional"
} # optional or mandatory depending if the theme must have an profile picture

PAGE_FORMATS = {
"A4": "@page { size: A4; margin: 0cm }",
"US_Letter": "@page { size: letter; margin: .5in }"
}

def no_tag(self, *args, **kw):
"""Drop tag in yaml.dump()
Expand Down Expand Up @@ -106,7 +111,14 @@ def validate(filename):
)
@click.option("-i", "--image", default=None, help="Portrait to include in the resume.")
@click.option("-o", "--output", default="resume", help="Name of the file to write.")
def export(filename, theme, extension, image, output):
@click.option(
"-pt",
"--page-type",
default="A4",
type=click.Choice(PAGE_FORMATS),
help="Page Type: A4 or 8.5\"x11\""
)
def export(filename, theme, extension, image, output, page_type):
"""cli subcommand to export a YAML resume to HTML or PDF

This function is a subcommand of yaml-resume.
Expand All @@ -117,7 +129,13 @@ def export(filename, theme, extension, image, output):
:type filename: str
:param theme: The name of the theme to use.
:type theme: str
:param format: The format of the exported data.
:param extension: The format of the exported data.
:type format: str
:param image: Path to Resume Image
:type format: str
:param output: Output filename
:type format: str
:param page: Page Type
:type format: str
:raises: ClickException

Expand Down Expand Up @@ -146,7 +164,7 @@ def export(filename, theme, extension, image, output):
outfile.close()
else:
html = HTML(string=template.render(resume=resume, image=image))
css = CSS(string="@page { size: A4; margin: 0cm }")
css = CSS(string=PAGE_FORMATS[page_type])
html.write_pdf("{}.{}".format(output, extension), stylesheets=[css])


Expand Down
2 changes: 2 additions & 0 deletions yaml_resume/resume/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ def ask():
if click.confirm("Do you want to add a Projects section?", default=False):
print("## Projects ##")
projects = Project.ask()
else:
projects = []
print("## Hobbies ##")
hobbies = Hobby.ask()
return Resume(
Expand Down
48 changes: 48 additions & 0 deletions yaml_resume/templates/modern.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
* {
font-family: Montserrat;
}

.header {
text-align: center;
width: 100%;
}

.header h1,h2 {
display: block;
}

.header h2 {
font-weight: 200;
}

.details {
text-align: center;
}

.details ul > li {
display: inline-block
}

.details li:not(:first-child)::before {
content: '| '
}

h3 .date {
font-weight: 100;
}

.experience h4 {
font-weight: 100;
font-style: italic;
}

.education h4 {
font-weight: 100;
font-style: italic;
}

.tags {
font-size: 10pt;
color: #999;
padding-bottom: 5px;
}
74 changes: 74 additions & 0 deletions yaml_resume/templates/modern.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{ resume.contact.name }}'s Resume</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500&display=swap" rel="stylesheet">
<link href="modern.css" rel="stylesheet">
<style type="text/css">{% include "modern.css" %}</style>
</head>
<body>
<div class="header">
<h1>{{ resume.contact.name }}</h1>
<h2>{{ resume.contact.job }}</h2>
</div>
<hr>
<div class="details">
<ul>
<li>{{ resume.contact.phone }}</li>
<li>{{ resume.contact.email }}</li>
<li>{{ resume.contact.location.address }}, {{ resume.contact.location.city }}{% if resume.contact.location.zip %}, {{ resume.contact.location.zip }}{% endif %}{% if resume.contact.location.country %}, {{ resume.contact.location.country }}{% endif %}</li>
</ul>
<ul>
{% for p in resume.profiles %}
<li>{{ p.network }}: <a href="{{ p.url }}">{{ p.url }}</a></li>
{% endfor %}
</ul>
{% if resume.contact.summary %}
<b>{{ resume.contact.summary }}</b>
{% endif %}
</div>
<br>
<div>
<h2>Experience</h2>
{% for e in resume.experiences %}
<div class="experience">
<h3>{{ e.company }} | <span class="date">{{ e.start_date }} - {% if not e.end_date %}Present{% else %}{{ e.end_date }}{% endif %}</span></h3>
<h4>{{ e.position }}</h4>
<ul>{% for line in e.summary.split('\n')[:-1] %}<li>{{ line }}</li>{% endfor %}</ul>
{% if e.tags %}<div class="tags">-{% for tag in e.tags %} {{ tag }} -{% endfor %}</div>{% endif %}
</div>
{% endfor %}
</div>
<br>
<div>
<h2>Education</h2>
{% for e in resume.education %}
<div class="education">
<h3>{{ e.institution }} | <span class="date">{{ e.start_date }} - {% if not e.end_date %}Present{% else %}{{ e.end_date }}{% endif %}</span></h3>
<h4>{{ e.degree }}</h4>
</div>
{% endfor %}
</div>
<br>
<div>
<h2>Skills</h2>
{% if resume.skills|selectattr('level', 'gt', 50)|list|length %}
<h4>Proficient</h4>
<ul>
{% for s in resume.skills|selectattr('level', 'gt', 50)|sort(attribute='level') %}
<li>{{ s.name }}</li>
{% endfor %}
</ul>
{% endif %}
{% if resume.skills|selectattr('level', 'le', 50)|list|length %}
<h4>Known</h4>
<ul>
{% for s in resume.skills|selectattr('level', 'le', 50)|sort(attribute='level') %}
<li>{{ s.name }}</li>
{% endfor %}
</ul>
{% endif %}
</div>
<br>
</body>
</html>