mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Fixed error page
This commit is contained in:
parent
a88afe40ec
commit
9a1bc8be03
@ -4,7 +4,7 @@ from .globalconf import datadir, DATA_DIR
|
||||
|
||||
|
||||
# server stuff
|
||||
from bottle import Bottle, route, get, post, error, run, template, static_file, request, response, FormsDict, redirect, template, HTTPResponse, BaseRequest
|
||||
from bottle import Bottle, route, get, post, error, run, template, static_file, request, response, FormsDict, redirect, template, HTTPResponse, BaseRequest, abort
|
||||
import waitress
|
||||
# templating
|
||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||
@ -94,10 +94,9 @@ def mainpage():
|
||||
def customerror(error):
|
||||
code = int(str(error).split(",")[0][1:])
|
||||
|
||||
if os.path.exists(pthjoin(WEBFOLDER,"errors",str(code) + ".pyhp")):
|
||||
return pyhpfile(pthjoin(WEBFOLDER,"errors",str(code) + ".pyhp"),{"errorcode":code})
|
||||
else:
|
||||
return pyhpfile(pthjoin(WEBFOLDER,"errors","generic.pyhp"),{"errorcode":code})
|
||||
template = jinjaenv.get_template('error.jinja')
|
||||
res = template.render(errorcode=code)
|
||||
return res
|
||||
|
||||
|
||||
|
||||
@ -222,7 +221,7 @@ jinjaenv = Environment(
|
||||
jinjaenv.globals.update(JINJA_CONTEXT)
|
||||
|
||||
|
||||
@webserver.route("/<name:re:(issues|manual|setup|admin)>")
|
||||
@webserver.route("/<name:re:(admin.*)>")
|
||||
@auth.authenticated
|
||||
def static_html_private(name):
|
||||
return static_html(name)
|
||||
@ -291,7 +290,7 @@ def static_html(name):
|
||||
|
||||
# if not, use the old way
|
||||
else:
|
||||
|
||||
try:
|
||||
with open(pthjoin(WEBFOLDER,name + ".html")) as htmlfile:
|
||||
html = htmlfile.read()
|
||||
|
||||
@ -332,7 +331,9 @@ def static_html(name):
|
||||
response.set_header("Link",",".join(linkheaders))
|
||||
log("Generated page {name} in {time:.5f}s (Python+HTML)".format(name=name,time=clock.stop()),module="debug")
|
||||
return html
|
||||
#return static_file("web/" + name + ".html",root="")
|
||||
|
||||
except:
|
||||
abort(404, "Page does not exist")
|
||||
|
||||
|
||||
# Shortlinks
|
||||
|
18
maloja/web/jinja/error.jinja
Normal file
18
maloja/web/jinja/error.jinja
Normal file
@ -0,0 +1,18 @@
|
||||
{% extends "admin.jinja" %}
|
||||
|
||||
{% block content %}
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('/favicon.png')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Error {{ errorcode }}</h1><br/>
|
||||
|
||||
|
||||
<p>That did not work. Don't ask me why.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
{% endblock %}
|
@ -1,28 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Maloja - Error <pyhp echo="errorcode" /></title>
|
||||
<pyhp include="../common/header.html" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<table class="top_info">
|
||||
<tr>
|
||||
<td class="image">
|
||||
<div style="background-image:url('/favicon.png')"></div>
|
||||
</td>
|
||||
<td class="text">
|
||||
<h1>Error <pyhp echo="errorcode" /></h1><br/>
|
||||
|
||||
|
||||
<p>That did not work. Don't ask me why.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user