mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Added new server controller for providing the content of a reading list.
This commit is contained in:
parent
ac03d61f7d
commit
d08740e32d
@ -0,0 +1,35 @@
|
||||
#include "readinglistcontentcontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
ReadingListContentController::ReadingListContentController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReadingListContentController::service(HttpRequest &request, HttpResponse &response)
|
||||
{
|
||||
response.setHeader("Content-Type", "text/plain; charset=utf-8");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(2).toInt();
|
||||
qulonglong readingListId = pathElements.at(4).toULongLong();
|
||||
|
||||
serviceContent(libraryId, readingListId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void ReadingListContentController::serviceContent(const int &library, const qulonglong &readingListId, HttpResponse &response)
|
||||
{
|
||||
QList<ComicDB> comics = DBHelper::getReadingListFullContent(library, readingListId);
|
||||
|
||||
for(const ComicDB &comic : comics)
|
||||
{
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef READINGLISTCONTENTCONTROLLER_H
|
||||
#define READINGLISTCONTENTCONTROLLER_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ReadingListContentController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ReadingListContentController)
|
||||
public:
|
||||
ReadingListContentController();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, const qulonglong &readingListId, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // READINGLISTCONTENTCONTROLLER_H
|
@ -26,7 +26,8 @@ HEADERS += \
|
||||
$$PWD/yacreader_server_data_helper.h \
|
||||
$$PWD/controllers/favoritescontroller.h \
|
||||
$$PWD/controllers/readingcomicscontroller.h \
|
||||
$$PWD/controllers/readinglistscontroller.h
|
||||
$$PWD/controllers/readinglistscontroller.h \
|
||||
$$PWD/controllers/readinglistcontentcontroller.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/static.cpp \
|
||||
@ -53,7 +54,8 @@ SOURCES += \
|
||||
$$PWD/yacreader_server_data_helper.cpp \
|
||||
$$PWD/controllers/favoritescontroller.cpp \
|
||||
$$PWD/controllers/readingcomicscontroller.cpp \
|
||||
$$PWD/controllers/readinglistscontroller.cpp
|
||||
$$PWD/controllers/readinglistscontroller.cpp \
|
||||
$$PWD/controllers/readinglistcontentcontroller.cpp
|
||||
|
||||
include(lib/logging/logging.pri)
|
||||
include(lib/httpserver/httpserver.pri)
|
||||
|
Loading…
Reference in New Issue
Block a user