Starting to add file management logic
This commit is contained in:
parent
339c031d28
commit
786687e0f1
1
src/app.pid
Normal file
1
src/app.pid
Normal file
@ -0,0 +1 @@
|
||||
203362
|
@ -1,7 +1,8 @@
|
||||
# Python imports
|
||||
import secrets
|
||||
|
||||
# Lib imports
|
||||
from flask import request, render_template
|
||||
from flask import request, session, render_template
|
||||
from flask_login import current_user
|
||||
|
||||
|
||||
@ -11,32 +12,39 @@ from core.utils import MessageHandler # Get simple message processor
|
||||
from core.utils.shellfm import WindowController # Get file manager controller
|
||||
|
||||
|
||||
msgHandler = MessageHandler()
|
||||
win_controller = WindowController()
|
||||
win_controller.pop_window()
|
||||
win_controller.list_windows()
|
||||
# win_controller.add_window()
|
||||
# win_controller.list_views_from_window(0)
|
||||
msgHandler = MessageHandler()
|
||||
window_controllers = {}
|
||||
|
||||
|
||||
def get_window_controller():
|
||||
if session.get('win_controller_id') is None:
|
||||
id = secrets.token_hex(16)
|
||||
session['win_controller_id'] = id
|
||||
window_controllers.update( {id: WindowController() } )
|
||||
|
||||
return window_controllers[ session["win_controller_id"] ]
|
||||
|
||||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
def home():
|
||||
if request.method == 'GET':
|
||||
_dHash = file_manager.getDotHash()
|
||||
_ddHash = file_manager.getDotDotHash()
|
||||
view = get_window_controller().get_window(1).get_view(0)
|
||||
|
||||
return render_template('pages/index.html')
|
||||
view.push_to_path("LazyShare")
|
||||
_path = view.get_path()
|
||||
_files = view.get_files()
|
||||
|
||||
return render_template('pages/index.html', path=_path, files=_files)
|
||||
|
||||
return render_template('error.html',
|
||||
title='Error!',
|
||||
message='Must use GET request type...')
|
||||
|
||||
|
||||
@app.route('/api/list-files', methods=['GET', 'POST'])
|
||||
def listFilesRoute():
|
||||
@app.route('/api/list-files/<_hash>', methods=['GET', 'POST'])
|
||||
def listFilesRoute(_hash):
|
||||
if request.method == 'POST':
|
||||
HASH = str(request.values['hash']).strip()
|
||||
HASH = _hash.strip()
|
||||
pathPart = file_manager.returnPathPartFromHash(HASH)
|
||||
lockedFolders = config["settings"]["locked_folders"].split("::::")
|
||||
path = file_manager.getPath().split('/')
|
||||
|
@ -1,4 +1,4 @@
|
||||
<nav class="navbar navbar-expand-lg bg-dark navbar-dark justify-content-center text-center fixed-bottom">
|
||||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark justify-content-center text-center fixed-bottom">
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse"
|
||||
data-target="#navbarTogglerFooter" aria-controls="navbarTogglerFooter"
|
||||
aria-expanded="false" aria-label="Toggle Footer Navigation">
|
||||
@ -9,7 +9,7 @@
|
||||
<div class="col col-lg-auto">
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item">
|
||||
<span id="currentDirectory">/fake/path/for/reference/in/footer.html</span>
|
||||
<span id="currentDirectory">{{path}}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<nav class="navbar navbar-expand-lg bg-dark navbar-dark sticky-top justify-content-center text-center">
|
||||
<nav class="navbar navbar-expand-sm bg-dark navbar-dark sticky-top justify-content-center text-center">
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse"
|
||||
data-target="#navbarTogglerHeader" aria-controls="navbarTogglerHeader"
|
||||
aria-expanded="false" aria-label="Toggle Header Navigation">
|
||||
@ -8,7 +8,7 @@
|
||||
<div id="navbarTogglerHeader" class="row collapse navbar-collapse">
|
||||
<div class="col-sm">
|
||||
<!-- Branding -->
|
||||
<div class="navbar-brand justify-content-center text-center">
|
||||
<div class="navbar-brand">
|
||||
<div class="site-branding">
|
||||
<h1 class="site-title">
|
||||
<a href="{{ url_for('home') }}" title="{{TITLE}} Home" rel="home">
|
||||
|
@ -15,32 +15,20 @@
|
||||
|
||||
{% block body_content_additional %}
|
||||
<div class="row" style="margin-bottom: 6em;">
|
||||
{% for app in deployments %}
|
||||
{% for file in files %}
|
||||
<div class="col-sm-3">
|
||||
<div app="<hash_here>" class="card">
|
||||
<div class="card-header">file name.mp4</div>
|
||||
<div class="card">
|
||||
<div class="card-header">{{file[0]}}</div>
|
||||
<div class="card-body">
|
||||
<img class="" src="" alt="" />
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<input class="btn btn-secondary btn-sm" type="button" value="Launch"/>
|
||||
<input class="btn btn-secondary btn-sm" type="button" value="Launch Locally"/>
|
||||
<input app="{{file[1]}}" class="btn btn-secondary btn-sm" type="button" value="Launch"/>
|
||||
<input app="{{file[1]}}" class="btn btn-secondary btn-sm" type="button" value="Launch Locally"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div class="col-sm-3">
|
||||
<div app="<hash_here>" class="card">
|
||||
<div class="card-header">file name.mp4</div>
|
||||
<div class="card-body">
|
||||
<img class="" src="" alt="" />
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<input class="btn btn-secondary btn-sm" type="button" value="Launch"/>
|
||||
<input class="btn btn-secondary btn-sm" type="button" value="Launch Locally"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock body_content_additional %}
|
||||
|
||||
|
@ -1,10 +1,12 @@
|
||||
# Python imports
|
||||
from os.path import isdir, isfile, join
|
||||
import hashlib
|
||||
from os import listdir
|
||||
from os.path import isdir, isfile, join
|
||||
|
||||
|
||||
# Lib imports
|
||||
|
||||
|
||||
# Application imports
|
||||
from . import Path, Filters
|
||||
|
||||
@ -62,21 +64,29 @@ class View(Filters, Path):
|
||||
|
||||
self.files = self.dirs + self.vids + self.images + self.desktop + self.ungrouped
|
||||
|
||||
def hashText(self, text):
|
||||
return hashlib.sha256(str.encode(text)).hexdigest()[:18]
|
||||
|
||||
def hashSet(self, arry):
|
||||
data = []
|
||||
for arr in arry:
|
||||
data.append([arr, self.hashText(arr)])
|
||||
return data
|
||||
|
||||
def get_files(self):
|
||||
return self.files
|
||||
return self.hashSet(self.files)
|
||||
|
||||
def get_dirs(self):
|
||||
return self.dirs
|
||||
return self.hashSet(self.dirs)
|
||||
|
||||
def get_videos(self):
|
||||
return self.vids
|
||||
return self.hashSet(self.vids)
|
||||
|
||||
def get_images(self):
|
||||
return self.images
|
||||
return self.hashSet(self.images)
|
||||
|
||||
def get_desktops(self):
|
||||
return self.desktop
|
||||
return self.hashSet(self.desktop)
|
||||
|
||||
def get_ungrouped(self):
|
||||
return self.ungrouped
|
||||
return self.hashSet(self.ungrouped)
|
||||
|
@ -10,7 +10,7 @@ function main() {
|
||||
echo "Working Dir: " $(pwd)
|
||||
source "../venv/bin/activate"
|
||||
|
||||
LOG_LEVEL=error
|
||||
LOG_LEVEL=warn
|
||||
WORKER_COUNT=1
|
||||
ADDR=127.0.0.1
|
||||
PORT=6969
|
||||
|
Loading…
Reference in New Issue
Block a user