summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFritz Reichwald <reichwald@b1-systems.de>2016-12-27 17:54:06 +0100
committerFritz Reichwald <reichwald@b1-systems.de>2016-12-27 17:54:06 +0100
commit004b0dc911e3aa88cbbfd2bc2065bb5873f72a07 (patch)
treee895cc74ec3b31876c9880603b085e351ee59b95
parent59b378e29a2ea668113436f9368ff90b7efa8e88 (diff)
downloadqutebrowser-004b0dc911e3aa88cbbfd2bc2065bb5873f72a07.tar.gz
qutebrowser-004b0dc911e3aa88cbbfd2bc2065bb5873f72a07.zip
Add fallback for missing error.html
-rw-r--r--qutebrowser/utils/jinja.py47
1 files changed, 45 insertions, 2 deletions
diff --git a/qutebrowser/utils/jinja.py b/qutebrowser/utils/jinja.py
index e60032ff4..f2dbbfe5f 100644
--- a/qutebrowser/utils/jinja.py
+++ b/qutebrowser/utils/jinja.py
@@ -31,6 +31,49 @@ from qutebrowser.utils import utils, urlutils, log
from PyQt5.QtCore import QUrl
+html_fallback = '''<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>{{ title }}</title>
+ {% if icon %}
+ <link rel="icon" type="image/png" href="{{ icon }}">
+ {% endif %}
+ <style type="text/css">
+ {% block style %}
+ body {
+ background-color: #fff;
+ margin: 0;
+ padding: 0;
+ }
+ {% endblock %}
+ </style>
+ </head>
+ <body>
+ <div id="error-container">
+ <table>
+ <tr>
+ <td style="width: 10%; vertical-align: top;">
+ <img style="width: 100%; display: block; max-width: 256px;" src="{{ data_url("img/broken_qutebrowser_logo.png") }}" />
+ </td>
+ <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>'''
+html_fallback2 = '''</p>
+ <h1>Unable to load page</h1>
+ Error while opening {{ url }}: <br>
+ <p id="error-message-text" style="color: #a31a1a;">{{ error }}</p><br><br>
+
+ <form name="bl">
+ <input type="button" value="Try again" onclick="javascript:location.reload();" />
+ </form>
+
+ </td>
+ </tr>
+ </table>
+</div>
+ </body>
+</html>
+'''
class Loader(jinja2.BaseLoader):
@@ -47,8 +90,8 @@ class Loader(jinja2.BaseLoader):
path = os.path.join(self._subdir, template)
try:
source = utils.read_file(path)
- except OSError:
- raise jinja2.TemplateNotFound(template)
+ except OSError as e:
+ source = html_fallback + str(e) + html_fallback2;
# Currently we don't implement auto-reloading, so we always return True
# for up-to-date.
return source, path, lambda: True