diff --git a/templates/macros.html b/templates/macros.html index 9e7785c..f9ca49f 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -265,3 +265,135 @@ {#
{{ item | pprint }}
#} {% endmacro %} + +{% macro flag(trip, flag) %}{% if trip.show_flags %}{{ flag }}{% endif %}{% endmacro %} + +{% macro conference_list(trip) %} + {% for item in trip.conferences %} + {% set country = get_country(item.country) if item.country else None %} +
+
+
+ {{ item.name }} + + {{ display_date_no_year(item.start) }} to {{ display_date_no_year(item.end) }} + +
+

+ Topic: {{ item.topic }} + | Venue: {{ item.venue }} + | Location: {{ item.location }} + {% if country %} + {{ country.flag }} + {% elif item.online %} + 💻 Online + {% else %} + + country code {{ item.country }} not found + + {% endif %} + {% if item.free %} + | free to attend + {% elif item.price and item.currency %} + | price: {{ item.price }} {{ item.currency }} + {% endif %} +

+
+
+ {% endfor %} +{% endmacro %} + +{% macro trip_item(trip) %} + {% set distances_by_transport_type = trip.distances_by_transport_type() %} + {% set total_distance = trip.total_distance() %} + {% set end = trip.end %} +
+

+ {{ trip_link(trip) }} + ({{ display_date(trip.start) }})

+ + {% if end %} +
Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }} + {% if g.user.is_authenticated and trip.start <= today %} + photos + {% endif %} +
+ {% else %} +
Start: {{ display_date_no_year(trip.start) }} (end date missing)
+ {% endif %} + {% if total_distance %} +
+ Total distance: + {{ format_distance(total_distance) }} +
+ {% endif %} + + {% if distances_by_transport_type %} + {% for transport_type, distance in distances_by_transport_type %} +
+ {{ transport_type | title }} + distance: {{format_distance(distance) }} +
+ {% endfor %} + {% endif %} + + {{ conference_list(trip) }} + + {% for day, elements in trip.elements_grouped_by_day() %} +

{{ display_date_no_year(day) }} + {% if g.user.is_authenticated and day <= today %} + + photos + + {% endif %} +

+ {% set accommodation_label = {"check-in": "check-in from", "check-out": "check-out by"} %} + {% for e in elements %} + {% if e.element_type in accommodation_label %} + {% set c = get_country(e.detail.country) %} +
+ {{ e.get_emoji() }} {{ e.title }} {{ flag(trip, c.flag) }} + ({{ accommodation_label[e.element_type] }} {{ display_time(e.start_time) }}) +
+ {% else %} +
+ {{ e.get_emoji() }} + {{ display_time(e.start_time) }} + – + {{ e.start_loc }} {{ flag(trip, e.start_country.flag) }} + → + {{ display_time(e.end_time) }} + – + {{ e.end_loc }} {{ flag(trip, e.end_country.flag) }} + {% if e.element_type == "flight" %} + {% set full_flight_number = e.detail.airline + e.detail.flight_number %} + {% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %} + airline: {{ e.detail.airline_name }} + flight number: {{ e.detail.airline }}{{ e.detail.flight_number }} + {% if e.detail.duration %} + duration: {{ e.detail.duration }} + {% endif %} + {#
{{ e.detail | pprint }}
#} + {% endif %} + {% if e.detail.distance %} + distance: {{ format_distance(e.detail.distance) }} + {% endif %} + {% if e.element_type == "flight" %} + flightradar24 + | FlightAware + | radarbox + {% endif %} +
+ {% endif %} + {% endfor %} + {% endfor %} + +
+{% endmacro %} diff --git a/templates/trip/list.html b/templates/trip/list.html index 14f829d..afb5c2c 100644 --- a/templates/trip/list.html +++ b/templates/trip/list.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% from "macros.html" import trip_link, display_date_no_year, display_date, display_datetime, display_time, format_distance with context %} +{% from "macros.html" import trip_link, display_date_no_year, display_date, display_datetime, display_time, format_distance, trip_item with context %} {% block title %}{{ heading }} - Edward Betts{% endblock %} @@ -47,8 +47,6 @@ {% endblock %} -{% macro flag(trip, flag) %}{% if trip.show_flags %}{{ flag }}{% endif %}{% endmacro %} - {% macro section(heading, item_list) %} {% if item_list %} {% set items = item_list | list %} @@ -65,142 +63,12 @@ {% endfor %} - - {% for trip in items %} - {% set distances_by_transport_type = trip.distances_by_transport_type() %} - {% set total_distance = trip.total_distance() %} - {% set end = trip.end %} -
-

