mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
fixed comics management on server sersion
This commit is contained in:
parent
b54264da06
commit
0e166fec4a
@ -211,7 +211,7 @@ void FolderController::service(HttpRequest& request, HttpResponse& response)
|
||||
//t.setVariable(QString("element%1.downloadurl").arg(i),"/library/"+libraryName+"/comic/"+QString("%1").arg(comic->id));
|
||||
if(!session.isComicOnDevice(comic->info.hash) && !session.isComicDownloaded(comic->info.hash))
|
||||
t.setVariable(QString("element%1.download").arg(i),QString("<a onclick=\"this.innerHTML='importing';this.className='importedButton';\" class =\"importButton\" href=\"%1\">import</a>").arg("/library/"+QString::number(libraryId)+"/comic/"+QString("%1").arg(comic->id)));
|
||||
else if (!session.isComicDownloaded(comic->info.hash))
|
||||
else if (session.isComicOnDevice(comic->info.hash))
|
||||
t.setVariable(QString("element%1.download").arg(i),QString("<div class=\"importedButton\">imported</div>"));
|
||||
else
|
||||
t.setVariable(QString("element%1.download").arg(i),QString("<div class=\"importedButton\">importing</div>"));
|
||||
|
@ -12,66 +12,11 @@ LibrariesController::LibrariesController() {}
|
||||
void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response);
|
||||
if(session.contains("ySession")) //session is already alive check if it is needed to update comics
|
||||
{
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
if(postData.length()>0) {
|
||||
QList<QString> data = postData.split("\n");
|
||||
if(data.length() > 2) {
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
|
||||
foreach(QString hash,comics) {
|
||||
session.setComicOnDevice(hash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(data.length()>1)
|
||||
{
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
session.set("ySession","ok");
|
||||
|
||||
session.clearNavigationPath();
|
||||
session.clearFoldersPath();
|
||||
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1");
|
||||
response.setHeader("Connection","close");
|
||||
|
||||
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1");
|
||||
response.setHeader("Connection","close");
|
||||
|
||||
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
//response.writeText(postData);
|
||||
|
||||
QList<QString> data = postData.split("\n");
|
||||
|
||||
QLOG_INFO() << "Data lenght : " << data.length();
|
||||
|
||||
if(data.length() > 2)
|
||||
{
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
|
||||
foreach(QString hash,comics)
|
||||
{
|
||||
session.setComicOnDevice(hash);
|
||||
}
|
||||
}
|
||||
else //values by default, only for debug purposes.
|
||||
{
|
||||
session.setDeviceType("ipad");
|
||||
session.setDisplayType("@2x");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Template t=Static::templateLoader->getTemplate("libraries_"+session.getDeviceType(),request.getHeader("Accept-Language"));
|
||||
Template t=Static::templateLoader->getTemplate("libraries_"+session.getDeviceType(),request.getHeader("Accept-Language"));
|
||||
t.enableWarnings();
|
||||
|
||||
YACReaderLibraries libraries = DBHelper::getLibraries();
|
||||
|
@ -210,7 +210,16 @@ QSet<QString> HttpSession::getDownloadedComics()
|
||||
if(dataPtr)
|
||||
return dataPtr->yacreaderSessionData.downloadedComics ;
|
||||
else
|
||||
return QSet<QString>();
|
||||
return QSet<QString>();
|
||||
}
|
||||
|
||||
void HttpSession::clearComics()
|
||||
{
|
||||
if(dataPtr)
|
||||
{
|
||||
dataPtr->yacreaderSessionData.comicsOnDevice.clear();
|
||||
dataPtr->yacreaderSessionData.downloadedComics.clear();
|
||||
}
|
||||
}
|
||||
//current comic (import)
|
||||
qulonglong HttpSession::getCurrentComicId()
|
||||
|
@ -101,6 +101,7 @@ public:
|
||||
bool isComicDownloaded(const QString & hash);
|
||||
QSet<QString> getComicsOnDevice();
|
||||
QSet<QString> getDownloadedComics();
|
||||
void clearComics();
|
||||
|
||||
//current comic (import)
|
||||
qulonglong getCurrentComicId();
|
||||
|
@ -24,9 +24,71 @@
|
||||
#include "db_helper.h"
|
||||
#include "yacreader_libraries.h"
|
||||
|
||||
#include "QsLog.h"
|
||||
|
||||
RequestMapper::RequestMapper(QObject* parent)
|
||||
:HttpRequestHandler(parent) {}
|
||||
|
||||
void RequestMapper::loadSession(HttpRequest & request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response);
|
||||
if(session.contains("ySession")) //session is already alive check if it is needed to update comics
|
||||
{
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
if(postData.length()>0) {
|
||||
QList<QString> data = postData.split("\n");
|
||||
if(data.length() > 2) {
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
|
||||
session.clearComics();
|
||||
foreach(QString hash,comics) {
|
||||
session.setComicOnDevice(hash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(data.length()>1)
|
||||
{
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
session.set("ySession","ok");
|
||||
|
||||
session.clearNavigationPath();
|
||||
session.clearFoldersPath();
|
||||
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
//response.writeText(postData);
|
||||
|
||||
QList<QString> data = postData.split("\n");
|
||||
|
||||
QLOG_INFO() << "Data lenght : " << data.length();
|
||||
|
||||
if(data.length() > 2)
|
||||
{
|
||||
session.setDeviceType(data.at(0).split(":").at(1));
|
||||
session.setDisplayType(data.at(1).split(":").at(1));
|
||||
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
|
||||
foreach(QString hash,comics)
|
||||
{
|
||||
session.setComicOnDevice(hash);
|
||||
}
|
||||
}
|
||||
else //values by default, only for debug purposes.
|
||||
{
|
||||
session.setDeviceType("ipad");
|
||||
session.setDisplayType("@2x");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
QByteArray path=request.getPath();
|
||||
qDebug("RequestMapper: path=%s",path.data());
|
||||
@ -41,10 +103,12 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
QRegExp comicPage("/library/.+/comic/[0-9]+/page/[0-9]+/?"); //get comic page
|
||||
QRegExp comicPageRemote("/library/.+/comic/[0-9]+/page/[0-9]+/remote?"); //get comic page (remote reading)
|
||||
|
||||
QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe
|
||||
QRegExp library("/library/([0-9]+)/.+"); //permite verificar que la biblioteca solicitada existe
|
||||
|
||||
path = QUrl::fromPercentEncoding(path).toLatin1();
|
||||
|
||||
loadSession(request, response);
|
||||
|
||||
//primera petición, se ha hecho un post, se sirven las bibliotecas si la seguridad mediante login no está habilitada
|
||||
if(path == "/")
|
||||
{
|
||||
@ -58,6 +122,8 @@ void RequestMapper::service(HttpRequest& request, HttpResponse& response) {
|
||||
HttpSession session=Static::sessionStore->getSession(request,response,false);
|
||||
if(!session.isNull() && session.contains("ySession"))
|
||||
{
|
||||
//
|
||||
|
||||
if(library.indexIn(path)!=-1 && DBHelper::getLibraries().contains(library.cap(1).toInt()) )
|
||||
{
|
||||
//listar el contenido del folder
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
@param response Must be used to return the response
|
||||
*/
|
||||
void service(HttpRequest& request, HttpResponse& response);
|
||||
void loadSession(HttpRequest & request, HttpResponse& response);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user