diff --git a/gallery/__init__.py b/gallery/__init__.py index 13db19a..5ca3c1a 100644 --- a/gallery/__init__.py +++ b/gallery/__init__.py @@ -19,9 +19,6 @@ import platformdirs from dotenv import load_dotenv from yaml import safe_load -# Utils -from gallery.utils import theme_manager - USER_DIR = platformdirs.user_config_dir('onlylegs') @@ -59,14 +56,13 @@ def create_app(test_config=None): else: app.config.from_mapping(test_config) - # Load theme - theme_manager.compile_theme('default', app.root_path) - # Load JS assets js_pre = Bundle('js/pre/*.js', output='gen/pre_packed.js') js_post = Bundle('js/post/*.js', output='gen/post_packed.js') + styles = Bundle('sass/style.sass', filters='libsass', output='gen/styles.css') assets.register('js_pre', js_pre) assets.register('js_post', js_post) + assets.register('styles', styles) # Error handlers, if the error is not a HTTP error, return 500 @app.errorhandler(Exception) diff --git a/gallery/themes/default/fonts/Manrope[wght].ttf b/gallery/static/fonts/Manrope[wght].ttf similarity index 100% rename from gallery/themes/default/fonts/Manrope[wght].ttf rename to gallery/static/fonts/Manrope[wght].ttf diff --git a/gallery/themes/default/fonts/Manrope[wght].woff2 b/gallery/static/fonts/Manrope[wght].woff2 similarity index 100% rename from gallery/themes/default/fonts/Manrope[wght].woff2 rename to gallery/static/fonts/Manrope[wght].woff2 diff --git a/gallery/themes/default/animations.sass b/gallery/static/sass/animations.sass similarity index 100% rename from gallery/themes/default/animations.sass rename to gallery/static/sass/animations.sass diff --git a/gallery/themes/default/components/banner.sass b/gallery/static/sass/components/banner.sass similarity index 100% rename from gallery/themes/default/components/banner.sass rename to gallery/static/sass/components/banner.sass diff --git a/gallery/themes/default/components/buttons/block.sass b/gallery/static/sass/components/buttons/block.sass similarity index 100% rename from gallery/themes/default/components/buttons/block.sass rename to gallery/static/sass/components/buttons/block.sass diff --git a/gallery/themes/default/components/buttons/info-button.sass b/gallery/static/sass/components/buttons/info-button.sass similarity index 100% rename from gallery/themes/default/components/buttons/info-button.sass rename to gallery/static/sass/components/buttons/info-button.sass diff --git a/gallery/themes/default/components/buttons/pill.sass b/gallery/static/sass/components/buttons/pill.sass similarity index 100% rename from gallery/themes/default/components/buttons/pill.sass rename to gallery/static/sass/components/buttons/pill.sass diff --git a/gallery/themes/default/components/buttons/top-of-page.sass b/gallery/static/sass/components/buttons/top-of-page.sass similarity index 100% rename from gallery/themes/default/components/buttons/top-of-page.sass rename to gallery/static/sass/components/buttons/top-of-page.sass diff --git a/gallery/themes/default/components/elements/labels.sass b/gallery/static/sass/components/elements/labels.sass similarity index 100% rename from gallery/themes/default/components/elements/labels.sass rename to gallery/static/sass/components/elements/labels.sass diff --git a/gallery/themes/default/components/elements/notification.sass b/gallery/static/sass/components/elements/notification.sass similarity index 100% rename from gallery/themes/default/components/elements/notification.sass rename to gallery/static/sass/components/elements/notification.sass diff --git a/gallery/themes/default/components/elements/pop-up.sass b/gallery/static/sass/components/elements/pop-up.sass similarity index 100% rename from gallery/themes/default/components/elements/pop-up.sass rename to gallery/static/sass/components/elements/pop-up.sass diff --git a/gallery/themes/default/components/elements/tags.sass b/gallery/static/sass/components/elements/tags.sass similarity index 100% rename from gallery/themes/default/components/elements/tags.sass rename to gallery/static/sass/components/elements/tags.sass diff --git a/gallery/themes/default/components/elements/upload-panel.sass b/gallery/static/sass/components/elements/upload-panel.sass similarity index 100% rename from gallery/themes/default/components/elements/upload-panel.sass rename to gallery/static/sass/components/elements/upload-panel.sass diff --git a/gallery/themes/default/components/gallery.sass b/gallery/static/sass/components/gallery.sass similarity index 100% rename from gallery/themes/default/components/gallery.sass rename to gallery/static/sass/components/gallery.sass diff --git a/gallery/themes/default/components/image-view/background.sass b/gallery/static/sass/components/image-view/background.sass similarity index 100% rename from gallery/themes/default/components/image-view/background.sass rename to gallery/static/sass/components/image-view/background.sass diff --git a/gallery/themes/default/components/image-view/fullscreen.sass b/gallery/static/sass/components/image-view/fullscreen.sass similarity index 100% rename from gallery/themes/default/components/image-view/fullscreen.sass rename to gallery/static/sass/components/image-view/fullscreen.sass diff --git a/gallery/themes/default/components/image-view/image.sass b/gallery/static/sass/components/image-view/image.sass similarity index 100% rename from gallery/themes/default/components/image-view/image.sass rename to gallery/static/sass/components/image-view/image.sass diff --git a/gallery/themes/default/components/image-view/info-tab.sass b/gallery/static/sass/components/image-view/info-tab.sass similarity index 100% rename from gallery/themes/default/components/image-view/info-tab.sass rename to gallery/static/sass/components/image-view/info-tab.sass diff --git a/gallery/themes/default/components/image-view/view.sass b/gallery/static/sass/components/image-view/view.sass similarity index 100% rename from gallery/themes/default/components/image-view/view.sass rename to gallery/static/sass/components/image-view/view.sass diff --git a/gallery/themes/default/components/navigation.sass b/gallery/static/sass/components/navigation.sass similarity index 100% rename from gallery/themes/default/components/navigation.sass rename to gallery/static/sass/components/navigation.sass diff --git a/gallery/themes/default/style.sass b/gallery/static/sass/style.sass similarity index 100% rename from gallery/themes/default/style.sass rename to gallery/static/sass/style.sass diff --git a/gallery/themes/default/variables.sass b/gallery/static/sass/variables.sass similarity index 100% rename from gallery/themes/default/variables.sass rename to gallery/static/sass/variables.sass diff --git a/gallery/templates/layout.html b/gallery/templates/layout.html index cf58624..cb19b32 100644 --- a/gallery/templates/layout.html +++ b/gallery/templates/layout.html @@ -33,6 +33,10 @@ {% endassets %} + {% assets "styles" %} + + {% endassets %} + {% block head %}{% endblock %} @@ -150,7 +154,7 @@ {% for message in get_flashed_messages() %} addNotification('{{ message[0] }}', {{ message[1] }}); {% endfor %} - + {% assets "js_post" %} diff --git a/gallery/themes/default/manifest.json b/gallery/themes/default/manifest.json deleted file mode 100644 index 6a1fbfb..0000000 --- a/gallery/themes/default/manifest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "default", - "version": "23.04.03", - "author": "MichaƂ Gdula", - "description": "Default theme for OnlyLegs", - "uses": "sass" -} \ No newline at end of file diff --git a/gallery/utils/theme_manager.py b/gallery/utils/theme_manager.py deleted file mode 100644 index c54f3c4..0000000 --- a/gallery/utils/theme_manager.py +++ /dev/null @@ -1,76 +0,0 @@ -""" -OnlyLegs - Theme Manager -""" -import os -import sys -import shutil -from datetime import datetime -import sass -import json - - -def compile_theme(theme_name, app_path): - """ - Compiles the theme into the static folder - """ - print(f"Loading '{theme_name}' theme...") - - # Set Paths - theme_source = os.path.join(app_path, 'themes', theme_name) - theme_target = os.path.join(app_path, 'static', 'theme') - - # If the theme doesn't exist, exit - if not os.path.exists(theme_source): - print("Theme does not exist!") - sys.exit(1) - - # If the destination folder doesn't exist, create it - if not os.path.exists(theme_target): - os.makedirs(theme_target) - - # Theme source file doesn't exist, exit - if not os.path.join(theme_source, 'style.sass'): - print("No sass file found!") - sys.exit(1) - - # Check if the theme has a manifest.json file - if os.path.exists(os.path.join(theme_source, 'manifest.json')): - source_info = json.load(open(os.path.join(theme_source, 'manifest.json'), encoding='utf-8', mode='r')) - else: - print("Theme lacks a manifest.json file, exiting as its required!") - sys.exit(1) - - # Check if the theme is upto date - if os.path.exists(os.path.join(theme_target, 'manifest.json')): - target_info = json.load(open(os.path.join(theme_target, 'manifest.json'), encoding='utf-8', mode='r')) - - if source_info['version'] == target_info['version'] and source_info['name'] == target_info['name']: - print("Theme is up to date!") - return - - # Compile the theme - with open(os.path.join(theme_target, 'style.css'), - encoding='utf-8', mode='w+') as file: - try: - file.write(sass.compile(filename=os.path.join(theme_source, 'style.sass'), - output_style='compressed')) - except sass.CompileError as err: - print("Failed to compile!\n", err) - sys.exit(1) - print("Compiled successfully!") - - # If the destination folder exists, remove it - if os.path.exists(os.path.join(theme_target, 'fonts')): - shutil.rmtree(os.path.join(theme_target, 'fonts')) - - # Copy the fonts - shutil.copytree(os.path.join(theme_source, 'fonts'), - os.path.join(theme_target, 'fonts')) - print("Fonts copied successfully!") - - # Copy the manifest - shutil.copyfile(os.path.join(theme_source, 'manifest.json'), - os.path.join(theme_target, 'manifest.json')) - print("Manifest copied successfully!") - - print(f"{datetime.now().hour}:{datetime.now().minute}:{datetime.now().second} - Done!\n")