summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2025-12-23 00:40:57 +0100
committerBotond Hende <nettingman@gmail.com>2025-12-23 00:40:57 +0100
commit71c7de032edca8bfd00871e0f0fe986bbd9e60a5 (patch)
treed4735895b56c6679c5f30af2f22b708da5ceaf97 /modules
parentb189fb816abf0e7b0f7c85f8b465916d8ba5ff63 (diff)
comic basic layout
Diffstat (limited to 'modules')
-rw-r--r--modules/blog_generate.py7
-rw-r--r--modules/comic_generate.py36
2 files changed, 36 insertions, 7 deletions
diff --git a/modules/blog_generate.py b/modules/blog_generate.py
index ff296e0..04bd673 100644
--- a/modules/blog_generate.py
+++ b/modules/blog_generate.py
@@ -27,10 +27,7 @@ def generate(jinja_env: jinja2.Environment, output_root_path: str, local: bool):
tags.sort(key=lambda key: tag_occurrence_count[key], reverse=True)
top_tags = tags[:10]
- jinja_env.globals.update(site={
- "assets_path": Config.ASSETS_IMPORT_PATH,
- "assets_path_static": Config.ASSETS_IMPORT_PATH_STATIC,
- "host_name": Config.BLOG_HOSTNAME,
+ jinja_env.globals.update(blog={
"blog_name": Config.BLOG_NAME,
"subtitle": Config.BLOG_SUBTITLE,
"top_tags": top_tags
@@ -109,4 +106,4 @@ def generate(jinja_env: jinja2.Environment, output_root_path: str, local: bool):
with open(os.path.join(output_root_path, "feed.xml"), "w") as f:
f.write(rss_template.render(ctx))
- shutil.copytree(Config.ASSETS_SOURCE_DIR, output_root_path + Config.ASSETS_IMPORT_PATH) \ No newline at end of file
+ shutil.copytree(Config.BLOG_ASSETS_SOURCE_DIR, output_root_path + Config.ASSETS_IMPORT_PATH) \ No newline at end of file
diff --git a/modules/comic_generate.py b/modules/comic_generate.py
index de8fad8..7c55521 100644
--- a/modules/comic_generate.py
+++ b/modules/comic_generate.py
@@ -10,17 +10,29 @@ from ..config import Config
META_FILE_NAME = "meta.json"
IMAGE_FILE_NAME = "comic.png"
+
+TITLE_KEY = "title"
+DESCRIPTION_KEY = "description"
PUBLISH_DATE_KEY = "publish_date"
class Issue:
def __init__(self, path: str):
self.path = path
- self.name = os.path.basename(path)
+ self.index = os.path.basename(path)
with open(os.path.join(path, META_FILE_NAME)) as f:
self.meta_data = json.load(f)
+ def title(self) -> str:
+ return self.meta_data[TITLE_KEY]
+
+ def description(self) -> str:
+ return self.meta_data[DESCRIPTION_KEY]
+
+ def get_publish_time(self) -> str:
+ return self.meta_data[PUBLISH_DATE_KEY]
+
def get_issues(path: str, local: bool) -> list[Issue]:
return_list = []
@@ -41,6 +53,26 @@ def generate(jinja_env: jinja2.Environment, output_root_path: str, local: bool):
os.mkdir(output_root_path)
- issues = get_issues(Config.POST_SOURCE_DIR, local)
+ jinja_env.globals.update(comic={
+ "comic_name": Config.COMIC_NAME,
+ })
+
+ issues = get_issues(Config.ISSUE_SOURCE_DIR, local)
+ issue_template = jinja_env.get_template("issue.html.j2")
+
+ for issue in issues:
+ output_dir = os.path.join(output_root_path, "issues", issue.index)
+ os.makedirs(output_dir, exist_ok=True)
+
+ ctx = {
+ "issue": issue,
+ "url": f"{Config.COMIC_ROOT_URL}/issues/{issue.index}"
+ }
+
+ with open(os.path.join(output_dir, "index.html"), "w") as f:
+ f.write(issue_template.render(ctx))
+
+ shutil.copyfile(os.path.join(issue.path, IMAGE_FILE_NAME), os.path.join(output_dir, IMAGE_FILE_NAME))
+ shutil.copytree(Config.COMIC_ASSETS_SOURCE_DIR, output_root_path + Config.ASSETS_IMPORT_PATH)