diff --git a/templates/macros.html b/templates/macros.html index f7926e6..cd331cd 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -3,6 +3,10 @@ {% macro display_date(dt) %}{{ dt.strftime("%a %-d %b %Y") }}{% endmacro %} {% macro display_date_no_year(dt) %}{{ dt.strftime("%a %-d %b") }}{% endmacro %} +{% macro trip_link(trip) %} + {{ trip.title }} +{% endmacro %} + {% macro conference_row(item, badge) %} {% set country = get_country(item.country) if item.country else None %}
{{ item.start.strftime("%a, %d %b %Y") }}
diff --git a/templates/trip_page.html b/templates/trip_page.html index a4157a6..45d4ec1 100644 --- a/templates/trip_page.html +++ b/templates/trip_page.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% from "macros.html" import display_date_no_year, display_date, conference_row, accommodation_row, flight_row, train_row with context %} +{% from "macros.html" import trip_link, display_date_no_year, display_date, conference_row, accommodation_row, flight_row, train_row with context %} {% set row = { "flight": flight_row, "train": train_row } %} @@ -77,6 +77,11 @@ {% endfor %} +

+ {% if prev_trip %}previous: {{ trip_link(prev_trip) }}{% endif %} + {% if next_trip %}next: {{ trip_link(next_trip) }}{% endif %} +

+ {% if coordinates %}
{% endif %} diff --git a/web_view.py b/web_view.py index 2f17afb..0c57977 100755 --- a/web_view.py +++ b/web_view.py @@ -191,10 +191,15 @@ def trip_list() -> str: @app.route("/trip/") def trip_page(start: str) -> str: """Individual trip page.""" - trip_list = agenda.trip.build_trip_list() + trip_iter = iter(agenda.trip.build_trip_list()) today = date.today() - trip = next((trip for trip in trip_list if trip.start.isoformat() == start), None) + prev_trip = None + for trip in trip_iter: + if trip.start.isoformat() == start: + break + prev_trip = trip + next_trip = next(trip_iter, None) if not trip: flask.abort(404) @@ -208,6 +213,8 @@ def trip_page(start: str) -> str: return flask.render_template( "trip_page.html", trip=trip, + prev_trip=prev_trip, + next_trip=next_trip, today=today, coordinates=coordinates, routes=routes,