diff options
| author | Mike Skec <skec@protonmail.ch> | 2020-12-31 15:06:22 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2020-12-31 10:13:49 +0100 |
| commit | d90e64ff7063d365ee939d96018876a43dcb321a (patch) | |
| tree | a2ca17ed0be8f36b1c532c3462c010177f5b58ca /src | |
| parent | 4fa674ef6101e89a55b2006090a18f871490e31f (diff) | |
| download | kristall-d90e64ff7063d365ee939d96018876a43dcb321a.tar.gz | |
Added prettier 'unsupported media type' page.
Now written in gemtext. A plaintext version is produced instead if plaintext_only is set
Diffstat (limited to 'src')
| -rw-r--r-- | src/browsertab.cpp | 43 |
1 files changed, 34 insertions, 9 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 70478a3..ad42359 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -632,21 +632,46 @@ void BrowserTab::renderPage(const QByteArray &data, const MimeType &mime) doc_type = Media; this->ui->media_browser->setMedia(data, this->current_location, mime.type); } - else + else if (plaintext_only) { document = std::make_unique<QTextDocument>(); document->setDefaultFont(doc_style.standard_font); document->setDefaultStyleSheet(doc_style.toStyleSheet()); - document->setPlainText(QString(R"md(You accessed an unsupported media type! - -Use the *File* menu to save the file to your local disk or navigate somewhere else. I cannot display this for you. ☹ + QString plain_data = QString( + "Unsupported Media Type!\n" + "\n" + "Kristall cannot display the requested document\n" + "To view this media, use the File menu to save it to your local drive, then open the saved file in another program that can display the document for you.\n\n" + "Details:\n" + "- MIME type: %1/%2\n" + "- Size: %3\n" + ).arg(mime.type, mime.subtype, IoUtil::size_human(data.size())); + + document->setPlainText(plain_data); + } + else + { + QString page_data = QString( + "# Unsupported Media Type!\n" + "\n" + "Kristall cannot display the requested document.\n" + "\n" + "> To view this media, use the File menu to save it to your local drive, then open the saved file in another program that can display the document for you.\n" + "\n" + "```\n" + "Details:\n" + "- MIME type: %1/%2\n" + "- Size: %3\n" + "```\n" + ).arg(mime.type, mime.subtype, IoUtil::size_human(data.size())); -Info: -MIME Type: %1 -File Size: %2 -)md") - .arg(mime.type, data.size())); + document = GeminiRenderer::render( + page_data.toUtf8(), + this->current_location, + doc_style, + this->outline, + &this->page_title); } assert((document != nullptr) == (doc_type == Text)); |
