Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
grewn0uille committed Oct 4, 2023
0 parents commit 9ebeef1
Show file tree
Hide file tree
Showing 41 changed files with 2,636 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
build
.venv
__pycache__
*.css
*.css.map
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.venv:
python3 -m venv .venv
.venv/bin/pip install frozen-flask libsass markdown2 beautifulsoup4 icalendar python-slugify

install: .venv

static: .venv
FLASK_APP=pyconfr.py .venv/bin/flask freeze

serve: .venv
@echo -e "\nHome page available at \033[0;32mhttp://localhost:5000/\033[0m\n"
FLASK_APP=pyconfr.py FLASK_DEBUG=1 .venv/bin/flask run

serve-static: .venv
@echo -e "\nHome page available at \033[0;33mhttp://localhost:8000/index.html\033[0m\n"
.venv/bin/python -m http.server 8000 -d build

deploy: static
rsync -vazh --delete build/2024/ [email protected]:/var/www/pycon.fr/2024/

clean:
rm -rf build .venv __pycache__

.PHONY: install static serve serve-static deploy clean
114 changes: 114 additions & 0 deletions pyconfr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
from urllib.request import urlopen
from xml.etree import ElementTree

from bs4 import BeautifulSoup
from flask import Flask, Response, render_template, url_for
from flask_frozen import Freezer
from icalendar import Calendar
from markdown2 import Markdown
from sassutils.wsgi import SassMiddleware
from slugify import slugify

app = Flask(__name__, static_url_path='/2024/static')
app.wsgi_app = SassMiddleware(app.wsgi_app, {
'pyconfr': {
'sass_path': 'static/sass',
'css_path': 'static/css',
'wsgi_path': '/2024/static/css',
'strip_extension': True}})


@app.template_filter()
def slug(string):
return slugify(string, max_length=30)


@app.route('/')
@app.route('/2024/')
@app.route('/2024/<lang>/<name>.html')
def page(name='index', lang='fr'):
return render_template(
f'{lang}/{name}.jinja2.html', page_name=name, lang=lang)


@app.route('/2024/<lang>/talks/<category>.html')
def talks(lang, category):
talks = []
with urlopen('https://cfp-2024.pycon.fr/schedule/xml/') as fd:
tree = ElementTree.fromstring(fd.read().decode('utf-8'))
for day in tree.findall('.//day'):
for event in day.findall('.//event'):
talk = {child.tag: child.text for child in event}
talk['person'] = ', '.join(
person.text for person in event.findall('.//person'))
talk['id'] = event.attrib['id']
talk['day'] = day.attrib['date']
if talk['type'] != category:
continue
if 'description' in talk:
talk['description'] = Markdown().convert(talk['description'])
talks.append(talk)
return render_template(
f'{lang}/talks.jinja2.html', category=category, talks=talks, lang=lang)


@app.route('/2024/<lang>/full-schedule.html')
def schedule(lang):
with urlopen('https://cfp-2024.pycon.fr/schedule/html/') as fd:
html = fd.read().decode('utf-8')

if lang == 'fr':
html = (
html
.replace('Room', 'Salle')
.replace('Saturday 18 February', 'Samedi 18 février')
.replace('Sunday 19 February', 'Dimanche 19 février'))
else:
for minute in (0, 30):
html = html.replace(f'12:{minute:02}', f'12:{minute:02} PM')
for hour in range(9, 12):
html = html.replace(
f'{hour:02}:{minute:02}', f'{hour:02}:{minute:02} AM')
for hour in range(13, 19):
html = html.replace(
f'{hour:02}:{minute:02}',
f'{hour-12:02}:{minute:02} PM')

# Insert links in the table
soup = BeautifulSoup(html, 'html.parser')
conf_colors = {
'#fe6f61': '1h',
'#f6b36a': '30m',
'#378899': 'workshop',
'#fce16b': 'plenary',
}
for color, kind in conf_colors.items():
for td in soup.find_all('td', attrs={'bgcolor': color}):
title = next(td.children)
anchor = slug(title)
href = url_for('talks', lang=lang, category=kind, _anchor=anchor)
link = soup.new_tag('a', href=href, target='_parent')
title.wrap(link)

for tag in soup.find_all(lambda tag: 'style' in tag.attrs):
del tag.attrs['style']

return render_template('schedule.jinja2.html', lang=lang, data=soup)


@app.route('/2024/pyconfr-2024.ics')
def calendar():
with urlopen('https://cfp-2024.pycon.fr/schedule/ics/') as fd:
calendar = Calendar.from_ical(fd.read())

# Delete sprints
calendar.subcomponents = [
event for event in calendar.subcomponents
if event['DTSTART'].dt.day != 16]

