diff --git a/.gitignore b/.gitignore index d125949..2e9eddc 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,6 @@ /access_log.db.bak /folder_permission_config.json /folder_mount_config.json -/.env \ No newline at end of file +/.env +/app_config.json +/custom_logo \ No newline at end of file diff --git a/app.py b/app.py index e678b70..e5721a0 100755 --- a/app.py +++ b/app.py @@ -20,15 +20,18 @@ import search import auth import analytics as a -cache_audio = diskcache.Cache('./filecache_audio', size_limit= 48 * 1024**3) # 48 GB limit -cache_image = diskcache.Cache('./filecache_image', size_limit= 48 * 1024**3) # 48 GB limit -cache_video = diskcache.Cache('./filecache_video', size_limit= 48 * 1024**3) # 48 GB limit -cache_other = diskcache.Cache('./filecache_other', size_limit= 48 * 1024**3) # 48 GB limit +with open("app_config.json", 'r') as file: + config = json.load(file) + +cache_audio = diskcache.Cache('./filecache_audio', size_limit= config['filecache_size_limit_audio'] * 1024**3) +cache_image = diskcache.Cache('./filecache_image', size_limit= config['filecache_size_limit_image'] * 1024**3) +cache_video = diskcache.Cache('./filecache_video', size_limit= config['filecache_size_limit_video'] * 1024**3) +cache_other = diskcache.Cache('./filecache_other', size_limit= config['filecache_size_limit_other'] * 1024**3) app = Flask(__name__) app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1) -app.config['SECRET_KEY'] = '85c1117eb3a5f2c79f0ff395bada8ff8d9a257b99ef5e143' +app.config['SECRET_KEY'] = config['SECRET_KEY'] app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=90) if os.environ.get('FLASK_ENV') == 'production': app.config['SESSION_COOKIE_SAMESITE'] = 'None' @@ -65,7 +68,7 @@ thread_lock = threading.Lock() @lru_cache(maxsize=10) def get_cached_image(size): dimensions = tuple(map(int, size.split('-')[1].split('x'))) - original_logo_path = os.path.join(app.root_path, 'static', 'logo.png') + original_logo_path = os.path.join(app.root_path, 'custom_logo', 'logoB.png') with Image.open(original_logo_path) as img: img = img.convert("RGBA") @@ -153,7 +156,7 @@ def generate_breadcrumbs(subpath=None): breadcrumbs.append({'name': part, 'path': path_accum}) return breadcrumbs -@app.route('/static/icons/.png') +@app.route('/icon/.png') def serve_resized_icon(size): cached_image_bytes = get_cached_image(size) response = send_file( @@ -163,6 +166,22 @@ def serve_resized_icon(size): response.headers['Cache-Control'] = 'public, max-age=86400' return response +@app.route('/custom_logo/.png') +def custom_logo(filename): + file_path = os.path.join('custom_logo', f"{filename}.png") + if not os.path.exists(file_path): + abort(404) + with open(file_path, 'rb') as file: + image_data = file.read() + + # Create a BytesIO object using the binary image data + image_io = io.BytesIO(image_data) + image_io.seek(0) # Important: reset the stream position + + response = send_file(image_io, mimetype='image/png') + response.headers['Cache-Control'] = 'public, max-age=86400' + return response + @app.route('/sw.js') def serve_sw(): return send_from_directory(os.path.join(app.root_path, 'static'), 'sw.js', mimetype='application/javascript') @@ -445,9 +464,20 @@ def handle_request_initial_data(): @app.route('/') @auth.require_secret def index(path): - title_short = os.environ.get('TITLE_SHORT', 'Default Title') - title_long = os.environ.get('TITLE_LONG', 'Default Title') - return render_template("app.html", title_short=title_short, title_long=title_long) + title_short = config.get('TITLE_SHORT', 'Default Title') + title_long = config.get('TITLE_LONG' , 'Default Title') + header_color = config.get('header_color' , '#000') + header_text_color = config.get('header_text_color', '#fff') + background_color = config.get('background_color', '#fff') + main_text_color = config.get('main_text_color', '#000') + return render_template("app.html", + title_short=title_short, + title_long=title_long, + header_color=header_color, + header_text_color=header_text_color, + main_text_color=main_text_color, + background_color=background_color, + ) if __name__ == '__main__': socketio.run(app, debug=True, host='0.0.0.0') diff --git a/static/app.css b/static/app.css index c1b7c09..b946d9b 100644 --- a/static/app.css +++ b/static/app.css @@ -7,9 +7,7 @@ html, body { /* Global Styles */ body { font-family: 'Helvetica Neue', Arial, sans-serif; - background-color: #f4f7f9; padding-top: 70px; /* Adjust to your header height */ - color: #333; } /* Header styles */ .site-header { @@ -20,8 +18,6 @@ body { display: flex; align-items: center; padding: 10px 20px; - background-color: #34495e; /* Using the theme color */ - color: #eee; } .site-header img.logo { height: 50px; diff --git a/static/logo.png b/static/logo.png deleted file mode 100644 index d2fcd45..0000000 Binary files a/static/logo.png and /dev/null differ diff --git a/static/logoW.png b/static/logoW.png deleted file mode 100644 index 37385be..0000000 Binary files a/static/logoW.png and /dev/null differ diff --git a/static/manifest.json b/static/manifest.json index b7d8342..c1c7a3f 100644 --- a/static/manifest.json +++ b/static/manifest.json @@ -7,12 +7,12 @@ "theme_color": "#34495e", "icons": [ { - "src": "/static/icons/logo-192x192.png", + "src": "/icon/logo-192x192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "/static/icons/logo-512x512.png", + "src": "/icon/logo-512x512.png", "sizes": "512x512", "type": "image/png" } diff --git a/static/sw.js b/static/sw.js index cfb6a83..43407e0 100644 --- a/static/sw.js +++ b/static/sw.js @@ -7,10 +7,10 @@ const assets = [ '/static/gallery.js', '/static/audioplayer.css', '/static/audioplayer.js', - '/static/icons/logo-192x192.png', - '/static/icons/logo-512x512.png', - '/static/logo.png', - '/static/logoW.png' + '/icon/logo-192x192.png', + '/icon/logo-512x512.png', + '/custom_logo/logoB.png', + '/custom_logo/logoW.png' ]; self.addEventListener('install', e => { diff --git a/templates/app.html b/templates/app.html index 6e81a17..66c24f5 100644 --- a/templates/app.html +++ b/templates/app.html @@ -5,21 +5,21 @@ - + {{ title_short }} - + - + @@ -32,11 +32,21 @@ + diff --git a/templates/error.html b/templates/error.html index ad7a243..659cbcf 100644 --- a/templates/error.html +++ b/templates/error.html @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ diff --git a/templates/index.html b/templates/index.html index ad8b387..2f2accf 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,7 +5,7 @@ - + @@ -16,7 +16,7 @@ diff --git a/templates/search.html b/templates/search.html index f69db2c..701fdae 100644 --- a/templates/search.html +++ b/templates/search.html @@ -5,14 +5,14 @@ - + {{ title_short }} - + @@ -43,7 +43,7 @@