Add a ListPage module.

This commit is contained in:
Relintai 2020-12-26 00:18:11 +01:00
parent 7e24a87c57
commit 374fb21257
4 changed files with 92 additions and 0 deletions

12
modules/list_page/SCsub Normal file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env python
Import("env_mod")
Import("env")
env_mod.core_sources = []
env_mod.add_source_files(env_mod.core_sources, "*.cpp")
# Build it all as a library
lib = env_mod.add_library("list_page", env_mod.core_sources)
env.Prepend(LIBS=[lib])

View File

@ -0,0 +1,27 @@
import os
import platform
import sys
def is_active():
return True
def get_name():
return "list_page"
def can_build():
return True
def get_opts():
return []
def get_flags():
return []
def configure(env):
pass

View File

@ -0,0 +1,29 @@
#include "list_page.h"
#include "core/query_builder.h"
#include "core/table_builder.h"
#include "core/query_result.h"
void ListPage::index(Request *request) {
std::string r = "";
for (uint32_t i = 0; i < messages.size(); ++i) {
r += "<p>" + messages[i] + "</p><br>";
}
r += "";
request->body += r;
request->compile_and_send_body();
}
ListPage::ListPage() :
Object() {
messages.push_back("T message 1");
messages.push_back("T message 2");
}
ListPage::~ListPage() {
}

View File

@ -0,0 +1,24 @@
#ifndef LIST_PAGE_H
#define LIST_PAGE_H
#include <vector>
#include <string>
#include "core/object.h"
#include "core/request.h"
class ListPage : public Object {
RCPP_OBJECT(ListPage, Object);
public:
void index(Request *request);
ListPage();
~ListPage();
std::vector<std::string> messages;
};
#endif