removing auth temporarily for easier usage

This commit is contained in:
Bryan Van Deusen
2025-12-21 18:51:38 -05:00
parent a77724dccc
commit 71d16dbfb3
2 changed files with 26 additions and 21 deletions
+20 -19
View File
@@ -17,20 +17,21 @@ main = Blueprint('main', __name__)
@main.route('/') @main.route('/')
def index(): def index():
from random import choice # (kept from your original) return redirect(url_for("gallery"))
image = ImageRecord.query.order_by(func.random()).first() # from random import choice # (kept from your original)
background_url = None # image = ImageRecord.query.order_by(func.random()).first()
# background_url = None
if image: # if image:
path = image.thumb_path or image.filepath # path = image.thumb_path or image.filepath
filename = path.replace('/images/', '') # filename = path.replace('/images/', '')
background_url = url_for('main.serve_image', filename=filename) # background_url = url_for('main.serve_image', filename=filename)
return render_template('index.html', background_url=background_url) # return render_template('index.html', background_url=background_url)
@main.route('/gallery') @main.route('/gallery')
@login_required # @login_required
def gallery(): def gallery():
""" """
Gallery with pagination and optional tag filter (?tag=artist:NAME or any tag name). Gallery with pagination and optional tag filter (?tag=artist:NAME or any tag name).
@@ -71,7 +72,7 @@ def serve_image(filename):
@main.route('/tags') @main.route('/tags')
@login_required # @login_required
def tag_list(): def tag_list():
""" """
Generic tag explorer: Generic tag explorer:
@@ -110,20 +111,20 @@ def tag_list():
active_kind=kind) active_kind=kind)
@main.route('/artists') @main.route('/artists')
@login_required # @login_required
def artist_list(): def artist_list():
# Backward-compatible route that now shows the Tag Explorer filtered to artist tags # Backward-compatible route that now shows the Tag Explorer filtered to artist tags
return redirect(url_for('main.tag_list', kind='artist')) return redirect(url_for('main.tag_list', kind='artist'))
@main.route('/artist/<artist_name>') @main.route('/artist/<artist_name>')
@login_required # @login_required
def artist_gallery(artist_name): def artist_gallery(artist_name):
# Backward-compatible: go to gallery filtered by artist tag # Backward-compatible: go to gallery filtered by artist tag
return redirect(url_for('main.gallery', tag=f"artist:{artist_name}")) return redirect(url_for('main.gallery', tag=f"artist:{artist_name}"))
@main.route('/settings') @main.route('/settings')
@login_required # @login_required
def settings(): def settings():
if not current_user.is_admin: if not current_user.is_admin:
abort(403) abort(403)
@@ -131,7 +132,7 @@ def settings():
@main.route('/trigger-thumbnail-generation', methods=['POST']) @main.route('/trigger-thumbnail-generation', methods=['POST'])
@login_required # @login_required
def trigger_thumbnail_generation(): def trigger_thumbnail_generation():
if not current_user.is_admin: if not current_user.is_admin:
flash("You do not have permission to perform this action.", "danger") flash("You do not have permission to perform this action.", "danger")
@@ -148,7 +149,7 @@ def trigger_thumbnail_generation():
@main.route('/import-images') @main.route('/import-images')
@login_required # @login_required
def trigger_image_import(): def trigger_image_import():
with open('/import/trigger.flag', 'w') as f: with open('/import/trigger.flag', 'w') as f:
f.write('start') f.write('start')
@@ -157,7 +158,7 @@ def trigger_image_import():
@main.route('/reset-db', methods=['POST']) @main.route('/reset-db', methods=['POST'])
@login_required # @login_required
def reset_db(): def reset_db():
""" """
Safe reset that works with Postgres (TRUNCATE ... CASCADE). Safe reset that works with Postgres (TRUNCATE ... CASCADE).
@@ -194,7 +195,7 @@ def reset_db():
# ---------------------------- # ----------------------------
@main.get("/image/<int:image_id>/tags") @main.get("/image/<int:image_id>/tags")
@login_required # @login_required
def list_tags(image_id): def list_tags(image_id):
from app.models import ImageRecord from app.models import ImageRecord
img = ImageRecord.query.get_or_404(image_id) img = ImageRecord.query.get_or_404(image_id)
@@ -202,7 +203,7 @@ def list_tags(image_id):
@main.post("/image/<int:image_id>/tags/add") @main.post("/image/<int:image_id>/tags/add")
@login_required # @login_required
def add_tag(image_id): def add_tag(image_id):
""" """
Minimal JSON endpoint to add a tag to an image. Minimal JSON endpoint to add a tag to an image.
@@ -233,7 +234,7 @@ def add_tag(image_id):
@main.post("/image/<int:image_id>/tags/remove") @main.post("/image/<int:image_id>/tags/remove")
@login_required # @login_required
def remove_tag(image_id): def remove_tag(image_id):
""" """
Minimal JSON endpoint to remove a tag from an image. Minimal JSON endpoint to remove a tag from an image.
+6 -2
View File
@@ -11,7 +11,11 @@
<header> <header>
<nav class="navbar"> <nav class="navbar">
<a class="nav-button" href="{{ url_for('main.gallery') if current_user.is_authenticated else url_for('main.index') }}">Home</a> <a class="nav-button" href="{{ url_for('main.gallery') }}">Home</a>
<a class="nav-button" href="{{ url_for('main.tag_list', kind='artist') }}">Artists</a>
<a class="nav-button" href="{{ url_for('main.tag_list') }}">Tags</a>
<a class="nav-button" href="{{ url_for('main.settings') }}">Settings</a>
<!-- <a class="nav-button" href="{{ url_for('main.gallery') if current_user.is_authenticated else url_for('main.index') }}">Home</a>
{% if current_user.is_authenticated and current_user.is_admin %} {% if current_user.is_authenticated and current_user.is_admin %}
<a class="nav-button" href="{{ url_for('main.settings') }}">Settings</a> <a class="nav-button" href="{{ url_for('main.settings') }}">Settings</a>
@@ -24,7 +28,7 @@
{% else %} {% else %}
<a class="nav-button" href="{{ url_for('auth.login') }}">Login</a> <a class="nav-button" href="{{ url_for('auth.login') }}">Login</a>
<a class="nav-button" href="{{ url_for('auth.register') }}">Register</a> <a class="nav-button" href="{{ url_for('auth.register') }}">Register</a>
{% endif %} {% endif %} -->
</nav> </nav>
</header> </header>