templates_DATA = \
src/templates/base.html \
src/templates/donate.html \
- src/templates/error.html \
- src/templates/error-404.html \
- src/templates/error-500.html \
+ src/templates/error.html
src/templates/index.html
templatesdir = $(datadir)/templates
+++ /dev/null
-{% extends "error.html" %}
+++ /dev/null
-{% extends "error.html" %}
-
-{% block explanation %}
- <div class="row">
- <div class="col-md-8 offset-2">
- <h4>{{ _("Detailed information") }}</h4>
-
- <p>
- {{ _("While processing the request, there was an internal problem of the web server") }}
- </p>
- </div>
- </div>
-{% end block %}
{% extends "base.html" %}
-{% block title %}{{ _("Error") }} {{ code }}{% end block %}
+{% block title %}{{ message or status_code }}{% end block %}
{% block container %}
-<div class="container">
- <section class="features-content col-12">
- <h2 class="display-2 text-center">{{ code }} - {{ message }}</h2>
-
- <div class="row mb-6">
- <div class="col-md-8 offset-md-2">
- <p class="lead">
- {{ _("Unfortunately, an unexpected error has occurred during page load.") }}
- </p>
- <p>
- If this is the first occurrence of the error, please wait a little bit
- and try again. If the error occurs anyway the webmaster would be happy
- to get a notification about this.
- </p>
+ <div class="container">
+ <div class="row justify-content-center mt-5">
+ <div class="col col-md-5">
+ <h5 class="mb-0">{{ _("Error %s") % status_code }}</h5>
+ <h1>{{ _("oops, something went wrong") }}</h1>
</div>
</div>
-
- {% block explanation %}{% end block %}
-
- {% if exception %}
- <div class="row">
- <div class="col-md-8 offset-md-2">
- <pre>{{ exception }}</pre>
- </div>
- </div>
- {% end %}
- </section>
-</div>
+ </div>
{% end block %}
+
+{% block footer %}{% end block %}
# Handle old pages that have moved elsewhere
(r"/imprint", tornado.web.RedirectHandler, { "url" : "/legal" }),
(r"/(de|en)/(.*)", LangCompatHandler),
+
+ # Export arbitrary error pages
+ (r"/error/([45][0-9]{2})", ErrorHandler),
])
# blog.ipfire.org
from .. import util
class BaseHandler(tornado.web.RequestHandler):
+ def write_error(self, status_code, **kwargs):
+ # Translate code into message
+ try:
+ message = httplib.responses[status_code]
+ except KeyError:
+ message = None
+
+ self.render("error.html", status_code=status_code, message=message, **kwargs)
+
@property
def hostname(self):
# Remove the development prefix
# Raises 404 as soon as it is called
raise tornado.web.HTTPError(404)
- def write_error(self, status_code, **kwargs):
- assert status_code == 404
- self.render("error-404.html")
+class ErrorHandler(BaseHandler):
+ """
+ Raises any error we want
+ """
+ def get(self, code):
+ try:
+ code = int(code)
+ except:
+ raise tornado.web.HTTPError(400)
+
+ raise tornado.web.HTTPError(code)