mirror of
https://github.com/YACReader/yacreader
synced 2025-07-15 19:44:32 -04:00
updated web library with new style and features
added remote reading from iOS
This commit is contained in:
@ -10,32 +10,53 @@ LibrariesController::LibrariesController() {}
|
||||
|
||||
void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
{
|
||||
HttpSession session=Static::sessionStore->getSession(request,response);
|
||||
session.set("ySession","ok");
|
||||
session.clearNavigationPath();
|
||||
response.setHeader("Content-Type", "text/html; charset=ISO-8859-1");
|
||||
response.setHeader("Connection","close");
|
||||
|
||||
|
||||
QString postData = QString::fromUtf8(request.getBody());
|
||||
//response.writeText(postData);
|
||||
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) {
|
||||
//ONLY COMICS ARE UPDATED, DEVICE CHARACTERISTICS ARE INMUTABLE
|
||||
QList<QString> comics = data.at(2).split(":").at(1).split("\t");
|
||||
foreach(QString hash,comics) {
|
||||
session.setComicOnDevice(hash);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
session.set("ySession","ok");
|
||||
|
||||
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 //valores por defecto, con propositos de depuraci<63>n
|
||||
{
|
||||
session.setDeviceType("ipad");
|
||||
session.setDisplayType("retina");
|
||||
}
|
||||
session.clearNavigationPath();
|
||||
session.clearFoldersPath();
|
||||
|
||||
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");
|
||||
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("iphone");
|
||||
session.setDisplayType("@2x");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Template t=Static::templateLoader->getTemplate("libraries_"+session.getDeviceType(),request.getHeader("Accept-Language"));
|
||||
t.enableWarnings();
|
||||
@ -54,6 +75,6 @@ void LibrariesController::service(HttpRequest& request, HttpResponse& response)
|
||||
i++;
|
||||
}
|
||||
|
||||
response.setStatus(200,"OK");
|
||||
response.write(t.toLatin1(),true);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user