Generate ics files correctly, incl. merged all.ics

This commit is contained in:
Daniel Molkentin 2018-07-13 00:03:33 +02:00
parent c4069f84f8
commit b36d187b37
10 changed files with 45 additions and 18 deletions

4
build.sh Executable file
View file

@ -0,0 +1,4 @@
#!/usr/bin/env sh
tools/merge_cals.py
hugo

View file

@ -3,8 +3,8 @@ title: "Amateurfunk"
subtitle: "Funken und Löten im CCCB"
date: 2018-05-17T22:41:48+02:00
dtstart: 20180709T200000
dtend: 20180709T220000
rrule: "FREQ=WEEKLY;BYDAY=MO;INTERVAL=1"
dtend: 20180709T220000
rrule: "FREQ=WEEKLY;BYDAY=MO;INTERVAL=1"
menu:
main:
parent: "veranstaltungen"

View file

@ -2,9 +2,9 @@
title: "Chaosradio"
subtitle: "Der Podcast im Radio"
date: 2018-05-17T22:47:26+02:00
rrule: "FREQ=MONTHLY;BYSETPOS=-1;BYDAY=TH;INTERVAL=1"
dtstart: 20180628T220000
dtend: 20180629T000000
dtend: 20180629T000000
rrule: "FREQ=MONTHLY;BYSETPOS=-1;BYDAY=TH;INTERVAL=1"
location: "CCCB oder Fritz"
menu:
main:

View file

@ -2,9 +2,9 @@
title: "Club Discordia"
subtitle: "Die offenen Abende im CCCB"
date: 2018-05-17T22:59:56+02:00
dtstart: 2018070300000
dtend: 20180704T000000
rrule: "FREQ=WEEKLY;BYDAY=TU,TH;INTERVAL=1"
dtstart: 20180703T190000
dtend: 20180704T000000
rrule: "FREQ=WEEKLY;BYDAY=TU,TH;INTERVAL=1"
menu:
main:
parent: "veranstaltungen"

View file

@ -2,9 +2,9 @@
title: "Chaos macht Schule"
subtitle: "Technikkompetenzvermittlung"
date: 2018-05-18T01:11:54+02:00
rrule: "FREQ=MONTHLY;BYSETPOS=1;BYDAY=TH;INTERVAL=1"
dtstart: 20180705T190000
dtend: 20180705T230000
dtend: 20180705T230000
rrule: "FREQ=MONTHLY;BYSETPOS=1;BYDAY=TH;INTERVAL=1"
menu:
main:
parent: "veranstaltungen"

View file

@ -2,7 +2,9 @@
title: "Coder Dojo"
subtitle: Hacken und Coden für Kinder
date: 2018-05-18T09:51:02+02:00
rrule: "FREQ=MONTHLY;BYSETPOS=3;BYDAY=SA;INTERVAL=1"
dtstart: 20180623T140000
dtend: 20180623T170000
rrule: "FREQ=MONTHLY;BYSETPOS=3;BYDAY=SA;INTERVAL=1"
menu:
main:
parent: "veranstaltungen"

View file

@ -2,9 +2,9 @@
title: "Plenum"
subtitle: "Instrument der internen Konsensfindung"
date: 2018-05-18T01:11:54+02:00
rrule: "FREQ=MONTHLY;BYSETPOS=1;BYDAY=WE;INTERVAL=1"
dtstart: 20180704T200000
dtend: 20180704T220000
dtend: 20180704T220000
rrule: "FREQ=MONTHLY;BYSETPOS=1;BYDAY=WE;INTERVAL=1"
menu:
main:
parent: "verein"

View file

@ -11,14 +11,12 @@ TZOFFSETFROM:+0100
TZOFFSETTO:+0200
TZNAME:CEST
DTSTART:19700329T020000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=3
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:FREQ=YEARLY;INTERVAL=1;BYDAY=-1SU;BYMONTH=10
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT

View file

@ -1,5 +1,4 @@
{{if isset .Params "rrule"}}
BEGIN:VCALENDAR
{{if isset .Params "rrule"}}BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//cccb//datengarten calendar//EN
CALSCALE:GREGORIAN
@ -18,13 +17,12 @@ TZOFFSETFROM:+0200
TZOFFSETTO:+0100
TZNAME:CET
DTSTART:19701025T030000
RRULE:{{.Params.rrule}}
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
ORGANIZER;CN="CCCB":mailto:mail@berlin.ccc.de
SUMMARY:{{.Title}}
UID: {{.Title}}@berlin.ccc.de
UID:{{lower (replace .Title " " "")}}@berlin.ccc.de
SEQUENCE:0
STATUS:CONFIRMED
DTSTAMP:20180508T200000Z

25
tools/merge_cals.py Executable file
View file

@ -0,0 +1,25 @@
#!/usr/bin/env python3
from glob import glob
import icalendar
import pytz
cals=[]
merged=icalendar.Calendar()
merged.add('prodid', '-//CCCB Calendar Generator//berlin.ccc.de//')
merged.add('version', '2.0')
for icsfilestr in glob("public/*/**/*.ics", recursive=True):
with open(icsfilestr, 'r') as icsfile:
print("Importing", icsfilestr)
cals.append(icalendar.Calendar.from_ical(icsfile.read()))
for cal in cals:
for e in cal.subcomponents:
merged.add_component(e)
outfile="static/all.ics"
with open(outfile, 'wb') as f:
print(f"writing to {outfile}...")
f.write(merged.to_ical())