diff --git a/controllers/worshipController.js b/controllers/worshipController.js index 9acf610..91ba64c 100644 --- a/controllers/worshipController.js +++ b/controllers/worshipController.js @@ -456,21 +456,40 @@ function resolveLeaderFromText(text, leaderMaps) { function buildWorshipTitleFromPlace(placeName, fallback = 'Gottesdienst') { const raw = normalizeText(placeName); if (!raw) return fallback; - let church = raw; + let location = raw; + let churchLabel = 'Evangelischen Kirche'; // Typische Muster: "Evangelische Kirche Nieder-Eschbach" -> "Nieder-Eschbach" const afterKirche = raw.match(/kirche\s+(.+)$/i); if (afterKirche && afterKirche[1]) { - church = normalizeText(afterKirche[1]); + location = normalizeText(afterKirche[1]); } else { const parts = raw.split(/\s*(?:,|\/|->|\(|\)|-)\s*/).filter(Boolean); if (parts.length > 0) { - church = normalizeText(parts[parts.length - 1]); + location = normalizeText(parts[parts.length - 1]); } } - if (!church) return fallback; - return `Gottesdienst in ${church}`; + if (!location) return fallback; + + // Wenn nur Ortsteil erkannt wurde, als Kirchenort formulieren. + // So vermeiden wir Titel wie "Gemeindehaus ...", auch wenn der EventPlace so heißt. + const normalizedLocation = location + .replace(/^evangelisch(?:e|es|er)?\s+(?:gemeindehaus|gemeindezentrum)\s*/i, '') + .replace(/^evangelisch(?:e|es|er)?\s+kirche\s*/i, '') + .replace(/^kirche\s*/i, '') + .trim(); + + // Ergänzende Kirchennamen erkennen, z. B. "Evangelische Friedenskirche Harheim". + const labelMatch = raw.match(/(evangelisch(?:e|es|er)?\s+[a-zäöüß-]*kirche)\b/i); + if (labelMatch && labelMatch[1]) { + churchLabel = normalizeText(labelMatch[1]); + } else if (/\bfriedenskirche\b/i.test(raw)) { + churchLabel = 'Evangelischen Friedenskirche'; + } + + const finalLocation = normalizedLocation || location; + return `Gottesdienst in der ${churchLabel} ${finalLocation}`; } function resolveEventPlaceIdFromHeader(eventPlaces, headerCell) {