mirror of
https://github.com/YACReader/yacreader
synced 2025-05-28 03:10:27 -04:00
Add new controller for requesting the "full" information for a comic.
For now it doesn't serve the full information, only the information shown in the current/next comic view in iOS. I will see if I create two separated controllers or just on sending all the information when more information is needed in another iOS view.
This commit is contained in:
parent
b41884d5db
commit
20c7ecadd4
@ -0,0 +1,46 @@
|
||||
#include "comicfullinfocontroller_v2.h"
|
||||
|
||||
|
||||
|
||||
#include <QUrl>
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
#include "folder.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
#include "qnaturalsorting.h"
|
||||
|
||||
#include <ctime>
|
||||
using namespace std;
|
||||
|
||||
|
||||
|
||||
ComicFullinfoController_v2::ComicFullinfoController_v2() {}
|
||||
|
||||
void ComicFullinfoController_v2::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
response.setHeader("Content-Type", "application/json");
|
||||
|
||||
QString path = QUrl::fromPercentEncoding(request.getPath()).toUtf8();
|
||||
QStringList pathElements = path.split('/');
|
||||
int libraryId = pathElements.at(3).toInt();
|
||||
qulonglong comicId = pathElements.at(5).toULongLong();
|
||||
|
||||
serviceContent(libraryId, comicId, response);
|
||||
|
||||
response.setStatus(200,"OK");
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void ComicFullinfoController_v2::serviceContent(const int &libraryId, const qulonglong &comicId, HttpResponse &response)
|
||||
{
|
||||
ComicDB comic = DBHelper::getComicInfo(libraryId, comicId);
|
||||
|
||||
QJsonObject json = YACReaderServerDataHelper::fullComicToJSON(libraryId, comic);
|
||||
|
||||
QJsonDocument output(json);
|
||||
|
||||
response.write(output.toJson());
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
#ifndef COMICFULLINFOCONTROLLER_V2_H
|
||||
#define COMICFULLINFOCONTROLLER_V2_H
|
||||
|
||||
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
|
||||
|
||||
class ComicFullinfoController_v2 : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ComicFullinfoController_v2)
|
||||
public:
|
||||
ComicFullinfoController_v2();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, const qulonglong &comicId, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // COMICFULLINFOCONTROLLER_V2_H
|
@ -36,6 +36,7 @@
|
||||
#include "controllers/v2/readingcomicscontroller_v2.h"
|
||||
#include "controllers/v2/readinglistscontroller_v2.h"
|
||||
#include "controllers/v2/readinglistcontentcontroller_v2.h"
|
||||
#include "controllers/v2/comicfullinfocontroller_v2.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
@ -218,8 +219,9 @@ void RequestMapper::serviceV2(HttpRequest& request, HttpResponse& response)
|
||||
|
||||
QRegExp folderInfo("/v2/library/.+/folder/[0-9]+/info/?"); //get folder info
|
||||
QRegExp comicDownloadInfo("/v2/library/.+/comic/[0-9]+/?"); //get comic info (basic/download info)
|
||||
QRegExp comicFullInfo("/v2/library/.+/comic/[0-9]+/info/?"); //get comic info (full info)
|
||||
QRegExp comicOpen("/v2/library/.+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
||||
QRegExp comicOpenForDownloading("/v2/library/.+/comic/[0-9]+/info/?"); //get comic info (full info + opening)
|
||||
QRegExp comicOpenForRemoteReading("/v2/library/.+/comic/[0-9]+/remote/?"); //the server will open for reading the comic
|
||||
QRegExp comicFullInfo("/v2/library/.+/comic/[0-9]+/fullinfo/?"); //get comic info (full info + opening)
|
||||
QRegExp comicUpdate("/v2/library/.+/comic/[0-9]+/update/?"); //get comic info
|
||||
QRegExp comicClose("/v2/library/.+/comic/[0-9]+/close/?"); //the server will close the comic and free memory
|
||||
QRegExp cover("/v2/library/.+/cover/[0-9a-f]+.jpg"); //get comic cover (navigation)
|
||||
@ -278,9 +280,11 @@ void RequestMapper::serviceV2(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
ComicDownloadInfoControllerV2().service(request, response);
|
||||
}
|
||||
else if(comicFullInfo.exactMatch(path) || comicOpen.exactMatch(path))//start download or start remote reading
|
||||
else if(comicOpenForDownloading.exactMatch(path) || comicOpenForRemoteReading.exactMatch(path))//start download or start remote reading
|
||||
{
|
||||
ComicControllerV2().service(request, response);
|
||||
} else if(comicFullInfo.exactMatch(path)) {
|
||||
ComicFullinfoController_v2().service(request, response);
|
||||
}
|
||||
else if(comicPage.exactMatch(path) || comicPageRemote.exactMatch(path))
|
||||
{
|
||||
|
@ -43,7 +43,8 @@ HEADERS += \
|
||||
$$PWD/controllers/v2/favoritescontroller_v2.h \
|
||||
$$PWD/controllers/v2/readingcomicscontroller_v2.h \
|
||||
$$PWD/controllers/v2/readinglistscontroller_v2.h \
|
||||
$$PWD/controllers/v2/readinglistcontentcontroller_v2.h
|
||||
$$PWD/controllers/v2/readinglistcontentcontroller_v2.h \
|
||||
$$PWD/controllers/v2/comicfullinfocontroller_v2.h
|
||||
|
||||
|
||||
SOURCES += \
|
||||
@ -81,7 +82,8 @@ SOURCES += \
|
||||
$$PWD/controllers/v2/favoritescontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/readingcomicscontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/readinglistscontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/readinglistcontentcontroller_v2.cpp
|
||||
$$PWD/controllers/v2/readinglistcontentcontroller_v2.cpp \
|
||||
$$PWD/controllers/v2/comicfullinfocontroller_v2.cpp
|
||||
|
||||
|
||||
include(lib/logging/logging.pri)
|
||||
|
@ -57,4 +57,18 @@ QJsonObject YACReaderServerDataHelper::comicToJSON(const qulonglong libraryId, c
|
||||
return json;
|
||||
}
|
||||
|
||||
QJsonObject YACReaderServerDataHelper::fullComicToJSON(const qulonglong libraryId, const ComicDB & comic)
|
||||
{
|
||||
QJsonObject json = comicToJSON(libraryId, comic);
|
||||
|
||||
json["volume"] = comic.info.volume.toString();
|
||||
json["total_volume_count"] = comic.info.count.toInt();
|
||||
json["genre"] = comic.info.genere.toString();
|
||||
json["date"] = comic.info.date.toString();
|
||||
|
||||
json["synopsis"] = comic.info.synopsis.toString();
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
YACReaderServerDataHelper::YACReaderServerDataHelper() {}
|
||||
|
@ -11,8 +11,9 @@ public:
|
||||
static QString folderToYSFormat(const qulonglong libraryId, const Folder & folder);
|
||||
static QString comicToYSFormat(const qulonglong libraryId, const ComicDB & comic);
|
||||
|
||||
static QJsonObject folderToJSON(const qulonglong libraryId, const Folder & folder);
|
||||
static QJsonObject folderToJSON(const qulonglong libraryId, const Folder & folder);
|
||||
static QJsonObject comicToJSON(const qulonglong libraryId, const ComicDB & comic);
|
||||
static QJsonObject fullComicToJSON(const qulonglong libraryId, const ComicDB & comic);
|
||||
|
||||
private:
|
||||
YACReaderServerDataHelper();
|
||||
|
Loading…
Reference in New Issue
Block a user