diff --git a/resources/rssguard.qrc b/resources/rssguard.qrc index cc63d84df..664e2cb00 100644 --- a/resources/rssguard.qrc +++ b/resources/rssguard.qrc @@ -9,6 +9,8 @@ text/COPYING_GNU_LGPL_21 text/COPYING_QT + scripts/web_ui/rssguard.html + sounds/boing.wav sounds/rooster.wav sounds/sheep.wav diff --git a/resources/scripts/web_ui/rssguard.html b/resources/scripts/web_ui/rssguard.html new file mode 100644 index 000000000..9cbb14ead --- /dev/null +++ b/resources/scripts/web_ui/rssguard.html @@ -0,0 +1,216 @@ + + + + + + +
+
+
+
+
+
+
+ +
+
+
+ +
+
+ +
+ +
+ +
+ + + diff --git a/src/librssguard/database/databasequeries.cpp b/src/librssguard/database/databasequeries.cpp index 752a9aa07..6430663fa 100644 --- a/src/librssguard/database/databasequeries.cpp +++ b/src/librssguard/database/databasequeries.cpp @@ -1202,7 +1202,7 @@ QList DatabaseQueries::getArticlesSlice(const QSqlDatabase& db, q.bindValue(QSL(":account_id"), account_id); q.bindValue(QSL(":row_limit"), row_limit); q.bindValue(QSL(":row_offset"), row_offset); - q.bindValue(QSL(":feed"), QSL("feed")); + q.bindValue(QSL(":feed"), feed_custom_id); if (unread_only) { q.bindValue(QSL(":is_read"), 0); diff --git a/src/librssguard/definitions/definitions.h b/src/librssguard/definitions/definitions.h index aae5aa890..324960924 100644 --- a/src/librssguard/definitions/definitions.h +++ b/src/librssguard/definitions/definitions.h @@ -356,6 +356,9 @@ #define APP_SQL_PATH QSL(":/sql") #define APP_INFO_PATH QSL(":/text") +#define WEB_UI_FOLDER QSL(":/scripts/web_ui") +#define WEB_UI_FILE QSL("rssguard.html") + #define APP_ICON_PATH QSL(":/graphics/rssguard.png") #define APP_ICON_PLAIN_PATH QSL(":/graphics/rssguard_plain.png") diff --git a/src/librssguard/network-web/apiserver.cpp b/src/librssguard/network-web/apiserver.cpp index 8059e038e..34072fb24 100644 --- a/src/librssguard/network-web/apiserver.cpp +++ b/src/librssguard/network-web/apiserver.cpp @@ -19,6 +19,9 @@ void ApiServer::answerClient(QTcpSocket* socket, const HttpRequest& request) { if (request.m_method == HttpRequest::Method::Options) { reply_message = processCorsPreflight(); } + else if (request.m_url.path().contains("rssguard")) { + reply_message = processHtmlPage(); + } else { QJsonParseError json_err; QByteArray json_data; @@ -74,6 +77,31 @@ QByteArray ApiServer::processCorsPreflight() const { return answer.toLocal8Bit(); } +QByteArray ApiServer::processHtmlPage() const { + QByteArray page; + QString runtime_page_path = QCoreApplication::applicationDirPath() + QDir::separator() + WEB_UI_FILE; + + if (QFile::exists(runtime_page_path)) { + page = IOFactory::readFile(runtime_page_path); + } + else { + page = IOFactory::readFile(WEB_UI_FOLDER + QL1C('/') + WEB_UI_FILE); + } + + QString answer = QSL("HTTP/1.0 200 OK\r\n" + "Access-Control-Allow-Origin: *\r\n" + "Access-Control-Allow-Headers: *\r\n" + "Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE\r\n" + "Content-Type: text/html; charset=\"utf-8\"\r\n" + "Content-Length: %1\r\n" + "\r\n") + .arg(QString::number(page.size())); + + QByteArray data = answer.toLocal8Bit(); + + return data + page; +} + ApiResponse ApiServer::processRequest(const ApiRequest& req) const { switch (req.m_method) { case ApiRequest::Method::AppVersion: @@ -102,6 +130,11 @@ ApiResponse ApiServer::processArticlesFromFeed(const QJsonValue& req) const { int row_offset = data.value(QSL("row_offset")).toInt(); int row_limit = data.value(QSL("row_limit")).toInt(); + // NOTE: Fixup arguments. + if (feed_id == QSL("0")) { + feed_id = QString(); + } + QSqlDatabase database = qApp->database()->driver()->connection(metaObject()->className()); QList msgs = DatabaseQueries::getArticlesSlice(database, feed_id, account_id, newest_first, unread_only, row_offset, row_limit); diff --git a/src/librssguard/network-web/apiserver.h b/src/librssguard/network-web/apiserver.h index 47b13b5ca..54a1a9e32 100644 --- a/src/librssguard/network-web/apiserver.h +++ b/src/librssguard/network-web/apiserver.h @@ -55,6 +55,8 @@ class ApiServer : public HttpServer { private: QByteArray processCorsPreflight() const; + QByteArray processHtmlPage() const; + ApiResponse processRequest(const ApiRequest& req) const; ApiResponse processAppVersion() const; ApiResponse processArticlesFromFeed(const QJsonValue& req) const;