From c20f3a73d0709989f15f6a82d38acff0a1301d86 Mon Sep 17 00:00:00 2001 From: Friederich Loheide Date: Sat, 3 Oct 2026 05:49:18 +0000 Subject: [PATCH] =?UTF-8?q?Leichte=20Sprache=20automatisch=20f=C3=BCr=20Le?= =?UTF-8?q?ser,=20mehrere=20KI-Anbieter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Statt eines KI-Knopfs in der Redaktion entsteht die Leichte Sprache jetzt automatisch für Leser: - Ist „Leichte Sprache“ eingeschaltet und gibt es keine eigene Fassung, wird der Text beim ersten Aufruf live übertragen, gespeichert und allen weiteren Lesern sofort gezeigt; nach Textänderungen neu (Prüfsumme) - Beim Speichern einer Seite/Meldung wird im Hintergrund vorab übertragen (Warteschlange, eine Übertragung gleichzeitig) - Gekennzeichnet als „automatisch übertragen“ mit „Fehler melden“; eigene Fassungen der Redaktion haben immer Vorrang - Modell-Ausgabe wird nur bereinigt als HTML angezeigt (Live-Text nur als reiner Text) – getestet mit Schadcode aus dem Modell Anbieter (Einstellungen): Anthropic (Claude, Anthropic-SDK), OpenAI, DeepSeek, Ollama (OpenAI-kompatibel über das OpenAI-SDK); Modelle laden, Verbindung testen, API-Schlüssel AES-256-GCM-verschlüsselt und nie wieder angezeigt, Tageslimit, Sperre pro Gerät, Anrede du/Sie. Datenschutz-Vorlage um den Abschnitt „Automatische Leichte Sprache“ ergänzt. Seed: „heute“ liegt nicht mehr in der Zukunft (Meldung sonst unsichtbar). Co-Authored-By: Claude Opus 5.5 (1M context) --- .env.example | 3 - README.md | 9 +- docker-compose.yml | 1 - drizzle/0003_leichte_sprache_auto.sql | 8 + drizzle/meta/0003_snapshot.json | 1589 +++++++++++++++++ drizzle/meta/_journal.json | 7 + package-lock.json | 38 + package.json | 1 + scripts/seed.ts | 3 +- src/lib/admin/AiSettings.svelte | 138 ++ src/lib/admin/EasyLanguageField.svelte | 156 +- src/lib/components/RichContent.svelte | 141 +- src/lib/server/ai.ts | 159 ++ src/lib/server/content.ts | 5 + src/lib/server/db/schema.ts | 12 + src/lib/server/easy-auto.ts | 192 ++ src/lib/server/easy-language.ts | 115 -- src/lib/server/legal.ts | 13 +- src/lib/server/secret.ts | 24 +- src/lib/settings.ts | 24 +- .../(app)/meldungen/[slug]/+page.svelte | 2 +- src/routes/(app)/s/[slug]/+page.svelte | 2 +- src/routes/admin/(panel)/+layout.server.ts | 2 - .../(panel)/einstellungen/+page.server.ts | 19 +- .../admin/(panel)/einstellungen/+page.svelte | 17 +- .../(panel)/meldungen/[id]/+page.server.ts | 6 + .../admin/(panel)/meldungen/[id]/+page.svelte | 2 +- .../admin/(panel)/seiten/[id]/+page.server.ts | 6 + .../admin/(panel)/seiten/[id]/+page.svelte | 2 +- src/routes/admin/api/ki/config.ts | 16 + src/routes/admin/api/ki/modelle/+server.ts | 13 + src/routes/admin/api/ki/test/+server.ts | 26 + .../admin/api/leichte-sprache/+server.ts | 46 - src/routes/api/leichte-sprache/+server.ts | 59 + 34 files changed, 2527 insertions(+), 329 deletions(-) create mode 100644 drizzle/0003_leichte_sprache_auto.sql create mode 100644 drizzle/meta/0003_snapshot.json create mode 100644 src/lib/admin/AiSettings.svelte create mode 100644 src/lib/server/ai.ts create mode 100644 src/lib/server/easy-auto.ts delete mode 100644 src/lib/server/easy-language.ts create mode 100644 src/routes/admin/api/ki/config.ts create mode 100644 src/routes/admin/api/ki/modelle/+server.ts create mode 100644 src/routes/admin/api/ki/test/+server.ts delete mode 100644 src/routes/admin/api/leichte-sprache/+server.ts create mode 100644 src/routes/api/leichte-sprache/+server.ts diff --git a/.env.example b/.env.example index 15a8df4..788715e 100644 --- a/.env.example +++ b/.env.example @@ -16,9 +16,6 @@ SMTP_USER= SMTP_PASS= SMTP_FROM="Werkstatt-App " -# Leichte Sprache mit KI (Claude von Anthropic). Ohne Schlüssel ist der Knopf ausgeblendet. -ANTHROPIC_API_KEY= - # Push-Benachrichtigungen: Schlüssel werden beim ersten Start automatisch erzeugt und # in der Datenbank gespeichert. Nur setzen, wenn eigene Schlüssel verwendet werden sollen # (erzeugen mit: npx web-push generate-vapid-keys). diff --git a/README.md b/README.md index 9635c47..1a51763 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ Tablet und Desktop. - Termine & Schließzeiten, gruppiert nach Monat, mit Kalender-Abo (`/termine.ics`) - Ansprechpartner-Verzeichnis, Kontaktformular, Volltextsuche - **Barrierearm:** klare Schrift (Montserrat, selbst gehostet), 3 Schriftgrößen, Hell/Dunkel, - **Leichte Sprache** pro Seite/Meldung + **Leichte Sprache** pro Seite/Meldung – eigene geprüfte Fassung oder automatisch per KI übertragen + (live beim ersten Aufruf bzw. vorab beim Speichern, gekennzeichnet, mit „Fehler melden“) - **Vorlesen** jeder Seite (Knopf in der Kopfzeile) oder eines Artikels: satzweise, der gelesene Satz wird markiert und mitgescrollt, mit Pause, Satz vor/zurück und langsamem Tempo - **Push-Benachrichtigungen** zu Neuigkeiten und Schließzeiten (Themen frei wählbar, jederzeit abbestellbar) @@ -34,9 +35,8 @@ Tablet und Desktop. - Meldungen (Entwurf, geplante Veröffentlichung, anheften), Seitenbaum, Termine, Startseiten-Bereiche, Mediathek, Postfach - Text-Editor mit Formatierungen, Links und Bildern -- **Leichte Sprache per KI:** „Mit KI erstellen“ schreibt aus dem normalen Text einen Entwurf nach den - Regeln für Leichte Sprache (Claude Opus 5, live gestreamt, Anrede du/Sie einstellbar) – zum Prüfen - und Speichern +- **Leichte Sprache per KI** (Einstellungen): Anbieter Anthropic (Claude), OpenAI, DeepSeek oder Ollama, + Modell wählbar, Schlüssel verschlüsselt gespeichert, Verbindungstest, Tageslimit - Bilder werden automatisch gedreht, verkleinert und als WebP gespeichert - **Benachrichtigungen:** beim Erscheinen einer Meldung (auch zeitgesteuert), automatisch am Vortag einer Schließzeit, oder von Hand – mit Vorschau und Verlauf @@ -91,7 +91,6 @@ Ohne Docker: `npm ci && npm run build && ORIGIN=https://… BODY_SIZE_LIMIT=30M | `ADMIN_EMAIL` / `ADMIN_PASSWORD` | Erster Admin, wird angelegt, solange es noch keinen Benutzer gibt | | `BODY_SIZE_LIMIT` | Max. Upload-Größe (im Docker-Image auf 30M gesetzt) | | `SMTP_HOST`, `SMTP_PORT`, `SMTP_USER`, `SMTP_PASS`, `SMTP_FROM` | E-Mail-Versand für „Passwort vergessen“. Ohne SMTP steht der Link im Server-Log | -| `ANTHROPIC_API_KEY` | Für „Leichte Sprache mit KI“ (Claude). Ohne Schlüssel ist die Funktion ausgeblendet | | `VAPID_PUBLIC_KEY` / `VAPID_PRIVATE_KEY` | Optional – sonst werden die Push-Schlüssel automatisch erzeugt und gespeichert | ## Erweitern diff --git a/docker-compose.yml b/docker-compose.yml index e0d4697..469c0ef 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,6 @@ services: ORIGIN: ${ORIGIN:-http://localhost:3000} ADMIN_EMAIL: ${ADMIN_EMAIL:-} ADMIN_PASSWORD: ${ADMIN_PASSWORD:-} - ANTHROPIC_API_KEY: ${ANTHROPIC_API_KEY:-} SMTP_HOST: ${SMTP_HOST:-} SMTP_PORT: ${SMTP_PORT:-587} SMTP_SECURE: ${SMTP_SECURE:-false} diff --git a/drizzle/0003_leichte_sprache_auto.sql b/drizzle/0003_leichte_sprache_auto.sql new file mode 100644 index 0000000..9663a77 --- /dev/null +++ b/drizzle/0003_leichte_sprache_auto.sql @@ -0,0 +1,8 @@ +ALTER TABLE `pages` ADD `content_easy_auto` text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE `pages` ADD `content_easy_auto_hash` text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE `pages` ADD `content_easy_auto_model` text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE `pages` ADD `content_easy_auto_at` integer;--> statement-breakpoint +ALTER TABLE `posts` ADD `content_easy_auto` text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE `posts` ADD `content_easy_auto_hash` text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE `posts` ADD `content_easy_auto_model` text DEFAULT '' NOT NULL;--> statement-breakpoint +ALTER TABLE `posts` ADD `content_easy_auto_at` integer; \ No newline at end of file diff --git a/drizzle/meta/0003_snapshot.json b/drizzle/meta/0003_snapshot.json new file mode 100644 index 0000000..2d67f44 --- /dev/null +++ b/drizzle/meta/0003_snapshot.json @@ -0,0 +1,1589 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "4153f885-5cdd-4042-8617-86f0ea210fcb", + "prevId": "0e4c3bd0-5e88-49e2-812a-47ec8aee00c8", + "tables": { + "contacts": { + "name": "contacts", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "photo_id": { + "name": "photo_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "listed": { + "name": "listed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": {}, + "foreignKeys": { + "contacts_photo_id_media_id_fk": { + "name": "contacts_photo_id_media_id_fk", + "tableFrom": "contacts", + "tableTo": "media", + "columnsFrom": [ + "photo_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "editorial_comments": { + "name": "editorial_comments", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "item_id": { + "name": "item_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "editorial_comments_item_idx": { + "name": "editorial_comments_item_idx", + "columns": [ + "item_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "editorial_comments_item_id_editorial_items_id_fk": { + "name": "editorial_comments_item_id_editorial_items_id_fk", + "tableFrom": "editorial_comments", + "tableTo": "editorial_items", + "columnsFrom": [ + "item_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "editorial_comments_user_id_users_id_fk": { + "name": "editorial_comments_user_id_users_id_fk", + "tableFrom": "editorial_comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "editorial_items": { + "name": "editorial_items", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "notes": { + "name": "notes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'post'" + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'idea'" + }, + "assignee_id": { + "name": "assignee_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "due_date": { + "name": "due_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "post_id": { + "name": "post_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "page_id": { + "name": "page_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_by": { + "name": "created_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "editorial_date_idx": { + "name": "editorial_date_idx", + "columns": [ + "date" + ], + "isUnique": false + }, + "editorial_assignee_idx": { + "name": "editorial_assignee_idx", + "columns": [ + "assignee_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "editorial_items_assignee_id_users_id_fk": { + "name": "editorial_items_assignee_id_users_id_fk", + "tableFrom": "editorial_items", + "tableTo": "users", + "columnsFrom": [ + "assignee_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "editorial_items_post_id_posts_id_fk": { + "name": "editorial_items_post_id_posts_id_fk", + "tableFrom": "editorial_items", + "tableTo": "posts", + "columnsFrom": [ + "post_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "editorial_items_page_id_pages_id_fk": { + "name": "editorial_items_page_id_pages_id_fk", + "tableFrom": "editorial_items", + "tableTo": "pages", + "columnsFrom": [ + "page_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "editorial_items_created_by_users_id_fk": { + "name": "editorial_items_created_by_users_id_fk", + "tableFrom": "editorial_items", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "events": { + "name": "events", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'event'" + }, + "start_date": { + "name": "start_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "end_date": { + "name": "end_date", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "start_time": { + "name": "start_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "end_time": { + "name": "end_time", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "published": { + "name": "published", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "events_start_idx": { + "name": "events_start_idx", + "columns": [ + "start_date" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "media": { + "name": "media", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "thumbnail": { + "name": "thumbnail", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "original_name": { + "name": "original_name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "mime_type": { + "name": "mime_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "width": { + "name": "width", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "height": { + "name": "height", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alt": { + "name": "alt", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "media_filename_unique": { + "name": "media_filename_unique", + "columns": [ + "filename" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "messages": { + "name": "messages", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "kind": { + "name": "kind", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'contact'" + }, + "page_url": { + "name": "page_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "read": { + "name": "read", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pages": { + "name": "pages", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "parent_id": { + "name": "parent_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "teaser": { + "name": "teaser", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'file-text'" + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'sky'" + }, + "cover_id": { + "name": "cover_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy": { + "name": "content_easy", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto": { + "name": "content_easy_auto", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto_hash": { + "name": "content_easy_auto_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto_model": { + "name": "content_easy_auto_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto_at": { + "name": "content_easy_auto_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "contact_ids": { + "name": "contact_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "published": { + "name": "published", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "pages_slug_idx": { + "name": "pages_slug_idx", + "columns": [ + "slug" + ], + "isUnique": true + }, + "pages_parent_idx": { + "name": "pages_parent_idx", + "columns": [ + "parent_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "pages_parent_id_pages_id_fk": { + "name": "pages_parent_id_pages_id_fk", + "tableFrom": "pages", + "tableTo": "pages", + "columnsFrom": [ + "parent_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + }, + "pages_cover_id_media_id_fk": { + "name": "pages_cover_id_media_id_fk", + "tableFrom": "pages", + "tableTo": "media", + "columnsFrom": [ + "cover_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "password_resets": { + "name": "password_resets", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "password_resets_user_id_users_id_fk": { + "name": "password_resets_user_id_users_id_fk", + "tableFrom": "password_resets", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "posts": { + "name": "posts", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "teaser": { + "name": "teaser", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "cover_id": { + "name": "cover_id", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy": { + "name": "content_easy", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto": { + "name": "content_easy_auto", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto_hash": { + "name": "content_easy_auto_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto_model": { + "name": "content_easy_auto_model", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "content_easy_auto_at": { + "name": "content_easy_auto_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "video_url": { + "name": "video_url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "gallery": { + "name": "gallery", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "attachments": { + "name": "attachments", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "contact_ids": { + "name": "contact_ids", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "pinned": { + "name": "pinned", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "notify": { + "name": "notify", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "notified_at": { + "name": "notified_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "published": { + "name": "published", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "published_at": { + "name": "published_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "posts_slug_idx": { + "name": "posts_slug_idx", + "columns": [ + "slug" + ], + "isUnique": true + }, + "posts_published_idx": { + "name": "posts_published_idx", + "columns": [ + "published_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "posts_cover_id_media_id_fk": { + "name": "posts_cover_id_media_id_fk", + "tableFrom": "posts", + "tableTo": "media", + "columnsFrom": [ + "cover_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "push_messages": { + "name": "push_messages", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "topic": { + "name": "topic", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "''" + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'/'" + }, + "recipients": { + "name": "recipients", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "failures": { + "name": "failures", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "sent_by": { + "name": "sent_by", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "automatic": { + "name": "automatic", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "dedupe_key": { + "name": "dedupe_key", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "push_messages_dedupe_key_unique": { + "name": "push_messages_dedupe_key_unique", + "columns": [ + "dedupe_key" + ], + "isUnique": true + } + }, + "foreignKeys": { + "push_messages_sent_by_users_id_fk": { + "name": "push_messages_sent_by_users_id_fk", + "tableFrom": "push_messages", + "tableTo": "users", + "columnsFrom": [ + "sent_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "push_subscriptions": { + "name": "push_subscriptions", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "topics": { + "name": "topics", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "push_subscriptions_endpoint_unique": { + "name": "push_subscriptions_endpoint_unique", + "columns": [ + "endpoint" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "rate_limits": { + "name": "rate_limits", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "at": { + "name": "at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "rate_limits_key_idx": { + "name": "rate_limits_key_idx", + "columns": [ + "key", + "at" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "sessions": { + "name": "sessions", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "settings": { + "name": "settings", + "columns": { + "key": { + "name": "key", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "tiles": { + "name": "tiles", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'star'" + }, + "color": { + "name": "color", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'sky'" + }, + "href": { + "name": "href", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "sort_order": { + "name": "sort_order", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users": { + "name": "users", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "password_hash": { + "name": "password_hash", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'editor'" + }, + "totp_secret": { + "name": "totp_secret", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "totp_enabled": { + "name": "totp_enabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "recovery_codes": { + "name": "recovery_codes", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'[]'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "users_email_unique": { + "name": "users_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json index a5cc0c6..04ac2fc 100644 --- a/drizzle/meta/_journal.json +++ b/drizzle/meta/_journal.json @@ -22,6 +22,13 @@ "when": 1790788599464, "tag": "0002_sicherheit_push_recht", "breakpoints": true + }, + { + "idx": 3, + "version": "6", + "when": 1791006046542, + "tag": "0003_leichte_sprache_auto", + "breakpoints": true } ] } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index b87b2c6..99a9ac9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,6 +12,7 @@ "better-sqlite3": "^13.0.3", "drizzle-orm": "^0.45.3", "nodemailer": "^10.0.13", + "openai": "^7.27.0", "qrcode": "^1.5.4", "sanitize-html": "^2.17.0", "sharp": "^0.35.5", @@ -5088,6 +5089,43 @@ "node": ">=12.20.0" } }, + "node_modules/openai": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/openai/-/openai-7.27.0.tgz", + "integrity": "sha512-QDo1FvnRDZn15YwGVOhT9vpyypDiLphkd/7a4mcURWf5upMoEetgA6o4DJeII+ZZkC6m6DvlilCwii3+ynDcTw==", + "license": "Apache-2.0", + "engines": { + "node": ">=22.0.0" + }, + "peerDependencies": { + "@aws-sdk/credential-provider-node": ">=3.972.0 <4", + "@smithy/hash-node": ">=4.3.0 <5", + "@smithy/signature-v4": ">=5.4.0 <6", + "undici": ">=5 <9", + "ws": "^8.21.0", + "zod": "^3.25 || ^4.0" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-provider-node": { + "optional": true + }, + "@smithy/hash-node": { + "optional": true + }, + "@smithy/signature-v4": { + "optional": true + }, + "undici": { + "optional": true + }, + "ws": { + "optional": true + }, + "zod": { + "optional": true + } + } + }, "node_modules/orderedmap": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/orderedmap/-/orderedmap-2.1.1.tgz", diff --git a/package.json b/package.json index d69345c..153d691 100644 --- a/package.json +++ b/package.json @@ -22,6 +22,7 @@ "better-sqlite3": "^13.0.3", "drizzle-orm": "^0.45.3", "nodemailer": "^10.0.13", + "openai": "^7.27.0", "qrcode": "^1.5.4", "sanitize-html": "^2.17.0", "sharp": "^0.35.5", diff --git a/scripts/seed.ts b/scripts/seed.ts index 9ba0f09..eb74c3a 100644 --- a/scripts/seed.ts +++ b/scripts/seed.ts @@ -43,7 +43,8 @@ const daysAgo = (n: number, hour = 9) => { const d = new Date(); d.setDate(d.getDate() - n); d.setHours(hour, 0, 0, 0); - return d; + // „heute 9 Uhr“ darf nicht in der Zukunft liegen, sonst ist die Meldung noch unsichtbar + return d.getTime() > Date.now() ? new Date(Date.now() - 30 * 60e3) : d; }; /** Erzeugt ein ruhiges Demo-Titelbild: Farbfläche mit großem Kreisausschnitt (keine echten Fotos in der Demo). */ diff --git a/src/lib/admin/AiSettings.svelte b/src/lib/admin/AiSettings.svelte new file mode 100644 index 0000000..b1a909b --- /dev/null +++ b/src/lib/admin/AiSettings.svelte @@ -0,0 +1,138 @@ + + +
+ + +
+
+ + +
+
+ +
+ + +
+ {#each models as m (m)}{/each} + {#if p.defaultModel}

Leer = {p.defaultModel}

{/if} +
+
+ + +

+ {#if provider === 'ollama'} + Adresse eures Ollama-Servers mit /v1 am Ende, z. B. http://ki.intern:11434/v1. Die Texte verlassen dann euer Netz nicht. + {:else} + Nur nötig für einen eigenen Endpunkt oder Proxy. + {/if} +

+
+ {#if p.needsKey} +
+ + +

Wird verschlüsselt gespeichert und nie wieder angezeigt.

+ {#if ai.keyHint} + + {/if} +
+ {/if} +
+ +
+ + Testet die Angaben oben, auch ungespeichert. +
+ {#if result} +

{result.text}

+ {/if} + +
+
+ Anrede +
+ {#each ['du', 'Sie'] as a (a)} + + {/each} +
+
+
+ + +

Heute verwendet: {ai.usedToday}. Schützt vor unerwarteten Kosten.

+
+
+

+ Status: {#if ai.ready}eingerichtet und aktiv{:else}nicht aktiv – einschalten, Modell wählen{p.needsKey ? ' und Schlüssel eintragen' : ''}, dann speichern.{/if} +

+
diff --git a/src/lib/admin/EasyLanguageField.svelte b/src/lib/admin/EasyLanguageField.svelte index 6ad8df1..cb12ee6 100644 --- a/src/lib/admin/EasyLanguageField.svelte +++ b/src/lib/admin/EasyLanguageField.svelte @@ -1,141 +1,63 @@ -
-
- - {#if page.data.aiEasy} - {#if busy} - - {:else} - - {/if} - {/if} -
+ + +
diff --git a/src/lib/components/RichContent.svelte b/src/lib/components/RichContent.svelte index 8c0a0d0..daadbcf 100644 --- a/src/lib/components/RichContent.svelte +++ b/src/lib/components/RichContent.svelte @@ -1,29 +1,144 @@ -{#if contentEasy} -
- - - {useEasy ? 'Du liest diesen Text in Leichter Sprache.' : 'Diesen Text gibt es auch in Leichter Sprache.'} +{#if available} +
+ {#if mode === 'auto' || mode === 'pending'}
{/if} -{#if useEasy || content} -
- {@html useEasy ? contentEasy : content} +{#if mode === 'pending' && status === 'loading'} +
+

+ {#if liveText}

{liveText}

{/if}
+{:else} + {@const html = mode === 'manual' ? contentEasy : mode === 'auto' ? auto : content} + {#if html} +
+ {@html html} +
+ {/if} {/if}