diff --git a/app.py b/app.py index be8c101..a9a0e8a 100755 --- a/app.py +++ b/app.py @@ -103,6 +103,11 @@ def list_directory_contents(directory, subpath): transcription_dir = os.path.join(directory, "Transkription") transcription_exists = os.path.isdir(transcription_dir) + direct_directories = [] + for item in folder_config: + for folder in item['folders']: + direct_directories.append(folder['foldername']) + # Define allowed file extensions. music_exts = ('.mp3',) image_exts = ('.jpg', '.jpeg', '.png', '.gif', '.bmp') @@ -125,7 +130,16 @@ def list_directory_contents(directory, subpath): if entry.name in ["Transkription", "@eaDir"]: continue rel_path = os.path.join(subpath, entry.name) if subpath else entry.name - directories.append({'name': entry.name, 'path': rel_path.replace(os.sep, '/')}) + + # check if path is inside a direct directory --> shareable + if subpath.split('/')[0] in direct_directories: + allow_share = True + else: + allow_share = False + + # build directory entry + directories.append({'name': entry.name, 'path': rel_path.replace(os.sep, '/'), 'share': allow_share}) + elif entry.is_file(follow_symlinks=False): lower_name = entry.name.lower() @@ -138,7 +152,10 @@ def list_directory_contents(directory, subpath): file_type = 'image' else: file_type = 'other' + + # build file entry file_entry = {'name': entry.name, 'path': rel_path.replace(os.sep, '/'), 'file_type': file_type} + # Only check for transcription if it's a audio file. if file_type == 'music' and transcription_exists: base_name = os.path.splitext(entry.name)[0] @@ -206,7 +223,7 @@ def serve_sw(): def api_browse(subpath): if subpath == '': # root directory foldernames = [] - for foldername, folderpath in session['folders'].items(): + for foldername, _ in session['folders'].items(): foldernames.append({'name': foldername, 'path': foldername}) return jsonify({ @@ -421,7 +438,6 @@ def create_share(subpath): return "Unauthorized", 403 paths = {} - for item in folder_config: for folder in item['folders']: paths[folder['foldername']] = folder['folderpath'] diff --git a/static/app.js b/static/app.js index 5f473e5..3f35783 100644 --- a/static/app.js +++ b/static/app.js @@ -81,7 +81,7 @@ function renderContent(data) { if (areAllShort && data.breadcrumbs.length !== 1) { contentHTML += '
diff --git a/templates/mylinks.html b/templates/mylinks.html
index abb3eac..9400509 100644
--- a/templates/mylinks.html
+++ b/templates/mylinks.html
@@ -24,6 +24,7 @@
+