From adb744089eac9e825661e740f2f1da9c4091939b Mon Sep 17 00:00:00 2001 From: Quentin Machu Date: Wed, 21 Oct 2015 15:28:45 -0400 Subject: [PATCH] Add 404 page Fixes coreos-inc/quay#677 --- conf/server-base.conf | 3 +- endpoints/web.py | 4 ++ static/js/app.js | 5 ++ templates/404.html | 12 +++++ templates/500.html | 121 ++++++++---------------------------------- templates/error.html | 92 ++++++++++++++++++++++++++++++++ 6 files changed, 136 insertions(+), 101 deletions(-) create mode 100644 templates/404.html create mode 100644 templates/error.html diff --git a/conf/server-base.conf b/conf/server-base.conf index 046121e24..65e491772 100644 --- a/conf/server-base.conf +++ b/conf/server-base.conf @@ -72,7 +72,8 @@ location /c1/ { location /static/ { # checks for static file, if not found proxy to app - alias /static/; + alias /static/; + error_page 404 /404; } location /v1/_ping { diff --git a/endpoints/web.py b/endpoints/web.py index f7450b599..cbca6c7cf 100644 --- a/endpoints/web.py +++ b/endpoints/web.py @@ -58,6 +58,10 @@ def index(path, **kwargs): def internal_error_display(): return render_page_template('500.html') +@web.errorhandler(404) +@web.route('/404', methods=['GET']) +def not_found_error_display(e = None): + return render_page_template('404.html') @web.route('/organization/', methods=['GET']) @no_cache diff --git a/static/js/app.js b/static/js/app.js index 17894fcd3..26c6c10fe 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -226,6 +226,11 @@ quayApp.run(['$location', '$rootScope', 'Restangular', 'UserService', 'PlanServi return false; } + if (response.status == 404) { + document.location = '/404'; + return false; + } + return true; }); diff --git a/templates/404.html b/templates/404.html new file mode 100644 index 000000000..cb243f3de --- /dev/null +++ b/templates/404.html @@ -0,0 +1,12 @@ +{% extends "error.html" %} + +{% block title %} + Quay.io - Page Not Found! +{% endblock %} + +{% block content %} +

The page doesn't exist !

+

+ This is somewhat embarrassing, isn’t it ? It looks like nothing was found at this location. Please return to the main page. +

+{% endblock %} diff --git a/templates/500.html b/templates/500.html index 2215a6e0a..3335cea5f 100644 --- a/templates/500.html +++ b/templates/500.html @@ -1,104 +1,25 @@ - +{% extends "error.html" %} + +{% block title %} Quay.io - Something went wrong! - - - - - - - - -
- -

Something went wrong on our end!

-

- We're currently working to fix the problem, but if its persists please feel free to contact us. In the meantime, try a refreshing drink (or just refreshing). -

- -
- Current Service Status: - (Loading) -
- - - -
- - + + +{% endblock %} diff --git a/templates/error.html b/templates/error.html new file mode 100644 index 000000000..de79500e3 --- /dev/null +++ b/templates/error.html @@ -0,0 +1,92 @@ + + + {% block title %} + + {% endblock %} + + + + + + + +
+ + {% block content %} + + {% endblock %} +
+ +