`}},
- "timeIntervals": []any{map[string]any{"start": "2026-09-01T12:00:00+02:00"}},
- }
- event, _, _, _, err := parseDestinationEvent(item)
- if err != nil {
- t.Fatal(err)
- }
- if event.Description != "Musik & Markt\nEintritt frei" {
- t.Fatalf("description=%q", event.Description)
- }
-}
diff --git a/docs/EVENT_CALENDAR.md b/docs/EVENT_CALENDAR.md
index 1ce911e..06a69e6 100644
--- a/docs/EVENT_CALENDAR.md
+++ b/docs/EVENT_CALENDAR.md
@@ -1,46 +1,23 @@
# Veranstaltungskalender
## Öffentliche Seite
+`GET /veranstaltungen` zeigt ausschließlich veröffentlichte redaktionelle Veranstaltungen und eigene Einsendungen aus Niedersachsen. Auch die öffentliche Suche, Detailansicht, iCal-Ausgabe und Startseite verwenden diese selbst verwalteten Termine.
-`GET /veranstaltungen` zeigt veröffentlichte Termine aus ganz Niedersachsen. Kategorien umfassen unter anderem Familie, Flohmarkt, Konzert, Kultur, Land & Leute, Markt, Sport, Tradition und Verein.
+## Veranstaltungen eintragen
+Unter `/admin/events` kann die Landwelle-Redaktion Termine anlegen, bearbeiten, veröffentlichen, ablehnen oder löschen und Rubriken pflegen. Es gibt nur eine Veranstaltungsliste, mit serverseitiger Pagination. Der bisherige Niedersachsen-HUB-Reiter existiert nicht mehr.
-## Einsendungen
+`POST /veranstaltungen/einsenden` nimmt Veranstaltungsdaten und optional eine Grafik als JPG, PNG oder WebP bis 8 MB entgegen. Eingesandte Termine erhalten den Status `pending` und erscheinen erst nach redaktioneller Freigabe.
-`POST /veranstaltungen/einsenden` nimmt Veranstaltungsdaten und optional eine Grafik als JPG, PNG oder WebP bis 8 MB entgegen. Neue Einsendungen erhalten den Status `pending` und werden erst nach redaktioneller Prüfung sichtbar.
+## Keine automatische Übernahme externer Veranstaltungskalender
+Die ehemalige destination.one-/Niedersachsen-HUB-Anbindung und die zusätzlichen Tourismusseiten sind im Portal deaktiviert und aus dem Quellcode entfernt. Es gibt keine Import-Schaltflächen, Synchronisierungsjobs oder API-Zugangsdaten-Einstellungen mehr.
-Der Absender erhält über das Template `event_submission_confirmation` eine Bestätigung. Die Redaktion erhält über `event_submission_admin` eine Nachricht an `radio@landwelle.de`; eine hochgeladene Grafik wird als Anhang versendet.
+Aus Gründen der Datensicherheit löscht das Update keine bereits in PostgreSQL gespeicherten importierten Einträge. Die öffentlichen Veranstaltungsabfragen und die Adminliste filtern solche Datensätze aus. Die Navigation wird in Migration 0047 bereinigt.
-## Externe Quellen für Niedersachsen
+## Favoriten
+Eigene, veröffentlichte Termine können als Startseiten-Favorit markiert werden. Die bestehende Zufallsauswahl der bis zu drei Termine auf der Startseite bleibt bestehen; Fremddaten werden ausgeschlossen.
-Die bevorzugte landesweite Quelle ist der Niedersachsen Hub beziehungsweise dessen Open Data-Finder. Dort werden touristische Open-Data-Datensätze einschließlich Events aus niedersächsischen Regionen gebündelt. Ein produktiver Import sollte erst nach Klärung von API-Zugang, Lizenz, Aktualisierungsintervall und Quellenkennzeichnung aktiviert werden.
+## Suche und Kalender
+Die öffentliche Suche und Detailansicht laufen unter `/api/events/search` und `/api/events/`. Der Kalenderexport steht unter `/veranstaltungen/kalender.ics` bereit.
-Als ergänzende Quellen kommen offizielle kommunale und touristische Kalender in Betracht, sofern RSS, iCal, JSON-LD oder eine dokumentierte API angeboten wird. Jede Quelle muss einzeln auf Nutzungsrechte, Niedersachsen-Bezug und stabile Identifikatoren geprüft werden. Reines ungefragtes Scraping ist nicht vorgesehen.
-
-Empfohlene Priorität:
-
-1. Niedersachsen Hub / Open Data-Finder
-2. offizielle Tourismusorganisationen und kommunale Kalender
-3. iCal- oder RSS-Feeds von Vereinen, Städten und Veranstaltern
-4. manuelle Landwelle-Einsendungen und eigene redaktionelle Termine
-
-
-## destination.one-Import
-
-Der Niedersachsen-Hub-Import wird im Adminbereich unter **Einstellungen → Veranstaltungen** konfiguriert. Unterstützt werden eine vollständige API-URL, ein frei benennbarer Query-Parameter für den Lizenzschlüssel sowie Experience/Projekt und dessen Parametername. Standardwerte sind `licensekey`, `experience` und `Niedersachsen Hub`.
-
-Der Importer erwartet die destination.one-Ausgabe als JSON, erkennt gängige Container (`items`, `results`, `data`, `features`, `records`) und ordnet Titel, Termine, Ort, Beschreibung, Webseite, Bild, Quelle und Lizenz dem Landwelle-Datenmodell zu. Datensätze werden anhand von `source_name + external_id` aktualisiert.
-
-Bei aktivierter automatischer Veröffentlichung erscheinen importierte Termine unmittelbar. Ohne automatische Veröffentlichung werden sie als `pending` gespeichert. Die Lizenzentscheidung bleibt redaktionelle Verantwortung; zugelassen sind nur Daten und Bilder, deren konkrete Lizenz die Nutzung auf landwelle.de erlaubt.
-
-## Startseiten-Favoriten und Zufallsauswahl
-
-Unter `/admin/events?tab=submissions` können ausschließlich eigene Einsendungen und redaktionelle Termine als Startseiten-Favorit markiert werden. Importierte Open-Data-Termine bleiben von dieser Funktion ausgeschlossen.
-
-Die Startseite lädt alle veröffentlichten und noch gültigen Termine über `ListPublished`. Ist mindestens ein aktiver Favorit vorhanden, steht ein Favorit immer an Position 1. Bei mehreren aktiven Favoriten wird diese erste Position pro Seitenaufruf zufällig zwischen den Favoriten verteilt. Die beiden übrigen Plätze werden zufällig aus den noch nicht ausgewählten aktiven Veranstaltungen ergänzt. Doppelte Karten sind ausgeschlossen. Ohne aktiven Favoriten werden wie bisher bis zu drei Termine zufällig gewählt. Die Veranstaltungskalenderseite selbst bleibt chronologisch sortiert.
-
-Die Migration `0026_event_homepage_favorites.sql` ergänzt `homepage_favorite` und `homepage_favorite_at`. Abgelaufene Favoriten bleiben zwar historisch gespeichert, werden aufgrund der bestehenden Gültigkeitsprüfung aber nicht mehr auf der Startseite angezeigt.
-
-
-## Live-Suche und Detailmodal
-
-Die öffentliche Seite durchsucht Titel, Beschreibung, Ort, Veranstalter und Kategorie über `/api/events/search`. Ein Klick auf eine Karte lädt `/api/events/` und zeigt den vollständigen Text in einem Modal.
+## Release v1.5.72
+Die früheren Datenbankmigrationen 0014 und 0046 bleiben aus Gründen der Migrationshistorie bestehen; nicht benötigte Tourismus-Datenbanktabellen werden nicht automatisch gelöscht. Migration 0047 entfernt nur den automatisch hinzugefügten Navigationseintrag.
diff --git a/docs/NIEDERSACHSEN_HUB.md b/docs/NIEDERSACHSEN_HUB.md
deleted file mode 100644
index a16c68e..0000000
--- a/docs/NIEDERSACHSEN_HUB.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Niedersachsen Hub – Landwelle Tourismus (v1.5.71)
-
-## Bestehende Integration
-Der Event-Import (`destination_one.go`, `/admin/events`, `event_submissions`) bleibt unverändert. Der neue touristische Datenbereich nutzt `landwelle.tourism_hub_items` und eigene Sync-Cursor. Redaktionelle Landwelle-Beiträge bleiben unabhängig.
-
-## Unterstützte destination.one-Inhaltstypen
-POI (Sehenswürdigkeiten und Ausflüge), Tour, Gastro, Hotel, City, Area, Package und Article. Event bleibt im bisherigen Kalenderimport.
-
-## Einrichtung
-1. GitHub-Version v1.5.71 beziehen.
-2. Vor produktivem Einsatz `migrations/0046_niedersachsen_tourism_hub.sql` mit dem vorhandenen Migrator ausführen.
-3. Unter `/admin/settings#events` den bestehenden persönlichen destination.one-Lizenzschlüssel hinterlegen und die Verbindung aktivieren. Keine Schlüssel nach GitHub übertragen.
-4. Unter `/admin/niedersachsen-hub` einzelne Arten importieren, Quellen und Rechte prüfen und dann redaktionell freigeben.
-5. Die öffentliche Darstellung befindet sich unter `/niedersachsen-entdecken`.
-
-## Import
-Abfrage gegen `meta.et4.de/rest.ashx/search/` mit `experience=open-data-niedersachsen-tourismus`, `template=ET2014A.json`, `mkt=de-DE` und ausgewähltem Datentyp. Der Import lädt 100 Datensätze pro Seite und höchstens zehn Seiten pro Typ/Durchlauf. Fortschritte werden in `tourism_hub_sync_state` gesichert, sodass die nächsten Läufe fortsetzen. Eindeutigkeit: (content_type, external_id). Ohne persönlichen API-Schlüssel wurden keine echten Live-Daten abgerufen.
-
-## Nutzungsrechte
-Standard: nicht öffentlich. Unterstützte offen lizenzierte Daten: CC0, CC BY, CC BY-SA. NC, ND und unbekannte Rechte sind gesperrt. CC BY und CC BY-SA verlangen einen Urheber-/Quellnachweis. Bilder werden unabhängig von den Texten geprüft; ihre separate Lizenz und Bildurheberangaben werden gespeichert und öffentlich angezeigt. Manuell geänderte Rechte erzwingen eine erneute redaktionelle Freigabe. Die Redaktion muss mögliche weitere Lizenzbedingungen (etwa ShareAlike) beachten.
-
-## Einschränkungen
-Diese technische erste Ausbaustufe importiert die acht Arten mit allgemeinen Feldern wie Name, Kategorie, Beschreibung, Ort, Link und Bildrechten. GPX, Höhenprofile, Buchungs- und Echtzeitverfügbarkeiten, komplexe Öffnungszeiten und Mehrfach-Mediengalerien sind damit noch nicht eingebunden. Je Art sind realistische API-Beispiele und Funktionstests nach Bereitstellung des Lizenzschlüssels nötig.
diff --git a/events.go b/events.go
index b7d7747..54ed2b9 100644
--- a/events.go
+++ b/events.go
@@ -120,7 +120,7 @@ func (s *eventStore) Categories(ctx context.Context, includeInactive bool) ([]Ev
var out []EventCategory
q := `SELECT COALESCE(json_agg(json_build_object(
'id',c.id,'name',c.name,'sort_order',c.sort_order,'active',c.active,
-'event_count',(SELECT count(*) FROM landwelle.event_submissions e WHERE lower(e.category)=lower(c.name))
+'event_count',(SELECT count(*) FROM landwelle.event_submissions e WHERE e.source_type IN ('submission','editorial') AND lower(e.category)=lower(c.name))
) ORDER BY c.sort_order,c.name),'[]'::json)::text FROM landwelle.event_categories c` + where + `;`
if err := s.db.queryJSON(ctx, q, &out); err != nil {
return nil, err
@@ -145,7 +145,7 @@ func (s *eventStore) ListPublished(ctx context.Context, category string) ([]Cale
if s == nil || s.db == nil || !s.db.Enabled() {
return nil, nil
}
- where := "status='published' AND start_at >= date_trunc('day', now()) - interval '14 days' AND CASE WHEN end_at IS NULL OR end_at <= start_at OR end_at - start_at > interval '31 days' THEN date_trunc('day',start_at)+interval '1 day' ELSE end_at END > now()"
+ where := "status='published' AND source_type IN ('submission','editorial') AND start_at >= date_trunc('day', now()) - interval '14 days' AND CASE WHEN end_at IS NULL OR end_at <= start_at OR end_at - start_at > interval '31 days' THEN date_trunc('day',start_at)+interval '1 day' ELSE end_at END > now()"
if strings.TrimSpace(category) != "" {
where += " AND category=" + sqlText(category)
}
@@ -170,7 +170,7 @@ func (s *eventStore) SearchPublished(ctx context.Context, query, category string
if limit <= 0 || limit > 100 {
limit = 50
}
- where := "status='published' AND start_at >= date_trunc('day', now()) - interval '14 days' AND CASE WHEN end_at IS NULL OR end_at <= start_at OR end_at - start_at > interval '31 days' THEN date_trunc('day',start_at)+interval '1 day' ELSE end_at END > now()"
+ where := "status='published' AND source_type IN ('submission','editorial') AND start_at >= date_trunc('day', now()) - interval '14 days' AND CASE WHEN end_at IS NULL OR end_at <= start_at OR end_at - start_at > interval '31 days' THEN date_trunc('day',start_at)+interval '1 day' ELSE end_at END > now()"
if strings.TrimSpace(category) != "" {
where += " AND category=" + sqlText(strings.TrimSpace(category))
}
@@ -200,7 +200,7 @@ func (s *eventStore) GetPublished(ctx context.Context, id int64) (CalendarEvent,
'id',id,'title',title,'category',category,'start_at',start_at,'end_at',end_at,'venue',venue,'city',city,'postal_code',postal_code,
'organizer',organizer,'description',description,'website',website,'image_url',CASE WHEN image_path<>'' THEN '/event-media/'||image_path ELSE external_image_url END,
'source_name',source_name,'source_url',source_url,'homepage_favorite',homepage_favorite)),'[]'::json)::text FROM landwelle.event_submissions
-WHERE id=` + strconv.FormatInt(id, 10) + ` AND status='published' AND CASE WHEN end_at IS NULL OR end_at <= start_at OR end_at - start_at > interval '31 days' THEN date_trunc('day',start_at)+interval '1 day' ELSE end_at END > now();`
+WHERE id=` + strconv.FormatInt(id, 10) + ` AND source_type IN ('submission','editorial') AND status='published' AND CASE WHEN end_at IS NULL OR end_at <= start_at OR end_at - start_at > interval '31 days' THEN date_trunc('day',start_at)+interval '1 day' ELSE end_at END > now();`
var rows []CalendarEvent
if err := s.db.queryJSON(ctx, q, &rows); err != nil {
return CalendarEvent{}, false, err
diff --git a/events_manual_only_v1572_test.go b/events_manual_only_v1572_test.go
new file mode 100644
index 0000000..4203e84
--- /dev/null
+++ b/events_manual_only_v1572_test.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+ "os"
+ "strings"
+ "testing"
+)
+
+func TestEventManagementHasNoExternalHubIntegration(t *testing.T) {
+ // The old tourism API and scheduled destination.one importer are no longer wired.
+ checks := map[string][]string{
+ "main.go": { "newDestinationOneImporter", "newTourismHub", "/niedersachsen-entdecken" },
+ "admin.go": { "/admin/niedersachsen-hub", "/admin/settings/import-events", "destinationOne" },
+ "settings.go": { "DestinationOneSettings", "destination_one" },
+ "web/admin/settings.html": { "destination_one_", "Niedersachsen Hub" },
+ "web/admin/management.html": { "EventTab", "HubCount", "?tab=hub", "Niedersachsen Hub" },
+ }
+ for path, forbidden := range checks {
+ data, err := os.ReadFile(path)
+ if err != nil { t.Fatal(err) }
+ for _, token := range forbidden {
+ if strings.Contains(string(data), token) {
+ t.Errorf("%s still contains %q", path, token)
+ }
+ }
+ }
+}
+func TestOnlyOwnEventsUsedInPublicAndAdminListings(t *testing.T) {
+ for _, path := range []string{"events.go", "admin_management.go"} {
+ data, err := os.ReadFile(path)
+ if err != nil { t.Fatal(err) }
+ if !strings.Contains(string(data), "source_type IN ('submission','editorial')") {
+ t.Errorf("%s must restrict events to own submissions and editorial records", path)
+ }
+ }
+ html, err := webFS.ReadFile("web/admin/management.html")
+ if err != nil { t.Fatal(err) }
+ if !strings.Contains(string(html), "Neue Veranstaltung eintragen") ||
+ !strings.Contains(string(html), "Rubriken verwalten") ||
+ !strings.Contains(string(html), "value=\"delete\"") {
+ t.Fatal("manual event editing controls must remain available")
+ }
+}
diff --git a/main.go b/main.go
index 531458c..4bb1bde 100644
--- a/main.go
+++ b/main.go
@@ -36,7 +36,7 @@ const (
apiVersion = "v1"
apiContractVersion = "1.0.0"
applicationName = "Landwelle Radio"
- applicationVersion = "1.5.71"
+ applicationVersion = "1.5.72"
)
var publicTemplateFiles = []string{
@@ -73,7 +73,6 @@ var publicTemplateFiles = []string{
"web/contact.html",
"web/mediathek.html",
"web/landwelle-zuhause.html",
- "web/tourism.html",
}
func displayVersion() string {
@@ -280,8 +279,6 @@ func main() {
directoryAutomation := newDirectoryWorkflow(settings, emailTemplates)
youtube := newYouTubeFeedService()
jobs := newJobsService()
- destinationOne := newDestinationOneImporter(settings, events, logger)
- tourismHub := newTourismHub(database, settings, logger)
team := newTeamStore(database)
forum := newForumStore(database)
accounts := newPublicAuth(database, settings, emailTemplates, logger)
@@ -295,7 +292,7 @@ func main() {
}
}()
}
- admin, err := newAdminHandler(logger, weather, data, settings, nowPlayingService, programs, downloads, ai, editorial, wishes, emailTemplates, wishAutomation, media, database, team, forum, destinationOne, navigation, directory)
+ admin, err := newAdminHandler(logger, weather, data, settings, nowPlayingService, programs, downloads, ai, editorial, wishes, emailTemplates, wishAutomation, media, database, team, forum, navigation, directory)
if err != nil {
logger.Fatal(err)
}
@@ -328,8 +325,6 @@ func main() {
rss := newRSSEngine(database, logger)
rss.Start()
- destinationOne.Start()
- tourismHub.Start()
registerPublicAPI(mux, data, weather, nowPlayingService, traffic, programs, database, rss, editorial, events, team, charts, playlist)
registerMobileAppAPI(mux, mobileAPIDependencies{data: data, database: database, rss: rss, editorial: editorial, events: events, team: team, charts: charts, playlist: playlist, programs: programs, settings: settings, nowPlaying: nowPlayingService})
registerExternalV1Alias(mux)
@@ -527,8 +522,6 @@ func main() {
w.Header().Set("Cache-Control", "private, no-store")
http.ServeFile(w, r, path)
}))
- mux.HandleFunc("/niedersachsen-entdecken", tourismPublicHandler(tmpl, data, tourismHub, logger))
- mux.HandleFunc("/niedersachsen-entdecken/", tourismPublicHandler(tmpl, data, tourismHub, logger))
mux.HandleFunc("/veranstaltungen", eventsPageHandler(tmpl, logger, data, events))
mux.HandleFunc("/veranstaltungen/kalender.ics", eventsICalHandler(events, logger))
mux.HandleFunc("/veranstaltungen/einsenden", eventSubmissionHandler(events, eventAutomation, logger))
@@ -692,8 +685,6 @@ func main() {
ctx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
defer cancel()
rss.Stop(ctx)
- destinationOne.Stop(ctx)
- tourismHub.Stop(ctx)
if err := server.Shutdown(ctx); err != nil {
logger.Printf("Graceful Shutdown: %v", err)
}
diff --git a/main_test.go b/main_test.go
index 395c217..a345667 100644
--- a/main_test.go
+++ b/main_test.go
@@ -181,7 +181,7 @@ func TestWeatherHelpers(t *testing.T) {
}
func TestApplicationVersion(t *testing.T) {
- if applicationVersion != "1.5.71" {
+ if applicationVersion != "1.5.72" {
t.Fatalf("unexpected application version %q", applicationVersion)
}
}
diff --git a/migrations/0047_only_manual_events_navigation.sql b/migrations/0047_only_manual_events_navigation.sql
new file mode 100644
index 0000000..4d0693c
--- /dev/null
+++ b/migrations/0047_only_manual_events_navigation.sql
@@ -0,0 +1,7 @@
+SET search_path TO landwelle, public;
+
+-- The optional tourism navigation item was introduced by migration 0046.
+-- Remove only that route; keep all calendar records and legacy tables intact.
+DELETE FROM navigation_items
+WHERE url='/niedersachsen-entdecken'
+ AND trim(label)='Niedersachsen entdecken';
diff --git a/settings.go b/settings.go
index 0984dc1..4fdabdf 100644
--- a/settings.go
+++ b/settings.go
@@ -24,7 +24,6 @@ type RuntimeSettings struct {
FTP FTPSettings `json:"ftp"`
WishAutomation WishAutomationSettings `json:"wish_automation"`
Social SocialSettings `json:"social"`
- DestinationOne DestinationOneSettings `json:"destination_one"`
AudioBackgrounds []AudioBackgroundTrack `json:"audio_backgrounds"`
AIAudioModules map[string]AIAudioModuleSettings `json:"ai_audio_modules"`
Website WebsiteSettings `json:"website"`
@@ -38,17 +37,6 @@ func (w WebsiteSettings) GoogleAdSenseEnabled() bool {
return !strings.EqualFold(strings.TrimSpace(w.GoogleAdSenseMode), "disabled")
}
-type DestinationOneSettings struct {
- Enabled bool `json:"enabled"`
- APIURL string `json:"api_url"`
- APIKey string `json:"api_key"`
- KeyParameter string `json:"key_parameter"`
- Experience string `json:"experience"`
- ExperienceParam string `json:"experience_parameter"`
- IntervalMinutes int `json:"interval_minutes"`
- AutoPublish bool `json:"auto_publish"`
-}
-
type SocialSettings struct {
FacebookEnabled bool `json:"facebook_enabled"`
FacebookPageID string `json:"facebook_page_id"`
@@ -167,7 +155,6 @@ func defaultRuntimeSettings(streamURL string) RuntimeSettings {
SMTP: SMTPSettings{Enabled: envBool("LANDWELLE_SMTP_ENABLED", false), Host: envOr("LANDWELLE_SMTP_HOST", ""), Port: envIntRange("LANDWELLE_SMTP_PORT", 587, 1, 65535), Username: os.Getenv("LANDWELLE_SMTP_USER"), Password: os.Getenv("LANDWELLE_SMTP_PASSWORD"), FromName: envOr("LANDWELLE_SMTP_FROM_NAME", "Landwelle Radio"), FromEmail: envOr("LANDWELLE_SMTP_FROM_EMAIL", "radio@landwelle.de"), AdminEmail: envOr("LANDWELLE_ADMIN_EMAIL", "radio@landwelle.de"), TLSMode: envOr("LANDWELLE_SMTP_TLS_MODE", "starttls")},
FTP: FTPSettings{Enabled: envBool("LANDWELLE_FTP_ENABLED", false), Host: os.Getenv("LANDWELLE_FTP_HOST"), Port: envIntRange("LANDWELLE_FTP_PORT", 21, 1, 65535), Username: os.Getenv("LANDWELLE_FTP_USER"), Password: os.Getenv("LANDWELLE_FTP_PASSWORD"), TLS: envBool("LANDWELLE_FTP_TLS", false), Passive: true, TimeoutSeconds: 20},
Social: SocialSettings{FacebookAPIVersion: "v25.0", PublicBaseURL: envOr("LANDWELLE_PUBLIC_URL", "https://landwelle.de"), WhatsAppChannelURL: "https://whatsapp.com/channel/0029Vb8bu1P9Bb5t5ZbtF011"},
- DestinationOne: DestinationOneSettings{Enabled: envBool("LANDWELLE_DESTINATION_ONE_ENABLED", false), APIURL: envOr("LANDWELLE_DESTINATION_ONE_API_URL", "https://meta.et4.de/rest.ashx/search/ET2014A.json/"), APIKey: strings.TrimSpace(os.Getenv("LANDWELLE_DESTINATION_ONE_API_KEY")), KeyParameter: envOr("LANDWELLE_DESTINATION_ONE_KEY_PARAMETER", "licensekey"), Experience: envOr("LANDWELLE_DESTINATION_ONE_EXPERIENCE", ""), ExperienceParam: envOr("LANDWELLE_DESTINATION_ONE_EXPERIENCE_PARAMETER", "experience"), IntervalMinutes: envIntRange("LANDWELLE_DESTINATION_ONE_INTERVAL_MINUTES", 360, 15, 10080), AutoPublish: true},
WishAutomation: WishAutomationSettings{Enabled: false, Prompt: "Formuliere eine freundliche Radio-Anmoderation für den Musikwunsch. Nutze ausschließlich die gelieferten Angaben, keine erfundenen Fakten. Länge: 20 bis 35 Sekunden, direkt sprechbar, ohne Überschrift.", Temperature: 0.4, TTSVolume: 12, BackgroundVolume: -18, RemoteDirectory: "/musikwunsch", FileNamePattern: "musikwunsch-{{id}}.mp3", PublicBaseURL: envOr("LANDWELLE_PUBLIC_URL", "https://landwelle.de"), AutoProcessOnApprove: true, DeleteLocalAfterUpload: true},
AIAudioModules: defaultAIAudioModuleSettings(),
Website: WebsiteSettings{GoogleAdSenseMode: "enabled"},
@@ -271,18 +258,6 @@ func mergeSettings(defaults, loaded RuntimeSettings) RuntimeSettings {
if loaded.Social.WhatsAppChannelURL == "" {
loaded.Social.WhatsAppChannelURL = defaults.Social.WhatsAppChannelURL
}
- if loaded.DestinationOne.APIURL == "" {
- loaded.DestinationOne.APIURL = defaults.DestinationOne.APIURL
- }
- if loaded.DestinationOne.KeyParameter == "" {
- loaded.DestinationOne.KeyParameter = defaults.DestinationOne.KeyParameter
- }
- if loaded.DestinationOne.ExperienceParam == "" {
- loaded.DestinationOne.ExperienceParam = defaults.DestinationOne.ExperienceParam
- }
- if loaded.DestinationOne.IntervalMinutes == 0 {
- loaded.DestinationOne.IntervalMinutes = defaults.DestinationOne.IntervalMinutes
- }
if loaded.WishAutomation.Prompt == "" {
loaded.WishAutomation.Prompt = defaults.WishAutomation.Prompt
}
@@ -358,10 +333,6 @@ func (s *settingsStore) Save(settings RuntimeSettings) error {
settings.Social.FacebookAPIVersion = strings.Trim(strings.TrimSpace(settings.Social.FacebookAPIVersion), "/")
settings.Social.PublicBaseURL = strings.TrimRight(strings.TrimSpace(settings.Social.PublicBaseURL), "/")
settings.Social.WhatsAppChannelURL = strings.TrimSpace(settings.Social.WhatsAppChannelURL)
- settings.DestinationOne.APIURL = strings.TrimSpace(settings.DestinationOne.APIURL)
- settings.DestinationOne.KeyParameter = strings.TrimSpace(settings.DestinationOne.KeyParameter)
- settings.DestinationOne.Experience = strings.TrimSpace(settings.DestinationOne.Experience)
- settings.DestinationOne.ExperienceParam = strings.TrimSpace(settings.DestinationOne.ExperienceParam)
if strings.EqualFold(strings.TrimSpace(settings.Website.GoogleAdSenseMode), "disabled") {
settings.Website.GoogleAdSenseMode = "disabled"
} else {
@@ -471,17 +442,6 @@ func validateRuntimeSettings(settings RuntimeSettings) error {
return errors.New("FTP benötigt Host, Port und Benutzername")
}
}
- if settings.DestinationOne.Enabled {
- if settings.DestinationOne.APIKey == "" {
- return errors.New("für destination.one fehlt der Lizenzschlüssel")
- }
- if !validServiceURL(settings.DestinationOne.APIURL) {
- return errors.New("die destination.one API-URL ist ungültig")
- }
- if settings.DestinationOne.IntervalMinutes < 15 || settings.DestinationOne.IntervalMinutes > 10080 {
- return errors.New("das destination.one Intervall muss zwischen 15 und 10080 Minuten liegen")
- }
- }
if settings.WishAutomation.Enabled && settings.WishAutomation.VoiceID == "" {
return errors.New("für die Musikwunsch-Automation fehlt die ElevenLabs Voice ID")
}
diff --git a/tourism_hub.go b/tourism_hub.go
deleted file mode 100644
index 86956ab..0000000
--- a/tourism_hub.go
+++ /dev/null
@@ -1,406 +0,0 @@
-package main
-
-import (
- "context"
- "crypto/subtle"
- "encoding/json"
- "errors"
- "fmt"
- "html/template"
- "io"
- "log"
- "net/http"
- "net/url"
- "strconv"
- "strings"
- "sync"
- "time"
-)
-
-var tourismImportMu sync.Mutex
-
-var tourismTypes = []string{"POI", "Tour", "Gastro", "Hotel", "City", "Area", "Package", "Article"}
-
-func tourismTypeValid(value string) bool {
- for _, t := range tourismTypes { if t == value { return true } }
- return false
-}
-
-type tourismItem struct {
- ID int64 `json:"id"`
- ExternalID string `json:"external_id"`
- ContentType string `json:"content_type"`
- Title string `json:"title"`
- Category string `json:"category"`
- City string `json:"city"`
- PostalCode string `json:"postal_code"`
- Description string `json:"description"`
- Website string `json:"website"`
- SourceURL string `json:"source_url"`
- DataLicense string `json:"data_license"`
- Attribution string `json:"attribution"`
- ImageAttribution string `json:"image_attribution"`
- ImageURL string `json:"image_url"`
- ImageLicense string `json:"image_license"`
- Published bool `json:"published"`
-}
-type tourismListing struct {
- Items []tourismItem `json:"items"`
- Total int `json:"total"`
-}
-type tourismPageData struct {
- PageData
- Items []tourismItem
- Item *tourismItem
- Types []string
- FilterType, FilterCity, Query, Error string
- Page, Total, Pages, PrevPage, NextPage int
- HasPrev, HasNext bool
-}
-type tourismAdminData struct {
- Username, CSRFToken, Error, Success string
- Items []tourismItem
- Types []string
- KeySet, Enabled bool
-}
-
-type tourismHub struct {
- db *postgresStore
- settings *settingsStore
- logger *log.Logger
- client *http.Client
- cancel context.CancelFunc
- done chan struct{}
-}
-
-func newTourismHub(db *postgresStore, settings *settingsStore, logger *log.Logger) *tourismHub {
- return &tourismHub{db: db, settings: settings, logger: logger, client: &http.Client{Timeout: 35 * time.Second}}
-}
-func (h *tourismHub) Ready() bool { return h != nil && h.db != nil && h.db.Enabled() }
-func (h *tourismHub) Start() {
- if !h.Ready() || h.settings == nil { return }
- ctx, cancel := context.WithCancel(context.Background())
- h.cancel = cancel
- h.done = make(chan struct{})
- go func() {
- defer close(h.done)
- timer := time.NewTimer(2 * time.Minute)
- defer timer.Stop()
- for {
- select {
- case <-ctx.Done(): return
- case <-timer.C:
- cfg := h.settings.Get().DestinationOne
- if cfg.Enabled && strings.TrimSpace(cfg.APIKey) != "" {
- for _, kind := range tourismTypes {
- runCtx, stop := context.WithTimeout(ctx, 4*time.Minute)
- _, err := h.SyncType(runCtx, kind)
- stop()
- if err != nil && h.logger != nil { h.logger.Printf("Tourismus-HUB %s: %v", kind, err) }
- if ctx.Err() != nil { return }
- }
- }
- interval := time.Duration(cfg.IntervalMinutes) * time.Minute
- if interval < 15*time.Minute { interval = 6*time.Hour }
- timer.Reset(interval)
- }
- }
- }()
-}
-func (h *tourismHub) Stop(ctx context.Context) {
- if h == nil || h.cancel == nil { return }
- h.cancel()
- select { case <-h.done: case <-ctx.Done(): }
-}
-
-// CC BY and CC BY-SA are usable only with attribution; media rights are separate.
-// Deliberately reject ambiguous or non-open licenses.
-func tourismLicense(raw string) string {
- s := strings.ToLower(strings.TrimSpace(raw))
- // Never accept non-commercial or no-derivatives licenses.
- if strings.Contains(s,"-nc") || strings.Contains(s,"-nd") || strings.Contains(s,"/nc/") || strings.Contains(s,"/nd/") ||
- strings.Contains(s,"by-nc") || strings.Contains(s,"by-nd") ||
- strings.Contains(s,"by nc") || strings.Contains(s,"by nd") ||
- strings.Contains(s,"noncommercial") || strings.Contains(s,"no derivatives") ||
- strings.Contains(s,"noderivatives") { return "" }
- switch {
- case strings.Contains(s, "creativecommons.org/publicdomain/zero/"), strings.Contains(s, "cc0"), strings.Contains(s, "cc-0"): return "CC0"
- case strings.Contains(s, "creativecommons.org/licenses/by-sa/"), strings.Contains(s, "cc-by-sa"), strings.Contains(s, "cc by-sa"), strings.Contains(s, "cc by sa"): return "CC BY-SA"
- case strings.Contains(s, "creativecommons.org/licenses/by/"), strings.Contains(s, "cc-by"), strings.Contains(s, "cc by"): return "CC BY"
- default: return ""
- }
-}
-func tourismMediaRights(m map[string]any, chosenURL string) (license, attribution string) {
- if chosenURL=="" { return "", "" }
- for _,key:=range []string{"media","medias","images","pictures","assets","mediaObjects"} {
- val,ok:=d1ValueCaseInsensitive(m,key)
- if !ok {continue}
- entries:=[]any{}
- if items,ok:=val.([]any);ok {entries=items} else {entries=[]any{val}}
- for _,entry:=range entries{
- obj,ok:=entry.(map[string]any)
- if !ok {continue}
- candidate:=tourismNormalizeURL(d1FirstStringCI(obj,"url","href","src","value"))
- if candidate!=chosenURL {continue}
- lic:=tourismLicense(d1FirstStringCI(obj,"license","licence","rights"))
- att:=d1FirstStringCI(obj,"copyright","attribution","credit","author","creator")
- if lic=="CC0" || (lic!="" && att!="") {return lic,att}
- }
- }
- return "", ""
-}
-func tourismNormalizeURL(raw string) string {
- u, err := url.Parse(strings.TrimSpace(raw))
- if err != nil || u.Host == "" || (u.Scheme != "https" && u.Scheme != "http") || u.User != nil { return "" }
- return u.String()
-}
-
-func tourismParse(kind string, m map[string]any) (tourismItem, error) {
- v := tourismItem{
- ContentType: kind,
- ExternalID: d1FirstStringCI(m, "global_id", "globalId", "id", "identifier", "uuid"),
- Title: d1FirstStringCI(m, "title", "name", "headline"),
- Category: d1Category(m),
- City: d1FirstStringCI(m, "city", "locality", "town"),
- PostalCode: d1FirstStringCI(m, "postalCode", "postal_code", "zip"),
- Description: normalizeDestinationText(d1TextByRel(m, "details", "detail", "teaser", "description", "shortdescription")),
- Website: tourismNormalizeURL(d1URL(m)),
- DataLicense: tourismLicense(d1License(m)),
- Attribution: d1FirstStringCI(m,"attribution","copyright","credit","author","creator","provider"),
- ImageURL: tourismNormalizeURL(extractImage(m)),
- }
- if v.Description == "" { v.Description = normalizeDestinationText(d1FirstStringCI(m, "description", "text", "shortDescription", "longDescription")) }
- if address := d1Address(m); address != nil {
- if v.City == "" { v.City = d1FirstStringCI(address, "city", "addressLocality", "locality", "town", "municipality") }
- if v.PostalCode == "" { v.PostalCode = d1FirstStringCI(address, "postalCode", "zip", "postal_code") }
- }
- if v.City == "" { v.City = d1RecursiveStringForKeys(m, "city", "addressLocality", "town", "municipality") }
- if v.PostalCode == "" { v.PostalCode = d1RecursiveStringForKeys(m, "postalCode", "zip") }
- v.SourceURL = tourismNormalizeURL(d1FirstStringCI(m, "url", "website", "link"))
- if v.SourceURL == "" { v.SourceURL = v.Website }
- if !tourismTypeValid(kind) { return v, errors.New("ungültiger touristischer Datentyp") }
- if v.Title == "" { return v, errors.New("Titel fehlt") }
- if v.ExternalID == "" { return v, errors.New("Quellen-ID fehlt") }
- // Image rights must be independent of the textual data rights.
- v.ImageLicense,v.ImageAttribution=tourismMediaRights(m,v.ImageURL)
- if len(v.Website)>1800 {v.Website=""}
- if len(v.SourceURL)>1800 {v.SourceURL=""}
- if len(v.ImageURL)>1800 {v.ImageURL="";v.ImageLicense="";v.ImageAttribution=""}
- if len(v.Attribution)>500 {v.Attribution=string([]rune(v.Attribution)[:min(len([]rune(v.Attribution)),500)])}
- if len(v.ImageAttribution)>500 {v.ImageAttribution=string([]rune(v.ImageAttribution)[:min(len([]rune(v.ImageAttribution)),500)])}
- if len(v.Title) > 250 { v.Title = v.Title[:250] }
- if len(v.Description) > 12000 { v.Description = v.Description[:12000] }
- return v, nil
-}
-func (h *tourismHub) SyncType(ctx context.Context, kind string) (int, error) {
- if !h.Ready() { return 0, errors.New("Datenbank nicht verfügbar") }
- if !tourismTypeValid(kind) { return 0, errors.New("ungültiger Typ") }
- if !tourismImportMu.TryLock() { return 0, errors.New("Import läuft bereits") }
- defer tourismImportMu.Unlock()
- cfg := h.settings.Get().DestinationOne
- if !cfg.Enabled || cfg.APIKey == "" { return 0, errors.New("Niedersachsen-HUB unter Einstellungen aktivieren und Lizenzschlüssel hinterlegen") }
- base, err := destinationOneURL(cfg)
- if err != nil { return 0, err }
- offset,err:=h.NextOffset(ctx,kind)
- if err!=nil{return 0,err}
- total := 0
- for page := 0; page < 10; page++ {
- u := *base
- q := u.Query()
- q.Set("type", kind)
- q.Set("limit", "100")
- q.Set("offset", strconv.Itoa(offset+page*100))
- q.Set("mkt", "de-DE")
- u.RawQuery = q.Encode()
- req, err := http.NewRequestWithContext(ctx, http.MethodGet, u.String(), nil)
- if err != nil { return total, err }
- req.Header.Set("Accept", "application/json")
- resp, err := h.client.Do(req)
- if err != nil { return total, fmt.Errorf("%s Abruf: %w", kind, err) }
- body, readErr := io.ReadAll(io.LimitReader(resp.Body, 16<<20))
- resp.Body.Close()
- if readErr != nil { return total, readErr }
- if resp.StatusCode != http.StatusOK { return total, fmt.Errorf("%s API HTTP %d", kind, resp.StatusCode) }
- var payload any
- if err := json.Unmarshal(body, &payload); err != nil { return total, fmt.Errorf("%s: kein gültiges JSON: %w", kind, err) }
- items := destinationMaps(payload)
- if page == 0 && offset==0 && len(items) == 0 { return 0, fmt.Errorf("%s: keine items in API-Antwort", kind) }
- parsed:=make([]tourismItem,0,len(items))
- seen:=make(map[string]struct{},len(items))
- for _, raw := range items {
- item, err := tourismParse(kind, raw)
- if err != nil {continue}
- if _,duplicate:=seen[item.ExternalID];duplicate {continue}
- seen[item.ExternalID]=struct{}{}
- parsed=append(parsed,item)
- }
- if err:=h.UpsertBatch(ctx,parsed);err!=nil{return total,err}
- total+=len(parsed)
- next:=offset+(page+1)*100
- if len(items)<100 {next=0}
- if err:=h.SaveOffset(ctx,kind,next);err!=nil{return total,err}
- if len(items) < 100 { break }
- }
- return total, nil
-}
-// The source catalogue can contain many thousands of records.
-// Save progress after each page, so a timeout never forces a restart from page zero.
-func (h *tourismHub) NextOffset(ctx context.Context, kind string) (int,error) {
- var next int
- q:="SELECT COALESCE((SELECT next_offset FROM landwelle.tourism_hub_sync_state WHERE content_type="+sqlText(kind)+"),0)::text;"
- if err:=h.db.queryJSON(ctx,q,&next);err!=nil{return 0,fmt.Errorf("Importfortsetzung benötigt Migration 0046: %w",err)}
- if next<0 || next>1000000 {return 0,errors.New("Import-Offset ungültig")}
- return next,nil
-}
-func (h *tourismHub) SaveOffset(ctx context.Context, kind string, next int) error {
- q:="INSERT INTO landwelle.tourism_hub_sync_state(content_type,next_offset,last_sync_at) VALUES ("+sqlText(kind)+","+strconv.Itoa(next)+",now()) "+
- "ON CONFLICT(content_type) DO UPDATE SET next_offset=excluded.next_offset,last_sync_at=excluded.last_sync_at;"
- _,err:=h.db.exec(ctx,q)
- return err
-}
-// Batch in groups of five to stay below operating-system command argument
-// limits of the existing psql-based storage adapter even with long descriptions.
-func (h *tourismHub) UpsertBatch(ctx context.Context, items []tourismItem) error {
- if !h.Ready() {return errors.New("Datenbank nicht verfügbar")}
- for start:=0;startlen(items){end=len(items)}
- values:=make([]string,0,end-start)
- for _,v:=range items[start:end] {
- values=append(values,"("+strings.Join([]string{
- sqlText(v.ExternalID),sqlText(v.ContentType),sqlText(v.Title),sqlText(v.Category),
- sqlText(v.City),sqlText(v.PostalCode),sqlText(v.Description),sqlText(v.Website),
- sqlText(v.SourceURL),sqlText(v.DataLicense),sqlText(v.Attribution),sqlText(v.ImageURL),
- sqlText(v.ImageLicense),sqlText(v.ImageAttribution),"now()",
- },",")+")")
- }
- query:="INSERT INTO landwelle.tourism_hub_items(external_id,content_type,title,category,city,postal_code,description,website,source_url,data_license,attribution,image_url,image_license,image_attribution,last_seen) VALUES "+
- strings.Join(values,",")+" ON CONFLICT(content_type,external_id) DO UPDATE SET title=excluded.title,category=excluded.category,city=excluded.city,postal_code=excluded.postal_code,description=excluded.description,website=excluded.website,source_url=excluded.source_url,data_license=excluded.data_license,"+
- "attribution=CASE WHEN excluded.attribution='' THEN landwelle.tourism_hub_items.attribution ELSE excluded.attribution END,"+
- "image_url=excluded.image_url,image_license=CASE WHEN excluded.image_url=landwelle.tourism_hub_items.image_url AND excluded.image_license='' THEN landwelle.tourism_hub_items.image_license ELSE excluded.image_license END,"+
- "image_attribution=CASE WHEN excluded.image_url=landwelle.tourism_hub_items.image_url AND excluded.image_license='' THEN landwelle.tourism_hub_items.image_attribution ELSE excluded.image_attribution END,"+
- "last_seen=now(),updated_at=now(),published=CASE WHEN excluded.data_license='' OR (excluded.data_license<>'CC0' AND excluded.attribution='' AND landwelle.tourism_hub_items.attribution='') THEN false ELSE landwelle.tourism_hub_items.published END;"
- if _,err:=h.db.exec(ctx,query);err!=nil{return err}
- }
- return nil
-}
-func (h *tourismHub) Upsert(ctx context.Context, item tourismItem) error {
- return h.UpsertBatch(ctx,[]tourismItem{item})
-}
-func (h *tourismHub) List(ctx context.Context, kind, city, search string, publishedOnly bool, page, perPage int) (tourismListing, error) {
- out := tourismListing{Items: []tourismItem{}}
- if !h.Ready() { return out, nil }
- if page < 1 { page = 1 }
- if perPage < 1 || perPage > 100 { perPage = 24 }
- where := []string{"1=1"}
- if publishedOnly { where = append(where, "published=true AND data_license IN ('CC0','CC BY','CC BY-SA') AND (data_license='CC0' OR attribution<>'')") }
- if tourismTypeValid(kind) { where = append(where, "content_type="+sqlText(kind)) }
- if city != "" { where = append(where, "lower(city) LIKE lower("+sqlText("%"+city+"%")+")") }
- if search != "" { where = append(where, "(title ILIKE "+sqlText("%"+search+"%")+" OR description ILIKE "+sqlText("%"+search+"%")+")") }
- condition := strings.Join(where, " AND ")
- query := "SELECT json_build_object('total',(SELECT count(*) FROM landwelle.tourism_hub_items WHERE "+condition+"),'items',"+
- "(SELECT coalesce(json_agg(row_to_json(p)),'[]'::json) FROM (SELECT id,external_id,content_type,title,category,city,postal_code,description,website,source_url,data_license,attribution,"+
- "CASE WHEN image_license='CC0' OR (image_license IN ('CC BY','CC BY-SA') AND image_attribution<>'') THEN image_url ELSE '' END AS image_url,image_license,image_attribution,published "+
- "FROM landwelle.tourism_hub_items WHERE "+condition+" ORDER BY title,id LIMIT "+strconv.Itoa(perPage)+" OFFSET "+strconv.Itoa((page-1)*perPage)+") p))::text;"
- err := h.db.queryJSON(ctx, query, &out)
- return out, err
-}
-func (h *tourismHub) Detail(ctx context.Context, id int64) (*tourismItem, error) {
- if !h.Ready() { return nil, nil }
- var item *tourismItem
- query := "SELECT coalesce((SELECT row_to_json(p)::text FROM (SELECT id,external_id,content_type,title,category,city,postal_code,description,website,source_url,data_license,attribution,"+
- "CASE WHEN image_license='CC0' OR (image_license IN ('CC BY','CC BY-SA') AND image_attribution<>'') THEN image_url ELSE '' END AS image_url,image_license,image_attribution,published "+
- "FROM landwelle.tourism_hub_items WHERE id="+strconv.FormatInt(id,10)+" AND published=true AND data_license IN ('CC0','CC BY','CC BY-SA') AND (data_license='CC0' OR attribution<>'')) p),'null');"
- if err := h.db.queryJSON(ctx, query, &item); err != nil { return nil, err }
- return item, nil
-}
-func (h *tourismHub) SetPublished(ctx context.Context, id int64, publish bool) error {
- if !h.Ready() { return errors.New("Datenbank nicht verfügbar") }
- clause := ""
- if publish { clause = " AND data_license IN ('CC0','CC BY','CC BY-SA') AND (data_license='CC0' OR attribution<>'')" }
- query := "UPDATE landwelle.tourism_hub_items SET published="+sqlBool(publish)+",updated_at=now() WHERE id="+strconv.FormatInt(id,10)+clause+" RETURNING id;"
- data, err := h.db.exec(ctx, query)
- if err != nil { return err }
- if strings.TrimSpace(string(data)) == "" { return errors.New("Datensatz fehlt oder Lizenz nicht freigegeben") }
- return nil
-}
-func (h *tourismHub) ReviewRights(ctx context.Context, id int64, attribution, imageLicense, imageAttribution string) error {
- if !h.Ready() { return errors.New("Datenbank nicht verfügbar") }
- attribution = strings.TrimSpace(attribution)
- imageLicense = tourismLicense(imageLicense)
- imageAttribution = strings.TrimSpace(imageAttribution)
- if len(attribution)>500 || len(imageAttribution)>500 {return errors.New("Urheberangabe zu lang")}
- if imageLicense!="" && imageLicense!="CC0" && imageAttribution=="" {
- return errors.New("Bei CC-BY-Bildern ist eine Urheberangabe Pflicht")
- }
- query:="UPDATE landwelle.tourism_hub_items SET attribution="+sqlText(attribution)+",image_license="+sqlText(imageLicense)+",image_attribution="+sqlText(imageAttribution)+",published=false,updated_at=now() WHERE id="+strconv.FormatInt(id,10)+" RETURNING id;"
- data,err:=h.db.exec(ctx,query)
- if err!=nil {return err}
- if strings.TrimSpace(string(data))==""{return errors.New("Datensatz nicht gefunden")}
- return nil
-}
-func tourismPublicHandler(tmpl *template.Template, data PageData, h *tourismHub, logger *log.Logger) http.HandlerFunc {
- return func(w http.ResponseWriter, r *http.Request) {
- if r.Method != http.MethodGet && r.Method != http.MethodHead { http.Error(w, "Methode nicht erlaubt", http.StatusMethodNotAllowed); return }
- if r.URL.Path != "/niedersachsen-entdecken" && !strings.HasPrefix(r.URL.Path, "/niedersachsen-entdecken/") { http.NotFound(w,r); return }
- d := tourismPageData{PageData:data, Types:tourismTypes, Page:1, FilterType:r.URL.Query().Get("typ"), FilterCity:strings.TrimSpace(r.URL.Query().Get("ort")), Query:strings.TrimSpace(r.URL.Query().Get("suche"))}
- if len(d.FilterCity)>80 { d.FilterCity=d.FilterCity[:80] }
- if len(d.Query)>100 { d.Query=d.Query[:100] }
- if strings.HasPrefix(r.URL.Path,"/niedersachsen-entdecken/") {
- n,err:=strconv.ParseInt(strings.TrimPrefix(r.URL.Path,"/niedersachsen-entdecken/"),10,64)
- if err != nil || n<1 {http.NotFound(w,r);return}
- item,err:=h.Detail(r.Context(),n)
- if err!=nil {logger.Printf("Tourismus Detail: %v",err);http.Error(w,"Daten derzeit nicht verfügbar",500);return}
- if item==nil {http.NotFound(w,r);return}
- d.Item=item
- } else {
- d.Page,_=strconv.Atoi(r.URL.Query().Get("seite"))
- if d.Page<1 || d.Page>10000 {d.Page=1}
- result,err:=h.List(r.Context(),d.FilterType,d.FilterCity,d.Query,true,d.Page,24)
- if err!=nil {logger.Printf("Tourismus Suche: %v",err);d.Error="Die touristischen Daten sind momentan nicht verfügbar."}
- d.Items=result.Items;d.Total=result.Total;d.Pages=(d.Total+23)/24
- d.HasPrev=d.Page>1;d.HasNext=d.Page0 {err=hub.ReviewRights(r.Context(),id,r.FormValue("attribution"),r.FormValue("image_license"),r.FormValue("image_attribution"))}
- if err!=nil {flash="Fehler: "+err.Error()} else {flash="Nutzungsrechte gespeichert; Datensatz ist zur erneuten Freigabe vorgemerkt."}
- case "publish","unpublish":
- id,err:=strconv.ParseInt(r.FormValue("id"),10,64)
- if err==nil && id>0 {err=hub.SetPublished(r.Context(),id,r.FormValue("action")=="publish")}
- if err!=nil{flash="Fehler: "+err.Error()} else {flash="Freigabestatus gespeichert."}
- default: http.Error(w,"Aktion nicht unterstützt",400);return
- }
- }
- cfg:=a.settings.Get().DestinationOne
- list,err:=hub.List(r.Context(),"","","",false,1,80)
- d:=tourismAdminData{Username:session.Username,CSRFToken:session.CSRFToken,Types:tourismTypes,Items:list.Items,KeySet:cfg.APIKey!="",Enabled:cfg.Enabled,Success:flash}
- if err!=nil{d.Error="Tourismus-Datenbank nicht bereit: "+err.Error()}
- if strings.HasPrefix(flash,"Fehler:"){d.Error=flash;d.Success=""}
- t,err:=parseAdminTemplate("web/admin/tourism.html")
- if err!=nil{http.Error(w,"Admin-Template nicht verfügbar",500);a.logger.Printf("Tourismus-Admin Template: %v",err);return}
- setAdminHTMLHeaders(w)
- if err=t.ExecuteTemplate(w,"tourism-admin.html",d);err!=nil{a.logger.Printf("Tourismus-Admin Render: %v",err)}
-}
diff --git a/tourism_hub_test.go b/tourism_hub_test.go
deleted file mode 100644
index 586229d..0000000
--- a/tourism_hub_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package main
-
-import (
- "bytes"
- "html/template"
- "strings"
- "testing"
-)
-
-func TestTourismHubTypesAndLicenses(t *testing.T) {
- if len(tourismTypes)!=8 { t.Fatalf("expected 8 tourist types, got %d",len(tourismTypes)) }
- for _,kind:=range tourismTypes {if !tourismTypeValid(kind){t.Fatalf("invalid supported type %s",kind)}}
- if tourismTypeValid("Event") || tourismTypeValid("all"){t.Fatal("events must remain in existing event importer")}
- tests:=[]struct{raw,want string}{
- {"CC0 1.0","CC0"},
- {"https://creativecommons.org/licenses/by/4.0/","CC BY"},
- {"https://creativecommons.org/licenses/by-sa/4.0/","CC BY-SA"},
- {"CC BY-NC 4.0",""},
- {"CC BY-ND 4.0",""},
- {"CC BY-SA-NC 4.0",""},
- {"copyright",""},
- {"All rights reserved",""},
- {"",""},
- }
- for _,tc:=range tests {if got:=tourismLicense(tc.raw);got!=tc.want{t.Errorf("%q => %q, want %q",tc.raw,got,tc.want)}}
-}
-
-func TestTourismHubParseSeparatesDataAndImageLicense(t *testing.T) {
- src:=map[string]any{
- "id":"nds:poi-1",
- "title":"Historisches Ausflugsziel",
- "categories":[]any{map[string]any{"name":"Sehenswürdigkeit"}},
- "address":map[string]any{"city":"Celle","postalCode":"29221"},
- "description":"
Ein Ort in Niedersachsen.
",
- "license":"CC BY 4.0",
- "media":[]any{map[string]any{"url":"https://example.org/image.jpg"}},
- "website":"https://example.org/",
- }
- item,err:=tourismParse("POI",src)
- if err!=nil{t.Fatal(err)}
- if item.ExternalID!="nds:poi-1" || item.City!="Celle" || item.PostalCode!="29221"{t.Fatalf("fields not parsed: %+v",item)}
- if item.DataLicense!="CC BY"{t.Fatalf("data license incorrect: %s",item.DataLicense)}
- if item.ImageLicense!=""{t.Fatal("image license must NOT be inferred from text license")}
- if item.Published{t.Fatal("import must not auto-publish")}
- if strings.Contains(item.Description,"
"){t.Fatal("HTML tags leaked into description")}
- if _,err:=tourismParse("Event",src);err==nil{t.Fatal("event import must be separate")}
-}
-func TestTourismHubURLSafety(t *testing.T){
- for _,s:=range []string{"javascript:alert(1)","file:///etc/passwd","https://example.org@evil.test", "ftp://example.org/file"}{
- if s=="https://example.org@evil.test"{continue} // ordinary URL userinfo is checked below
- if got:=tourismNormalizeURL(s);got!=""{t.Errorf("accepted %q as %q",s,got)}
- }
- if got:=tourismNormalizeURL("https://user:pass@example.org/");got!=""{t.Fatalf("accepted credentials in URL: %q",got)}
- if got:=tourismNormalizeURL("https://example.org/path");got==""{t.Fatal("rejected valid HTTPS URL")}
-}
-
-func TestTourismHubTemplatesRender(t *testing.T) {
- admin,err:=parseAdminTemplate("web/admin/tourism.html")
- if err!=nil{t.Fatalf("admin tourism parse: %v",err)}
- var b bytes.Buffer
- if err:=admin.ExecuteTemplate(&b,"tourism-admin.html",tourismAdminData{Username:"redaktion",CSRFToken:"test",Types:tourismTypes});err!=nil{
- t.Fatalf("admin tourism render: %v",err)
- }
- if !strings.Contains(b.String(),"Niedersachsen Hub verwalten") {t.Fatal("admin tourism view missing")}
- tpls,err:=template.New("portal").Funcs(template.FuncMap{
- "year":func()int{return 2026},
- "seoHead":seoHead,
- "publicNavigation":func() template.HTML{return ""},
- }).ParseFS(webFS,"web/partials.html","web/tourism.html")
- if err!=nil {t.Fatalf("tourism public parse: %v",err)}
- b.Reset()
- if err:=tpls.ExecuteTemplate(&b,"tourism.html",tourismPageData{PageData:pageData(),Types:tourismTypes,Page:1});err!=nil{
- t.Fatalf("tourism public render: %v",err)
- }
- if !strings.Contains(b.String(),"Niedersachsen entdecken") {t.Fatal("public tourism view missing")}
-}
diff --git a/web/admin/management.html b/web/admin/management.html
index dc6226e..bf3e244 100644
--- a/web/admin/management.html
+++ b/web/admin/management.html
@@ -45,15 +45,15 @@
{{end}}
{{else if eq .Module "events"}}
-
Kalender
Veranstaltungen verwalten
Hub-Termine und eigene Veranstaltungen getrennt verwalten. Eigene Termine kannst du direkt anlegen, bearbeiten und veröffentlichen.
-
-{{if eq .EventTab "hub"}}
Niedersachsen HubHier erscheinen aktuelle importierte Termine. Änderungen an importierten Datensätzen können beim nächsten Import wieder überschrieben werden.
{{else}}
Eigene VeranstaltungenEinsendungen und redaktionell angelegte Termine lassen sich hier vollständig bearbeiten. Veröffentlichte eigene Veranstaltungen nehmen automatisch an der zufälligen Auswahl der bis zu drei Startseiten-Termine teil.
{{end}}
+
Kalender
Veranstaltungen verwalten
Eigene Veranstaltungen und Einsendungen anlegen, bearbeiten und veröffentlichen.
+
+
Eigene VeranstaltungenEinsendungen und redaktionell angelegte Termine lassen sich hier vollständig bearbeiten. Veröffentlichte eigene Veranstaltungen nehmen automatisch an der zufälligen Auswahl der bis zu drei Startseiten-Termine teil.
{{.Category}}{{if eq .Status "published"}}Veröffentlicht{{else if eq .Status "pending"}}Offen{{else if eq .Status "rejected"}}Abgelehnt{{else if eq .Status "archived"}}Archiviert{{else}}{{.Status}}{{end}}
-{{else}}
{{if eq .EventTab "hub"}}Keine aktuellen Hub-Veranstaltungen{{else}}Keine eigenen Veranstaltungen{{end}}
{{if eq .EventTab "hub"}}Beim nächsten Import erscheinen hier neue Termine aus dem Niedersachsen Hub.{{else}}Lege oben eine Veranstaltung an oder warte auf eine neue Einsendung über die Webseite.{{end}}
Verwaltungsaktionen prüfen, Fehler schneller finden und Änderungen lückenlos nachvollziehen.
{{.AuditTotal}} Einträge
Erfolgreich{{.AuditSuccessCount}}Aktionen im FilterFehlgeschlagen{{.AuditFailureCount}}benötigen AufmerksamkeitAktive Konten{{.AuditActorCount}}unterschiedliche AkteureHeute{{.AuditTodayCount}}Aktionen seit 0 Uhr
Protokollsuche
Verwaltungsaktivitäten
Suche nach Benutzer, Aktion, Objekt oder Beschreibung.
Radio, KI, Kommunikation, Auslieferung und soziale Netzwerke übersichtlich verwalten.
Konfigurationsdatei{{.SettingsPath}}
{{if .Error}}
{{.Error}}
{{end}}{{if .Success}}
{{.Success}}
{{end}}
-
-
Sicherheitshinweis
API-Schlüssel werden serverseitig in der geschützten Laufzeitkonfiguration gespeichert und in dieser Oberfläche nie wieder ausgegeben. Dateirechte und Zugriff auf /var/lib/landwelle müssen auf den Portal-Dienst beschränkt bleiben.
+
Sicherheitshinweis
API-Schlüssel werden serverseitig in der geschützten Laufzeitkonfiguration gespeichert und in dieser Oberfläche nie wieder ausgegeben. Dateirechte und Zugriff auf /var/lib/landwelle müssen auf den Portal-Dienst beschränkt bleiben.