summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlaise Thompson <blaise@untzag.com>2024-09-08 20:00:28 -0500
committerBlaise Thompson <blaise@untzag.com>2024-09-08 20:00:28 -0500
commit085435b289badabc6791982486c5f6d330730405 (patch)
tree30722b0d4c5b4c2b739535a404affbebca27ec7b
parentbab7f737c637e8b3be373abeb6db545018ae5d9f (diff)
-rw-r--r--build.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/build.py b/build.py
index 8427010..24fe7b2 100644
--- a/build.py
+++ b/build.py
@@ -17,7 +17,7 @@ latest_scheduled = datetime.date.today()
class Event:
- def __init__(self, line):
+ def __init__(self, line, prefix=""):
global latest_scheduled
# timestamp (start time)
year, month, day = (int(s) for s in line.split("<")[1][0:10].split("-"))
@@ -35,7 +35,7 @@ class Event:
# time of day
tod = line[line.find("<") + 1 : line.find(">")][15:]
# description
- self.description = " ".join(filter(None, [tod, line.split(">")[-1].strip()]))
+ self.description = " ".join(filter(None, [tod, prefix, line.split(">")[-1].strip()]))
org_fp = "/home/nginx/org/agenda.org"
@@ -72,7 +72,20 @@ with open(org_fp, "r") as org:
continue
if ":info:" in line:
continue
- events.append(Event(line))
+ events.append(Event(line, prefix="⚗️"))
+
+
+# sort -------------------------------------------------------------------------------------------
+
+
+def get_timestamp(event):
+ if event.description[0].isdigit():
+ return f"__{event.description}"
+ else:
+ return event.description
+
+
+sorted_events = sorted(events, key=get_timestamp)
# create html -------------------------------------------------------------------------------------
@@ -117,7 +130,7 @@ with open(__here__ / "public" / "index.html", "w") as html:
html.write(
f"<h3 id={id}><a href=#{id}>{day.isoformat()} {day.strftime('%A')}</a></h3>"
)
- for event in events:
+ for event in sorted_events:
try:
total = event.end - event.timestamp
assert total.days > 0