50 lines
1.6 KiB
C++
50 lines
1.6 KiB
C++
#ifndef ____viewlist_h__
|
|
#define ____viewlist_h__
|
|
|
|
#include "HTTPPage.h"
|
|
#include "Directory.h"
|
|
|
|
namespace http {
|
|
|
|
class __viewlist : public HTTPPage {
|
|
|
|
int processCommand(std::string request,
|
|
core::TCPSession *session,
|
|
HTTPSession *httpSession,
|
|
HTTPRequest *httpRequest,
|
|
std::stringstream &data) override {
|
|
|
|
coreutils::Directory directory("../../jetserver/views");
|
|
|
|
data << "<div>" << std::endl;
|
|
|
|
data << " <div style=\"background: #484; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
|
data << " onmousedown=\"getPage('/editview','main');\">" << std::endl;
|
|
data << " <span>Create new view</span>" << std::endl;
|
|
data << " </div>" << std::endl;
|
|
|
|
while(!directory.eod()) {
|
|
|
|
if(directory.get().getName().substr(0, 1) == ".") {
|
|
directory.next();
|
|
continue;
|
|
}
|
|
|
|
data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
|
|
data << " onmousedown=\"getPage('/editview?view=testview1','main');\">" << std::endl;
|
|
data << " <span>" << directory.get().getName() << "</span>" << std::endl;
|
|
data << " </div>" << std::endl;
|
|
directory.next();
|
|
}
|
|
|
|
data << "</div>" << std::endl;
|
|
|
|
httpRequest->response.addHeader("Content-Type", "text/html");
|
|
|
|
return true;
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif
|