Refactorings.
This commit is contained in:
parent
5b4f06aa7e
commit
d6571bf60c
@ -4,7 +4,8 @@
|
|||||||
<url platform="x86" os="OS2">https://bitbucket.org/skunkos/rssguard/downloads/rssguard-1.9.9.6-os2.7z</url>
|
<url platform="x86" os="OS2">https://bitbucket.org/skunkos/rssguard/downloads/rssguard-1.9.9.6-os2.7z</url>
|
||||||
<url platform="x86" os="Windows">https://bitbucket.org/skunkos/rssguard/downloads/rssguard-1.9.9.6-win32.7z</url>
|
<url platform="x86" os="Windows">https://bitbucket.org/skunkos/rssguard/downloads/rssguard-1.9.9.6-win32.7z</url>
|
||||||
<changes>
|
<changes>
|
||||||
<![CDATA[Fixed:
|
<![CDATA[<body>
|
||||||
|
Fixed:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Restarting of application on all platforms fixed.</li>
|
<li>Restarting of application on all platforms fixed.</li>
|
||||||
<li>Feed type saved correctly to database when feed is added.</li>
|
<li>Feed type saved correctly to database when feed is added.</li>
|
||||||
@ -21,7 +22,8 @@ Changed:
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Localization handling improved.</li>
|
<li>Localization handling improved.</li>
|
||||||
<li>Default feed list improved.</li>
|
<li>Default feed list improved.</li>
|
||||||
</ul>]]>
|
</ul>
|
||||||
|
</body>]]>
|
||||||
</changes>
|
</changes>
|
||||||
</release>
|
</release>
|
||||||
</releases>
|
</releases>
|
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "core/parsingfactory.h"
|
#include "core/parsingfactory.h"
|
||||||
|
|
||||||
|
#include "core/webfactory.h"
|
||||||
#include "core/textfactory.h"
|
#include "core/textfactory.h"
|
||||||
|
|
||||||
#include <QDomDocument>
|
#include <QDomDocument>
|
||||||
@ -56,13 +57,13 @@ QList<Message> ParsingFactory::parseAsATOM10(const QString &data) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Title is empty but description is not.
|
// Title is empty but description is not.
|
||||||
new_message.m_title = TextFactory::stripTags(elem_summary.simplified());
|
new_message.m_title = WebFactory::instance()->stripTags(elem_summary.simplified());
|
||||||
new_message.m_contents = elem_summary;
|
new_message.m_contents = elem_summary;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Title is not empty, description does not matter.
|
// Title is not empty, description does not matter.
|
||||||
new_message.m_title = TextFactory::stripTags(elem_title);
|
new_message.m_title = WebFactory::instance()->stripTags(elem_title);
|
||||||
new_message.m_contents = elem_summary;
|
new_message.m_contents = elem_summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,7 +79,7 @@ QList<Message> ParsingFactory::parseAsATOM10(const QString &data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Deal with authors.
|
// Deal with authors.
|
||||||
new_message.m_author = TextFactory::escapeHtml(message_item.namedItem("author").namedItem("name").toElement().text());
|
new_message.m_author = WebFactory::instance()->escapeHtml(message_item.namedItem("author").namedItem("name").toElement().text());
|
||||||
|
|
||||||
// Deal with creation date.
|
// Deal with creation date.
|
||||||
new_message.m_created = TextFactory::parseDateTime(message_item.namedItem("updated").toElement().text());
|
new_message.m_created = TextFactory::parseDateTime(message_item.namedItem("updated").toElement().text());
|
||||||
@ -134,13 +135,13 @@ QList<Message> ParsingFactory::parseAsRDF(const QString &data) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Title is empty but description is not.
|
// Title is empty but description is not.
|
||||||
new_message.m_title = TextFactory::escapeHtml(TextFactory::stripTags(elem_description.simplified()));
|
new_message.m_title = WebFactory::instance()->escapeHtml(WebFactory::instance()->stripTags(elem_description.simplified()));
|
||||||
new_message.m_contents = elem_description;
|
new_message.m_contents = elem_description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Title is really not empty, description does not matter.
|
// Title is really not empty, description does not matter.
|
||||||
new_message.m_title = TextFactory::escapeHtml(TextFactory::stripTags(elem_title));
|
new_message.m_title = WebFactory::instance()->escapeHtml(WebFactory::instance()->stripTags(elem_title));
|
||||||
new_message.m_contents = elem_description;
|
new_message.m_contents = elem_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,13 +211,13 @@ QList<Message> ParsingFactory::parseAsRSS20(const QString &data) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Title is empty but description is not.
|
// Title is empty but description is not.
|
||||||
new_message.m_title = TextFactory::stripTags(elem_description.simplified());
|
new_message.m_title = WebFactory::instance()->stripTags(elem_description.simplified());
|
||||||
new_message.m_contents = elem_description;
|
new_message.m_contents = elem_description;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Title is really not empty, description does not matter.
|
// Title is really not empty, description does not matter.
|
||||||
new_message.m_title = TextFactory::stripTags(elem_title);
|
new_message.m_title = WebFactory::instance()->stripTags(elem_title);
|
||||||
new_message.m_contents = elem_description;
|
new_message.m_contents = elem_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QLocale>
|
#include <QLocale>
|
||||||
#include <QRegExp>
|
|
||||||
#include <QMap>
|
|
||||||
|
|
||||||
|
|
||||||
TextFactory::TextFactory() {
|
TextFactory::TextFactory() {
|
||||||
@ -100,62 +98,3 @@ QString TextFactory::shorten(const QString &input, int text_length_limit) {
|
|||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString TextFactory::stripTags(QString text) {
|
|
||||||
return text.remove(QRegExp("<[^>]*>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString TextFactory::escapeHtml(const QString &html) {
|
|
||||||
static QMap<QString, QString> escape_sequences = generetaEscapes();
|
|
||||||
|
|
||||||
QList<QString> keys = escape_sequences.uniqueKeys();
|
|
||||||
QString output = html;
|
|
||||||
|
|
||||||
foreach (const QString &key, keys) {
|
|
||||||
output.replace(key, escape_sequences.value(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString TextFactory::deEscapeHtrml(const QString &text) {
|
|
||||||
static QMap<QString, QString> deescape_sequences = generateDeescapes();
|
|
||||||
|
|
||||||
QList<QString> keys = deescape_sequences.uniqueKeys();
|
|
||||||
QString output = text;
|
|
||||||
|
|
||||||
foreach (const QString &key, keys) {
|
|
||||||
output.replace(key, deescape_sequences.value(key));
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, QString> TextFactory::generetaEscapes() {
|
|
||||||
QMap<QString, QString> sequences;
|
|
||||||
|
|
||||||
sequences["<"] = '<';
|
|
||||||
sequences[">"] = '>';
|
|
||||||
sequences["&"] = '&';
|
|
||||||
sequences["""] = '\"';
|
|
||||||
sequences[" "] = ' ';
|
|
||||||
sequences["±"] = "±";
|
|
||||||
sequences["×"] = "×";
|
|
||||||
sequences["'"] = '\'';
|
|
||||||
|
|
||||||
return sequences;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, QString> TextFactory::generateDeescapes() {
|
|
||||||
QMap<QString, QString> sequences;
|
|
||||||
|
|
||||||
sequences["<"] = "<";
|
|
||||||
sequences[">"] = ">";
|
|
||||||
sequences["&"] = "&";
|
|
||||||
sequences["\""] = """;
|
|
||||||
sequences["±"] = "±";
|
|
||||||
sequences["×"] = "×";
|
|
||||||
sequences["\'"] = "'";
|
|
||||||
|
|
||||||
return sequences;
|
|
||||||
}
|
|
||||||
|
@ -43,17 +43,6 @@ class TextFactory {
|
|||||||
// NOTE: This apparently returns date/time in localtime.
|
// NOTE: This apparently returns date/time in localtime.
|
||||||
static QDateTime parseDateTime(qint64 milis_from_epoch);
|
static QDateTime parseDateTime(qint64 milis_from_epoch);
|
||||||
|
|
||||||
// Strips "<....>" (HTML, XML) tags from given text.
|
|
||||||
static QString stripTags(QString text);
|
|
||||||
|
|
||||||
// HTML entity escaping.
|
|
||||||
// TODO: Optimize these methods.
|
|
||||||
static QString escapeHtml(const QString &html);
|
|
||||||
static QString deEscapeHtrml(const QString &text);
|
|
||||||
|
|
||||||
static QMap<QString, QString> generetaEscapes();
|
|
||||||
static QMap<QString, QString> generateDeescapes();
|
|
||||||
|
|
||||||
// Shortens input string according to given length limit.
|
// Shortens input string according to given length limit.
|
||||||
static QString shorten(const QString &input, int text_length_limit = TEXT_TITLE_LIMIT);
|
static QString shorten(const QString &input, int text_length_limit = TEXT_TITLE_LIMIT);
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "core/webfactory.h"
|
#include "core/webfactory.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QRegExp>
|
||||||
|
|
||||||
|
|
||||||
QPointer<WebFactory> WebFactory::s_instance;
|
QPointer<WebFactory> WebFactory::s_instance;
|
||||||
@ -19,3 +20,62 @@ WebFactory *WebFactory::instance() {
|
|||||||
|
|
||||||
return s_instance;
|
return s_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString WebFactory::stripTags(QString text) {
|
||||||
|
return text.remove(QRegExp("<[^>]*>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WebFactory::escapeHtml(const QString &html) {
|
||||||
|
static QMap<QString, QString> escape_sequences = generetaEscapes();
|
||||||
|
|
||||||
|
QList<QString> keys = escape_sequences.uniqueKeys();
|
||||||
|
QString output = html;
|
||||||
|
|
||||||
|
foreach (const QString &key, keys) {
|
||||||
|
output.replace(key, escape_sequences.value(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WebFactory::deEscapeHtml(const QString &text) {
|
||||||
|
static QMap<QString, QString> deescape_sequences = generateDeescapes();
|
||||||
|
|
||||||
|
QList<QString> keys = deescape_sequences.uniqueKeys();
|
||||||
|
QString output = text;
|
||||||
|
|
||||||
|
foreach (const QString &key, keys) {
|
||||||
|
output.replace(key, deescape_sequences.value(key));
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QString> WebFactory::generetaEscapes() {
|
||||||
|
QMap<QString, QString> sequences;
|
||||||
|
|
||||||
|
sequences["<"] = '<';
|
||||||
|
sequences[">"] = '>';
|
||||||
|
sequences["&"] = '&';
|
||||||
|
sequences["""] = '\"';
|
||||||
|
sequences[" "] = ' ';
|
||||||
|
sequences["±"] = "±";
|
||||||
|
sequences["×"] = "×";
|
||||||
|
sequences["'"] = '\'';
|
||||||
|
|
||||||
|
return sequences;
|
||||||
|
}
|
||||||
|
|
||||||
|
QMap<QString, QString> WebFactory::generateDeescapes() {
|
||||||
|
QMap<QString, QString> sequences;
|
||||||
|
|
||||||
|
sequences["<"] = "<";
|
||||||
|
sequences[">"] = ">";
|
||||||
|
sequences["&"] = "&";
|
||||||
|
sequences["\""] = """;
|
||||||
|
sequences["±"] = "±";
|
||||||
|
sequences["×"] = "×";
|
||||||
|
sequences["\'"] = "'";
|
||||||
|
|
||||||
|
return sequences;
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
|
#include <QMap>
|
||||||
|
|
||||||
|
|
||||||
class WebFactory : public QObject {
|
class WebFactory : public QObject {
|
||||||
@ -12,6 +13,14 @@ class WebFactory : public QObject {
|
|||||||
// Destructor.
|
// Destructor.
|
||||||
virtual ~WebFactory();
|
virtual ~WebFactory();
|
||||||
|
|
||||||
|
// Strips "<....>" (HTML, XML) tags from given text.
|
||||||
|
QString stripTags(QString text);
|
||||||
|
|
||||||
|
// HTML entity escaping.
|
||||||
|
// TODO: Optimize these methods.
|
||||||
|
QString escapeHtml(const QString &html);
|
||||||
|
QString deEscapeHtml(const QString &text);
|
||||||
|
|
||||||
// Singleton getter.
|
// Singleton getter.
|
||||||
static WebFactory *instance();
|
static WebFactory *instance();
|
||||||
|
|
||||||
@ -24,6 +33,10 @@ class WebFactory : public QObject {
|
|||||||
// Constructor.
|
// Constructor.
|
||||||
explicit WebFactory(QObject *parent = 0);
|
explicit WebFactory(QObject *parent = 0);
|
||||||
|
|
||||||
|
// Escape sequences generators.
|
||||||
|
QMap<QString, QString> generetaEscapes();
|
||||||
|
QMap<QString, QString> generateDeescapes();
|
||||||
|
|
||||||
// Singleton.
|
// Singleton.
|
||||||
static QPointer<WebFactory> s_instance;
|
static QPointer<WebFactory> s_instance;
|
||||||
};
|
};
|
||||||
|
@ -52,8 +52,9 @@ FormWelcome::FormWelcome(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormWe
|
|||||||
this, SLOT(openLink(QString)));
|
this, SLOT(openLink(QString)));
|
||||||
|
|
||||||
// Setup the text.
|
// Setup the text.
|
||||||
|
m_ui->m_lblCaption->setText(tr("Welcome to %1").arg(APP_NAME));
|
||||||
m_ui->m_lblInfo->setText(
|
m_ui->m_lblInfo->setText(
|
||||||
tr("<p>RSS Guard is a (very) easy-to-use feed reader. "
|
tr("<p>%3 is a (very) easy-to-use feed reader. "
|
||||||
"It supports all major feed formats, including RSS, "
|
"It supports all major feed formats, including RSS, "
|
||||||
"ATOM and RDF.</p>"
|
"ATOM and RDF.</p>"
|
||||||
"<p>Make sure you explore all available features. "
|
"<p>Make sure you explore all available features. "
|
||||||
@ -62,11 +63,12 @@ FormWelcome::FormWelcome(QWidget *parent) : QDialog(parent), m_ui(new Ui::FormWe
|
|||||||
"<a href=\"%1\"><span "
|
"<a href=\"%1\"><span "
|
||||||
"style=\"text-decoration: underline; color:#0000ff;\">issue "
|
"style=\"text-decoration: underline; color:#0000ff;\">issue "
|
||||||
"report</span></a>.</p>"
|
"report</span></a>.</p>"
|
||||||
"<p>RSS Guard can be translated to any language. "
|
"<p>%3 can be translated to any language. "
|
||||||
"Contact its <a href=\"mailto:%2\"><span "
|
"Contact its <a href=\"mailto:%2\"><span "
|
||||||
"style=\"text-decoration: underline; color:#0000ff;\">author</span></a> "
|
"style=\"text-decoration: underline; color:#0000ff;\">author</span></a> "
|
||||||
"in case of your interest.</p><p><br/></p>").arg(APP_URL_ISSUES,
|
"in case of your interest.</p><p><br/></p>").arg(APP_URL_ISSUES,
|
||||||
APP_EMAIL));
|
APP_EMAIL,
|
||||||
|
APP_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FormWelcome::openLink(const QString &link) {
|
void FormWelcome::openLink(const QString &link) {
|
||||||
|
@ -70,7 +70,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Welcome to RSS Guard</string>
|
<string notr="true"/>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user