forked from Decentrala/website
add ical page
This commit is contained in:
parent
17a8e7fc95
commit
95f02eb0c9
36
prep.py
36
prep.py
@ -45,6 +45,35 @@ def build_html(events: list[dict], dayNames: list[str]) -> str:
|
|||||||
events_html.append(f"\n<div class='event'>{event_html}</div>")
|
events_html.append(f"\n<div class='event'>{event_html}</div>")
|
||||||
return events_html
|
return events_html
|
||||||
|
|
||||||
|
def build_ical(events: list[dict]) -> str:
|
||||||
|
today = datetime.today().now()
|
||||||
|
# Header
|
||||||
|
events_ical = ""
|
||||||
|
with open("template/head.ical", "r") as file:
|
||||||
|
events_ical += file.read()
|
||||||
|
# Events
|
||||||
|
for event in events:
|
||||||
|
title = event["title"]
|
||||||
|
location = event["location"]
|
||||||
|
date = event["date"]
|
||||||
|
date = str(date.year) + str(date.month).zfill(2) + str(date.day).zfill(2)
|
||||||
|
created = str(today.year) + str(today.month).zfill(2) + str(today.day).zfill(2) + "T" + str(today.hour).zfill(2) + str(today.minute).zfill(2) + str(today.second).zfill(2) + "Z"
|
||||||
|
time = event["time"]
|
||||||
|
date = date + "T" + time.replace(":", "") + "00"
|
||||||
|
|
||||||
|
event_template = ""
|
||||||
|
with open("template/event.ical", "r") as file:
|
||||||
|
event_template += file.read()
|
||||||
|
event_template = event_template.replace("<!--CREATED-->", created)
|
||||||
|
event_template = event_template.replace("<!--DATE-->", date)
|
||||||
|
event_template = event_template.replace("<!--TITLE-->", title)
|
||||||
|
|
||||||
|
events_ical += event_template
|
||||||
|
# Footer
|
||||||
|
with open("template/end.ical", "r") as file:
|
||||||
|
events_ical += file.read()
|
||||||
|
return events_ical
|
||||||
|
|
||||||
events = sorted(load_events("dogadjaji.csv"), key=lambda e: e["date"])
|
events = sorted(load_events("dogadjaji.csv"), key=lambda e: e["date"])
|
||||||
|
|
||||||
today = datetime.today().date()
|
today = datetime.today().date()
|
||||||
@ -87,3 +116,10 @@ with open("pages/en/events_archive.html", "r") as file:
|
|||||||
|
|
||||||
with open("pages/en/events_archive.html", "w") as file:
|
with open("pages/en/events_archive.html", "w") as file:
|
||||||
file.writelines(page_template + past_events_html)
|
file.writelines(page_template + past_events_html)
|
||||||
|
|
||||||
|
new_events_ical = build_ical(new_events)
|
||||||
|
|
||||||
|
# Build ical
|
||||||
|
with open("site/events.ical", "w") as file:
|
||||||
|
file.write(build_ical)
|
||||||
|
|
||||||
|
1
template/end.ical
Normal file
1
template/end.ical
Normal file
@ -0,0 +1 @@
|
|||||||
|
END:VCALENDAR
|
13
template/event.ical
Normal file
13
template/event.ical
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
BEGIN:VEVENT
|
||||||
|
UID:calendar.462701.field_date_time.0@dmz.rs
|
||||||
|
DTSTAMP:<!--CREATED-->
|
||||||
|
CREATED:<!--CREATED-->
|
||||||
|
DTSTART;TZID=Europe/Belgrade:<!--DATE-->
|
||||||
|
DTEND;TZID=Europe/Belgrade:<!--DATE-->
|
||||||
|
GEO:+44.805613;+20.479234
|
||||||
|
LAST-MODIFIED:20240102T222415Z
|
||||||
|
LOCATION:DC Krov\, Kraljice Marije 47\, 6\, Beograd\, Serbia
|
||||||
|
STATUS:CONFIRMED
|
||||||
|
SUMMARY:<!--TITLE-->
|
||||||
|
URL;TYPE=URI:https://dmz.rs
|
||||||
|
END:VEVENT
|
20
template/head.ical
Normal file
20
template/head.ical
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
BEGIN:VCALENDAR
|
||||||
|
VERSION:2.0
|
||||||
|
PRODID:-//Date iCal v3.8//NONSGML kigkonsult.se iCalcreator 2.20.2//
|
||||||
|
METHOD:PUBLISH
|
||||||
|
X-WR-CALNAME;VALUE=TEXT:Decentrala events
|
||||||
|
BEGIN:VTIMEZONE
|
||||||
|
TZID:Europe/Belgrade
|
||||||
|
BEGIN:STANDARD
|
||||||
|
DTSTART:20231029T030000
|
||||||
|
TZOFFSETFROM:+0200
|
||||||
|
TZOFFSETTO:+0100
|
||||||
|
TZNAME:CET
|
||||||
|
END:STANDARD
|
||||||
|
BEGIN:DAYLIGHT
|
||||||
|
DTSTART:20240331T020000
|
||||||
|
TZOFFSETFROM:+0100
|
||||||
|
TZOFFSETTO:+0200
|
||||||
|
TZNAME:CEST
|
||||||
|
END:DAYLIGHT
|
||||||
|
END:VTIMEZONE
|
Loading…
Reference in New Issue
Block a user