Generate sections from content dict

This commit is contained in:
clerie 2024-02-17 17:42:38 +01:00
parent 6225b664a7
commit 4c64ecae24
2 changed files with 12 additions and 16 deletions

View File

@ -53,10 +53,17 @@ def main(ics_url, out_path):
(out_path / "chaosevents.ics").write_text(r.text) (out_path / "chaosevents.ics").write_text(r.text)
sections = {}
if any(t.now()):
sections["Current"] = t.now()
sections["Upcoming"] = t.start_after(arrow.utcnow())
(out_path / "index.html").write_text( (out_path / "index.html").write_text(
env.get_template("index.html").render( env.get_template("index.html").render(
currentevents=t.now() if any(t.now()) else None, sections=sections,
upcomingevents=t.start_after(arrow.utcnow())
) )
) )

View File

@ -13,11 +13,11 @@
<a href="/chaosevents.ics">Add to calendar</a> | <a href="mailto:chaosevents@clerie.de"> Event missing?</a> <a href="/chaosevents.ics">Add to calendar</a> | <a href="mailto:chaosevents@clerie.de"> Event missing?</a>
</div> </div>
</header> </header>
{% if currentevents %} {% for section_title, section_events in sections.items() %}
<section> <section>
<h2>Current</h2> <h2>{{ section_title }}</h2>
</section> </section>
{% for event in currentevents %} {% for event in section_events %}
<section> <section>
<h3>{{ event.name }} <span class="date">{{ event.begin.format("YYYY-MM-DD") }} - {{ event.end.shift(seconds=-1).format("YYYY-MM-DD") }}</span></h3> <h3>{{ event.name }} <span class="date">{{ event.begin.format("YYYY-MM-DD") }} - {{ event.end.shift(seconds=-1).format("YYYY-MM-DD") }}</span></h3>
<div class="description"> <div class="description">
@ -25,17 +25,6 @@
</div> </div>
</section> </section>
{% endfor %} {% endfor %}
{% endif %}
<section>
<h2>Upcoming</h2>
</section>
{% for event in upcomingevents %}
<section>
<h3>{{ event.name }} <span class="date">{{ event.begin.format("YYYY-MM-DD") }} - {{ event.end.shift(seconds=-1).format("YYYY-MM-DD") }}</span></h3>
<div class="description">
{{ event.description_rendered|safe }}
</div>
</section>
{% endfor %} {% endfor %}
<footer> <footer>
<a href="https://legal.clerie.de/impressum">Imprint</a> | <a href="https://legal.clerie.de/datenschutz">Privacy</a> | <a href="https://git.clerie.de/clerie/chaosevents">Source Code</a> <a href="https://legal.clerie.de/impressum">Imprint</a> | <a href="https://legal.clerie.de/datenschutz">Privacy</a> | <a href="https://git.clerie.de/clerie/chaosevents">Source Code</a>