From 0ba35f8f1c4cd0b6485beeb0d0137fddef66b717 Mon Sep 17 00:00:00 2001 From: maximstewart Date: Sat, 6 Feb 2021 02:34:44 -0600 Subject: [PATCH] Further file manager work --- src/core/routes/Routes.py | 40 +++++----- src/core/templates/body-footer.html | 6 +- src/core/templates/body-header.html | 25 +++++- src/core/utils/shellfm/windows/Launcher.py | 93 ++++++++++++++++++++++ src/core/utils/shellfm/windows/View.py | 13 ++- src/core/utils/shellfm/windows/__init__.py | 1 + 6 files changed, 148 insertions(+), 30 deletions(-) create mode 100644 src/core/utils/shellfm/windows/Launcher.py diff --git a/src/core/routes/Routes.py b/src/core/routes/Routes.py index 0f29d5f..6a5211e 100644 --- a/src/core/routes/Routes.py +++ b/src/core/routes/Routes.py @@ -2,7 +2,7 @@ import secrets # Lib imports -from flask import request, session, render_template +from flask import request, session, render_template, send_from_directory, redirect from flask_login import current_user @@ -22,18 +22,15 @@ def get_window_controller(): session['win_controller_id'] = id window_controllers.update( {id: WindowController() } ) - return window_controllers[ session["win_controller_id"] ] + return window_controllers[ session["win_controller_id"] ] @app.route('/', methods=['GET', 'POST']) def home(): if request.method == 'GET': - view = get_window_controller().get_window(1).get_view(0) - - view.push_to_path("LazyShare") + view = get_window_controller().get_window(1).get_view(0) _path = view.get_path() _files = view.get_files() - return render_template('pages/index.html', path=_path, files=_files) return render_template('error.html', @@ -128,35 +125,38 @@ def manageFavoritesRoute(_action): @app.route('/api/reset-path', methods=['GET', 'POST']) def resetPath(): if request.method == 'GET': - file_manager.reset_path() + view = get_window_controller().get_window(1).get_view(0) + view.set_to_home() return redirect("/") - # Used to get files from non gunicorn root path... # Allows us to pull images and stuff to user without simlinking. @app.route('/api/files/') def returnFile(hash): - path = file_manager.getFullPath() - pathPart = file_manager.returnPathPartFromHash(hash) - return send_from_directory(path, pathPart) + view = get_window_controller().get_window(1).get_view(0) + folder = view.get_path() + file = view.returnPathPartFromHash(hash) + return send_from_directory(folder, file) @app.route('/api/remux/') def remuxRoute(hash): - folder = file_manager.getFullPath() - file = file_manager.returnPathPartFromHash(hash) - fpath = os.path.join(folder, file) + view = get_window_controller().get_window(1).get_view(0) + folder = view.get_path() + file = view.returnPathPartFromHash(hash) + fpath = os.path.join(folder, file) logging.debug(fpath) - return file_manager.remuxVideo(hash, fpath) + return view.remuxVideo(hash, fpath) @app.route('/api/run-locally/') def runLocallyRoute(hash): - path = file_manager.getFullPath() - pathPart = file_manager.returnPathPartFromHash(hash) - fullpath = path + "/" + pathPart + view = get_window_controller().get_window(1).get_view(0) + folder = view.get_path() + file = view.returnPathPartFromHash(hash) + fpath = os.path.join(folder, file) - logging.debug(fullpath) - file_manager.openFilelocally(fullpath) + logging.debug(fpath) + view.openFilelocally(fpath) msg = "Opened media..." return msgHandler.createMessageJSON("success", msg) diff --git a/src/core/templates/body-footer.html b/src/core/templates/body-footer.html index 788599b..19e40c3 100644 --- a/src/core/templates/body-footer.html +++ b/src/core/templates/body-footer.html @@ -1,7 +1,8 @@ +{% if files %} +{% endif %} diff --git a/src/core/templates/body-header.html b/src/core/templates/body-header.html index cead9ac..3591f7d 100644 --- a/src/core/templates/body-header.html +++ b/src/core/templates/body-header.html @@ -7,17 +7,34 @@