From 0fa6a2cdda0022fd4aa0f1599729adae980cb426 Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Mon, 4 Dec 2023 21:53:33 +0000 Subject: [PATCH] Highlight today in conference list --- templates/conference_list.html | 10 ++++++++++ web_view.py | 13 +++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/templates/conference_list.html b/templates/conference_list.html index a375dc6..a0e891b 100644 --- a/templates/conference_list.html +++ b/templates/conference_list.html @@ -31,12 +31,22 @@
{% for item in item_list %} + {% if item == "today" %} + {% set bg="bg-warning-subtle" %} +
{{ today.strftime("%a, %d %b %Y") }}
+
+
today
+
+
+
+ {% else %}
{{ item.start.strftime("%a, %d %b %Y") }}
{{ item.end.strftime("%a, %d %b") }}
{{ item.name }}
{{ item.topic }}
{{ item.location }}
+ {% endif %} {% endfor %}
diff --git a/web_view.py b/web_view.py index 112a824..1b5e826 100755 --- a/web_view.py +++ b/web_view.py @@ -3,6 +3,7 @@ """Web page to show upcoming events.""" import inspect +import operator import os.path import sys import traceback @@ -79,10 +80,18 @@ def conference_list() -> str: data_dir = config["data"]["personal-data"] filepath = os.path.join(data_dir, "conferences.yaml") item_list = yaml.safe_load(open(filepath))["conferences"] + today = date.today() + for conf in item_list: + conf["as_date"] = as_date(conf["start"]) - item_list.sort(key=lambda conf: as_date(conf["start"])) + item_list.sort(key=operator.itemgetter("as_date")) - return flask.render_template("conference_list.html", item_list=item_list) + past = [conf for conf in item_list if conf["as_date"] < today] + future = [conf for conf in item_list if conf["as_date"] >= today] + + return flask.render_template( + "conference_list.html", item_list=past + ["today"] + future, today=today + ) if __name__ == "__main__":