Fix html_fallback and logged error message

This commit is contained in:
Fritz Reichwald 2016-12-28 02:23:35 +01:00
parent 07143dd433
commit f38dda5f16

View File

@ -34,45 +34,37 @@ from PyQt5.QtCore import QUrl
html_fallback = """<!DOCTYPE html> html_fallback = """<!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>{{ title }}</title> <title>{{ title }}</title>
{% if icon %} {% if icon %}
<link rel="icon" type="image/png" href="{{ icon }}"> <link rel="icon" type="image/png" href="{{ icon }}">
{% endif %} {% endif %}
<style type="text/css"> <style type="text/css">
{% block style %} {% block style %}
body { body {
background-color: #fff; background-color: #fff;
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
{% endblock %} {% endblock %}
</style> </style>
</head> </head>
<body> <body>
<div id="error-container"> <div id="error-container">
<table> <table>
<tr> <tr>
<td style="width: 10%; vertical-align: top;"> <td style="width: 10%; vertical-align: top;">
<img style="width: 100%; display: block; max-width: 256px;" src="{{ data_url("img/broken_qutebrowser_logo.png") }}" /> <img style="width: 100%; display: block; max-width: 256px;" src="{{ data_url("img/broken_qutebrowser_logo.png") }}" />
</td> </td>
<td style="padding-left: 40px;"> <td style="padding-left: 40px;">
<p><span style="font-size:120%;color:red">The error.html template could not be found!<br>Please check your qutebrowser installation</span><br> <p><span style="font-size:120%;color:red">The error.html template could not be found!<br>Please check your qutebrowser installation</span><br>
%ERROR%</p> %ERROR%</p>
<h1>Unable to load page</h1> </td>
Error while opening {{ url }}: <br> </tr>
<p id="error-message-text" style="color: #a31a1a;">{{ error }}</p><br><br> </table>
</div>
<form name="bl"> </body>
<input type="button" value="Try again" onclick="javascript:location.reload();" />
</form>
</td>
</tr>
</table>
</div>
</body>
</html> </html>
""" """
@ -93,7 +85,7 @@ class Loader(jinja2.BaseLoader):
source = utils.read_file(path) source = utils.read_file(path)
except OSError as e: except OSError as e:
source = html_fallback.replace("%ERROR%", html.escape(str(e))) source = html_fallback.replace("%ERROR%", html.escape(str(e)))
log.misc.error("The error.html template could not be found" + path) log.misc.error("The error.html template could not be found at " + path)
# Currently we don't implement auto-reloading, so we always return True # Currently we don't implement auto-reloading, so we always return True
# for up-to-date. # for up-to-date.
return source, path, lambda: True return source, path, lambda: True