From 023f940255f79ded2454c3fe949cdb42759e947b Mon Sep 17 00:00:00 2001 From: elpatron Date: Sat, 20 Sep 2025 10:19:37 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20Umlaute=20einbeziehen=20Funktionalit?= =?UTF-8?q?=C3=A4t=20repariert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - HTML: name-Attribut und form-Attribut zur Umlaute-Checkbox hinzugefügt - Backend: use_umlaut Parameter zur Form-Verarbeitung hinzugefügt - Backend: Umlaute-Filterung in filter_words() Funktion implementiert - Backend: use_umlaut Variable an Template weitergegeben - JavaScript: applyFilters() Funktion für Umlaute-Checkbox erweitert Die Umlaute einbeziehen Option funktioniert jetzt korrekt sowohl auf Backend- als auch Frontend-Ebene. --- app.py | 13 ++++++++++--- templates/index.html | 4 ++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index f793990..4c07fd6 100644 --- a/app.py +++ b/app.py @@ -209,7 +209,7 @@ def load_words() -> Tuple[List[str], Dict[str, List[str]]]: return words, sources_map -def filter_words(words: List[str], position_letters: List[str], includes_text: str, excludes_text: str) -> List[str]: +def filter_words(words: List[str], position_letters: List[str], includes_text: str, excludes_text: str, use_umlaut: bool = True) -> List[str]: results: List[str] = [] includes_letters = [ch for ch in includes_text.lower() if ch.isalpha()] excludes_letters = [ch for ch in excludes_text.lower() if ch.isalpha()] @@ -223,6 +223,9 @@ def filter_words(words: List[str], position_letters: List[str], includes_text: s # darf-nicht-enthalten if any(ch in word for ch in excludes_letters): continue + # Umlaute-Filter + if not use_umlaut and ('ä' in word or 'ö' in word or 'ü' in word or 'ß' in word): + continue results.append(word) return results @@ -242,6 +245,7 @@ def index(): excludes: str = "" use_ot: bool = True use_wf: bool = False + use_umlaut: bool = True if request.method == "POST": pos = [ (request.form.get("pos1") or "").strip().lower(), @@ -254,6 +258,7 @@ def index(): excludes = (request.form.get("excludes") or "").strip() use_ot = request.form.get("use_ot") is not None use_wf = request.form.get("use_wf") is not None + use_umlaut = request.form.get("use_umlaut") is not None # Falls keine Quelle gewählt ist, standardmäßig OpenThesaurus aktivieren if not use_ot and not use_wf: use_ot = True @@ -264,12 +269,13 @@ def index(): 'includes': includes, 'excludes': excludes, 'use_ot': use_ot, - 'use_wf': use_wf + 'use_wf': use_wf, + 'use_umlaut': use_umlaut } log_search_query(search_params, request.headers.get('User-Agent')) # 1) Buchstaben-/Positionssuche über alle Wörter - matched = filter_words(all_words, pos, includes, excludes) + matched = filter_words(all_words, pos, includes, excludes, use_umlaut) # 2) Quellen-Filter nur auf Ergebnisansicht anwenden allowed = set() if use_ot: @@ -291,6 +297,7 @@ def index(): sources_map=sources_map, use_ot=use_ot, use_wf=use_wf, + use_umlaut=use_umlaut, error_message=None, ) diff --git a/templates/index.html b/templates/index.html index 87a30b4..cb56389 100644 --- a/templates/index.html +++ b/templates/index.html @@ -154,7 +154,7 @@
Umlaute
- +
@@ -228,7 +228,7 @@ var ot = document.getElementById('filter-ot'); var wf = document.getElementById('filter-wf'); var uml = document.getElementById('filter-umlaut'); - if (!ot || !wf) return; + if (!ot || !wf || !uml) return; var allowed = []; if (ot.checked) allowed.push('ot'); if (wf.checked) allowed.push('wf');