From db2f67bdd0902048a5d3faa9fe46a71c4aaa4bb3 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Fri, 1 May 2026 12:40:06 +0200 Subject: root domain content generation wip --- __main__.py | 5 ++--- config.py | 12 ++++++++++-- main/templates/main.html.j2 | 17 +++++++++++++++++ modules/main_generate.py | 28 ++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 5 deletions(-) create mode 100644 main/templates/main.html.j2 create mode 100644 modules/main_generate.py diff --git a/__main__.py b/__main__.py index 0e1dc48..1f28fdf 100644 --- a/__main__.py +++ b/__main__.py @@ -3,9 +3,7 @@ import sys import jinja2 from .config import Config -from .modules import blog_generate -from .modules import comic_generate -from .modules import codenames_generate +from .modules import main_generate, blog_generate, comic_generate, codenames_generate def init_jinja_env() -> jinja2.Environment: @@ -30,6 +28,7 @@ def main(output_root_path: str, local: bool): "git_url": Config.GIT_ROOT_URL, }) + main_generate.generate(jinja_env, os.path.join(output_root_path, "main"), local) blog_generate.generate(jinja_env, os.path.join(output_root_path, "blog"), local) comic_generate.generate(jinja_env, os.path.join(output_root_path, "comic"), local) codenames_generate.generate(jinja_env, os.path.join(output_root_path, "codenames"), local) diff --git a/config.py b/config.py index 81fd243..d5ed156 100644 --- a/config.py +++ b/config.py @@ -7,15 +7,23 @@ class Config: ASSETS_IMPORT_PATH = "/assets" EMAIL = "webmaster@wazul.moe" ASSETS_IMPORT_PATH_STATIC = "https://static.wazul.moe" - MAIN_ROOT_URL = "https://wazul.moe" GIT_ROOT_URL = "https://git.wazul.moe" RSS_FILE_NAME = "feed.xml" TIMEZONE = datetime.timezone(datetime.timedelta(hours=2)) + # MAIN + MAIN_ROOT_URL = "https://wazul.moe" + MAIN_NAME = "Wazul's website" + # BLOG BLOG_ROOT_URL = "https://blog.wazul.moe" BLOG_ASSETS_SOURCE_DIR = os.path.join(__DIR, "blog/assets") - TEMPLATES_SOURCE_DIR = [os.path.join(__DIR, "blog/templates"), os.path.join(__DIR, "comic/templates"), os.path.join(__DIR, "codenames/templates")] + TEMPLATES_SOURCE_DIR = [ + os.path.join(__DIR, "main/templates"), + os.path.join(__DIR, "blog/templates"), + os.path.join(__DIR, "comic/templates"), + os.path.join(__DIR, "codenames/templates"), + ] POST_SOURCE_DIR = os.path.join(__DIR, "blog/posts") BLOG_HOSTNAME = "yggdrasil" diff --git a/main/templates/main.html.j2 b/main/templates/main.html.j2 new file mode 100644 index 0000000..d72558f --- /dev/null +++ b/main/templates/main.html.j2 @@ -0,0 +1,17 @@ + + + + + {{ title }} + + + + + + + +

Hello world.

+ + + diff --git a/modules/main_generate.py b/modules/main_generate.py new file mode 100644 index 0000000..7137537 --- /dev/null +++ b/modules/main_generate.py @@ -0,0 +1,28 @@ +import os.path +import shutil +import jinja2 + +from ..config import Config +import os.path +import shutil + +import jinja2 + +from ..config import Config + + +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) + + jinja_env.globals.update(main={ + "main_url": Config.MAIN_ROOT_URL, + }) + + root_template = jinja_env.get_template("main.html.j2") + with open(os.path.join(output_root_path, "index.html"), "w") as f: + f.write(root_template.render({"url" : Config.MAIN_ROOT_URL, "title": Config.MAIN_NAME})) + + shutil.copytree(Config.CODENAMES_ASSETS_SOURCE_DIR, output_root_path + Config.ASSETS_IMPORT_PATH) \ No newline at end of file -- cgit v1.3