feature: add brightspot rendering

This commit is contained in:
Matthias Jung
2026-02-14 01:38:37 +01:00
parent 0e9a4dceac
commit c79020e239
4 changed files with 49 additions and 0 deletions
+1
View File
@@ -13,3 +13,4 @@ bd.build_edition("NE")
bd.build_edition("EA")
bd.build_edition("NEA")
bd.build_assets()
bd.build_brightspots()
+21
View File
@@ -1,3 +1,4 @@
import functools
import json
import random
import shutil
@@ -453,3 +454,23 @@ class Build:
self.__build_course_page(snippets, "patenkarte", "patenkarte")
self.__build_html_page(contents, "pruefung")
self.__build_html_page(contents, "infos")
def build_brightspots(self):
for brightspot_file in self.config.p_data_brightspots.glob("*.md"):
with brightspot_file.open() as file:
content = file.read()
with (self.config.p_build / f"{brightspot_file.stem}.html").open("w") as file:
with FiftyOhmHtmlRenderer(
question_renderer=functools.partial(
self.__build_question,
template_file="html/brightspot_question.html",
),
picture_handler=self.__picture_handler,
photo_handler=self.__photo_handler,
include_handler=self.__include_handler,
) as renderer:
brightspot_template = self.env.get_template("html/brightspot.html")
result = renderer.render(Document(content))
result = brightspot_template.render(content=result, number=brightspot_file.stem)
result = self.__build_page(result, course_wrapper=False)
file.write(result)
+10
View File
@@ -0,0 +1,10 @@
<div class="alert alert-warning text-dark" role="alert">
<h2>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 640" fill="currentColor" aria-hidden="true" focusable="false" style="width: 1.1em; height: 1.1em; vertical-align: -0.1em;">
<path d="M420.9 448C428.2 425.7 442.8 405.5 459.3 388.1C492 353.7 512 307.2 512 256C512 150 426 64 320 64C214 64 128 150 128 256C128 307.2 148 353.7 180.7 388.1C197.2 405.5 211.9 425.7 219.1 448L420.8 448zM416 496L224 496L224 512C224 556.2 259.8 592 304 592L336 592C380.2 592 416 556.2 416 512L416 496zM312 176C272.2 176 240 208.2 240 248C240 261.3 229.3 272 216 272C202.7 272 192 261.3 192 248C192 181.7 245.7 128 312 128C325.3 128 336 138.7 336 152C336 165.3 325.3 176 312 176z"/>
</svg>
Lichtblick: {{number}}
</h2>
{{content}}
</div>
+17
View File
@@ -0,0 +1,17 @@
<div class="question layout-{{ layout }}" id="{{ number }}">
<div class="question-text">{{ number }}: {{ question }}</div>
{% if picture_question %}
<div class="question-picture"><img src="pictures/{{ picture_question }}.svg" alt="{{ alt_text_question }}"></div>
{% endif %}
<div class="question-text">
Richtige Lösung: <br/>
{% if answers[0] %}
{{ answers[0] }}
{% endif %}
{% if answer_pictures[0] %}
<div class="question-picture"><img src="pictures/{{ answer_pictures[0] }}.svg" alt="{{ alt_text_answers[0] }}"></div>
{% endif %}
</div>
</div>