Restructuring file layout, import cleanup
This commit is contained in:
parent
93706aeed6
commit
353acf7ae6
@ -3,6 +3,7 @@ certifi==2022.12.7
|
||||
charset-normalizer==3.0.1
|
||||
click==7.1.2
|
||||
dnspython==1.16.0
|
||||
ecdsa==0.18.0
|
||||
email-validator==1.1.2
|
||||
eventlet==0.30.1
|
||||
Flask==1.1.2
|
||||
@ -26,6 +27,7 @@ pyasn1-modules==0.2.8
|
||||
pycairo==1.23.0
|
||||
PyGObject==3.42.2
|
||||
pyparsing==2.4.7
|
||||
pywebpush==1.14.0
|
||||
pyxdg==0.28
|
||||
requests==2.28.2
|
||||
rsa==4.7
|
||||
|
@ -11,6 +11,7 @@ from flask import session
|
||||
# Application imports
|
||||
from core import app
|
||||
from core.utils import Logger
|
||||
from core.utils import MessageHandler # Get simple message processor
|
||||
|
||||
|
||||
|
||||
@ -51,7 +52,7 @@ builtins.BG_IMGS_PATH = ROOT_FILE_PTH + "/static/imgs/backgrounds/"
|
||||
builtins.BG_FILE_TYPE = (".webm", ".mp4", ".gif", ".jpg", ".png", ".webp")
|
||||
builtins.valid_fname_pat = re.compile(r"[a-z0-9A-Z-_\[\]\(\)\| ]{4,20}")
|
||||
builtins.logger = Logger().get_logger()
|
||||
|
||||
builtins.json_message = MessageHandler()
|
||||
|
||||
|
||||
# NOTE: Need threads defined befor instantiating
|
||||
|
@ -6,7 +6,11 @@ from flask import Flask
|
||||
from flask_oidc import OpenIDConnect
|
||||
# Flask Login Path
|
||||
from flask_bcrypt import Bcrypt
|
||||
from flask_login import current_user, login_user, logout_user, LoginManager
|
||||
from flask_login import current_user
|
||||
from flask_login import login_user
|
||||
from flask_login import logout_user
|
||||
from flask_login import LoginManager
|
||||
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_object("core.config.ProductionConfig")
|
||||
@ -36,10 +40,14 @@ app.jinja_env.globals['oidc_isAdmin'] = oidc_isAdmin
|
||||
app.jinja_env.globals['TITLE'] = app.config["TITLE"]
|
||||
|
||||
|
||||
from core.models import db, User, Favorites
|
||||
from core.models import db
|
||||
from core.models import User
|
||||
from core.models import Favorites
|
||||
|
||||
db.init_app(app)
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
|
||||
from core.forms import RegisterForm, LoginForm
|
||||
from core.forms import RegisterForm
|
||||
from core.forms import LoginForm
|
||||
from core import routes
|
||||
|
@ -1,14 +1,14 @@
|
||||
# System import
|
||||
import os, secrets
|
||||
import os
|
||||
import secrets
|
||||
from datetime import timedelta
|
||||
|
||||
|
||||
# Lib imports
|
||||
|
||||
|
||||
# Apoplication imports
|
||||
|
||||
|
||||
|
||||
# Configs
|
||||
APP_NAME = 'WebFM'
|
||||
ROOT_FILE_PTH = os.path.dirname(os.path.realpath(__file__))
|
||||
@ -44,8 +44,8 @@ class Config(object):
|
||||
# We are overiding some of the the shellmen view settings with these to make it all work with flask.
|
||||
# These are passed along to the shellmen view from the Routes file upon the window controller creation.
|
||||
ABS_THUMBS_PTH = f"{STATIC_FPTH}/imgs/thumbnails" # Used for thumbnail generation
|
||||
REMUX_FOLDER = f"{STATIC_FPTH}/remuxs" # Remuxed files folder
|
||||
FFMPG_THUMBNLR = f"{STATIC_FPTH}/ffmpegthumbnailer" # Thumbnail generator binary
|
||||
REMUX_FOLDER = f"{STATIC_FPTH}/remuxs" # Remuxed files folder
|
||||
FFMPG_THUMBNLR = f"{STATIC_FPTH}/ffmpegthumbnailer" # Thumbnail generator binary
|
||||
|
||||
|
||||
|
||||
|
@ -1,9 +1,19 @@
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, PasswordField, SubmitField
|
||||
from wtforms.validators import DataRequired, Length, Email, EqualTo, ValidationError
|
||||
|
||||
from wtforms import StringField
|
||||
from wtforms import PasswordField
|
||||
from wtforms import SubmitField
|
||||
|
||||
from wtforms.validators import DataRequired
|
||||
from wtforms.validators import Length
|
||||
from wtforms.validators import Email
|
||||
from wtforms.validators import EqualTo
|
||||
from wtforms.validators import ValidationError
|
||||
|
||||
from core import User
|
||||
|
||||
|
||||
|
||||
class RegisterForm(FlaskForm):
|
||||
username = StringField('Username', validators=[DataRequired(), Length(min=4, max=24)])
|
||||
email = StringField('Email', validators=[DataRequired(), Email()])
|
||||
|
@ -1,11 +1,12 @@
|
||||
# System imports
|
||||
|
||||
# Lib imports
|
||||
from flask_login import UserMixin
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
# App imports
|
||||
from . import app, login_manager
|
||||
from flask_login import UserMixin
|
||||
from . import app
|
||||
from . import login_manager
|
||||
|
||||
|
||||
db = SQLAlchemy(app)
|
||||
|
@ -9,7 +9,6 @@ from flask_uploads import ALL
|
||||
from flask_uploads import configure_uploads
|
||||
from flask_uploads import UploadSet
|
||||
|
||||
|
||||
# App imports
|
||||
# Get from __init__
|
||||
from core import app
|
||||
@ -17,10 +16,6 @@ from core import db
|
||||
from core import Favorites
|
||||
from core import oidc
|
||||
|
||||
from core.utils import MessageHandler # Get simple message processor
|
||||
|
||||
json_message = MessageHandler()
|
||||
|
||||
|
||||
|
||||
@app.route('/api/delete/<_hash>', methods=['GET', 'POST'])
|
||||
|
@ -7,10 +7,6 @@ from flask import request
|
||||
from core import app
|
||||
from core import db
|
||||
from core import Favorites # Get from __init__
|
||||
from core.utils import MessageHandler # Get simple message processor
|
||||
|
||||
|
||||
json_message = MessageHandler()
|
||||
|
||||
|
||||
|
||||
|
@ -6,17 +6,15 @@ import shutil
|
||||
# Lib imports
|
||||
from flask import request
|
||||
|
||||
|
||||
# App imports
|
||||
# Get from __init__
|
||||
from core import app
|
||||
|
||||
from core.utils import MessageHandler # Get simple message processor
|
||||
from core.utils.tmdbscraper import scraper # Get media art scraper
|
||||
|
||||
|
||||
json_message = MessageHandler()
|
||||
tmdb = scraper.get_tmdb_scraper()
|
||||
|
||||
tmdb = scraper.get_tmdb_scraper()
|
||||
|
||||
|
||||
|
||||
@app.route('/api/get-background-poster-trailer', methods=['GET', 'POST'])
|
||||
|
@ -5,21 +5,16 @@ import os
|
||||
from flask import redirect
|
||||
from flask import request
|
||||
from flask import render_template
|
||||
from flask import session
|
||||
from flask import send_from_directory
|
||||
|
||||
# App imports
|
||||
# Get from __init__
|
||||
# Get from __init__
|
||||
from core import app
|
||||
from core import db
|
||||
from core import Favorites
|
||||
from core import oidc
|
||||
|
||||
from core.utils import MessageHandler # Get simple message processor
|
||||
|
||||
|
||||
|
||||
json_message = MessageHandler()
|
||||
|
||||
|
||||
|
||||
@app.route('/', methods=['GET', 'POST'])
|
||||
@ -34,7 +29,6 @@ def home():
|
||||
message = 'Must use GET request type...')
|
||||
|
||||
|
||||
|
||||
@app.route('/api/list-files/<_hash>', methods=['GET', 'POST'])
|
||||
def listFiles(_hash = None):
|
||||
if request.method == 'POST':
|
||||
@ -75,7 +69,6 @@ def listFiles(_hash = None):
|
||||
return json_message.create("danger", msg)
|
||||
|
||||
|
||||
|
||||
@app.route('/api/file-manager-action/<_type>/<_hash>', methods=['GET', 'POST'])
|
||||
def fileManagerAction(_type, _hash = None):
|
||||
view = get_view()
|
||||
|
@ -1,15 +1,24 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
from flask import request, render_template, flash, redirect, url_for
|
||||
from flask_login import current_user, login_user, logout_user
|
||||
from flask import request
|
||||
from flask import render_template
|
||||
from flask import flash
|
||||
from flask import redirect
|
||||
from flask import url_for
|
||||
|
||||
from flask_login import current_user
|
||||
from flask_login import login_user
|
||||
from flask_login import logout_user
|
||||
|
||||
# App imports
|
||||
from core import app, bcrypt, db, User, LoginForm
|
||||
from core.utils import MessageHandler # Get simple message processor
|
||||
from core import app
|
||||
from core import bcrypt
|
||||
from core import db
|
||||
from core import User
|
||||
from core import LoginForm
|
||||
|
||||
|
||||
msgHandler = MessageHandler()
|
||||
|
||||
@app.route('/app-login', methods=['GET', 'POST'])
|
||||
def app_login():
|
||||
|
@ -1,16 +1,21 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
from flask import request, render_template, url_for, redirect, flash
|
||||
from flask import render_template
|
||||
from flask import url_for
|
||||
from flask import redirect
|
||||
from flask import flash
|
||||
|
||||
# App imports
|
||||
from core import app, bcrypt, db, current_user, RegisterForm # Get from __init__
|
||||
# Get from __init__
|
||||
from core import app
|
||||
from core import bcrypt
|
||||
from core import db
|
||||
from core import current_user
|
||||
from core import RegisterForm
|
||||
from core.models import User
|
||||
from core.utils import MessageHandler # Get simple message processor
|
||||
|
||||
|
||||
msgHandler = MessageHandler()
|
||||
|
||||
|
||||
@app.route('/app-register', methods=['GET', 'POST'])
|
||||
def app_register():
|
||||
|
@ -1,17 +1,19 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
from flask import request, redirect, flash
|
||||
|
||||
from flask import request
|
||||
from flask import redirect
|
||||
from flask import flash
|
||||
|
||||
# App imports
|
||||
from ... import app, oidc
|
||||
from ... import app
|
||||
from ... import oidc
|
||||
|
||||
|
||||
|
||||
@app.route('/oidc-login', methods=['GET', 'POST'])
|
||||
@oidc.require_login
|
||||
def oidc_login():
|
||||
print(request)
|
||||
return redirect("/")
|
||||
|
||||
|
||||
|
@ -1,15 +1,19 @@
|
||||
# Python imports
|
||||
|
||||
# Lib imports
|
||||
from flask import request, render_template, url_for, redirect, flash
|
||||
from flask import request
|
||||
from flask import render_template
|
||||
from flask import url_for
|
||||
from flask import redirect
|
||||
from flask import flash
|
||||
|
||||
# App imports
|
||||
from ... import app, oidc, db # Get from __init__
|
||||
from ...utils import MessageHandler # Get simple message processor
|
||||
# Get from __init__
|
||||
from ... import app
|
||||
from ... import oidc
|
||||
from ... import db
|
||||
|
||||
|
||||
msgHandler = MessageHandler()
|
||||
|
||||
|
||||
@app.route('/oidc-register', methods=['GET', 'POST'])
|
||||
def oidc_register():
|
||||
|
@ -15,11 +15,13 @@ const setPosition = ({ top, left }) => {
|
||||
};
|
||||
|
||||
|
||||
window.addEventListener("click", e => {
|
||||
document.body.addEventListener("click", e => {
|
||||
if(menuVisible) toggleMenu("hide");
|
||||
});
|
||||
|
||||
window.addEventListener("contextmenu", e => {
|
||||
document.body.addEventListener("contextmenu", e => {
|
||||
e.preventDefault();
|
||||
|
||||
let target = e.target;
|
||||
let elm = target;
|
||||
while (elm.nodeName != "BODY") {
|
||||
@ -50,6 +52,7 @@ window.addEventListener("contextmenu", e => {
|
||||
left: posX,
|
||||
top: posY
|
||||
};
|
||||
|
||||
setPosition(origin);
|
||||
return false;
|
||||
});
|
@ -53,9 +53,7 @@ class FilesList extends React.Component {
|
||||
|
||||
for (let file of files) {
|
||||
const name = file[0];
|
||||
if (name == "000.jpg") {
|
||||
continue
|
||||
}
|
||||
if (name == "000.jpg") { continue }
|
||||
|
||||
const hash = file[1];
|
||||
const fsize = file[2];
|
@ -117,10 +117,10 @@
|
||||
{% block body_scripts_additional %}
|
||||
{% endblock body_scripts_additional%}
|
||||
|
||||
<script src="{{ url_for('static', filename='js/cookie-manager.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/color-mode-toggler.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/context-menu.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/backgrounds-manager.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/libs/cookie-manager.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/libs/color-mode-toggler.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/context-menu.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/backgrounds-manager.js')}}"></script>
|
||||
{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
|
@ -14,6 +14,7 @@
|
||||
{% endblock body_header_additional %}
|
||||
|
||||
{% block body_content_additional %}
|
||||
<span id="VAPID_PUBLIC_KEY" class="hidden">{{VAPID_PUBLIC_KEY}}</span>
|
||||
<div id="files" class="row">
|
||||
</div>
|
||||
{% block favorites_modal %}
|
||||
@ -26,16 +27,16 @@
|
||||
|
||||
{% block body_scripts_additional %}
|
||||
<!-- App JS -->
|
||||
<script type="text/jsx" src="{{ url_for('static', filename='js/react-ui-logic.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/ui-logic.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/post-ajax.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/ajax.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/video-events.js')}}"></script>
|
||||
<script type="text/jsx" src="{{ url_for('static', filename='js/webfm/react-ui-logic.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/ui-logic.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/post-ajax.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/ajax.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/video-events.js')}}"></script>
|
||||
|
||||
{% if oidc_loggedin() and oidc_isAdmin() %}
|
||||
<script src="{{ url_for('static', filename='js/privileged-logic.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/events-privileged.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/privileged-logic.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/events-privileged.js')}}"></script>
|
||||
{% endif %}
|
||||
|
||||
<script src="{{ url_for('static', filename='js/events.js')}}"></script>
|
||||
<script src="{{ url_for('static', filename='js/webfm/events.js')}}"></script>
|
||||
{% endblock body_scripts_additional %}
|
||||
|
@ -1,5 +1,6 @@
|
||||
# Python imports
|
||||
import os, logging
|
||||
import os
|
||||
import logging
|
||||
|
||||
# Application imports
|
||||
|
||||
|
@ -6,6 +6,7 @@ import json
|
||||
# Application imports
|
||||
|
||||
|
||||
|
||||
class MessageHandler:
|
||||
def __init__(self):
|
||||
print("MessageHandler initialized...")
|
||||
|
Loading…
Reference in New Issue
Block a user