diff --git a/chaosevents.py b/chaosevents.py index 8fa5bbd..9f62c42 100755 --- a/chaosevents.py +++ b/chaosevents.py @@ -53,10 +53,17 @@ def main(ics_url, out_path): (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( env.get_template("index.html").render( - currentevents=t.now() if any(t.now()) else None, - upcomingevents=t.start_after(arrow.utcnow()) + sections=sections, ) ) diff --git a/templates/index.html b/templates/index.html index c9b9849..5e0a3ee 100644 --- a/templates/index.html +++ b/templates/index.html @@ -13,11 +13,11 @@ Add to calendar | Event missing? - {% if currentevents %} + {% for section_title, section_events in sections.items() %} - Current + {{ section_title }} - {% for event in currentevents %} + {% for event in section_events %} {{ event.name }} {{ event.begin.format("YYYY-MM-DD") }} - {{ event.end.shift(seconds=-1).format("YYYY-MM-DD") }} @@ -25,17 +25,6 @@ {% endfor %} - {% endif %} - - Upcoming - - {% for event in upcomingevents %} - - {{ event.name }} {{ event.begin.format("YYYY-MM-DD") }} - {{ event.end.shift(seconds=-1).format("YYYY-MM-DD") }} - - {{ event.description_rendered|safe }} - - {% endfor %}