return Response(calendar.to_ical(), mimetype='text/calendar')


@app.cli.command('freeze')
def freeze():
Freezer(app).freeze()
Binary file added static/fonts/FiraSans-Bold.otf
Binary file not shown.
Binary file added static/fonts/FiraSans-Regular.otf
Binary file not shown.
Binary file added static/fonts/manrope/Manrope-Bold.otf
Binary file not shown.
Binary file added static/fonts/manrope/Manrope-ExtraBold.otf
Binary file not shown.
Binary file added static/fonts/manrope/Manrope-ExtraLight.otf
Binary file not shown.
Binary file added static/fonts/manrope/Manrope-Light.otf
Binary file not shown.
Binary file added static/fonts/manrope/Manrope-Medium.otf
Binary file not shown.
Binary file added static/fonts/manrope/Manrope-Regular.otf
Binary file not shown.
Binary file added static/fonts/manrope/Manrope-SemiBold.otf
Binary file not shown.
43 changes: 43 additions & 0 deletions static/fonts/manrope/SIL Open Font License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Copyright 2018 The Manrope Project Authors (https://github.com/sharanda/manrope), with Reserved Font Name “Manrope”.

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL

-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide development of collaborative font projects, to support the font creation efforts of academic and linguistic communities, and to provide a free and open framework in which fonts may be shared and improved in partnership with others.

The OFL allows the licensed fonts to be used, studied, modified and redistributed freely as long as they are not sold by themselves. The fonts, including any derivative works, can be bundled, embedded, redistributed and/or sold with any software provided that any reserved names are not used by derivative works. The fonts and derivatives, however, cannot be released under any other type of license. The requirement for fonts to remain under this license does not apply to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright Holder(s) under this license and clearly marked as such. This may include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the copyright statement(s).

"Original Version" refers to the collection of Font Software components as distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting, or substituting -- in part or in whole -- any of the components of the Original Version, by changing formats or by porting the Font Software to a new environment.

"Author" refers to any designer, engineer, programmer, technical writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining a copy of the Font Software, to use, study, copy, merge, embed, modify, redistribute, and sell modified and unmodified copies of the Font Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components, in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled, redistributed and/or sold with any software, provided that each copy contains the above copyright notice and this license. These can be included either as stand-alone text files, human-readable headers or in the appropriate machine-readable metadata fields within text or binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font Name(s) unless explicit written permission is granted by the corresponding Copyright Holder. This restriction only applies to the primary font name as presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font Software shall not be used to promote, endorse or advertise any Modified Version, except to acknowledge the contribution(s) of the Copyright Holder(s) and the Author(s) or with their explicit written permission.

5) The Font Software, modified or unmodified, in part or in whole, must be distributed entirely under this license, and must not be distributed under any other license. The requirement for fonts to remain under this license does not apply to any document created using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE FONT SOFTWARE.
Binary file added static/images/banniere.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions static/images/favicon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions static/images/france.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions static/images/united-kingdom.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 86 additions & 0 deletions static/sass/schedule.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
@font-face
font-family: Manrope
font-weight: 100 400
font-style: normal
src: url(/2023/static/fonts/manrope/Manrope-Regular.otf)

html
font-family: Manrope
padding: 0

body
margin: 0
padding: 0

table
border-spacing: 1px
font-size: 10pt
line-height: 1.3

em
display: inline-block
font-size: 0.8em
font-style: normal
margin-top: 0.5em

tr td:first-child[colspan]
background: white
position: sticky
top: 5em
z-index: 1

h3
margin: 0

tr:first-child
height: 5em
position: sticky
top: 0
z-index: 1

td
background: white

&:last-of-type
display: none

tr:nth-child(2), tr:nth-child(3)
display: none

td
position: relative
padding: 1.5em 0.5em
text-align: center

a
color: inherit

td:not(:hover) a
text-decoration: inherit

[bgcolor]::before
background: #fff5
border-radius: 0 0 0 1em
font-size: 0.7em
padding: 0.25em 0.5em 0.25em 0.75em
position: absolute
right: 0
top: 0

[bgcolor="#f6b36a"]::before
content: "30 mn"

[bgcolor="#fe6f61"]::before
content: "1 h"

[lang="en"] [bgcolor="#378899"]::before
content: "workshop"

[lang="fr"] [bgcolor="#378899"]::before
content: "atelier"

[lang="en"] [bgcolor="#fce16b"]::before
content: "plenary"

[lang="fr"] [bgcolor="#fce16b"]::before
content: "plénière"
Loading

0 comments on commit 9ebeef1

Please sign in to comment.