Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions core/cog-webkit-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@
#include <stdlib.h>
#include <string.h>

static const char error_message_template[] =
"<!DOCTYPE html><html><head><title>%s</title><style type='text/css'>\n"
"html { background: #fffafa; color: #0f0f0f; }\n"
"h3 { font-weight: 600; color: #fffafa; background: #555;\n"
" border-radius: 3px; padding: 0.15em 0.5em; margin-bottom: 0.25em }\n"
"p { margin-left: 0.5em; margin-right: 0.5em }\n"
"p.uri { size: 70%%; font-family: monospace; color: #888;\n"
" margin-left: 0.75em; margin-top: 0 }\n"
".try-again { text-align: center; font-size: 1em; \n"
" height: 100%; margin: 1em; }\n"
"</style></head><body>\n"
" <h3>%s</h3>\n"
" <p class='uri'>%s</p>\n"
" <p>%s</p>\n"
"<button onclick=\"window.location.href = '%s'\" class=\"try-again\">Try again</button>"
"</body></html>";
static const char error_message_template[] = "<!DOCTYPE html><html><head><title>%s</title><style type='text/css'>\n"
"html { background: #fffafa; color: #0f0f0f; }\n"
"h3 { font-weight: 600; color: #fffafa; background: #555;\n"
" border-radius: 3px; padding: 0.15em 0.5em; margin-bottom: 0.25em }\n"
"p { margin-left: 0.5em; margin-right: 0.5em }\n"
"p.uri { size: 70%%; font-family: monospace; color: #888;\n"
" margin-left: 0.75em; margin-top: 0 }\n"
".try-again { text-align: center; font-size: 1em; \n"
" height: 100%; margin: 1em; }\n"
"</style>\n"
"<script>\nfunction retry() { window.location.href = '%s' }\n"
"setTimeout(retry, 5000);\n</script></head><body>\n"
" <h3>%s</h3>\n"
" <p class='uri'>%s</p>\n"
" <p>%s</p>\n"
"<button onclick=\"retry()\" class=\"try-again\">Try again</button>"
"</body></html>";

gboolean
load_error_page (WebKitWebView *web_view,
Expand All @@ -34,7 +35,7 @@ load_error_page (WebKitWebView *web_view,
{
g_warning ("<%s> %s: %s", failing_uri, title, message);

g_autofree char *html = g_strdup_printf(error_message_template, title, title, failing_uri, message, failing_uri);
g_autofree char *html = g_strdup_printf(error_message_template, title, failing_uri, title, failing_uri, message);
webkit_web_view_load_alternate_html (web_view,
html,
failing_uri,
Expand Down