Added an "Error page" with Sugar style that informs the users about they are not connected to the internet when the page can not reached 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 <humi...@gmail.com> --- browser.py | 31 +++++++++++++++++++++++++ data/activity-web.png | Bin 0 -> 6064 bytes data/browse-view-refresh.png | Bin 0 -> 481 bytes data/error_page.tmpl | 53 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 data/activity-web.png create mode 100644 data/browse-view-refresh.png create mode 100644 data/error_page.tmpl diff --git a/browser.py b/browser.py index de546f2..c9bcc1c 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.html') + 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,33 @@ class Browser(WebKit.WebView): downloadmanager.add_download(download, browser) return True + def __create_error_page(self, url): + """Create the error page in the correct language""" + + data = { + 'page_title': _('You are not connected to the internet'), + 'title': _('You are not connected to the internet'), + 'message': _('You will need to connect using the ' + 'Neighborhood<br />view in order ' + 'to continue browsing'), + 'btn_value': _('Try again'), + 'url': url, + } + filepath = os.path.join(activity.get_bundle_path(), + 'data/error_page.tmpl') + html = open(filepath, 'r').read() % data + + f = open(DEFAULT_ERROR_PAGE, 'w') + f.write(html) + f.close() + + def __load_error_cb(self, web_view, web_frame, uri, web_error): + """Show Sugar's error page""" + + self.__create_error_page(uri) + self.load_uri('file://' + DEFAULT_ERROR_PAGE) + return True + class PopupDialog(Gtk.Window): def __init__(self): diff --git a/data/activity-web.png b/data/activity-web.png new file mode 100644 index 0000000000000000000000000000000000000000..d27964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@|}R$x}dhCoiS_Ls9)l$e6?ny}y*#mzW3sOE&QX4qS%&#A1Bl+#o& za5A@iG$2Xf1esRjaG7GMXTiJHWynVibc6i;3P%X{o+h+C%_tbZ^4MPpu8agSC(7qh zo5Z`vW&addVHj-$79Dw_2XTH81QlTssZM$#yP6l7yis%W{@C}4BWP$<Z!s%ZDM|Zz z*E#J>_}TvtULDWNnzfs=tmt=1=z!TG_1XY<_ri69w&k^LaUFKLDcWOmo3BBAz5OdX zib?*5F3=js37aNp<822HIQ38xR_<&}V*>a5S<6adAzW;Kgfwc-+E4c#cbr|mUIGT@ zd(`9To>fp@cC~2=r>_jR&k_b>6WyW(JJF)f**tyr?-HR9KJ#&UqUsZ&ZDcsBBamH$ b+)L8Yyp)z@E2ajf>qsDZb-8L8^U(hT_>9o& literal 0 HcmV?d00001 diff --git a/data/browse-view-refresh.png b/data/browse-view-refresh.png new file mode 100644 index 0000000000000000000000000000000000000000..0958cc119ee618b119392c9cb7039d15b495b3d3 GIT binary patch literal 481 zcmV<70UrK|P)<h;3K|Lk000e1NJLTq000pH000sQ1^@s6z4<j%00004b3#c}2nYxW zd<bNS00009a7bBm000j*000j*0ZdL*wEzGB8FWQhbW?9;ba!ELWdL_~cP?peYja~^ zaAhuUa%Y?FJQ@H10bWT&K~y-6m6JV713?gm-&`Xa!OE0J8X=99Bv@Dp{)BXakV-qN z2#R1~XQ#acZS8IR0~!$#l8AbsB4{ImjffZ?i_FSqjrkZDX6NRehq?Vo0SatFQdv?# z(ww9jNq3SiB-JGyNc!mN0DNBn68c+Wy5Bw@PzBnaxCI;nn-*JMt!?@)NCEgZ!7ES< zCUjo3I;Nj@kTIZXg*PDn2jDz59l#ARE@0UkvorwUyyW$)2&h@o7!u&TVSTkoQr-^g zJUr_G=JfeUQqGd*h!CgGMUoyZ$&Lt#Ej~q(uH0A_%aV?VfEFw^+$D3i=xx|hpG{rz zde#M`foJ>B1a@ux1!Q^vGQhQIUVuqgsCeXiZ(R)lvvj|$3c=gi=C3_iEeo6kwH+Yk zL(;$+aM=Ttv--Q`pTMd=p<C?tXa=YQQ>NJhHh}5i7u6Z3bF6!kZY7;cI<uGzb76h} XJ)PM3q=+B&00000NkvXXu0mjfaW%iu literal 0 HcmV?d00001 diff --git a/data/error_page.tmpl b/data/error_page.tmpl new file mode 100644 index 0000000..f421ad5 --- /dev/null +++ b/data/error_page.tmpl @@ -0,0 +1,53 @@ +<!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; + width: 150px; + height: 35px; + background-color: #a3a1a3; + border: 0; + font-size: 12pt; + font-weight: bold; + -webkit-border-radius: 20px; + background-image: url("browse-view-refresh.png"); + background-position: 16px; + background-repeat: no-repeat; + text-align: right; + padding-right: 16px; + } + + #container { + /* we need double percent sign here because + of Python sustitution */ + margin: 15%%; + } + </style> + </head> + + <body> + <div id="container"> + <img id="browse-logo" src="activity-web.png"></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 _______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel