From b36d187b371b1836727a6b1da80736a61c5a6e56 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Fri, 13 Jul 2018 00:03:33 +0200 Subject: [PATCH] Generate ics files correctly, incl. merged all.ics --- build.sh | 4 ++++ content/page/amateurfunk.md | 4 ++-- content/page/chaosradio.md | 4 ++-- content/page/clubdiscordia.md | 6 +++--- content/page/cms.md | 4 ++-- content/page/coderdojo.md | 4 +++- content/page/plenum.md | 4 ++-- layouts/datengarten/section.ics | 2 -- layouts/page/single.ics | 6 ++---- tools/merge_cals.py | 25 +++++++++++++++++++++++++ 10 files changed, 45 insertions(+), 18 deletions(-) create mode 100755 build.sh create mode 100755 tools/merge_cals.py diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..4334054 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh + +tools/merge_cals.py +hugo diff --git a/content/page/amateurfunk.md b/content/page/amateurfunk.md index 12547fd..89f6319 100644 --- a/content/page/amateurfunk.md +++ b/content/page/amateurfunk.md @@ -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" diff --git a/content/page/chaosradio.md b/content/page/chaosradio.md index 177f824..707a7d9 100644 --- a/content/page/chaosradio.md +++ b/content/page/chaosradio.md @@ -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: diff --git a/content/page/clubdiscordia.md b/content/page/clubdiscordia.md index 9f34cd1..919a22d 100644 --- a/content/page/clubdiscordia.md +++ b/content/page/clubdiscordia.md @@ -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" diff --git a/content/page/cms.md b/content/page/cms.md index f2c5ea9..68690db 100644 --- a/content/page/cms.md +++ b/content/page/cms.md @@ -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" diff --git a/content/page/coderdojo.md b/content/page/coderdojo.md index f613c7d..5acd302 100644 --- a/content/page/coderdojo.md +++ b/content/page/coderdojo.md @@ -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" diff --git a/content/page/plenum.md b/content/page/plenum.md index 21daaef..4558ab0 100644 --- a/content/page/plenum.md +++ b/content/page/plenum.md @@ -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" diff --git a/layouts/datengarten/section.ics b/layouts/datengarten/section.ics index c572328..1c9da72 100644 --- a/layouts/datengarten/section.ics +++ b/layouts/datengarten/section.ics @@ -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 diff --git a/layouts/page/single.ics b/layouts/page/single.ics index c02ba10..086495d 100644 --- a/layouts/page/single.ics +++ b/layouts/page/single.ics @@ -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 diff --git a/tools/merge_cals.py b/tools/merge_cals.py new file mode 100755 index 0000000..463cd80 --- /dev/null +++ b/tools/merge_cals.py @@ -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()) +