Highlight today in conference list
This commit is contained in:
parent
8cc8e3f9d3
commit
0fa6a2cdda
|
@ -31,12 +31,22 @@
|
||||||
|
|
||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
{% for item in item_list %}
|
{% for item in item_list %}
|
||||||
|
{% if item == "today" %}
|
||||||
|
{% set bg="bg-warning-subtle" %}
|
||||||
|
<div class="grid-item text-end {{ bg }}">{{ today.strftime("%a, %d %b %Y") }}</div>
|
||||||
|
<div class="{{ bg }}"></div>
|
||||||
|
<div class="{{ bg }}">today</div>
|
||||||
|
<div class="{{ bg }}"></div>
|
||||||
|
<div class="{{ bg }}"></div>
|
||||||
|
<div class="{{ bg }}"></div>
|
||||||
|
{% else %}
|
||||||
<div class="grid-item text-end">{{ item.start.strftime("%a, %d %b %Y") }}</div>
|
<div class="grid-item text-end">{{ item.start.strftime("%a, %d %b %Y") }}</div>
|
||||||
<div class="grid-item text-end">{{ item.end.strftime("%a, %d %b") }}</div>
|
<div class="grid-item text-end">{{ item.end.strftime("%a, %d %b") }}</div>
|
||||||
<div class="grid-item">{{ item.name }}</div>
|
<div class="grid-item">{{ item.name }}</div>
|
||||||
<div class="grid-item">{{ item.topic }}</div>
|
<div class="grid-item">{{ item.topic }}</div>
|
||||||
<div class="grid-item">{{ item.location }}</div>
|
<div class="grid-item">{{ item.location }}</div>
|
||||||
<div class="grid-item"><a href="{{ item.url }}">{{ item.url }}</a></div>
|
<div class="grid-item"><a href="{{ item.url }}">{{ item.url }}</a></div>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
13
web_view.py
13
web_view.py
|
@ -3,6 +3,7 @@
|
||||||
"""Web page to show upcoming events."""
|
"""Web page to show upcoming events."""
|
||||||
|
|
||||||
import inspect
|
import inspect
|
||||||
|
import operator
|
||||||
import os.path
|
import os.path
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
|
@ -79,10 +80,18 @@ def conference_list() -> str:
|
||||||
data_dir = config["data"]["personal-data"]
|
data_dir = config["data"]["personal-data"]
|
||||||
filepath = os.path.join(data_dir, "conferences.yaml")
|
filepath = os.path.join(data_dir, "conferences.yaml")
|
||||||
item_list = yaml.safe_load(open(filepath))["conferences"]
|
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__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue