Embed calendar view on other sites
Is there a supported way to embed a calendar view of events on another site? I've hacked something together to create an iframe-able version of the ICS feed using the MIT licensed fullcalendar.io bundle and its icalendar plugin. This will fetch the ICS feed for a Mobilizon group and render a month view with clickable entries that lead to the event pages.
<iframe src="https://hackerspace.zone/html/calview.html?ics=https://events.hackerspace.zone/@events/feed/ics"
width="100%" height=600 style="border:0"></iframe>
<html>
<head>
<meta charset='utf-8' />
<meta http-equiv="Content-Security-Policy" content="frame-src '*'">
<style>
html, body {
margin: 0;
padding: 0;
font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
font-size: 14px;
}
#calendar {
max-width: 800px;
margin: 00px auto;
}
</style>
<link href='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.0/main.min.css' rel='stylesheet' />
<script src='https://cdn.jsdelivr.net/npm/fullcalendar@5.11.0/main.min.js'></script>
<script src='https://github.com/mozilla-comm/ical.js/releases/download/v1.4.0/ical.js'></script>
<script src='https://cdn.jsdelivr.net/npm/@fullcalendar/icalendar@5.11.0/main.global.min.js'></script>
<script>
const param = new URL(location).searchParams;
const ics = param.get("ics") || 'https://events.hackerspace.zone/@events/feed/ics';
const view = param.get("view") || "dayGridMonth";
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
initialView: view,
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
events: {
url: ics,
format: 'ics'
}
});
calendar.render();
});
</script>
</head>
<body>
<div id='calendar'></div>
</html>