Skip to content

Commit ee3ed21

Browse files
committed
save
1 parent 4c78196 commit ee3ed21

3 files changed

Lines changed: 44 additions & 11 deletions

File tree

resources/text/CHANGELOG

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
5.1.2
22
-----
3-
Released on: 2026-05-XX
3+
Released on: 2026-05-11
44

55
Added:
66
* Show URL of loaded website in status bar. (#2097)
77
* Article extractor now can be called with existing article `HTML` and thus can run Readability algorithm directly on the existing article data instead of downloading full source web page. (#2252)
88
* Auto-fetching articles can now be limited to times when a network connection is active. (#2211)
99
* Feed retrieval can now be skipped while Windows Game Mode is active. (#1230)
10+
* Text-based article viewer can now load remote article images when external resources are enabled, cache them, and show the same article without images when external resources are disabled. (08a2127d9, 561f5b432, 7a179c47c)
11+
* Text-based article viewer can now display directly opened image files. (4c7819676)
12+
* Text-based article viewer can now show directly opened JSON files in readable form and render directly opened Markdown files.
13+
* Updated Japanese translation. (#2262)
1014

1115
Fixed:
1216
* Initial state of "web attributes" is properly set in WebEngine builds. (#2227)
1317
* Fix some cases where link does not load in internal browser when clicked.
1418
* Article filter action "Filter articles like this" now uses the article that was actually right-clicked after testing a filter. (#2139)
19+
* Image attachments in articles now respect the configured height limit in both text-based and WebEngine-based viewers. (#2254, 8f4abac60, bc247ad0b)
20+
* Image context menu actions in the text-based viewer can again detect the image under the cursor, copy its URL, copy the image and save it. (c3902db73)
21+
* Relative links opened from the internal browser are now resolved against the currently loaded page before opening. (4c7819676)
22+
* Directly opened non-HTML text content is now displayed as text instead of being treated as HTML. (4c7819676)
1523

1624
5.1.1
1725
-----

resources/text/licenses.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@
22
{
33
"title": "GNU GPL v3.0",
44
"file": "COPYING_GNU_GPL",
5-
"components": "RSS Guard, mimesis, Kristall/geminiclient, QLiteHtmlWidget"
6-
},
7-
{
8-
"title": "BSD-3-Clause license",
9-
"file": "COPYING_BSD",
10-
"components": "litehtml"
5+
"components": "RSS Guard, mimesis, Kristall/geminiclient"
116
},
127
{
138
"title": "Apache license",

src/librssguard/gui/webviewers/qtextbrowser/textbrowserviewer.cpp

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <QFile>
2121
#include <QFileIconProvider>
2222
#include <QFileInfo>
23+
#include <QJsonDocument>
24+
#include <QJsonParseError>
2325
#include <QScrollBar>
2426
#include <QTextImageFormat>
2527
#include <QTimer>
@@ -474,7 +476,11 @@ void TextBrowserViewer::loadMessage(const Message& message, RootItem* root) {
474476

475477
void TextBrowserViewer::displayDownloadedPage(const QUrl& url, const QByteArray& data, const NetworkResult& res) {
476478
if (res.m_networkError == QNetworkReply::NetworkError::NoError) {
477-
if (res.m_contentType.startsWith(QSL("image"))) {
479+
const QString content_type = res.m_contentType.toLower();
480+
const QString path = url.path().toLower();
481+
482+
// Images handling - either open externally or open as "data:base64".
483+
if (content_type.startsWith(QSL("image"))) {
478484
if (!loadExternalResources()) {
479485
emit openUrlInNewTab(true, url);
480486
}
@@ -486,7 +492,8 @@ void TextBrowserViewer::displayDownloadedPage(const QUrl& url, const QByteArray&
486492
loadStaticHtml(html, url);
487493
}
488494
}
489-
else if (res.m_contentType.contains(QSL("xml"))) {
495+
// XML handling - pretty print.
496+
else if (content_type.contains(QSL("xml"))) {
490497
QDomDocument dom;
491498

492499
if (dom.setContent(data)) {
@@ -496,7 +503,29 @@ void TextBrowserViewer::displayDownloadedPage(const QUrl& url, const QByteArray&
496503
loadStaticHtml(QString::fromUtf8(data).toHtmlEscaped(), url);
497504
}
498505
}
499-
else if (res.m_contentType.contains(QSL("html"))) {
506+
// JSON handling - pretty print.
507+
else if (content_type.contains(QSL("json")) || path.endsWith(QSL(".json"))) {
508+
QJsonParseError error;
509+
const QJsonDocument doc = QJsonDocument::fromJson(data, &error);
510+
511+
if (error.error == QJsonParseError::NoError) {
512+
loadStaticHtml(Qt::convertFromPlainText(QString::fromUtf8(doc.toJson(QJsonDocument::Indented))), url);
513+
}
514+
else {
515+
loadStaticHtml(Qt::convertFromPlainText(QString::fromUtf8(data)), url);
516+
}
517+
}
518+
// Markdown handling - pretty print.
519+
else if (content_type.contains(QSL("markdown")) || content_type.contains(QSL("x-markdown")) ||
520+
path.endsWith(QSL(".md")) || path.endsWith(QSL(".markdown")) || path.endsWith(QSL(".mdown")) ||
521+
path.endsWith(QSL(".mkd"))) {
522+
QTextDocument markdown_doc;
523+
524+
markdown_doc.setMarkdown(QString::fromUtf8(data));
525+
loadStaticHtml(markdown_doc.toHtml(), url);
526+
}
527+
// HTML handling - display.
528+
else if (content_type.contains(QSL("html"))) {
500529
bool no_images = loadStaticHtml(QString::fromUtf8(data), url);
501530

502531
if (url.hasFragment()) {
@@ -507,6 +536,7 @@ void TextBrowserViewer::displayDownloadedPage(const QUrl& url, const QByteArray&
507536
return;
508537
}
509538
}
539+
// Fallback - show as plain text.
510540
else {
511541
loadStaticHtml(Qt::convertFromPlainText(QString::fromUtf8(data)), url);
512542
}
@@ -764,7 +794,7 @@ QVariant TextBrowserDocument::loadResource(int type, const QUrl& name) {
764794
return QTextDocument::loadResource(type, name);
765795
}
766796

767-
if (QTextDocument::ResourceType(type) != QTextDocument::ResourceType::ImageResource) {
797+
if (QTextDocument::ResourceType(type) != QTextDocument::ImageResource) {
768798
return QTextDocument::loadResource(type, name);
769799
}
770800

0 commit comments

Comments
 (0)