diff --git a/search.py b/search.py index 913b07b..3a9c4b6 100644 --- a/search.py +++ b/search.py @@ -16,12 +16,18 @@ with open("app_config.json", 'r') as file: def searchcommand(): query = request.form.get("query", "").strip() category = request.form.get("category", "").strip() + searchfolder = request.form.get("folder", "").strip() + include_transcript = request.form.get("includeTranscript") in ["true", "on"] words = [w for w in query.split() if w] cursor = search_db.cursor() allowed_basefolders = list(session['folders'].keys()) - print("Allowed base folders:", allowed_basefolders) + + # if the search folder is allowed to be searched, select it + # if not just allowed_basefolders rules apply + if searchfolder != "" and searchfolder in allowed_basefolders: + allowed_basefolders = [searchfolder] if not include_transcript: conditions = [] @@ -93,10 +99,12 @@ def searchcommand(): return jsonify(results=results) def search(): + allowed_basefolders = list(session['folders'].keys()) title_short = app_config.get('TITLE_SHORT', 'Default Title') title_long = app_config.get('TITLE_LONG' , 'Default Title') return render_template("search.html", title_short=title_short, - title_long=title_long + title_long=title_long, + search_folders=allowed_basefolders ) diff --git a/templates/search.html b/templates/search.html index dfd810f..fde8869 100644 --- a/templates/search.html +++ b/templates/search.html @@ -88,6 +88,16 @@ + +
+ + +
@@ -198,6 +208,7 @@ document.addEventListener('DOMContentLoaded', function() { const formData = new FormData(); formData.append('query', query); formData.append('category', category); + formData.append('folder', document.getElementById('folder').value); formData.append('includeTranscript', includeTranscript); fetch('/searchcommand', {