mirror of
https://github.com/YACReader/yacreader
synced 2025-07-18 21:14:33 -04:00
New controller for serving the comics being read.
This commit is contained in:
@ -0,0 +1,37 @@
|
||||
#include "readingcomicscontroller.h"
|
||||
|
||||
#include "db_helper.h"
|
||||
#include "comic_db.h"
|
||||
|
||||
#include "yacreader_server_data_helper.h"
|
||||
|
||||
ReadingComicsController::ReadingComicsController()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ReadingComicsController::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();
|
||||
|
||||
serviceContent(libraryId, response);
|
||||
|
||||
response.write("",true);
|
||||
}
|
||||
|
||||
void ReadingComicsController::serviceContent(const int &library, HttpResponse &response)
|
||||
{
|
||||
//TODO sort comics before serving them
|
||||
int FIXME;
|
||||
|
||||
QList<ComicDB> tagComics = DBHelper::getReading(library);
|
||||
|
||||
for(const ComicDB &comic : tagComics)
|
||||
{
|
||||
response.write(YACReaderServerDataHelper::comicToYSFormat(library, comic).toUtf8());
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
#ifndef READINGCOMICSCONTROLLER_H
|
||||
#define READINGCOMICSCONTROLLER_H
|
||||
|
||||
#include "httprequest.h"
|
||||
#include "httpresponse.h"
|
||||
#include "httprequesthandler.h"
|
||||
|
||||
class ReadingComicsController : public HttpRequestHandler {
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(ReadingComicsController)
|
||||
public:
|
||||
ReadingComicsController();
|
||||
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
|
||||
private:
|
||||
void serviceContent(const int &library, HttpResponse &response);
|
||||
};
|
||||
|
||||
#endif // READINGCOMICSCONTROLLER_H
|
Reference in New Issue
Block a user