mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-01 02:48:05 +01:00
rougly working script feed generating
This commit is contained in:
parent
2c5b014151
commit
301c87c40c
@ -61,4 +61,6 @@ Also, working directory of process executing the script is set to RSS Guard's us
|
||||
|
||||
After your source feed data are downloaded either via URL or custom script, you can optionally post-process the data with one more custom script, which will take raw source data as input and must produce processed feed data to **standard output** while printing all error messages to **error output**.
|
||||
|
||||
Formatting of post-process script execution line is the same as above.
|
||||
Typical post-processing filter might do things like advanced CSS formatting of feed file entries, removing some ads etc.
|
||||
|
||||
Format of post-process script execution line is the same as above.
|
@ -1 +1 @@
|
||||
Subproject commit 47f4125753452eff8800dbd6600c5a05540b15d9
|
||||
Subproject commit 9c10723bfbaf6cb85107d6ee16e0324e9e487749
|
@ -2107,7 +2107,7 @@ int DatabaseQueries::addStandardFeed(const QSqlDatabase& db, int parent_id, int
|
||||
q.bindValue(QSL(":encoding"), encoding);
|
||||
q.bindValue(QSL(":url"), url);
|
||||
q.bindValue(QSL(":source_type"), int(source_type));
|
||||
q.bindValue(QSL(":post_process"), post_process_script);
|
||||
q.bindValue(QSL(":post_process"), post_process_script.simplified());
|
||||
q.bindValue(QSL(":protected"), is_protected ? 1 : 0);
|
||||
q.bindValue(QSL(":username"), username);
|
||||
q.bindValue(QSL(":account_id"), account_id);
|
||||
@ -2171,7 +2171,7 @@ bool DatabaseQueries::editStandardFeed(const QSqlDatabase& db, int parent_id, in
|
||||
q.bindValue(QSL(":encoding"), encoding);
|
||||
q.bindValue(QSL(":url"), url);
|
||||
q.bindValue(QSL(":source_type"), int(source_type));
|
||||
q.bindValue(QSL(":post_process"), post_process_script);
|
||||
q.bindValue(QSL(":post_process"), post_process_script.simplified());
|
||||
q.bindValue(QSL(":protected"), is_protected ? 1 : 0);
|
||||
q.bindValue(QSL(":username"), username);
|
||||
|
||||
|
@ -85,6 +85,7 @@ StandardFeedDetails::StandardFeedDetails(QWidget* parent) : QWidget(parent) {
|
||||
onUrlChanged(m_ui.m_txtSource->lineEdit()->text());
|
||||
});
|
||||
connect(m_ui.m_txtSource->lineEdit(), &BaseLineEdit::textChanged, this, &StandardFeedDetails::onUrlChanged);
|
||||
connect(m_ui.m_txtPostProcessScript->lineEdit(), &BaseLineEdit::textChanged, this, &StandardFeedDetails::onPostProcessScriptChanged);
|
||||
connect(m_actionLoadIconFromFile, &QAction::triggered, this, &StandardFeedDetails::onLoadIconFromFile);
|
||||
connect(m_actionUseDefaultIcon, &QAction::triggered, this, &StandardFeedDetails::onUseDefaultIcon);
|
||||
|
||||
@ -100,9 +101,10 @@ StandardFeedDetails::StandardFeedDetails(QWidget* parent) : QWidget(parent) {
|
||||
|
||||
GuiUtilities::setLabelAsNotice(*m_ui.m_lblScriptInfo, false);
|
||||
|
||||
onTitleChanged(QString());
|
||||
onDescriptionChanged(QString());
|
||||
onUrlChanged(QString());
|
||||
onTitleChanged({});
|
||||
onDescriptionChanged({});
|
||||
onUrlChanged({});
|
||||
onPostProcessScriptChanged({});
|
||||
}
|
||||
|
||||
void StandardFeedDetails::guessIconOnly(const QString& url, const QString& username,
|
||||
@ -219,7 +221,7 @@ void StandardFeedDetails::onUrlChanged(const QString& new_url) {
|
||||
m_ui.m_txtSource->setStatus(LineEditWithStatus::StatusType::Ok, tr("The source is ok."));
|
||||
}
|
||||
else if (!new_url.simplified().isEmpty()) {
|
||||
m_ui.m_txtSource->setStatus(LineEditWithStatus::StatusType::Warning,
|
||||
m_ui.m_txtSource->setStatus(LineEditWithStatus::StatusType::Error,
|
||||
tr("The source needs to include \"#\" separator."));
|
||||
}
|
||||
else {
|
||||
@ -231,6 +233,19 @@ void StandardFeedDetails::onUrlChanged(const QString& new_url) {
|
||||
}
|
||||
}
|
||||
|
||||
void StandardFeedDetails::onPostProcessScriptChanged(const QString& new_pp) {
|
||||
if (QRegularExpression(SCRIPT_SOURCE_TYPE_REGEXP).match(new_pp).hasMatch()) {
|
||||
m_ui.m_txtPostProcessScript->setStatus(LineEditWithStatus::StatusType::Ok, tr("The source is ok."));
|
||||
}
|
||||
else if (!new_pp.simplified().isEmpty()) {
|
||||
m_ui.m_txtPostProcessScript->setStatus(LineEditWithStatus::StatusType::Error,
|
||||
tr("The source needs to include \"#\" separator."));
|
||||
}
|
||||
else {
|
||||
m_ui.m_txtPostProcessScript->setStatus(LineEditWithStatus::StatusType::Ok, tr("The source is empty."));
|
||||
}
|
||||
}
|
||||
|
||||
void StandardFeedDetails::onLoadIconFromFile() {
|
||||
QFileDialog dialog(this, tr("Select icon file for the feed"),
|
||||
qApp->homeFolder(), tr("Images (*.bmp *.jpg *.jpeg *.png *.svg *.tga)"));
|
||||
|
@ -35,6 +35,7 @@ class StandardFeedDetails : public QWidget {
|
||||
void onTitleChanged(const QString& new_title);
|
||||
void onDescriptionChanged(const QString& new_description);
|
||||
void onUrlChanged(const QString& new_url);
|
||||
void onPostProcessScriptChanged(const QString& new_pp);
|
||||
void onLoadIconFromFile();
|
||||
void onUseDefaultIcon();
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "core/feedsmodel.h"
|
||||
#include "definitions/definitions.h"
|
||||
#include "exceptions/applicationexception.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/feedsview.h"
|
||||
#include "miscellaneous/databasequeries.h"
|
||||
@ -563,15 +564,14 @@ QString StandardFeed::generateFeedFileWithScript(const QString& execution_line,
|
||||
process.setWorkingDirectory(qApp->userDataFolder());
|
||||
process.setProgram(prepared_query.first);
|
||||
|
||||
//#if defined(Q_OS_WIN) || defined(Q_CLANG_QDOC)
|
||||
// process.setNativeArguments(prepared_query.second);
|
||||
//#else
|
||||
#if defined(Q_OS_WIN)
|
||||
process.setNativeArguments(prepared_query.second);
|
||||
#else
|
||||
process.setArguments({ prepared_query.second });
|
||||
|
||||
//#endif
|
||||
#endif
|
||||
|
||||
if (!process.open() || process.error() == QProcess::ProcessError::FailedToStart) {
|
||||
return "";
|
||||
throw ApplicationException(QSL("process failed to start"));
|
||||
}
|
||||
|
||||
if (process.waitForFinished(run_timeout)) {
|
||||
@ -581,7 +581,15 @@ QString StandardFeed::generateFeedFileWithScript(const QString& execution_line,
|
||||
}
|
||||
else {
|
||||
process.kill();
|
||||
return "";
|
||||
|
||||
auto raw_error = process.readAllStandardError();
|
||||
|
||||
if (raw_error.simplified().isEmpty()) {
|
||||
throw ApplicationException(QSL("process failed to finish properly"));
|
||||
}
|
||||
else {
|
||||
throw ApplicationException(QString(raw_error));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user