Add index of events by year

This commit is contained in:
clerie 2024-02-17 18:10:46 +01:00
parent 4c64ecae24
commit ae351c9685
3 changed files with 37 additions and 4 deletions

View File

@ -38,6 +38,10 @@ section .description {
list-style-position: inside;
}
section.years-index {
text-align: center;
}
footer {
text-align: center;
}

View File

@ -53,17 +53,40 @@ def main(ics_url, out_path):
(out_path / "chaosevents.ics").write_text(r.text)
sections = {}
events_by_year = {}
for event in t:
if event.begin.year not in events_by_year:
events_by_year[event.begin.year] = []
events_by_year[event.begin.year].append(event)
years_index = sorted(events_by_year.keys())
# Index page
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(
sections=sections,
years_index=years_index,
)
)
# Year pages
for year, year_events in events_by_year.items():
year_directory = out_path / "year" / str(year)
year_directory.mkdir(exist_ok=True, parents=True)
(year_directory / "index.html").write_text(
env.get_template("index.html").render(
title=f"Year {year}",
sections={f"Year {year}": year_events},
years_index=years_index,
)
)

View File

@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8">
<title>Upcoming Chaos Events</title>
<title>{% if title %}{{ title }} | {% endif %}Upcoming Chaos Events</title>
<link rel="stylesheet" href="/style.css">
</head>
<body>
@ -26,6 +26,12 @@
</section>
{% endfor %}
{% endfor %}
<section class="years-index">
<a href="/">Upcoming</a>
{% for year in years_index %}
| <a href="/year/{{ year }}/">{{ year }}</a>
{% endfor %}
</section>
<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>
</footer>