parent
ad47f291f8
commit
2744f67987
71
templates/trip_page.html
Normal file
71
templates/trip_page.html
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% from "macros.html" import display_date_no_year, display_date, conference_row, accommodation_row, flight_row, train_row with context %}
|
||||||
|
|
||||||
|
{% set row = { "flight": flight_row, "train": train_row } %}
|
||||||
|
|
||||||
|
{% block style %}
|
||||||
|
{% set conference_column_count = 6 %}
|
||||||
|
{% set accommodation_column_count = 7 %}
|
||||||
|
{% set travel_column_count = 7 %}
|
||||||
|
<style>
|
||||||
|
.conferences {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat({{ conference_column_count }}, auto); /* 7 columns for each piece of information */
|
||||||
|
gap: 10px;
|
||||||
|
justify-content: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.accommodation {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat({{ accommodation_column_count }}, auto);
|
||||||
|
gap: 10px;
|
||||||
|
justify-content: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.travel {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat({{ travel_column_count }}, auto);
|
||||||
|
gap: 10px;
|
||||||
|
justify-content: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid-item {
|
||||||
|
/* Additional styling for grid items can go here */
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% set end = trip.end %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="p-2">
|
||||||
|
<h1>{{ trip.title }}<small class="text-muted">({{ display_date(trip.start) }})</small></h1>
|
||||||
|
<div>Countries: {{ trip.countries_str }}</div>
|
||||||
|
{% if end %}
|
||||||
|
<div>Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}</div>
|
||||||
|
{% else %}
|
||||||
|
<div>Start: {{ display_date_no_year(trip.start) }} (end date missing)</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="conferences">
|
||||||
|
{% for conf in trip.conferences %}
|
||||||
|
{{ conference_row(conf, "going") }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="accommodation">
|
||||||
|
{% for conf in trip.accommodation %}
|
||||||
|
{{ accommodation_row(conf, "going") }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="travel">
|
||||||
|
{% for item in trip.travel %}
|
||||||
|
{{ row[item.type](item) }}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{# <pre>{{ trip | pprint }}</pre> #}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -44,7 +44,9 @@
|
||||||
{% for trip in items %}
|
{% for trip in items %}
|
||||||
{% set end = trip.end %}
|
{% set end = trip.end %}
|
||||||
<div class="border border-2 rounded mb-2 p-2">
|
<div class="border border-2 rounded mb-2 p-2">
|
||||||
<h3>{{ trip.title }} <small class="text-muted">({{ display_date(trip.start) }})</small></h3>
|
<h3>
|
||||||
|
<a href="{{ url_for("trip_page", start=trip.start.isoformat()) }}">{{ trip.title }}</a>
|
||||||
|
<small class="text-muted">({{ display_date(trip.start) }})</small></h3>
|
||||||
<div>Countries: {{ trip.countries_str }}</div>
|
<div>Countries: {{ trip.countries_str }}</div>
|
||||||
{% if end %}
|
{% if end %}
|
||||||
<div>Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}</div>
|
<div>Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}</div>
|
||||||
|
|
33
web_view.py
33
web_view.py
|
@ -170,8 +170,24 @@ def build_trip_list() -> list[Trip]:
|
||||||
|
|
||||||
data_dir = app.config["PERSONAL_DATA"]
|
data_dir = app.config["PERSONAL_DATA"]
|
||||||
|
|
||||||
|
stations = travel.parse_yaml("stations", data_dir)
|
||||||
|
by_name = {station["name"]: station for station in stations}
|
||||||
|
|
||||||
|
trains = load_travel("train")
|
||||||
|
for train in trains:
|
||||||
|
assert train["from"] in by_name
|
||||||
|
assert train["to"] in by_name
|
||||||
|
train["from_station"] = by_name[train["from"]]
|
||||||
|
train["to_station"] = by_name[train["to"]]
|
||||||
|
|
||||||
|
for leg in train["legs"]:
|
||||||
|
assert leg["from"] in by_name
|
||||||
|
assert leg["to"] in by_name
|
||||||
|
leg["from_station"] = by_name[train["from"]]
|
||||||
|
leg["to_station"] = by_name[train["to"]]
|
||||||
|
|
||||||
travel_items = sorted(
|
travel_items = sorted(
|
||||||
load_travel("flight") + load_travel("train"), key=operator.itemgetter("depart")
|
load_travel("flight") + trains, key=operator.itemgetter("depart")
|
||||||
)
|
)
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
|
@ -219,5 +235,20 @@ def trip_list() -> str:
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/trip/<start>")
|
||||||
|
def trip_page(start: str) -> str:
|
||||||
|
trip_list = build_trip_list()
|
||||||
|
today = date.today()
|
||||||
|
|
||||||
|
trip = next((trip for trip in trip_list if trip.start.isoformat() == start), None)
|
||||||
|
return flask.render_template(
|
||||||
|
"trip_page.html",
|
||||||
|
trip=trip,
|
||||||
|
today=today,
|
||||||
|
get_country=agenda.get_country,
|
||||||
|
format_list_with_ampersand=format_list_with_ampersand,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0")
|
app.run(host="0.0.0.0")
|
||||||
|
|
Loading…
Reference in a new issue