-
Notifications
You must be signed in to change notification settings - Fork 5
/
freezer.py
executable file
·51 lines (37 loc) · 1.19 KB
/
freezer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
from flask_frozen import Freezer
from pycon import app
LANGUAGES = (
{'lang_code': 'sk'},
{'lang_code': 'en'}
)
app.config['FREEZER_DESTINATION'] = 'docs' # GitHub pages directory for static site
# app.config['APPLICATION_ROOT'] = '/2019.pycon.sk/'
WEBSITE_DOMAIN = '2022.pycon.sk'
freezer = Freezer(app)
@freezer.register_generator
def index():
for lang in LANGUAGES:
yield lang
def fix_calendar():
for f in os.listdir(freezer.root):
full_path = os.path.join(freezer.root, f)
if os.path.isdir(full_path):
cal = os.path.join(full_path, 'calendar.ics')
if os.path.exists(cal):
print('Replacing "\\n" with "\\r\\n" in {}'.format(cal))
with open(cal, 'r') as f:
cal_content = f.read()
with open(cal, 'w') as f:
f.write(cal_content.replace('\n', '\r\n'))
def add_cname():
"""
After successful freeze, add CNAME record for GitHub Pages.
"""
cname = os.path.join(freezer.root, 'CNAME')
with open(cname, 'w') as f:
f.write(WEBSITE_DOMAIN)
if __name__ == '__main__':
freezer.freeze()
# fix_calendar()
add_cname()