add an ability to add links to events

This commit is contained in:
Marko Kevac
2024-07-25 20:47:34 +02:00
parent a60280756a
commit 4d843a1254
2 changed files with 12 additions and 4 deletions

12
prep.py
View File

@@ -29,11 +29,16 @@ def load_events(csv_path:str) -> list[dict]:
event_location = event[2]
event_title = event[3]
types = event[4].split()
try:
link = event[5]
except IndexError:
link = ""
current_event = {"date":event_date_parsed,
"time":event_time,
"location": event_location,
"title":event_title.strip(),
"types": types }
"types": types,
"link": link}
events.append(current_event)
return events
@@ -47,7 +52,10 @@ def build_html(events: list[dict], dayNames: list[str], typesNames: dict) -> str
time = event["time"]+"h"
event_html = []
event_html.append(f"<div class='date'>{date} {time}</div>")
event_html.append(f"<div class='title'>{title}</div>")
if event["link"] != "":
event_html.append(f"<div class='title'><a href=\"{event['link']}\">{title}</a></div>")
else:
event_html.append(f"<div class='title'>{title}</div>")
if "https://" in location:
place,link = location.split("https://")
event_html.append(f"<div class='place'><a href=\"https://{link}\">@{place.strip()}</a></div>")