diff --git a/__pycache__/models.cpython-313.pyc b/__pycache__/models.cpython-313.pyc index 73b579e..4d2cb8b 100644 Binary files a/__pycache__/models.cpython-313.pyc and b/__pycache__/models.cpython-313.pyc differ diff --git a/app.py b/app.py index 516d599..a99297e 100644 --- a/app.py +++ b/app.py @@ -53,6 +53,15 @@ def create_app(): db.session.commit() return dict(config=app.config, site_settings=site_settings) + @app.context_processor + def inject_unread_notifications(): + from flask_login import current_user + from utils import get_unread_count + if current_user.is_authenticated: + unread_count = get_unread_count(current_user.id) + return {'unread_notifications': unread_count} + return {'unread_notifications': 0} + @app.template_filter('asset_version') def asset_version_filter(filename): """Template filter to get version hash for static assets""" @@ -134,6 +143,34 @@ def create_app(): app = create_app() +@app.errorhandler(404) +def page_not_found(e): + from flask import render_template + return render_template('common/404.html'), 404 + +@app.errorhandler(403) +def forbidden(e): + from flask import render_template + return render_template('common/403.html'), 403 + +@app.errorhandler(401) +def unauthorized(e): + from flask import render_template + return render_template('common/401.html'), 401 + +@app.errorhandler(400) +def bad_request(e): + from flask import render_template + return render_template('common/400.html'), 400 + +@app.errorhandler(500) +def internal_server_error(e): + from flask import render_template + import traceback + error_details = f"{str(e)}\n\n{traceback.format_exc()}" + app.logger.error(f"500 error: {error_details}") + return render_template('common/500.html', error=error_details), 500 + @app.route('/uploads/profile_pics/') def profile_pic(filename): return send_from_directory('/app/uploads/profile_pics', filename) diff --git a/routes/__pycache__/main.cpython-313.pyc b/routes/__pycache__/main.cpython-313.pyc index 559ffd5..52cdf19 100644 Binary files a/routes/__pycache__/main.cpython-313.pyc and b/routes/__pycache__/main.cpython-313.pyc differ diff --git a/routes/__pycache__/rooms.cpython-313.pyc b/routes/__pycache__/rooms.cpython-313.pyc index a0f1ae8..b76f3d8 100644 Binary files a/routes/__pycache__/rooms.cpython-313.pyc and b/routes/__pycache__/rooms.cpython-313.pyc differ diff --git a/templates/common/400.html b/templates/common/400.html new file mode 100644 index 0000000..c672a98 --- /dev/null +++ b/templates/common/400.html @@ -0,0 +1,19 @@ +{% extends "common/base.html" %} + +{% block title %}Bad Request - 400{% endblock %} + +{% block content %} +
+

400

+

Bad Request

+

Sorry, the request could not be processed. Please check your input and try again.

+
+ + Back to Dashboard + + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/common/401.html b/templates/common/401.html new file mode 100644 index 0000000..f919593 --- /dev/null +++ b/templates/common/401.html @@ -0,0 +1,19 @@ +{% extends "common/base.html" %} + +{% block title %}Authentication Required - 401{% endblock %} + +{% block content %} +
+

401

+

Authentication Required

+

Please log in to access this resource.

+
+ + Log In + + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/common/403.html b/templates/common/403.html new file mode 100644 index 0000000..4942531 --- /dev/null +++ b/templates/common/403.html @@ -0,0 +1,19 @@ +{% extends "common/base.html" %} + +{% block title %}Access Denied - 403{% endblock %} + +{% block content %} +
+

403

+

Access Denied

+

Sorry, you don't have permission to access this resource.

+
+ + Back to Dashboard + + +
+
+{% endblock %} \ No newline at end of file diff --git a/templates/common/404.html b/templates/common/404.html new file mode 100644 index 0000000..8138db2 --- /dev/null +++ b/templates/common/404.html @@ -0,0 +1,15 @@ +{% extends "common/base.html" %} + +{% block title %}Page Not Found - 404{% endblock %} + +{% block content %} +
+

404

+

Page Not Found

+

Sorry, the page you are looking for does not exist or has been moved.

+

If you were trying to access a room, conversation, or file, it may have been deleted by an administrator.

+ + Back to Dashboard + +
+{% endblock %} \ No newline at end of file diff --git a/templates/common/500.html b/templates/common/500.html new file mode 100644 index 0000000..2502e53 --- /dev/null +++ b/templates/common/500.html @@ -0,0 +1,55 @@ +{% extends "common/base.html" %} + +{% block title %}Server Error - 500{% endblock %} + +{% block content %} +
+

500

+

Internal Server Error

+

Sorry, something went wrong on our end. Our team has been notified and we're working to fix it.

+
+ + Back to Dashboard + + +
+ + +
+ +
+
+
+
+
Error Details
+ +
+
{{ error }}
+
+
+
+
+
+ +{% block extra_js %} + +{% endblock %} +{% endblock %} \ No newline at end of file