- {{ trip_link(trip) }} - ({{ display_date(trip.start) }})

- - {% if end %} -
Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }} - {% if g.user.is_authenticated and trip.start <= today %} - photos - {% endif %} -
- {% else %} -
Start: {{ display_date_no_year(trip.start) }} (end date missing)
- {% endif %} - {% if total_distance %} -
- Total distance: - {{ format_distance(total_distance) }} -
- {% endif %} - - {% if distances_by_transport_type %} - {% for transport_type, distance in distances_by_transport_type %} -
- {{ transport_type | title }} - distance: {{format_distance(distance) }} -
- {% endfor %} - {% endif %} - - {{ conference_list(trip) }} - - {% for day, elements in trip.elements_grouped_by_day() %} -

{{ display_date_no_year(day) }} - {% if g.user.is_authenticated and day <= today %} - - photos - - {% endif %} -

- {% set accommodation_label = {"check-in": "check-in from", "check-out": "check-out by"} %} - {% for e in elements %} - {% if e.element_type in accommodation_label %} - {% set c = get_country(e.detail.country) %} -
- {{ e.get_emoji() }} {{ e.title }} {{ flag(trip, c.flag) }} - ({{ accommodation_label[e.element_type] }} {{ display_time(e.start_time) }}) -
- {% else %} -
- {{ e.get_emoji() }} - {{ display_time(e.start_time) }} - – - {{ e.start_loc }} {{ flag(trip, e.start_country.flag) }} - → - {{ display_time(e.end_time) }} - – - {{ e.end_loc }} {{ flag(trip, e.end_country.flag) }} - {% if e.element_type == "flight" %} - {% set full_flight_number = e.detail.airline + e.detail.flight_number %} - {% set radarbox_url = "https://www.radarbox.com/data/flights/" + full_flight_number %} - airline: {{ e.detail.airline_name }} - flight number: {{ e.detail.airline }}{{ e.detail.flight_number }} - {% if e.detail.duration %} - duration: {{ e.detail.duration }} - {% endif %} - {#
{{ e.detail | pprint }}
#} - {% endif %} - {% if e.detail.distance %} - distance: {{ format_distance(e.detail.distance) }} - {% endif %} - {% if e.element_type == "flight" %} - flightradar24 - | FlightAware - | radarbox - {% endif %} -
- {% endif %} - {% endfor %} - {% endfor %} - -
+ {{ trip_item(trip) }} {% endfor %} {% endif %} {% endmacro %} -{% macro conference_list(trip) %} - {% for item in trip.conferences %} - {% set country = get_country(item.country) if item.country else None %} -
-
-
- {{ item.name }} - - {{ display_date_no_year(item.start) }} to {{ display_date_no_year(item.end) }} - -
-

- Topic: {{ item.topic }} - | Venue: {{ item.venue }} - | Location: {{ item.location }} - {% if country %} - {{ country.flag }} - {% elif item.online %} - 💻 Online - {% else %} - - country code {{ item.country }} not found - - {% endif %} - {% if item.free %} - | free to attend - {% elif item.price and item.currency %} - | price: {{ item.price }} {{ item.currency }} - {% endif %} -

-
-
- {% endfor %} - - -{% endmacro %} - {% block content %}