Werkstatt-App: öffentliche PWA und Redaktions-Backend
Werbefreie, barrierearme Info-App für Werkstätten (WfbM) auf Basis von SvelteKit, Tailwind, SQLite/Drizzle: - App: Startseite mit Kacheln, Meldungen, Seitenbaum, Termine inkl. Schließzeiten und iCal-Abo, Ansprechpartner, Suche, Kontaktformular, Merkliste, Vorlesen, Leichte Sprache, Schriftgrößen, Hell/Dunkel, PWA - Redaktion: Dashboard, Meldungen, Seiten, Termine, Kacheln, Ansprechpartner, Mediathek mit Bildoptimierung, Postfach, Benutzer mit Rollen, Einstellungen (Name, Logo, Farbe, Rechtstexte) - Demo-Seed, CLI zum Anlegen von Benutzern, Dockerfile und Compose Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
4f145116d8
commit
bef8574e07
143 changed files with 13518 additions and 1 deletions
45
src/routes/termine.ics/+server.ts
Normal file
45
src/routes/termine.ics/+server.ts
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { upcomingEvents } from '$lib/server/content';
|
||||
import { getSettings } from '$lib/server/settings';
|
||||
import { addDays, today } from '$lib/dates';
|
||||
|
||||
/** Kalender-Abo (iCal) – z. B. für Handy-Kalender oder Outlook. */
|
||||
export const GET = ({ url }) => {
|
||||
const s = getSettings();
|
||||
const esc = (v: string) => v.replace(/\\/g, '\\\\').replace(/;/g, '\;').replace(/,/g, '\\,').replace(/\r?\n/g, '\\n');
|
||||
const d = (iso: string) => iso.replaceAll('-', '');
|
||||
const t = (time: string) => time.replace(':', '') + '00';
|
||||
const stamp = new Date().toISOString().replace(/[-:]/g, '').replace(/\.\d+/, '');
|
||||
|
||||
const lines = [
|
||||
'BEGIN:VCALENDAR',
|
||||
'VERSION:2.0',
|
||||
`PRODID:-//${esc(s.appName)}//Termine//DE`,
|
||||
'CALSCALE:GREGORIAN',
|
||||
`X-WR-CALNAME:${esc(s.appName)}`,
|
||||
'X-WR-TIMEZONE:Europe/Berlin'
|
||||
];
|
||||
|
||||
for (const e of upcomingEvents({ from: addDays(today(), -60) })) {
|
||||
const end = e.endDate || e.startDate;
|
||||
lines.push('BEGIN:VEVENT', `UID:event-${e.id}@${url.host}`, `DTSTAMP:${stamp}`);
|
||||
if (e.startTime && end === e.startDate) {
|
||||
lines.push(`DTSTART;TZID=Europe/Berlin:${d(e.startDate)}T${t(e.startTime)}`);
|
||||
lines.push(`DTEND;TZID=Europe/Berlin:${d(end)}T${t(e.endTime || e.startTime)}`);
|
||||
} else {
|
||||
lines.push(`DTSTART;VALUE=DATE:${d(e.startDate)}`, `DTEND;VALUE=DATE:${d(addDays(end, 1))}`);
|
||||
}
|
||||
lines.push(`SUMMARY:${esc(e.kind === 'closure' ? `Geschlossen: ${e.title}` : e.title)}`);
|
||||
if (e.location) lines.push(`LOCATION:${esc(e.location)}`);
|
||||
if (e.description) lines.push(`DESCRIPTION:${esc(e.description)}`);
|
||||
lines.push('END:VEVENT');
|
||||
}
|
||||
lines.push('END:VCALENDAR');
|
||||
|
||||
return new Response(lines.join('\r\n'), {
|
||||
headers: {
|
||||
'Content-Type': 'text/calendar; charset=utf-8',
|
||||
'Content-Disposition': 'inline; filename="termine.ics"',
|
||||
'Cache-Control': 'public, max-age=900'
|
||||
}
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue