fix(calendar): strip HTML from ICS export and add line folding
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
ICS format requires plain text (not HTML) in DESCRIPTION field and lines must not exceed 75 octets per RFC 5545. This fixes "preview unavailable" when importing ICS into Outlook/macOS Calendar. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9bb2659ffd
commit
73c42f59a6
@ -649,6 +649,23 @@ async function toggleRSVP() {
|
||||
}
|
||||
|
||||
/* --- Add to Calendar functions --- */
|
||||
function stripHtml(html) {
|
||||
const tmp = document.createElement('div');
|
||||
tmp.innerHTML = html;
|
||||
return tmp.textContent || tmp.innerText || '';
|
||||
}
|
||||
|
||||
function foldIcsLine(line) {
|
||||
// ICS spec: lines max 75 octets, continuation lines start with space
|
||||
const parts = [];
|
||||
while (line.length > 75) {
|
||||
parts.push(line.substring(0, 75));
|
||||
line = ' ' + line.substring(75);
|
||||
}
|
||||
parts.push(line);
|
||||
return parts.join('\r\n');
|
||||
}
|
||||
|
||||
const _evt = {
|
||||
title: {{ event.title|tojson }},
|
||||
date: '{{ event.event_date.strftime("%Y%m%d") }}',
|
||||
@ -687,14 +704,15 @@ function downloadICS() {
|
||||
const end = _evt.end ? (_evt.date + 'T' + _evt.end + '00') : (_evt.date + 'T' + _evt.start + '00');
|
||||
const uid = 'nordabiz-event-{{ event.id }}@nordabiznes.pl';
|
||||
const now = new Date().toISOString().replace(/[-:]/g,'').split('.')[0] + 'Z';
|
||||
const plainDesc = stripHtml(_evt.description);
|
||||
const descParts = [
|
||||
_evt.speaker ? 'Prowadzący: ' + _evt.speaker : '',
|
||||
_evt.description,
|
||||
plainDesc,
|
||||
'',
|
||||
'Szczegóły: ' + _evt.url,
|
||||
].filter(Boolean);
|
||||
const desc = descParts.join('\\n');
|
||||
const ics = [
|
||||
const lines = [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
'PRODID:-//NordaBiznes//PL',
|
||||
@ -715,7 +733,8 @@ function downloadICS() {
|
||||
'END:VALARM',
|
||||
'END:VEVENT',
|
||||
'END:VCALENDAR',
|
||||
].join('\r\n');
|
||||
];
|
||||
const ics = lines.map(foldIcsLine).join('\r\n');
|
||||
const blob = new Blob([ics], { type: 'text/calendar;charset=utf-8' });
|
||||
const a = document.createElement('a');
|
||||
a.href = URL.createObjectURL(blob);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user