add ical generator
This commit is contained in:
parent
501af07c95
commit
89e80937ee
66
_includes/program-ical.11ty.js
Normal file
66
_includes/program-ical.11ty.js
Normal file
|
@ -0,0 +1,66 @@
|
|||
const { ICalCalendar, ICalCalendarMethod } = require('ical-generator')
|
||||
|
||||
module.exports = class ProgramIcal {
|
||||
getDate(date, time) {
|
||||
const d = new Date(date);
|
||||
const [ hours, mins ] = time.split(":");
|
||||
d.setHours(hours);
|
||||
d.setMinutes(mins);
|
||||
return d
|
||||
}
|
||||
|
||||
getLocalized(item, lang) {
|
||||
if (typeof item === "string") return item;
|
||||
return item[lang];
|
||||
}
|
||||
|
||||
data() {
|
||||
return {
|
||||
permalink: data => `/${data.lang}/program.ics`
|
||||
}
|
||||
}
|
||||
|
||||
render({ ese, program, lang }) {
|
||||
const url = `https://ese.ifsr.de/${ese.year}`;
|
||||
|
||||
const cal = new ICalCalendar({
|
||||
name: `ESE ${ese.year}`,
|
||||
url,
|
||||
method: ICalCalendarMethod.PUBLISH,
|
||||
});
|
||||
|
||||
for (const [date, events] of Object.entries(program)) {
|
||||
for (const [i, event] of events.entries()) {
|
||||
// nunjucks loops are 1-indexed by default
|
||||
const id = `${date}_${i+1}`;
|
||||
|
||||
let description = this.getLocalized(event.description, lang);
|
||||
|
||||
if ("annotation" in event && event.annotation !== null) {
|
||||
description += "\n\n";
|
||||
+ (lang == "en" ? "Notice: " : "Hinweis: ")
|
||||
+ this.getLocalized(event.annotation, lang);
|
||||
}
|
||||
|
||||
if ("location" in event && event.location !== null) {
|
||||
description += "\n\n"
|
||||
+ (lang == "en" ? "Location: " : "Veranstaltungsort: ")
|
||||
+ this.getLocalized(event.location, lang);
|
||||
}
|
||||
|
||||
cal.createEvent({
|
||||
id,
|
||||
start: this.getDate(date, event.start),
|
||||
end: ("end" in event && event.end !== null)
|
||||
? this.getDate(date, event.end)
|
||||
: this.getDate(date, "23:59"),
|
||||
summary: this.getLocalized(event.title, lang),
|
||||
description,
|
||||
url: `${url}/${lang}/program/#${id}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return cal.toString()
|
||||
}
|
||||
}
|
3
content/de/program.ical.njk
Normal file
3
content/de/program.ical.njk
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
layout: program-ical.11ty.js
|
||||
---
|
|
@ -10,3 +10,5 @@ eleventyNavigation:
|
|||
Die ESE startet dieses Jahr am Montag, den {{ese.startDay}}. Oktober {{ese.year}}. Los geht es mit der Begrüßungsveranstaltung. Am Sonntag wird vorab schon eine Radtour angeboten.
|
||||
|
||||
Einige Veranstaltungen übertragen wir auch Live in unserem ESE-Stream, gekennzeichnet mit diesem Symbol: {% icon "solid:video", title="Livestream" %}
|
||||
|
||||
Der Wochenplan ist auch für deine Kalender-App verfügbar. Öffne oder kopiere dazu diesen Link: [ESE-Kalender](/de/program.ics)
|
||||
|
|
3
content/en/program.ical.njk
Normal file
3
content/en/program.ical.njk
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
layout: program-ical.11ty.js
|
||||
---
|
|
@ -10,3 +10,5 @@ eleventyNavigation:
|
|||
The ESE starts this year on Monday, October {{ese.startDay}}, {{ese.year}} with the opening event. There is also a bicycle tour planned on Sunday.
|
||||
|
||||
Some events will also be broadcast live in our ESE stream, marked with this symbol: {% icon "solid:video", title="Livestream" %}
|
||||
|
||||
The schedule is also available for your calendar app. Open or copy this link: [ESE Calender](/en/program.ics)
|
||||
|
|
60
package-lock.json
generated
60
package-lock.json
generated
|
@ -16,6 +16,7 @@
|
|||
"@fortawesome/fontawesome-free": "^6.6.0",
|
||||
"eleventy-plugin-gen-favicons": "^1.1.3",
|
||||
"eleventy-plugin-icons": "^4.5.1",
|
||||
"ical-generator": "^8.0.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"markdown-it": "^14.1.0",
|
||||
"svg-text-to-path": "^2.0.3"
|
||||
|
@ -2351,6 +2352,58 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/ical-generator": {
|
||||
"version": "8.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ical-generator/-/ical-generator-8.0.0.tgz",
|
||||
"integrity": "sha512-CvVKK3JJrKop6z7i7/NS69FjYdR6ux1LswIeiZ3yaicX7ocMFLQI475JhQabCT7koUkaCVFNVxLaYaxtdPgwww==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"uuid-random": "^1.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": "18 || 20 || >=22.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@touch4it/ical-timezones": ">=1.6.0",
|
||||
"@types/luxon": ">= 1.26.0",
|
||||
"@types/mocha": ">= 8.2.1",
|
||||
"dayjs": ">= 1.10.0",
|
||||
"luxon": ">= 1.26.0",
|
||||
"moment": ">= 2.29.0",
|
||||
"moment-timezone": ">= 0.5.33",
|
||||
"rrule": ">= 2.6.8"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@touch4it/ical-timezones": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/luxon": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/mocha": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/node": {
|
||||
"optional": true
|
||||
},
|
||||
"dayjs": {
|
||||
"optional": true
|
||||
},
|
||||
"luxon": {
|
||||
"optional": true
|
||||
},
|
||||
"moment": {
|
||||
"optional": true
|
||||
},
|
||||
"moment-timezone": {
|
||||
"optional": true
|
||||
},
|
||||
"rrule": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
|
@ -4224,6 +4277,13 @@
|
|||
"requires-port": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uuid-random": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid-random/-/uuid-random-1.3.2.tgz",
|
||||
"integrity": "sha512-UOzej0Le/UgkbWEO8flm+0y+G+ljUon1QWTEZOq1rnMAsxo2+SckbiZdKzAHHlVh6gJqI1TjC/xwgR50MuCrBQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/void-elements": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz",
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
"@fortawesome/fontawesome-free": "^6.6.0",
|
||||
"eleventy-plugin-gen-favicons": "^1.1.3",
|
||||
"eleventy-plugin-icons": "^4.5.1",
|
||||
"ical-generator": "^8.0.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"markdown-it": "^14.1.0",
|
||||
"svg-text-to-path": "^2.0.3"
|
||||
|
|
Loading…
Reference in a new issue