[Sugar-devel] [PATCH Browse] Error page SL #3500
Manuel Kaufmann
humitos at gmail.com
Wed Sep 19 07:38:54 EDT 2012
Added an "Error page" with Sugar style that informs the users about
the the page could not be loaded for any reason.
This patch contains a HTML template (error_page.tmpl) that is used to
generate the error page with the correct language.
Signed-off-by: Manuel Kaufmann <humitos at gmail.com>
---
browser.py | 22 +++++++++++++++++++++
data/error_page.tmpl | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 76 insertions(+)
create mode 100644 data/error_page.tmpl
diff --git a/browser.py b/browser.py
index de546f2..52e05bd 100644
--- a/browser.py
+++ b/browser.py
@@ -58,6 +58,9 @@ _NON_SEARCH_REGEX = re.compile('''
^file:.*$)
''', re.VERBOSE)
+DEFAULT_ERROR_PAGE = os.path.join(activity.get_bundle_path(),
+ 'data/error_page.tmpl')
+
class CommandListener(object):
def __init__(self, window):
@@ -462,6 +465,7 @@ class Browser(WebKit.WebView):
self.__mime_type_policy_cb)
self.connect('new-window-policy-decision-requested',
self.__new_window_policy_cb)
+ self.connect('load-error', self.__load_error_cb)
try:
self.connect('run-file-chooser', self.__run_file_chooser)
@@ -603,6 +607,24 @@ class Browser(WebKit.WebView):
downloadmanager.add_download(download, browser)
return True
+ def __load_error_cb(self, web_view, web_frame, uri, web_error):
+ """Show Sugar's error page"""
+
+ data = {
+ 'page_title': _('This web page could not be loaded'),
+ 'title': _('This web page could not be loaded'),
+ 'message': _('"%s" could not be loaded. Please check for<br/>'
+ 'typing errors, and make sure you are connected '
+ 'to the internet.') % uri,
+ 'btn_value': _('Try again'),
+ 'url': uri,
+ }
+
+ html = open(DEFAULT_ERROR_PAGE, 'r').read() % data
+ web_frame.load_alternate_string(html, '', uri)
+
+ return True
+
class PopupDialog(Gtk.Window):
def __init__(self):
diff --git a/data/error_page.tmpl b/data/error_page.tmpl
new file mode 100644
index 0000000..68c76f2
--- /dev/null
+++ b/data/error_page.tmpl
@@ -0,0 +1,54 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <title>%(page_title)s</title>
+ <style type="text/css">
+ body {
+ font-family: sans-serif;
+ text-align:center;
+ color: #a1a1a1;
+ }
+
+ #browse-logo {
+ align: center;
+ width: 130px;
+ }
+
+ p {
+ font-size: 1em;
+ }
+
+ #button {
+ color: white;
+ min-width: 150px;
+ height: 35px;
+ background-color: #a3a1a3;
+ border: 0;
+ font-size: 12pt;
+ font-weight: bold;
+ -webkit-border-radius: 20px;
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABEAAAASCAYAAAC9+TVUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAPNgAADzYBTE5UtQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAFeSURBVDiNlZM9SwNBEIbfXCMawcqURxohjZUkWFgJ/oR0gZBKO6sIimBhZ6e9BG3tbfwDGhERkoh6oCJoI4KNiBgei8zKZo35GBhm5+adh7n9SAEKbEJSWVJB0pykGUl3ki4k1SUdSPro6gB8XwAS+ltiut8+H1AF2p64BRwCmxZbXq1t+i5IAfg2wStQDCZ0XrQ6pp93kDGgaYU3IP4H4Dw2HcANMC5g2RuzNADgvOT1rAioWdIYEuC8YX21SFLeDuo8POsB5vT5SFLOkuaIEKfPRZIeLcmOCIktPkWSrtxYFsuSjoeAFiw23CVztuht2FGfTV3yetYFpIFn+9AEdm39BWR6ADLAtWlegElXqHjke29dDQCzdL+tCsHb2eavPVgtC5wEtR0g5UPSwBpw2QOUs/q75Z/Aqj+hW+z3aAaoA1Om2QI2gOngF9UZp3Ose5JuJZ1KOrOYDHNhfgA9ndj5pIgf9QAAAABJRU5ErkJggg==");
+ background-position: 16px;
+ background-repeat: no-repeat;
+ text-align: center;
+ padding-left: 40px;
+ padding-right: 15px;
+ }
+
+ #container {
+ /* we need double percent sign here because
+ of Python sustitution */
+ margin: 15%%;
+ }
+ </style>
+ </head>
+
+ <body>
+ <div id="container">
+ <img id="browse-logo" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIIAAACCCAYAAACKAxD9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAApiwAAKYsBK9yyHwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAABctSURBVHic7Z1bTFzX1YC/uQDDGAw22MXBjmG4NQanxsF2bGNkx2lqOW7y1EpVpNNffYnU16gPTZ7TPlR9jZSHVvKRokjpUxvLddU0tNiQxOVmG+xwMRBDArEN5mYYLsP8D+cMHjCXvfaZYQbqTxoh43P22XPWYu2911p7bVc4HGYrYppmDlAW9QkA2UAGsM3+GfkATEZ9Hts/R4EeoCPyMQxjeOO+xcbh2gqKYJrmDuAMcBY4hCX4nDg9bhhLKVqBfwG1hmE8itOzNoxNqQimafqBk1iCfxWoBNwJ6s4C0AJ8hqUY9YZhTCWoL9psGkUwTdMD/Bj4JfAmkJ7YHq3KNPBX4CLwT8MwQgnujxJJrwimaR4EDOAtYE+CuyNlEPgIMA3DuJXozqxFUiqCaZou4A3gXeBogrsTK64DvwP+ZhhG0r30pFIE0zTdwM+A94CDCe5OvLgFvA/8xTCMhUR3JkJSKIJpml4s0/9brBn//wIdwO+BjwzDmE90ZxKuCKZpVgMfsHUtwHrcAn5tGMa1RHYiYYpgmuYu4A9YE0FXQjqRPIQBE/iNYRgPEtGBDVcEex7wNtY4uWNDH578PMKaH3240fOHDVUE0zTzgY+BUxv20M3JVeAXhmF8u1EP3DBvnGma57HcsjFVApfLRUZGxvoXxoHMzExyc3NxuWI+sp0CWu13tiHE3SKYppmCtX5+hxjOBXJycggEAmzbto26ujoWFhKzEisvL6e8vJze3l56enoYHo5pTCoM/BF41zCMuVg2vJy4KoJpmvuAT4CXY9Gez+ejpKSEQCBAVlYWY2Nj/P3vf2d2djYWzWtTXV1NIBAAYGxsjJ6eHrq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QwNGjR+nt7aWnp0fseVyHMFZc511dj6EqcVeECKZpnsfaiq1eWk0Bl8tFenp6rMyviPT0dPx+PyMjI/HYa/EQK4ooDiDpsGGKAGCaZj7wMXBqwx66ObmKlU+wYalXG3rKm/3FTmNlRidHCnJy8Qjr3ZzeSCWADbYI0ZimuQv4A2AQw7nDJiWMlSn+G9Ucw1iTMEWIYJpmNfABIE/t3Rrcwtp3sG7KeTxJ+AGg9gs4DPwfgr2WW4AOrO98ONFKAElgEaIxTdMN/AwrdX6rWohbWDvN/yJJLo03SaUIEUzTdAFvYKVdHU1wd2LFdSx/yt9W25qeSJJSEaIxTfMg1oTyLWBPgrsjZRBr86m5UrmaZCLpFSGCaZoe4MdY6fRv4iC6GWemsQqXXgT+ubx6WbKyaRQhGtM0/cBJ4CzwKlBJ4ia+C1iV7T/Dqm1cH13RdLOwKRVhOaZp7gDOYCnGIaAM0CtFsj7DWDP+VizB10ZK3W9mtoQirIRpmjlYChH5BIBsIAPYZv+MfMA6GjnyeWz/HMU6ILUj8rEPQ9ty/D8hHxNBQyqmHgAAAABJRU5ErkJggg=="></img>
+ <h3>%(title)s</h3>
+ <p>%(message)s</p>
+ <input id="button" type="button" value="%(btn_value)s" onclick="location.href='%(url)s';" />
+ </div>
+ </body>
+</html>
--
1.7.11.4
More information about the Sugar-devel
mailing list