From da98a8b6e6f8fdfd148e9af150b0f3b90df7ded4 Mon Sep 17 00:00:00 2001 From: lelo Date: Sun, 11 May 2025 08:53:49 +0200 Subject: [PATCH] search fix --- app.py | 7 +++---- search.py | 8 ++++++++ static/search.js | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app.py b/app.py index a7d0946..997cf0f 100755 --- a/app.py +++ b/app.py @@ -547,12 +547,11 @@ def handle_request_initial_data(): @auth.require_secret def index(path): app_config = auth.return_app_config() - title_short = app_config.get('TITLE_SHORT', 'Default Title') - title_long = app_config.get('TITLE_LONG' , 'Default Title') return render_template("app.html", - title_short=title_short, - title_long=title_long, + search_folders = list(session['folders'].keys()), + title_short=app_config.get('TITLE_SHORT', 'Default Title'), + title_long=app_config.get('TITLE_LONG' , 'Default Title'), admin_enabled=auth.is_admin() ) diff --git a/search.py b/search.py index 41cad76..3b78248 100644 --- a/search.py +++ b/search.py @@ -2,6 +2,7 @@ import sqlite3 from flask import Flask, render_template, request, request, jsonify, session import random import json +from datetime import datetime app = Flask(__name__) @@ -88,6 +89,13 @@ def searchcommand(): transcript.lower().count(w.lower()) for w in words ) record.pop('transcript', None) + # convert date to TT.MM.YYYY format + if record.get('performance_date'): + try: + performance_date = datetime.strptime(record['performance_date'], "%Y-%m-%d") + record['performance_date'] = performance_date.strftime("%d.%m.%Y") + except (ValueError, TypeError): + record['performance_date'] = None results.append(record) # Randomize and sort diff --git a/static/search.js b/static/search.js index a66514c..34d8229 100644 --- a/static/search.js +++ b/static/search.js @@ -17,6 +17,7 @@ document.addEventListener('DOMContentLoaded', function() { ? `

Treffer im Transkript: ${file.transcript_hits}

` : `

Downloads: ${file.hitcount}

` } +

Datum: ${file.performance_date}

`; resultsDiv.appendChild(card);