From 7a5319aa8356fd79306885260d59b6f818eab65f Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 6 Jan 2024 15:39:46 +0000 Subject: [PATCH] Improve trip template layout --- templates/macros.html | 4 ++-- templates/trips.html | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/templates/macros.html b/templates/macros.html index 96651a9..a9d7364 100644 --- a/templates/macros.html +++ b/templates/macros.html @@ -1,7 +1,7 @@ {% macro display_datetime(dt) %}{{ dt.strftime("%a, %d, %b %Y %H:%M %z") }}{% endmacro %} {% macro display_time(dt) %}{{ dt.strftime("%H:%M %z") }}{% 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(dt) %}{{ dt.strftime("%a %-d %b %Y") }}{% endmacro %} +{% macro display_date_no_year(dt) %}{{ dt.strftime("%a %-d %b") }}{% endmacro %} {% macro conference_row(item, badge) %} {% set country = get_country(item.country) if item.country else None %} diff --git a/templates/trips.html b/templates/trips.html index 664c49e..e2c45bd 100644 --- a/templates/trips.html +++ b/templates/trips.html @@ -1,6 +1,6 @@ {% extends "base.html" %} -{% from "macros.html" import display_date_no_year, conference_row, accommodation_row, flight_row, train_row with context %} +{% 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 } %} @@ -38,11 +38,13 @@ {% macro section(heading, item_list, badge) %} {% if item_list %} + {% set items = item_list | list %}

{{ heading }}

- {% for trip in item_list %} +

{{ items | count }} trips

+ {% for trip in items %} {% set end = trip.end %}
-

{{ trip.title }} ({{ trip.start.strftime("%b %Y") }})

+

{{ trip.title }} ({{ display_date(trip.start) }})

Countries: {{ trip.countries_str }}
{% if end %}
Dates: {{ display_date_no_year(trip.start) }} to {{ display_date_no_year(end) }}