-
Notifications
You must be signed in to change notification settings - Fork 7
/
freeze.py
executable file
·54 lines (38 loc) · 1.21 KB
/
freeze.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
52
53
54
#!/usr/bin/env python3
"""
Freeze the app into a static site.
"""
import glob
import os
from flask_frozen import Freezer
from lso import app, data
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
OUTPUT_DIR = os.path.join(PROJECT_DIR, "build")
app.debug = False
freezer = Freezer(app)
app.config["FREEZER_DESTINATION"] = OUTPUT_DIR
app.config["FREEZER_RELATIVE_URLS"] = False
app.config["FREEZER_IGNORE_404_NOT_FOUND"] = False
@freezer.register_generator
def all_pages():
for section in data.TABLE_OF_CONTENTS:
yield section.url + "/"
if section.children:
for chapter in section.children:
yield chapter.url + "/"
if chapter.children:
for lesson in chapter.children:
yield lesson.url + "/"
if lesson.has_exercises:
yield lesson.url + "-e/"
@freezer.register_generator
def static_assets():
yield "/static/fonts/Sanskrit2003.ttf"
yield "/static/favicon.png"
yield "/static/pdf/guide.pdf"
@freezer.register_generator
def site_404():
yield "/errors/404.html"
if __name__ == "__main__":
freezer.freeze()
print("Written to: " + OUTPUT_DIR)