diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/data/rekonqinfo.html | 88 | ||||
-rw-r--r-- | src/protocolhandler.cpp | 16 | ||||
-rw-r--r-- | src/webpage.cpp | 17 |
3 files changed, 82 insertions, 39 deletions
diff --git a/src/data/rekonqinfo.html b/src/data/rekonqinfo.html index e347f53a..c3e6a8fa 100644 --- a/src/data/rekonqinfo.html +++ b/src/data/rekonqinfo.html @@ -1,55 +1,81 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> +<!DOCTYPE html> +<html> + +<!-- NOTE + +This page is the "skeleton" of rekonq info pages (eg: host not found page). +To let it work you need to set also some variables +about (prepend a $ to actually use them): + +DEFAULT_PATH = rekonq default installation files path +PAGE_TITLE = page title +MAIN_CONTENT = page main content +... + +--> + <head> -<title>%1</title> +<title>$PAGE_TITLE</title> <style type="text/css"> html{ -margin:0; -padding:0; + margin:0; + padding:0; +} + +@font-face { + font-family: 'Nunito'; + src: url($DEFAULT_PATH/fonts/Nunito-Regular.ttf); + font-weight: normal; + font-style: normal; } body{ -background: #AAA; -margin:0; -padding:0; -font-family: sans-serif; -font-size: 100%; + background: #AAA; + margin:0; + padding:0; + font-family: 'Nunito', sans-serif; + font-size: 0.9em; } #block { -background: #fff; -border: 2px solid #d9d9d9; -padding: 40px; -width: 800px; -margin: 60px auto; -color: #444; --webkit-border-radius: 15px + background: #fff; + border: 2px solid #d9d9d9; + padding: 40px; + width: 900px; + margin: 50px auto; + color: #444; + -webkit-border-radius: 15px } h1{ -font-size: 130%; -font-weight: bold; -border-bottom: 1px solid lightgray; -margin-left: 48px; + font-size: 130%; + font-weight: bold; + border-bottom: 1px solid lightgray; + margin-left: 48px; } h2{ -font-size: 100%; -font-weight: normal; -border-bottom: 1px solid lightgray; -margin-left: 48px; + font-size: 100%; + font-weight: normal; + border-bottom: 1px solid lightgray; + margin-left: 48px; } ul { -padding: 12px 48px; -margin: 0; + padding: 12px 48px; + margin: 0; +} + +a { + color: #3F7AB7; + text-decoration: none; + -webkit-transition: color 0.5s ease; } -#reloadButton { -margin-left: 48px; -margin-bottom: 12px; +a:hover { + color: black; } </style> @@ -57,7 +83,7 @@ margin-bottom: 12px; </head> <body> -<div id="block">%3</div> +<div id="block">$MAIN_CONTENT</div> </body> </html> diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp index d69171ac..292ca7d9 100644 --- a/src/protocolhandler.cpp +++ b/src/protocolhandler.cpp @@ -294,7 +294,14 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) return QString("rekonq error, sorry :("); } + // 1. default data path + QString dataPath = QL1S("file://") + infoFilePath; + dataPath.remove(QL1S("/htmls/rekonqinfo.html")); + + // 2. title QString title = _url.prettyUrl(); + + // 3. main content QString msg = i18nc("%1=an URL", "<h1>Index of %1</h1>", _url.prettyUrl()); @@ -338,11 +345,12 @@ QString ProtocolHandler::dirHandling(const KFileItemList &list) } msg += "</table>"; + // done. Replace variables and show it + QString html = QL1S(file.readAll()); - QString html = QString(QL1S(file.readAll())) - .arg(title) - .arg(msg) - ; + html.replace(QL1S("$DEFAULT_PATH"), dataPath); + html.replace(QL1S("$PAGE_TITLE"), title); + html.replace(QL1S("$MAIN_CONTENT"), msg); return html; } diff --git a/src/webpage.cpp b/src/webpage.cpp index ce1151da..6cd52bd7 100644 --- a/src/webpage.cpp +++ b/src/webpage.cpp @@ -574,6 +574,11 @@ QString WebPage::errorPage(QNetworkReply *reply) return QString("Couldn't open the rekonqinfo.html file"); } + // 1. data path + QString dataPath = QL1S("file://") + notfoundFilePath; + dataPath.remove(QL1S("/htmls/rekonqinfo.html")); + + // 2. title QString title = i18n("There was a problem while loading the page"); // NOTE: @@ -583,6 +588,7 @@ QString WebPage::errorPage(QNetworkReply *reply) QString iconPath = QString("file://") + KIconLoader::global()->iconPath("dialog-warning" , KIconLoader::Small); iconPath.replace(QL1S("16"), QL1S("128")); + // 3. main content QString msg; msg += QL1S("<table>"); msg += QL1S("<tr><td>"); @@ -610,10 +616,13 @@ QString WebPage::errorPage(QNetworkReply *reply) msg += i18n("Search with %1", defaultEngine->name()) + QL1S("</a>"); } - QString html = QString(QL1S(file.readAll())) - .arg(title) - .arg(msg) - ; + // done. Replace variables and show it + QString html = QL1S(file.readAll()); + + html.replace(QL1S("$DEFAULT_PATH"), dataPath); + html.replace(QL1S("$PAGE_TITLE"), title); + html.replace(QL1S("$MAIN_CONTENT"), msg); + return html; } |