diff --git a/gallery/__init__.py b/gallery/__init__.py index 1db7d79..098c5c9 100644 --- a/gallery/__init__.py +++ b/gallery/__init__.py @@ -11,7 +11,8 @@ import logging from flask_compress import Compress from flask_caching import Cache from flask_assets import Environment, Bundle -from flask import Flask, render_template +from flask import Flask, render_template, abort +from werkzeug.exceptions import HTTPException # Configuration import platformdirs @@ -66,17 +67,17 @@ def create_app(test_config=None): assets.register('js_all', js_scripts) # Error handlers - @app.errorhandler(400) - @app.errorhandler(401) - @app.errorhandler(403) - @app.errorhandler(404) - @app.errorhandler(405) - @app.errorhandler(418) - @app.errorhandler(500) + + @app.errorhandler(Exception) def error_page(err): - error = err.code - msg = err.description - return render_template('error.html', error=error, msg=msg), err.code + # If the error is a HTTP error, return the error page + if isinstance(err, HTTPException): + error = err.code + msg = err.description + return render_template('error.html', error=error, msg=msg), err.code + + # Otherwise this an internal error + abort(500) # Load login, registration and logout manager from gallery import auth diff --git a/gallery/static/js/notifications.js b/gallery/static/js/notifications.js index de7e3c6..49a8242 100644 --- a/gallery/static/js/notifications.js +++ b/gallery/static/js/notifications.js @@ -6,7 +6,7 @@ function addNotification(text='Sample notification', type=4) { div.classList.add('sniffle__notification'); div.onclick = function() { if (div.parentNode) { - div.classList.add('sniffle__notification--hide'); + div.classList.add('hide'); setTimeout(function() { container.removeChild(div); @@ -19,20 +19,20 @@ function addNotification(text='Sample notification', type=4) { icon.classList.add('sniffle__notification-icon'); switch (type) { case 1: - div.classList.add('sniffle__notification--success'); - icon.innerHTML = ''; + div.classList.add('success'); + icon.innerHTML = ''; break; case 2: - div.classList.add('sniffle__notification--error'); - icon.innerHTML = ''; + div.classList.add('critical'); + icon.innerHTML = ''; break; case 3: - div.classList.add('sniffle__notification--warning'); - icon.innerHTML = ''; + div.classList.add('warning'); + icon.innerHTML = ''; break; default: - div.classList.add('sniffle__notification--info'); - icon.innerHTML = ''; + div.classList.add('info'); + icon.innerHTML = ''; break; } div.appendChild(icon); @@ -51,13 +51,13 @@ function addNotification(text='Sample notification', type=4) { // Append notification to container container.appendChild(div); setTimeout(function() { - div.classList.add('sniffle__notification-show'); + div.classList.add('show'); }, 100); // Remove notification after 5 seconds setTimeout(function() { if (div.parentNode) { - div.classList.add('sniffle__notification--hide'); + div.classList.add('hide'); setTimeout(function() { container.removeChild(div); diff --git a/gallery/templates/groups/list.html b/gallery/templates/groups/list.html index 8b87493..25ed66c 100644 --- a/gallery/templates/groups/list.html +++ b/gallery/templates/groups/list.html @@ -1,16 +1,15 @@ {% extends 'layout.html' %} {% block nav_groups %}selected{% endblock %} {% block content %} -