blob: 5e058ed37837e35e053ae309af5149e5dc08f6e6 (
plain)
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
|
import os.path
import shutil
import jinja2
from ..config import Config
import os.path
import shutil
import jinja2
from ..config import Config
def init(jinja_env: jinja2.Environment, local: bool):
jinja_env.globals.update(main={
"main_name": Config.MAIN_NAME,
"main_url": Config.MAIN_ROOT_URL,
})
def generate(jinja_env: jinja2.Environment, output_root_path: str, local: bool):
if os.path.exists(output_root_path):
shutil.rmtree(output_root_path)
os.mkdir(output_root_path)
for page in ("index", "neighbors"):
template = jinja_env.get_template(f"main_{page}.html.j2")
html_file_name = f"{page}.html"
with open(os.path.join(output_root_path, html_file_name), "w") as f:
url = (Config.MAIN_ROOT_URL + ("" if page == "index" else "/" + html_file_name))
f.write(template.render({"url" : url}))
shutil.copytree(Config.MAIN_ASSETS_SOURCE_DIR, output_root_path + Config.ASSETS_IMPORT_PATH)
|