Merge branch 'main' into feature/slides

This commit is contained in:
Prof. Dr. Matthias Jung DL9MJ
2025-06-24 22:09:48 +02:00
committed by Tim Grelka
8 changed files with 89 additions and 33 deletions
+11 -30
View File
@@ -138,6 +138,11 @@ class Build:
result = self.__build_page(result, course_wrapper=True)
file.write(result)
def __include_handler(self, include):
with open("data/includes.json") as file:
includes = json.load(file)
return includes.get(include)
# cached
def __build_section(self, edition, edition_name, section, section_id, chapter, next_section=None, next_chapter=None):
section_template = self.env.get_template("html/section.html")
@@ -148,7 +153,8 @@ class Build:
with FiftyOhmHtmlRenderer(
question_renderer=self.__build_question,
picture_handler=self.__picture_handler,
photo_handler=self.__photo_handler
photo_handler=self.__photo_handler,
include_handler=self.__include_handler
) as renderer:
section["content"] = renderer.render(Document(section["content"]))
@@ -182,34 +188,8 @@ class Build:
with FiftyOhmHtmlSlideRenderer(
question_renderer=self.__build_question_slide,
picture_handler=self.__picture_handler,
photo_handler=self.__photo_handler
) as renderer:
result = "<section>\n"
result += f'<section data-background="#DAEEFA">\n<h1>{chapter["title"]}</h1>\n</section>\n'
result += help_template.render()
result += "</section>\n"
for section in sections:
tmp = f'<section data-background="#DAEEFA">\n<h1>{section["title"]}</h1>\n</section>\n'
tmp += renderer.render_wrapper(section["slide"])
result += f"<section>{tmp}</section>\n"
result += next_template.render(
edition=edition,
next_chapter=next_chapter,
chapter=chapter,
)
result = slide_template.render(content=result)
file.write(result)
def __build_chapter_slidedeck(self, edition, chapter, sections, next_chapter):
with open(f'build/{edition}_slide_{chapter["ident"]}.html', 'w') as file:
slide_template = self.env.get_template("slide/slide.html")
help_template = self.env.get_template("slide/help.html")
next_template = self.env.get_template("slide/next.html")
with FiftyOhmHtmlSlideRenderer(
question_renderer=self.__build_question_slide,
picture_handler=self.__picture_handler,
photo_handler=self.__photo_handler
photo_handler=self.__photo_handler,
include_handler=self.__include_handler
) as renderer:
result = "<section>\n"
result += f'<section data-background="#DAEEFA">\n<h1>{chapter["title"]}</h1>\n</section>\n'
@@ -286,7 +266,8 @@ class Build:
with FiftyOhmHtmlRenderer(
question_renderer=self.__build_question,
picture_handler=self.__picture_handler,
photo_handler=self.__photo_handler
photo_handler=self.__photo_handler,
include_handler=self.__include_handler
) as renderer:
for key, value in snippets.items():
snippets[key] = renderer.render_inner(Document(value))