mirror of
https://github.com/nfonteyne/octane-website.git
synced 2026-09-03 23:24:48 +02:00
fix: show all upcomming concerts in calendar add url to export the slot
This commit is contained in:
parent
fea5c30d69
commit
16110d8ad3
10 changed files with 227 additions and 89 deletions
|
|
@ -66,3 +66,55 @@ function avatarHtml(user, extraClass) {
|
|||
}
|
||||
return `<span class="${cls} avatar-initials">${escapeHtml(initials(user.name))}</span>`;
|
||||
}
|
||||
|
||||
// ---------- "Add to my calendar" links (rehearsals, concerts) ----------
|
||||
|
||||
// Google's "render" template link — well-documented, stable format. Opens
|
||||
// directly in the browser with the event pre-filled.
|
||||
function googleCalendarLink({ title, startISO, endISO, location }) {
|
||||
const fmt = (iso) => new Date(iso).toISOString().replace(/[-:]/g, '').replace(/\.\d{3}Z$/, 'Z');
|
||||
const params = new URLSearchParams({
|
||||
action: 'TEMPLATE',
|
||||
text: title,
|
||||
dates: `${fmt(startISO)}/${fmt(endISO)}`,
|
||||
});
|
||||
if (location) params.set('location', location);
|
||||
return `https://calendar.google.com/calendar/render?${params.toString()}`;
|
||||
}
|
||||
|
||||
// Outlook's compose deep-link — same idea, direct web link, no download.
|
||||
function outlookCalendarLink({ title, startISO, endISO, location }) {
|
||||
const params = new URLSearchParams({
|
||||
path: '/calendar/action/compose',
|
||||
rru: 'addevent',
|
||||
subject: title,
|
||||
startdt: startISO,
|
||||
enddt: endISO,
|
||||
});
|
||||
if (location) params.set('location', location);
|
||||
return `https://outlook.live.com/calendar/0/deeplink/compose?${params.toString()}`;
|
||||
}
|
||||
|
||||
// Apple has no equivalent public compose-URL — build a real .ics file
|
||||
// client-side instead and expose it as a data: link. Works as a universal
|
||||
// fallback too (Android, desktop imports, etc.), not just Apple.
|
||||
function icsDataUrl({ uid, title, startISO, endISO, location }) {
|
||||
const fmt = (iso) => new Date(iso).toISOString().replace(/[-:]/g, '').replace(/\.\d{3}Z$/, 'Z');
|
||||
const escapeIcs = (s) => String(s || '').replace(/([,;])/g, '\\$1').replace(/\n/g, '\\n');
|
||||
const lines = [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//Octane//Event//FR',
|
||||
'CALSCALE:GREGORIAN',
|
||||
'METHOD:PUBLISH',
|
||||
'BEGIN:VEVENT',
|
||||
`UID:${uid || Date.now()}@octane`,
|
||||
`DTSTAMP:${fmt(new Date().toISOString())}`,
|
||||
`DTSTART:${fmt(startISO)}`,
|
||||
`DTEND:${fmt(endISO)}`,
|
||||
`SUMMARY:${escapeIcs(title)}`,
|
||||
];
|
||||
if (location) lines.push(`LOCATION:${escapeIcs(location)}`);
|
||||
lines.push('END:VEVENT', 'END:VCALENDAR');
|
||||
return `data:text/calendar;charset=utf-8,${encodeURIComponent(lines.join('\r\n'))}`;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue