Push-Benachrichtigungen, Rechtstexte und Barrierefreiheitserklärung

Push:
- Abos mit Themen (Neuigkeiten, Schließzeiten), jederzeit abbestellbar;
  iPhone-Hinweis zur Installation; VAPID-Schlüssel automatisch erzeugt
- Meldungen mit „Benachrichtigung senden“ gehen beim Erscheinen raus
  (auch zeitgesteuert), Schließzeiten automatisch am Nachmittag davor
- Redaktionsseite „Benachrichtigungen“ mit Vorschau, Empfängerzahlen und
  Verlauf; abgelaufene Abos werden entfernt, doppeltes Senden verhindert
- Automatische Nachrichten ohne Empfänger werden nicht als gesendet
  verbucht (sonst verpasste Schließzeit-Erinnerung)

Rechtliches (eigener Server):
- Angaben zur Einrichtung in den Einstellungen; Impressum (§ 5 DDG,
  § 18 MStV) und Datenschutzerklärung aus Vorlagen, die genau beschreiben,
  was die App verarbeitet – fehlende Angaben gelb markiert
- Seite „Barrierefreiheit“ mit Erklärung und Formular „Barriere melden“,
  Meldungen gekennzeichnet und filterbar im Postfach
- Vorlesen bevorzugt Stimmen auf dem Gerät (keine Online-Stimme, wenn
  vermeidbar)

Geprüft: Push Ende-zu-Ende gegen nachgebauten Push-Dienst (Entschlüsselung,
VAPID, 410-Abbau), axe-Audit aller Seiten ohne Befund.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Friederich Loheide 2026-09-30 17:37:25 +00:00
parent 3230618596
commit 0dfb787d06
29 changed files with 1119 additions and 43 deletions

View file

@ -100,6 +100,8 @@
<a href="/kontakt" class="hover:text-on-brand">Kontakt</a>
<a href="/impressum" class="hover:text-on-brand">Impressum</a>
<a href="/datenschutz" class="hover:text-on-brand">Datenschutz</a>
<a href="/barrierefreiheit" class="hover:text-on-brand">Barrierefreiheit</a>
<a href="/barrierefreiheit?seite={encodeURIComponent(page.url.pathname)}#message" class="hover:text-on-brand">Barriere melden</a>
<a href="/admin" class="ml-auto hover:text-on-brand">Redaktion</a>
</div>
</footer>

View file

@ -0,0 +1,38 @@
import { fail } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { messages } from '$lib/server/db/schema';
import { getSettings } from '$lib/server/settings';
import { allow } from '$lib/server/ratelimit';
import { formatDate } from '$lib/dates';
export const load = ({ url }) => {
const s = getSettings();
return {
orgName: s.legal.name || s.orgName,
status: s.a11y.status,
issues: s.a11y.issues.split('\n').map((l) => l.trim()).filter(Boolean),
date: s.a11y.date ? formatDate(s.a11y.date) : '',
contact: s.a11y.contact,
enforcement: s.a11y.enforcement,
// Von welcher Seite kommt die Meldung? (Link „Barriere melden“)
page: (url.searchParams.get('seite') ?? '').slice(0, 300)
};
};
export const actions = {
default: async ({ request, getClientAddress }) => {
const form = await request.formData();
const get = (k: string, max: number) => String(form.get(k) ?? '').trim().slice(0, max);
const values = { name: get('name', 200), email: get('email', 200), message: get('message', 5000), page: get('page', 300) };
if (form.get('website')) return { sent: true }; // Honeypot
if (!values.message) return fail(400, { ...values, error: 'Bitte beschreibe kurz, was nicht funktioniert.' });
if (values.email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(values.email))
return fail(400, { ...values, error: 'Die E-Mail-Adresse sieht nicht richtig aus.' });
if (!allow(`barriere:${getClientAddress()}`, 5, 3600e3))
return fail(429, { ...values, error: 'Zu viele Meldungen. Bitte versuche es später noch einmal.' });
db.insert(messages)
.values({ kind: 'barrier', name: values.name || 'Ohne Namen', email: values.email, message: values.message, pageUrl: values.page })
.run();
return { sent: true };
}
};

View file

