From cdb3836dab89c01fea5b93d6b59724b36766a947 Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Sat, 25 Mar 2023 20:24:38 +0000 Subject: [PATCH] Fix new styling errors Fix error page Update Notification styling --- gallery/__init__.py | 23 ++++----- gallery/static/js/notifications.js | 22 ++++----- gallery/templates/groups/list.html | 11 ++--- gallery/templates/image.html | 28 +++++------ gallery/templates/index.html | 9 ++-- gallery/templates/layout.html | 24 ++++----- gallery/themes/default/components/banner.sass | 33 ++++++++++++- .../default/components/buttons/block.sass | 5 +- .../components/buttons/info-button.sass | 2 +- .../default/components/buttons/pill.sass | 20 +++++--- .../components/buttons/top-of-page.sass | 2 +- .../components/elements/notification.sass | 49 ++++++++++--------- .../components/elements/upload-panel.sass | 5 +- .../components/image-view/info-tab.sass | 6 ++- .../themes/default/components/navigation.sass | 2 +- gallery/themes/default/style.sass | 9 ++++ 16 files changed, 154 insertions(+), 96 deletions(-) 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 %} -