Compare commits

..

3 commits

3 changed files with 21 additions and 5 deletions

View file

@ -61,7 +61,7 @@ def build_events(events: list[Event]) -> list[dict[str, typing.Any]]:
continue continue
if e.has_time: if e.has_time:
end = e.end_date or e.date + timedelta(hours=1) end = e.end_date or e.date + timedelta(minutes=30)
else: else:
end = (e.end_as_date if e.end_date else e.as_date) + one_day end = (e.end_as_date if e.end_date else e.as_date) + one_day
item = { item = {

View file

@ -9,6 +9,12 @@ from agenda import travel
from agenda.types import StrDict, Trip from agenda.types import StrDict, Trip
class UnknownStation(Exception):
"""Unknown station."""
pass
def load_travel(travel_type: str, data_dir: str) -> list[StrDict]: def load_travel(travel_type: str, data_dir: str) -> list[StrDict]:
"""Read flight and train journeys.""" """Read flight and train journeys."""
items = travel.parse_yaml(travel_type + "s", data_dir) items = travel.parse_yaml(travel_type + "s", data_dir)
@ -24,8 +30,10 @@ def load_trains(data_dir: str) -> list[StrDict]:
by_name = {station["name"]: station for station in stations} by_name = {station["name"]: station for station in stations}
for train in trains: for train in trains:
assert train["from"] in by_name if train["from"] not in by_name:
assert train["to"] in by_name raise UnknownStation(train["from"])
if train["to"] not in by_name:
raise UnknownStation(train["to"])
train["from_station"] = by_name[train["from"]] train["from_station"] = by_name[train["from"]]
train["to_station"] = by_name[train["to"]] train["to_station"] = by_name[train["to"]]

View file

@ -7,7 +7,11 @@
<title>{% block title %}{% endblock %}</title> <title>{% block title %}{% endblock %}</title>
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📅</text></svg>"> <link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>📅</text></svg>">
{% if config.USE_CDN %}
<link href="https://unpkg.com/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous"> <link href="https://unpkg.com/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
{% else %}
<link href="{{ url_for("static", filename="bootstrap5/css/bootstrap.min.css") }}" rel="stylesheet">
{% endif %}
{% block style %} {% block style %}
{% endblock %} {% endblock %}
@ -18,6 +22,10 @@
{% block nav %}{{ navbar() }}{% endblock %} {% block nav %}{{ navbar() }}{% endblock %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
{% block scripts %}{% endblock %} {% block scripts %}{% endblock %}
<script src="https://unpkg.com/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script> {% if config.USE_CDN %}
<script src="https://unpkg.com/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
{% else %}
<script src="{{ url_for("static", filename="bootstrap5/js/bootstrap.bundle.min.js") }}"></script>
{% endif %}
</body> </body>
</html> </html>