@ -0,0 +1,103 @@
<script lang="ts">
import { enhance } from '$app/forms';
import Send from '@lucide/svelte/icons/send';
import CircleCheck from '@lucide/svelte/icons/circle-check';
import PageTitle from '$lib/components/PageTitle.svelte';
let { data, form } = $props();
let sending = $state(false);
const statusText = {
full: 'vollständig barrierefrei',
partial: 'teilweise barrierefrei',
none: 'nicht barrierefrei'
} as const;
</script>
<svelte:head><title>Barrierefreiheit · {data.brand.appName}</title></svelte:head>
<article class="max-w-3xl mx-auto">
<PageTitle eyebrow="Erklärung" title="Barrierefreiheit" />
<div class="rich space-y-4">
<p>
{data.orgName} möchte, dass alle Menschen diese App gut nutzen können. Diese Erklärung beschreibt, wie weit uns das
gelingt{data.date ? ` (Stand: ${data.date})` : ''}.
</p>
<h2>Wie barrierefrei ist die App?</h2>
<p>Die App „{data.brand.appName}“ ist <strong>{statusText[data.status]}</strong>.</p>
<p>
Wir prüfen App und Redaktionsbereich regelmäßig mit dem Prüfwerkzeug axe gegen die Web-Richtlinien WCAG 2.2 (Stufe AA),
in hellem und dunklem Farbschema, am Handy und am Computer. Dazu gibt es: große Schrift, dunkles Farbschema,
Vorlesen, Leichte Sprache, Bedienung mit Tastatur und Unterstützung für Bildschirmleser.
</p>
{#if data.issues.length}
<h2>Was ist noch nicht barrierefrei?</h2>
<ul>
{#each data.issues as issue (issue)}<li>{issue}</li>{/each}
</ul>
{/if}
<h2>Barriere gefunden?</h2>
<p>
Wenn dir etwas auffällt, das du nicht gut nutzen kannst, sag uns bitte Bescheid. Wir kümmern uns darum und melden uns
bei dir, wenn du uns eine E-Mail-Adresse gibst.
{#if data.contact}Du erreichst uns auch per E-Mail: <a href="mailto:{data.contact}">{data.contact}</a>.{/if}
</p>
</div>
<div class="mt-6">
{#if form?.sent}
<div class="rounded-[1.5rem] bg-surface-2 p-6 flex items-start gap-4" role="status">
<CircleCheck class="size-7 text-brand-ink shrink-0" />
<div>
<p class="font-bold text-lg">Danke für deine Meldung!</p>
<p class="text-ink-2">Wir schauen uns das an.</p>
</div>
</div>
{:else}
<form
method="POST"
class="rounded-[1.5rem] bg-surface-2 p-5 sm:p-6 space-y-4"
use:enhance={() => {
sending = true;
return async ({ update }) => {
await update({ reset: false });
sending = false;
};
}}
>
{#if form?.error}<p class="rounded-xl bg-danger/10 text-danger px-4 py-3 font-semibold" role="alert">{form.error}</p>{/if}
<div>
<label class="label" for="message">Was funktioniert nicht?</label>
<textarea id="message" name="message" rows="5" class="field" required defaultValue={form?.message ?? ''}></textarea>
</div>
<div>
<label class="label" for="page">Auf welcher Seite? <span class="font-normal text-ink-3">(optional)</span></label>
<input id="page" name="page" class="field" defaultValue={form?.page ?? data.page} />
</div>
<div class="grid sm:grid-cols-2 gap-4">
<div>
<label class="label" for="name">Name <span class="font-normal text-ink-3">(optional)</span></label>
<input id="name" name="name" class="field" autocomplete="name" defaultValue={form?.name ?? ''} />
</div>
<div>
<label class="label" for="email">E-Mail für eine Antwort <span class="font-normal text-ink-3">(optional)</span></label>
<input id="email" name="email" type="email" class="field" autocomplete="email" defaultValue={form?.email ?? ''} />
</div>
</div>
<div class="hidden" aria-hidden="true"><input name="website" tabindex="-1" autocomplete="off" /></div>
<button class="btn btn-primary" disabled={sending}><Send class="size-4" />{sending ? 'Wird gesendet …' : 'Barriere melden'}</button>
</form>
{/if}
</div>
{#if data.enforcement}
<div class="rich mt-10">
<h2>Durchsetzungsverfahren</h2>
<p class="whitespace-pre-line">{data.enforcement}</p>
</div>
{/if}
</article>

View file

@ -1,6 +1,7 @@
<script lang="ts">
import Smartphone from '@lucide/svelte/icons/smartphone';
import PrefsControls from '$lib/components/PrefsControls.svelte';
import PushSettings from '$lib/components/PushSettings.svelte';
let { data } = $props();
</script>
@ -12,6 +13,9 @@
<div class="card p-5">
<PrefsControls />
</div>
<div class="card p-5">
<PushSettings />
</div>
<div class="card p-5 flex gap-4">
<span class="grid place-items-center size-10 rounded-xl bg-brand-soft text-brand-ink shrink-0"><Smartphone class="size-5" /></span>
<div>

View file

@ -9,6 +9,7 @@
import Users from '@lucide/svelte/icons/users';
import Image from '@lucide/svelte/icons/image';
import Inbox from '@lucide/svelte/icons/inbox';
import BellRing from '@lucide/svelte/icons/bell-ring';
import UserCog from '@lucide/svelte/icons/user-cog';
import Settings from '@lucide/svelte/icons/settings';
import LogOut from '@lucide/svelte/icons/log-out';
@ -45,6 +46,7 @@
title: 'Verwaltung',
items: [
{ href: '/admin/postfach', label: 'Postfach', icon: Inbox, badge: data.unread },
{ href: '/admin/benachrichtigungen', label: 'Benachrichtigungen', icon: BellRing },
...(data.user.role === 'admin'
? [
{ href: '/admin/benutzer', label: 'Benutzer', icon: UserCog },

View file

@ -0,0 +1,36 @@
import { fail } from '@sveltejs/kit';
import { desc, eq } from 'drizzle-orm';
import { db } from '$lib/server/db';
import { pushMessages, users } from '$lib/server/db/schema';
import { sendToTopic, subscriberCounts } from '$lib/server/push';
import { fields } from '$lib/server/forms';
import { allow } from '$lib/server/ratelimit';
import { PUSH_TOPICS, type PushTopic } from '$lib/push';
export const load = () => ({
counts: subscriberCounts(),
history: db
.select({ m: pushMessages, by: users.name })
.from(pushMessages)
.leftJoin(users, eq(pushMessages.sentBy, users.id))
.orderBy(desc(pushMessages.id))
.limit(50)
.all()
.map(({ m, by }) => ({ ...m, by, createdAt: m.createdAt.toISOString() }))
});
export const actions = {
send: async ({ request, locals }) => {
const f = fields(await request.formData());
const topic = f.str('topic');
const title = f.str('title', 80);
const body = f.str('body', 200);
const url = f.str('url', 300) || '/';
if (topic !== 'all' && !(topic in PUSH_TOPICS)) return fail(400, { error: 'Bitte wähle, wer die Nachricht bekommt.' });
if (!title) return fail(400, { error: 'Bitte gib einen Titel ein.' });
if (!url.startsWith('/')) return fail(400, { error: 'Der Link muss auf eine Seite der App zeigen (beginnt mit /).' });
if (!allow(`push-send:${locals.user!.id}`, 10, 3600e3)) return fail(429, { error: 'Zu viele Nachrichten in kurzer Zeit.' });
const res = await sendToTopic(topic as PushTopic | 'all', { title, body, url }, { sentBy: locals.user!.id });
return { sent: res?.recipients ?? 0 };
}
};

View file

@ -0,0 +1,129 @@
<script lang="ts">
import { enhance } from '$app/forms';
import Send from '@lucide/svelte/icons/send';
import Bell from '@lucide/svelte/icons/bell';
import Bot from '@lucide/svelte/icons/bot';
import PageHeader from '$lib/admin/PageHeader.svelte';
import { toasts } from '$lib/admin/toast.svelte';
import { PUSH_TOPICS, pushTopicKeys } from '$lib/push';
let { data, form } = $props();
let busy = $state(false);
let title = $state('');
let body = $state('');
const topicLabel = (t: string) => (t === 'all' ? 'Alle' : (PUSH_TOPICS as Record<string, { label: string }>)[t]?.label ?? t);
const when = (iso: string) => new Date(iso).toLocaleString('de-DE', { dateStyle: 'short', timeStyle: 'short' });
</script>
<PageHeader title="Benachrichtigungen" description="Push-Nachrichten aufs Handy – für Wichtiges, nicht für jede Kleinigkeit." />
<div class="grid sm:grid-cols-3 gap-3 mb-8">
<div class="card p-4">
<p class="text-3xl font-bold tabular-nums">{data.counts.total}</p>
<p class="text-sm text-ink-2">Geräte mit Benachrichtigungen</p>
</div>
{#each pushTopicKeys as t (t)}
<div class="card p-4">
<p class="text-3xl font-bold tabular-nums">{data.counts.byTopic[t]}</p>
<p class="text-sm text-ink-2">{PUSH_TOPICS[t].label}</p>
</div>
{/each}
</div>
<div class="grid lg:grid-cols-[1fr_22rem] gap-6 items-start">
<section class="card p-5 sm:p-6" aria-labelledby="senden">
<h2 id="senden" class="text-lg font-bold mb-4">Nachricht senden</h2>
<form
method="POST"
action="?/send"
class="space-y-4"
use:enhance={() => {
busy = true;
return async ({ result, update }) => {
busy = false;
if (result.type === 'failure') toasts.show(String(result.data?.error), 'error');
else if (result.type === 'success') {
toasts.show(`An ${result.data?.sent ?? 0} Geräte gesendet`);
title = body = '';
}
await update({ reset: false });
};
}}
>
<fieldset>
<legend class="label">An wen?</legend>
<div class="flex flex-wrap gap-2">
{#each [...pushTopicKeys, 'all'] as t (t)}
<label class="inline-flex items-center gap-2 rounded-full border-2 border-line px-3 py-1.5 text-sm font-semibold cursor-pointer has-[:checked]:border-brand has-[:checked]:bg-brand-soft">
<input type="radio" name="topic" value={t} checked={t === 'news'} class="accent-[var(--brand)]" />
{topicLabel(t)}
<span class="text-ink-3 font-medium">({t === 'all' ? data.counts.total : data.counts.byTopic[t as keyof typeof data.counts.byTopic]})</span>
</label>
{/each}
</div>
</fieldset>
<div>
<label class="label" for="p-title">Titel</label>
<input id="p-title" name="title" class="field" maxlength="80" required bind:value={title} placeholder="z. B. Heute kein Mittagessen in Halle 2" />
<p class="hint">{title.length} / 80 Zeichen – kurz halten, auf dem Sperrbildschirm ist wenig Platz.</p>
</div>
<div>
<label class="label" for="p-body">Text (optional)</label>
<textarea id="p-body" name="body" rows="2" class="field" maxlength="200" bind:value={body}></textarea>
</div>
<div>
<label class="label" for="p-url">Öffnet beim Antippen</label>
<input id="p-url" name="url" class="field" value="/" placeholder="/meldungen/…" />
<p class="hint">Pfad innerhalb der App, z. B. <code>/termine</code> oder <code>/s/speiseplaene</code>.</p>
</div>
<button class="btn btn-primary" disabled={busy}><Send class="size-4" />Jetzt senden</button>
{#if form?.error}<p class="text-sm text-danger font-semibold" role="alert">{form.error}</p>{/if}
</form>
</section>
<aside aria-labelledby="vorschau" class="space-y-3">
<h2 id="vorschau" class="font-bold">Vorschau</h2>
<div class="rounded-2xl bg-surface-2 p-3 flex gap-3" aria-hidden="true">
<span class="grid place-items-center size-10 rounded-xl bg-brand text-on-brand shrink-0"><Bell class="size-5" /></span>
<div class="min-w-0">
<p class="text-xs text-ink-3">{data.brand.appName} · jetzt</p>
<p class="font-bold leading-snug truncate">{title || 'Titel der Nachricht'}</p>
<p class="text-sm text-ink-2 line-clamp-2">{body || 'Text der Nachricht'}</p>
</div>
</div>
<p class="text-xs text-ink-3">Automatisch: Meldungen mit „Benachrichtigung senden“ beim Erscheinen, Schließzeiten am Nachmittag davor.</p>
</aside>
</div>
<section class="mt-10" aria-labelledby="verlauf">
<h2 id="verlauf" class="text-lg font-bold mb-3">Verlauf</h2>
<div class="card overflow-x-auto">
<table class="w-full text-sm">
<thead class="bg-surface-2 text-left">
<tr>
<th scope="col" class="px-4 py-2.5">Zeitpunkt</th>
<th scope="col" class="px-3 py-2.5">Nachricht</th>
<th scope="col" class="px-3 py-2.5">An</th>
<th scope="col" class="px-3 py-2.5 text-right">Zugestellt</th>
<th scope="col" class="px-3 py-2.5">Von</th>
</tr>
</thead>
<tbody class="divide-y divide-line">
{#each data.history as m (m.id)}
<tr>
<td class="px-4 py-2.5 tabular-nums whitespace-nowrap">{when(m.createdAt)}</td>
<td class="px-3 py-2.5"><span class="font-semibold">{m.title}</span>{#if m.body}<span class="block text-ink-3 line-clamp-1">{m.body}</span>{/if}</td>
<td class="px-3 py-2.5 whitespace-nowrap">{topicLabel(m.topic)}</td>
<td class="px-3 py-2.5 text-right tabular-nums">{m.recipients}{#if m.failures}<span class="text-ink-3"> ({m.failures} fehlgeschlagen)</span>{/if}</td>
<td class="px-3 py-2.5 whitespace-nowrap">
{#if m.automatic}<span class="inline-flex items-center gap-1 text-ink-2"><Bot class="size-4" aria-hidden="true" />automatisch</span>{:else}{m.by ?? '–'}{/if}
</td>
</tr>
{:else}
<tr><td colspan="5" class="px-4 py-8 text-center text-ink-3">Noch keine Benachrichtigungen gesendet.</td></tr>
{/each}
</tbody>
</table>
</div>
</section>

View file

@ -3,6 +3,8 @@ import { getSettings, saveSettings } from '$lib/server/settings';
import { getMedia } from '$lib/server/content';
import { fields, requireAdmin } from '$lib/server/forms';
import { cleanHtml } from '$lib/server/sanitize';
import { imprintTemplate, privacyTemplate } from '$lib/server/legal';
import type { AppSettings } from '$lib/settings';
export const load = ({ locals }) => {
requireAdmin(locals.user);
@ -10,38 +12,78 @@ export const load = ({ locals }) => {
return { settings: s, logo: getMedia(s.logoId), hero: getMedia(s.heroImageId) };
};
/** Liest alle Felder des Formulars – oder gibt eine Fehlermeldung zurück */
function read(form: FormData): Partial<AppSettings> | string {
const f = fields(form);
const appName = f.str('appName', 40);
const brandColor = f.str('brandColor', 7);
const accentColor = f.str('accentColor', 7);
if (!appName) return 'Die App braucht einen Namen.';
if (![brandColor, accentColor].every((c) => /^#[0-9a-f]{6}$/i.test(c))) return 'Eine der Farben ist ungültig.';
const website = f.str('website', 300);
if (website && !/^https?:\/\//.test(website)) return 'Die Website muss mit https:// beginnen.';
const a11yStatus = f.str('a11yStatus');
const a11yDate = f.str('a11yDate');
return {
appName,
orgName: f.str('orgName', 120),
greeting: f.str('greeting', 120),
intro: f.str('intro', 400),
brandColor,
accentColor,
logoId: f.int('logoId'),
heroEnabled: f.bool('heroEnabled'),
heroImageId: f.int('heroImageId'),
heroTagline: f.str('heroTagline', 40),
website,
contactEmail: f.str('contactEmail', 200),
contactIntro: f.str('contactIntro', 400),
imprint: cleanHtml(f.html('imprint')),
privacy: cleanHtml(f.html('privacy')),
require2faAdmins: f.bool('require2faAdmins'),
homeNewsCount: Math.min(12, Math.max(0, f.int('homeNewsCount') ?? 4)),
homeEventsCount: Math.min(12, Math.max(0, f.int('homeEventsCount') ?? 4)),
legal: {
name: f.str('legalName', 200),
street: f.str('legalStreet', 200),
city: f.str('legalCity', 200),
phone: f.str('legalPhone', 60),
email: f.str('legalEmail', 200),
representatives: f.str('legalRepresentatives', 300),
register: f.str('legalRegister', 200),
vatId: f.str('legalVatId', 40),
contentResponsible: f.str('legalContentResponsible', 300),
dpo: f.str('legalDpo', 300),
supervisory: f.str('legalSupervisory', 300),
logRetentionDays: Math.min(90, Math.max(1, f.int('legalLogDays') ?? 7))
},
a11y: {
status: a11yStatus === 'full' || a11yStatus === 'none' ? a11yStatus : 'partial',
issues: f.str('a11yIssues', 4000),
date: /^\d{4}-\d{2}-\d{2}$/.test(a11yDate) ? a11yDate : '',
contact: f.str('a11yContact', 200),
enforcement: f.str('a11yEnforcement', 2000)
}
};
}
export const actions = {
save: async ({ request, locals }) => {
requireAdmin(locals.user);
const f = fields(await request.formData());
const appName = f.str('appName', 40);
const brandColor = f.str('brandColor', 7);
const accentColor = f.str('accentColor', 7);
if (!appName) return fail(400, { error: 'Die App braucht einen Namen.' });
if (![brandColor, accentColor].every((c) => /^#[0-9a-f]{6}$/i.test(c))) return fail(400, { error: 'Eine der Farben ist ungültig.' });
const website = f.str('website', 300);
if (website && !/^https?:\/\//.test(website)) return fail(400, { error: 'Die Website muss mit https:// beginnen.' });
saveSettings({
appName,
orgName: f.str('orgName', 120),
greeting: f.str('greeting', 120),
intro: f.str('intro', 400),
brandColor,
accentColor,
logoId: f.int('logoId'),
heroEnabled: f.bool('heroEnabled'),
heroImageId: f.int('heroImageId'),
heroTagline: f.str('heroTagline', 40),
website,
contactEmail: f.str('contactEmail', 200),
contactIntro: f.str('contactIntro', 400),
imprint: cleanHtml(f.html('imprint')),
privacy: cleanHtml(f.html('privacy')),
require2faAdmins: f.bool('require2faAdmins'),
homeNewsCount: Math.min(12, Math.max(0, f.int('homeNewsCount') ?? 4)),
homeEventsCount: Math.min(12, Math.max(0, f.int('homeEventsCount') ?? 4))
});
const patch = read(await request.formData());
if (typeof patch === 'string') return fail(400, { error: patch });
saveSettings(patch);
return { saved: true };
},
/** Speichert und erzeugt Impressum und Datenschutzerklärung neu aus den Angaben */
generateLegal: async ({ request, locals }) => {
requireAdmin(locals.user);
const patch = read(await request.formData());
if (typeof patch === 'string') return fail(400, { error: patch });
const next = saveSettings(patch);
saveSettings({ imprint: imprintTemplate(next), privacy: privacyTemplate(next) });
return { saved: true, generated: true };
}
};

View file

@ -102,9 +102,102 @@
/>
</Panel>
<Panel title="Rechtliches">
<RichEditor name="imprint" value={s.imprint} label="Impressum" minHeight="10rem" />
<RichEditor name="privacy" value={s.privacy} label="Datenschutzerklärung" minHeight="10rem" />
<Panel title="Angaben zur Einrichtung" description="Daraus erzeugt die App Impressum und Datenschutzerklärung. Die Vorlagen beschreiben genau, was diese App verarbeitet – bitte trotzdem rechtlich prüfen lassen.">
<div class="grid sm:grid-cols-2 gap-4">
<div class="sm:col-span-2">
<label class="label" for="legalName">Name der Einrichtung / des Trägers (mit Rechtsform)</label>
<input id="legalName" name="legalName" class="field" value={s.legal.name} placeholder="z. B. Lindenhof Werkstätten gGmbH" />
</div>
<div>
<label class="label" for="legalStreet">Straße und Hausnummer</label>
<input id="legalStreet" name="legalStreet" class="field" value={s.legal.street} autocomplete="street-address" />
</div>
<div>
<label class="label" for="legalCity">PLZ und Ort</label>
<input id="legalCity" name="legalCity" class="field" value={s.legal.city} />
</div>
<div>
<label class="label" for="legalPhone">Telefon</label>
<input id="legalPhone" name="legalPhone" type="tel" class="field" value={s.legal.phone} />
</div>
<div>
<label class="label" for="legalEmail">E-Mail</label>
<input id="legalEmail" name="legalEmail" type="email" class="field" value={s.legal.email} />
</div>
<div class="sm:col-span-2">
<label class="label" for="legalRepresentatives">Vertreten durch</label>
<input id="legalRepresentatives" name="legalRepresentatives" class="field" value={s.legal.representatives} placeholder="z. B. Erika Muster (Geschäftsführung)" />
</div>
<div>
<label class="label" for="legalRegister">Registereintrag (optional)</label>
<input id="legalRegister" name="legalRegister" class="field" value={s.legal.register} placeholder="Amtsgericht …, HRB …" />
</div>
<div>
<label class="label" for="legalVatId">USt-IdNr. (optional)</label>
<input id="legalVatId" name="legalVatId" class="field" value={s.legal.vatId} />
</div>
<div class="sm:col-span-2">
<label class="label" for="legalContentResponsible">Verantwortlich für den Inhalt (§ 18 Abs. 2 MStV)</label>
<input id="legalContentResponsible" name="legalContentResponsible" class="field" value={s.legal.contentResponsible} placeholder="Name, Anschrift" />
</div>
<div class="sm:col-span-2">
<label class="label" for="legalDpo">Datenschutzbeauftragte/r (falls benannt)</label>
<input id="legalDpo" name="legalDpo" class="field" value={s.legal.dpo} placeholder="Name, E-Mail" />
</div>
<div class="sm:col-span-2">
<label class="label" for="legalSupervisory">Zuständige Datenschutz-Aufsichtsbehörde (optional)</label>
<input id="legalSupervisory" name="legalSupervisory" class="field" value={s.legal.supervisory} placeholder="z. B. Die Landesbeauftragte für den Datenschutz Niedersachsen" />
</div>
<div>
<label class="label" for="legalLogDays">Server-Protokolle löschen nach (Tagen)</label>
<input id="legalLogDays" name="legalLogDays" type="number" min="1" max="90" class="field" value={s.legal.logRetentionDays} />
<p class="hint">So einstellen, wie es der Webserver (z. B. Caddy) tatsächlich tut.</p>
</div>
</div>
<button
class="btn btn-soft"
formaction="?/generateLegal"
data-confirm="Impressum und Datenschutzerklärung werden aus den Angaben neu erzeugt. Eigene Änderungen an diesen beiden Texten gehen dabei verloren. Fortfahren?"
>
Impressum & Datenschutz aus Vorlage erzeugen
</button>
</Panel>
<Panel title="Rechtliches" description="Hier kannst du die erzeugten Texte anpassen. Gelb markierte Stellen fehlen noch.">
{#key `${s.imprint}|${s.privacy}`}
<RichEditor name="imprint" value={s.imprint} label="Impressum" minHeight="10rem" />
<RichEditor name="privacy" value={s.privacy} label="Datenschutzerklärung" minHeight="10rem" />
{/key}
</Panel>
<Panel title="Erklärung zur Barrierefreiheit" description="Erscheint in der App unter „Barrierefreiheit“ – mit Formular, über das Barrieren gemeldet werden können.">
<fieldset>
<legend class="label">Die App ist …</legend>
<div class="space-y-1.5">
{#each [['full', 'vollständig barrierefrei'], ['partial', 'teilweise barrierefrei'], ['none', 'nicht barrierefrei']] as [v, l] (v)}
<label class="flex items-center gap-2 cursor-pointer"><input type="radio" name="a11yStatus" value={v} checked={s.a11y.status === v} class="accent-[var(--brand)]" />{l}</label>
{/each}
</div>
</fieldset>
<div>
<label class="label" for="a11yIssues">Bekannte Barrieren (eine pro Zeile)</label>
<textarea id="a11yIssues" name="a11yIssues" rows="4" class="field" placeholder="z. B. Ältere PDF-Dokumente sind nicht barrierefrei.">{s.a11y.issues}</textarea>
</div>
<div class="grid sm:grid-cols-2 gap-4">
<div>
<label class="label" for="a11yDate">Erklärung erstellt am</label>
<input id="a11yDate" name="a11yDate" type="date" class="field" value={s.a11y.date} />
</div>
<div>
<label class="label" for="a11yContact">Kontakt für Rückmeldungen (E-Mail)</label>
<input id="a11yContact" name="a11yContact" type="email" class="field" value={s.a11y.contact} placeholder="Leer = Meldungen nur über das Formular" />
</div>
</div>
<div>
<label class="label" for="a11yEnforcement">Durchsetzungsverfahren / Schlichtungsstelle (optional)</label>
<textarea id="a11yEnforcement" name="a11yEnforcement" rows="3" class="field">{s.a11y.enforcement}</textarea>
<p class="hint">Für öffentliche Stellen vorgeschrieben (BITV 2.0 bzw. Landesrecht) – bitte die zuständige Stelle eintragen. Sonst leer lassen.</p>
</div>
</Panel>
{#snippet aside()}

View file

@ -6,6 +6,7 @@ import { attachmentsOf, contactOptions as listContactOptions, getMedia, mediaByI
import { fields, parseId, uniqueSlug } from '$lib/server/forms';
import { cleanHtml } from '$lib/server/sanitize';
import { fromLocalInput, toLocalInput } from '$lib/dates';
import { sendDuePosts, subscriberCounts } from '$lib/server/push';
import type { MediaItem } from '$lib/types';
export const load = ({ params }) => {
@ -15,9 +16,10 @@ export const load = ({ params }) => {
if (id === 'new') {
return {
isNew: true,
subscribers: subscriberCounts().byTopic.news,
contactOptions,
post: {
id: 0, title: '', slug: '', teaser: '', content: '', contentEasy: '', videoUrl: '', pinned: false, published: true,
id: 0, title: '', slug: '', teaser: '', content: '', contentEasy: '', videoUrl: '', pinned: false, published: true, notify: false, notifiedAt: null as string | null,
publishedAt: toLocalInput(new Date()), cover: null as MediaItem | null, gallery: [] as MediaItem[],
attachments: [] as ReturnType<typeof attachmentsOf>, contactIds: [] as number[]
}
@ -29,10 +31,12 @@ export const load = ({ params }) => {
const gallery = mediaByIds(p.gallery);
return {
isNew: false,
subscribers: subscriberCounts().byTopic.news,
contactOptions,
post: {
id: p.id, title: p.title, slug: p.slug, teaser: p.teaser, content: p.content, contentEasy: p.contentEasy,
videoUrl: p.videoUrl, pinned: p.pinned, published: p.published, publishedAt: toLocalInput(p.publishedAt),
notify: p.notify, notifiedAt: p.notifiedAt?.toISOString() ?? null,
cover: getMedia(p.coverId),
gallery: p.gallery.map((g) => gallery.get(g)).filter((m): m is MediaItem => !!m),
attachments: attachmentsOf(p.attachments),
@ -60,15 +64,19 @@ export const actions = {
attachments: f.attachments('attachments'),
contactIds: f.ids('contactIds'),
pinned: f.bool('pinned'),
notify: f.bool('notify'),
published: f.bool('published'),
publishedAt: fromLocalInput(f.str('publishedAt')) ?? new Date()
};
if (id === 'new') {
const created = db.insert(posts).values(values).returning({ id: posts.id }).get();
await sendDuePosts();
redirect(303, `/admin/meldungen/${created.id}`);
}
db.update(posts).set(values).where(eq(posts.id, id)).run();
// Ist die Meldung jetzt erschienen und soll benachrichtigen? Dann sofort senden.
await sendDuePosts();
return { saved: true };
},
delete: ({ params }) => {

View file

@ -53,6 +53,17 @@
<Panel title="Veröffentlichung">
<Switch name="published" checked={p.published} label="Veröffentlicht" hint="Aus = Entwurf, nur hier sichtbar" />
<Switch name="pinned" checked={p.pinned} label="Oben anheften" hint="Bleibt ganz oben in der Liste" />
{#if p.notifiedAt}
<p class="text-sm rounded-xl bg-surface-2 px-3 py-2">Benachrichtigung gesendet am {new Date(p.notifiedAt).toLocaleString('de-DE', { dateStyle: 'short', timeStyle: 'short' })}.</p>
<input type="hidden" name="notify" value="on" />
{:else}
<Switch
name="notify"
checked={p.notify}
label="Benachrichtigung senden"
hint="Beim Erscheinen an {data.subscribers} {data.subscribers === 1 ? 'Person' : 'Personen'} mit abonnierten Neuigkeiten"
/>
{/if}
<div>
<label class="label" for="publishedAt">Datum</label>
<input id="publishedAt" name="publishedAt" type="datetime-local" class="field" value={p.publishedAt} />

View file

@ -3,15 +3,20 @@ import { db } from '$lib/server/db';
import { messages } from '$lib/server/db/schema';
import { fields } from '$lib/server/forms';
export const load = () => ({
export const load = ({ url }) => {
const kind = url.searchParams.get('art');
return {
kind: kind === 'barrier' || kind === 'contact' ? kind : null,
messages: db
.select()
.from(messages)
.where(kind === 'barrier' || kind === 'contact' ? eq(messages.kind, kind) : undefined)
.orderBy(desc(messages.id))
.limit(500)
.all()
.map((m) => ({ ...m, createdAt: m.createdAt.toISOString() }))
});
};
};
export const actions = {
read: async ({ request }) => {

View file

@ -12,7 +12,13 @@
let openId = $state<number | null>(null);
</script>
<PageHeader title="Postfach" description="Nachrichten aus dem Kontaktformular der App." />
<PageHeader title="Postfach" description="Nachrichten aus dem Kontaktformular und Meldungen von Barrieren." />
<nav aria-label="Filter" class="flex gap-2 mb-5">
{#each [{ v: null, l: 'Alle' }, { v: 'contact', l: 'Kontakt' }, { v: 'barrier', l: 'Barrieren' }] as f (f.l)}
<a href={f.v ? `?art=${f.v}` : '?'} class="btn btn-sm {data.kind === f.v ? 'btn-primary' : 'btn-soft'}" aria-current={data.kind === f.v ? 'page' : undefined}>{f.l}</a>
{/each}
</nav>
{#if data.messages.length}
<ul class="space-y-2">
@ -34,7 +40,10 @@
{#if m.read}<MailOpen class="size-5" />{:else}<Mail class="size-5" />{/if}
</span>
<span class="flex-1 min-w-0">
<span class="block {m.read ? 'font-semibold' : 'font-extrabold'}">{m.name}</span>
<span class="flex items-center gap-2 {m.read ? 'font-semibold' : 'font-extrabold'}">
{m.name}
{#if m.kind === 'barrier'}<span class="rounded-full bg-accent-soft text-accent-ink px-2 py-0.5 text-[0.7rem] font-bold uppercase tracking-wider">Barriere</span>{/if}
</span>
<span class="block text-sm text-ink-3 truncate">{m.message}</span>
</span>
<span class="text-sm text-ink-3 shrink-0">{formatShort(m.createdAt)}</span>
@ -42,6 +51,7 @@
</form>
{#if open}
<div class="px-4 pb-4 pl-[4.5rem] space-y-4">
{#if m.pageUrl}<p class="text-sm text-ink-2">Seite: <a href={m.pageUrl.startsWith('/') ? m.pageUrl : undefined} target="_blank" class="font-semibold underline underline-offset-2">{m.pageUrl}</a></p>{/if}
<p class="whitespace-pre-line">{m.message}</p>
<div class="flex flex-wrap gap-2">
{#if m.email}<a href="mailto:{m.email}?subject=Ihre Nachricht" class="btn btn-soft btn-sm"><Reply class="size-4" />Antworten ({m.email})</a>{/if}

View file

@ -0,0 +1,33 @@
import { error, json } from '@sveltejs/kit';
import { publicKey, removeSubscription, saveSubscription, type BrowserSubscription } from '$lib/server/push';
import { allow } from '$lib/server/ratelimit';
/** Öffentlicher Schlüssel für das Abonnieren im Browser */
export const GET = () => json({ publicKey: publicKey() });
const isSub = (s: unknown): s is BrowserSubscription => {
const x = s as BrowserSubscription;
return (
!!x &&
typeof x.endpoint === 'string' &&
/^https:\/\//.test(x.endpoint) &&
x.endpoint.length < 1000 &&
typeof x.keys?.p256dh === 'string' &&
typeof x.keys?.auth === 'string'
);
};
/** Abo anlegen oder Themen ändern */
export const POST = async ({ request, getClientAddress }) => {
if (!allow(`push:${getClientAddress()}`, 30, 3600e3)) error(429, 'Zu viele Anfragen.');
const body = await request.json().catch(() => null);
if (!isSub(body?.subscription)) error(400, 'Ungültiges Abo.');
return json({ topics: saveSubscription(body.subscription, body.topics) });
};
/** Abo beenden */
export const DELETE = async ({ request }) => {
const body = await request.json().catch(() => null);
if (typeof body?.endpoint === 'string') removeSubscription(body.endpoint);
return json({ ok: true });
};