diff --git a/src/routes/generic.py b/src/routes/generic.py index e737f1a..cf350dd 100644 --- a/src/routes/generic.py +++ b/src/routes/generic.py @@ -1,7 +1,7 @@ # Imports -from flask import Blueprint, render_template, request, abort, send_from_directory, send_file +from flask import Blueprint, render_template, request, abort, send_file from os import getenv as env -import logging +import logging, os # Create blueprint @@ -44,10 +44,22 @@ def sitemap(): # Catch-all route for generic pages @bp.route('/') def catch_all(filename): - # try to find template in the pages directory and add .html extension - if not filename.endswith('.html'): - filename += '.html' - try: - return render_template(f'pages/{filename}') + try: return render_template(f'pages/{filename if filename.endswith(".html") else filename + ".html"}') except Exception as e: + # If the template is not found, check if it is a directory + os_path = os.path.join(bp.template_folder, 'pages', filename)[3:] + if os.path.isdir(os_path): + # walk through the directory and find all files + pages = [] + for root, dirs, files_in_dir in os.walk(os_path): + for file in files_in_dir: + pages.append(os.path.relpath(os.path.join(root, file), os_path)) + for dir in dirs: + pages.append(os.path.relpath(os.path.join(root, dir), os_path) + '/') + + # If it is a directory, render a directory page + if not filename.endswith('/'): filename += '/' + return render_template('bases/directory.html', directory=filename, pages=pages) + + # If it is a file, return a 404 error abort(404, f"Template '{filename}' not found: {e}") \ No newline at end of file diff --git a/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_140629639.jpg b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_140629639.jpg new file mode 100644 index 0000000..0714fff Binary files /dev/null and b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_140629639.jpg differ diff --git a/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_141242090.jpg b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_141242090.jpg new file mode 100644 index 0000000..55a18a3 Binary files /dev/null and b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_141242090.jpg differ diff --git a/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_182023562.jpg b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_182023562.jpg new file mode 100644 index 0000000..04a0ea6 Binary files /dev/null and b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_182023562.jpg differ diff --git a/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_184321576.jpg b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_184321576.jpg new file mode 100644 index 0000000..00d9404 Binary files /dev/null and b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_184321576.jpg differ diff --git a/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_200906329.jpg b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_200906329.jpg new file mode 100644 index 0000000..b4ee0aa Binary files /dev/null and b/static/content/fur_meets/03-08-2025_paws_n_pistons/PXL_20250803_200906329.jpg differ diff --git a/static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_152110445.jpg b/static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_152110445.jpg similarity index 100% rename from static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_152110445.jpg rename to static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_152110445.jpg diff --git a/static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_155134418.jpg b/static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_155134418.jpg similarity index 100% rename from static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_155134418.jpg rename to static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_155134418.jpg diff --git a/static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_155226274.jpg b/static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_155226274.jpg similarity index 100% rename from static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_155226274.jpg rename to static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_155226274.jpg diff --git a/static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_155434701.jpg b/static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_155434701.jpg similarity index 100% rename from static/content/fur_meets/26-08-2025_critters_mk/PXL_20250726_155434701.jpg rename to static/content/fur_meets/26-07-2025_critters_mk/PXL_20250726_155434701.jpg diff --git a/static/css/directory.css b/static/css/directory.css new file mode 100644 index 0000000..0854233 --- /dev/null +++ b/static/css/directory.css @@ -0,0 +1,13 @@ +section#directory ul { + list-style: none; + padding: 0; + margin: 0; +} + +section#directory li { + margin: 0.5rem 0; +} + +section#directory a:hover { + scale: 1.05; +} \ No newline at end of file diff --git a/static/css/gallery.css b/static/css/gallery.css new file mode 100644 index 0000000..5faafc5 --- /dev/null +++ b/static/css/gallery.css @@ -0,0 +1,17 @@ +.gallery { + display: flex; + flex-wrap: wrap; + justify-content: space-between; + gap: 1rem; +} + +.gallery img { + max-width: 100%; + height: auto; + border-radius: 10px; +} + +.gallery-date { + margin: 1rem 0 .25rem 0; + font-size: 2rem; +} \ No newline at end of file diff --git a/templates/bases/base.html b/templates/bases/base.html index ff8689f..44f434b 100644 --- a/templates/bases/base.html +++ b/templates/bases/base.html @@ -4,7 +4,7 @@ {% block title %}Alfie's basement{% endblock %} - + @@ -28,6 +28,7 @@