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
|
# 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
|
import waitress
|
||||||
# templating
|
# templating
|
||||||
from jinja2 import Environment, PackageLoader, select_autoescape
|
from jinja2 import Environment, PackageLoader, select_autoescape
|
||||||
@ -94,10 +94,9 @@ def mainpage():
|
|||||||
def customerror(error):
|
def customerror(error):
|
||||||
code = int(str(error).split(",")[0][1:])
|
code = int(str(error).split(",")[0][1:])
|
||||||
|
|
||||||
if os.path.exists(pthjoin(WEBFOLDER,"errors",str(code) + ".pyhp")):
|
template = jinjaenv.get_template('error.jinja')
|
||||||
return pyhpfile(pthjoin(WEBFOLDER,"errors",str(code) + ".pyhp"),{"errorcode":code})
|
res = template.render(errorcode=code)
|
||||||
else:
|
return res
|
||||||
return pyhpfile(pthjoin(WEBFOLDER,"errors","generic.pyhp"),{"errorcode":code})
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -222,7 +221,7 @@ jinjaenv = Environment(
|
|||||||
jinjaenv.globals.update(JINJA_CONTEXT)
|
jinjaenv.globals.update(JINJA_CONTEXT)
|
||||||
|
|
||||||
|
|
||||||
@webserver.route("/<name:re:(issues|manual|setup|admin)>")
|
@webserver.route("/<name:re:(admin.*)>")
|
||||||
@auth.authenticated
|
@auth.authenticated
|
||||||
def static_html_private(name):
|
def static_html_private(name):
|
||||||
return static_html(name)
|
return static_html(name)
|
||||||
@ -291,7 +290,7 @@ def static_html(name):
|
|||||||
|
|
||||||
# if not, use the old way
|
# if not, use the old way
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
with open(pthjoin(WEBFOLDER,name + ".html")) as htmlfile:
|
with open(pthjoin(WEBFOLDER,name + ".html")) as htmlfile:
|
||||||
html = htmlfile.read()
|
html = htmlfile.read()
|
||||||
|
|
||||||
@ -332,7 +331,9 @@ def static_html(name):
|
|||||||
response.set_header("Link",",".join(linkheaders))
|
response.set_header("Link",",".join(linkheaders))
|
||||||
log("Generated page {name} in {time:.5f}s (Python+HTML)".format(name=name,time=clock.stop()),module="debug")
|
log("Generated page {name} in {time:.5f}s (Python+HTML)".format(name=name,time=clock.stop()),module="debug")
|
||||||
return html
|
return html
|
||||||
#return static_file("web/" + name + ".html",root="")
|
|
||||||
|
except:
|
||||||
|
abort(404, "Page does not exist")
|
||||||
|
|
||||||
|
|
||||||
# Shortlinks
|
# 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