parent
36b5d38274
commit
fbee775f5b
|
@ -3,6 +3,10 @@
|
||||||
{% macro display_date(dt) %}{{ dt.strftime("%a %-d %b %Y") }}{% endmacro %}
|
{% macro display_date(dt) %}{{ dt.strftime("%a %-d %b %Y") }}{% endmacro %}
|
||||||
{% macro display_date_no_year(dt) %}{{ dt.strftime("%a %-d %b") }}{% endmacro %}
|
{% macro display_date_no_year(dt) %}{{ dt.strftime("%a %-d %b") }}{% endmacro %}
|
||||||
|
|
||||||
|
{% macro trip_link(trip) %}
|
||||||
|
<a href="{{ url_for("trip_page", start=trip.start.isoformat()) }}">{{ trip.title }}</a>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro conference_row(item, badge) %}
|
{% macro conference_row(item, badge) %}
|
||||||
{% set country = get_country(item.country) if item.country else None %}
|
{% set country = get_country(item.country) if item.country else None %}
|
||||||
<div class="grid-item text-end">{{ item.start.strftime("%a, %d %b %Y") }}</div>
|
<div class="grid-item text-end">{{ item.start.strftime("%a, %d %b %Y") }}</div>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "base.html" %}
|
{% 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 } %}
|
{% set row = { "flight": flight_row, "train": train_row } %}
|
||||||
|
|
||||||
|
@ -77,6 +77,11 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{% if prev_trip %}previous: {{ trip_link(prev_trip) }}{% endif %}
|
||||||
|
{% if next_trip %}next: {{ trip_link(next_trip) }}{% endif %}
|
||||||
|
</p>
|
||||||
|
|
||||||
{% if coordinates %}
|
{% if coordinates %}
|
||||||
<div id="map"></div>
|
<div id="map"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
11
web_view.py
11
web_view.py
|
@ -191,10 +191,15 @@ def trip_list() -> str:
|
||||||
@app.route("/trip/<start>")
|
@app.route("/trip/<start>")
|
||||||
def trip_page(start: str) -> str:
|
def trip_page(start: str) -> str:
|
||||||
"""Individual trip page."""
|
"""Individual trip page."""
|
||||||
trip_list = agenda.trip.build_trip_list()
|
trip_iter = iter(agenda.trip.build_trip_list())
|
||||||
today = date.today()
|
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:
|
if not trip:
|
||||||
flask.abort(404)
|
flask.abort(404)
|
||||||
|
@ -208,6 +213,8 @@ def trip_page(start: str) -> str:
|
||||||
return flask.render_template(
|
return flask.render_template(
|
||||||
"trip_page.html",
|
"trip_page.html",
|
||||||
trip=trip,
|
trip=trip,
|
||||||
|
prev_trip=prev_trip,
|
||||||
|
next_trip=next_trip,
|
||||||
today=today,
|
today=today,
|
||||||
coordinates=coordinates,
|
coordinates=coordinates,
|
||||||
routes=routes,
|
routes=routes,
|
||||||
|
|
Loading…
Reference in a new issue