From efdedf9c540e3856ec1348ef5a45ab21af9bd22a Mon Sep 17 00:00:00 2001 From: Guillaume Ayoub Date: Tue, 22 Oct 2024 00:18:00 +0200 Subject: [PATCH] Add PDF schedule --- Makefile | 2 +- pyconfr.py | 8 ++++- static/sass/style.sass | 54 +++++++++++++++++++++++++++++++ templates/en/schedule.jinja2.html | 7 ++-- templates/fr/schedule.jinja2.html | 7 ++-- 5 files changed, 70 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 8038bca..bbce75c 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ .venv: python3 -m venv .venv - .venv/bin/pip install setuptools frozen-flask flask libsass markdown2 python-slugify babel + .venv/bin/pip install setuptools frozen-flask flask flask-weasyprint libsass markdown2 python-slugify babel install: .venv diff --git a/pyconfr.py b/pyconfr.py index 1ba0806..dec8531 100644 --- a/pyconfr.py +++ b/pyconfr.py @@ -3,8 +3,9 @@ from babel.dates import format_date, format_time, format_timedelta from datetime import date, time, timedelta -from flask import Flask, Response, render_template +from flask import Flask, Response, render_template, url_for from flask_frozen import Freezer +from flask_weasyprint import render_pdf from markdown2 import Markdown from sassutils.wsgi import SassMiddleware from slugify import slugify @@ -98,6 +99,11 @@ def schedule(lang): schedule=SCHEDULE) +@app.route('/2024//full-schedule.pdf') +def pdf_schedule(lang): + return render_pdf(url_for('schedule', lang=lang)) + + @app.route('/2024//calendar.ics') def calendar(lang): ics = render_template('calendar.jinja2.ics', lang=lang, schedule=SCHEDULE) diff --git a/static/sass/style.sass b/static/sass/style.sass index 35cbf06..516fb50 100644 --- a/static/sass/style.sass +++ b/static/sass/style.sass @@ -910,3 +910,57 @@ main float: none margin: 0 width: 100% + + +// Print + +@media print + @page + margin: 1.35cm 1.5cm + size: A4 landscape + + #full-schedule + background: none + + table + border-spacing: 0 + font-size: 8pt + + thead + height: auto + text-align: center + top: 0 + + th:not(:empty) + background: $purple + + &.rooms + tr > :first-child::before + content: none + + &.day + th + padding-bottom: 0 + transform: translate(0 -4em) + + tr:not(:last-child) + height: 6em + + tr:has([href$="#talk-MRHUVD"]) + tr, + tr:has(#sunday-lunch) + tr + height: 0 !important + + td + border-bottom: 1px solid $grey + border-top: 1px solid $grey + border-right: 1px solid $grey + line-height: 1.15 + padding: 0.5em 0.5em 2.5em 0.5em + + .extra div + background: none !important + color: inherit + height: 4em !important + justify-content: flex-start + padding-left: 0.25em + width: 100% diff --git a/templates/en/schedule.jinja2.html b/templates/en/schedule.jinja2.html index 0d85ca5..29c3562 100644 --- a/templates/en/schedule.jinja2.html +++ b/templates/en/schedule.jinja2.html @@ -70,9 +70,10 @@

Keynotes

Calendar

- The calendar is available below, in a - fullscreen page, or - in your favourite calendar application. + The calendar is available below, + in a fullscreen page, + in PDF format, + or in your favourite calendar application.

You can read the description of diff --git a/templates/fr/schedule.jinja2.html b/templates/fr/schedule.jinja2.html index 2889e82..58b92cb 100644 --- a/templates/fr/schedule.jinja2.html +++ b/templates/fr/schedule.jinja2.html @@ -69,9 +69,10 @@

Keynotes

Calendrier

- Le calendrier est disponible ci-dessous, sur une - page en plein écran, - ou dans votre application de calendrier favorite. + Le calendrier est disponible ci-dessous, + sur une page en plein écran, + en format PDF, + ou dans votre application de calendrier favorite.

Vous pouvez également lire la description des