Skip to content

Commit

Permalink
Merge pull request #85 from adinhodovic/bump-weasyprint
Browse files Browse the repository at this point in the history
chore: Bump weasyprint
  • Loading branch information
adinhodovic committed Apr 30, 2024
2 parents a8dd4d5 + 401819e commit 7155d4a
Show file tree
Hide file tree
Showing 7 changed files with 343 additions and 97 deletions.
355 changes: 293 additions & 62 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "poetry.core.masonry.api"
name = "wagtail-resume"
authors = ["Adin Hodovic <hodovicadin@gmail.com>"]
license = "MIT"
version = "2.7.2"
version = "2.8.0"
readme = "README.md"
homepage = "https://github.com/adinhodovic/wagtail-resume"
repository = "https://github.com/adinhodovic/wagtail-resume"
Expand All @@ -31,15 +31,16 @@ classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]

[tool.poetry.dependencies]
python = "^3.10 || ^3.11"
python = "^3.10 || ^3.11 || 3.12"
Django = "^3.2.0 || ^4.0.0 || ^5.0.0"
wagtail = "^4.0.0 || ^5.0.0 || ^6.0.0"
wagtail-markdown = "^0.10 || ^0.11"
wagtail-markdown = "^0.10 || ^0.11 || ^0.12 || ^0.13"
wagtail-metadata = "^4.0.0 || ^5.0.0"
weasyprint = "^52"
weasyprint = "^59 || ^60 || ^61"

[tool.poetry.group.dev.dependencies]
black = "^22.6.0"
Expand Down
16 changes: 10 additions & 6 deletions wagtail_resume/static/wagtail_resume/css/resume_page.css
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ a {
display: None;
}

@media (min-width: 768px) {
.personal-info {
align-items: center;
display: flex;
justify-content: space-between;
}
.personal-info {
align-items: center;
display: flex;
justify-content: space-between;
}

@media (min-width: 768px) {
.resume {
padding: 4rem 3rem;
width: 80%;
Expand Down Expand Up @@ -173,6 +173,10 @@ a {
padding: 1.5rem;
}

.personal-info {
display: block;
}

.photo {
width: 45%;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@ <h2 class="mt-4 mb-0">
<ul>
{% for contribution in value.contributions %}
<li>
<a href="{{ contribution.url }}">
<h3>{{ contribution.title }}</h3>
</a>
<p>{{ contribution.description }}</p>
<a href="{{ contribution.url }}"><b>{{ contribution.title }}</b></a>
<p class="mt-1">{{ contribution.description }}</p>
</li>
{% endfor %}
</ul>
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
{% load wagtailcore_tags %}

<h2 class="mt-4 mb-0">
{% if value.fa_icon %}<i class="{{ value.fa_icon }}"></i>{% endif %}
{% if value.fa_icon %}<i class="{{ value.fa_icon }} mr-2"></i>{% endif %}
<span>{{ value.heading }}</span>
</h2>
<hr />
{% for post in value.posts %}
<ul>
<ul>
{% for post in value.posts %}
<li>
{% if post.block_type == "external_post" %}
<a href="{{ post.value.url }}">{{ post.value.title }}</a>
<a href="{{ post.value.url }}"><b>{{ post.value.title }}</b></a>
<p class="date mt-1">{{ post.value.date }}</p>
{% else %}
{% with post.value.post as internal_post %}
<a href="{{ internal_post.url }}">{{ internal_post.title }}</a>
<a href="{{ internal_post.url }}"><b>{{ internal_post.title }}</b></a>
<p class="date mt-1">{{ internal_post.first_published_at|date:"M. d, Y" }}</p>
{% endwith %}
{% endif %}
</li>
</ul>
{% endfor %}
{% endfor %}
</ul>
13 changes: 8 additions & 5 deletions wagtail_resume/templates/wagtail_resume/resume_page_head.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
{% load wagtail_resume_extras %}

<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css" />
<link href="https://fonts.googleapis.com/css?family={% if page.font %}{{ page.font|title|space_to_plus }}|{% endif %}Roboto+Condensed&display=swap" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{% static 'wagtail_resume/css/resume_page.css' %}" />
<meta name="viewport" content="width=device-width, initial-scale=1">

<link rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css" />
<link href="https://fonts.googleapis.com/css?family={% if page.font %}{{ page.font|title|space_to_plus }}|{{ page.font|title|space_to_plus }}:bold,bolditalic:italic|{% endif %}Roboto|Roboto+Condensed:bold,bolditalic,italic&display=swap"
rel="stylesheet" />
<link rel="stylesheet"
type="text/css"
href="{% static 'wagtail_resume/css/resume_page.css' %}" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
{% meta_tags %}
</head>
27 changes: 18 additions & 9 deletions wagtail_resume/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,28 @@ def resume_pdf(request):

resume_url = specific.full_url
name = slugify(specific.full_name)
date = datetime.datetime.now().strftime("%Y-%m-%d")
if resume.latest_revision_created_at:
resume_date = resume.latest_revision_created_at
else:
resume_date = datetime.datetime.now()
date = resume_date.strftime("%Y-%m-%d")
font = specific.font

response["Content-Disposition"] = f"inline; filename={name}-resume-{date}.pdf"
if font:
font = space_to_plus(font).title()
HTML(url=resume_url).write_pdf(
response,
stylesheets=[
# pylint: disable=line-too-long
f"https://fonts.googleapis.com/css2?family={font}&display=swap"
],
)
full_font = f"{font}:bold|{font}:bold,bolditalic,italic"
else:
HTML(url=resume_url).write_pdf(response)
full_font = "Roboto+Condensed|Roboto+Condensed:bold,bolditalic,italic"

print(full_font)
HTML(url=resume_url).write_pdf(
response,
stylesheets=[
# pylint: disable=line-too-long
# We use the default CSS API from Google Fonts to load the font
# CSS2 requires boldness specification for bold fonts
f"https://fonts.googleapis.com/css?family={full_font}&display=swap",
],
)
return response

0 comments on commit 7155d4a

Please sign in to comment.