JETServer
/home/bradarant/barant/HTTPServer/__viewlist.h
1 #ifndef ____viewlist_h__
2 #define ____viewlist_h__
3 
4 #include "HTTPPage.h"
5 #include "Directory.h"
6 
7 namespace http {
8 
9  class __viewlist : public HTTPPage {
10 
11  int processCommand(std::string request,
12  core::Session *session,
13  HTTPSession *httpSession,
14  HTTPRequest &httpRequest,
15  std::stringstream &data) override {
16 
17  coreutils::Directory directory("/home/bradarant/jetserver/views");
18 
19  data << "<div>" << std::endl;
20 
21  data << " <div style=\"background: #484; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
22  data << " onmousedown=\"getPage('/newview','main');\">" << std::endl;
23  data << " <span>Create new view</span>" << std::endl;
24  data << " </div>" << std::endl;
25 
26  while(!directory.eod()) {
27 
28  if(directory.get().getName().substr(0, 1) == ".") {
29  directory.next();
30  continue;
31  }
32 
33  data << " <div style=\"background: #448; color: #fff; width: 400px; margin: 5px; padding: 5px; cursor: pointer;\"" << std::endl;
34  data << " onmousedown=\"getPage('/newview','main');\">" << std::endl;
35  data << " <span>" << directory.get().getName() << "</span>" << std::endl;
36  data << " </div>" << std::endl;
37  directory.next();
38  }
39 
40  data << "</div>" << std::endl;
41 
42  httpRequest.response.addHeader("Content-Type", "text/html");
43 
44  return true;
45  }
46  };
47 }
48 
49 #endif
Definition: __viewlist.h:9
Definition: HTTPSession.h:9
Definition: __configure.h:4
Definition: HTTPPage.h:11
Definition: HTTPRequest.h:11