From c94e98acb1a9d1c7d17c6b270786aabf817f2a1a Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Tue, 5 Dec 2023 00:04:56 +0000 Subject: [PATCH] Highlight today in events list Closes: #75 --- agenda/calendar.py | 2 ++ agenda/data.py | 3 ++- templates/index.html | 46 +++++++++++++++++++++++++++----------------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/agenda/calendar.py b/agenda/calendar.py index 8cbd58a..4d2a8d8 100644 --- a/agenda/calendar.py +++ b/agenda/calendar.py @@ -30,6 +30,8 @@ def build_events(events: list[Event]) -> list[dict[str, typing.Any]]: one_day = timedelta(days=1) for e in events: + if e.name == "today": + continue if e.name == "accommodation": assert e.title and e.end_date item = { diff --git a/agenda/data.py b/agenda/data.py index 66662a4..52fbaa1 100644 --- a/agenda/data.py +++ b/agenda/data.py @@ -10,7 +10,7 @@ from datetime import date, datetime, timedelta import dateutil.rrule import dateutil.tz import holidays # type: ignore -import isodate +import isodate # type: ignore import lxml import pytz import yaml @@ -265,6 +265,7 @@ async def get_data(now: datetime) -> typing.Mapping[str, str | object]: events += hn.whoishiring(last_year, next_year) events += domains.renewal_dates(my_data) + events += [Event(name="today", date=today)] for launch in rockets: dt = None diff --git a/templates/index.html b/templates/index.html index dc9f28a..0c877c4 100644 --- a/templates/index.html +++ b/templates/index.html @@ -148,27 +148,37 @@ {% endif %} -
-
- {{event.as_date.strftime("%a, %d, %b")}} -   -   - {{event.display_time or ""}} -   -   - {{event.display_timezone or ""}} + {% set delta = event.delta_days(today) %} + {% if event.name == "today" %} +
+
+

today

+
+ {% else %} + {% set cell_bg = " bg-warning-subtle" if delta == "today" else "" %} +
+
+ {{event.as_date.strftime("%a, %d, %b")}} +   +   + {{event.display_time or ""}} +   +   + {{event.display_timezone or ""}} +
- -
- {{ event.delta_days(today) }} -
-
+ {% endif %} {% endfor %}

Space launches