xmreg:page

This commit is contained in:
moneroexamples 2016-04-08 14:54:04 +08:00
parent 8247faf232
commit 28a7df74e0
4 changed files with 55 additions and 3 deletions

View File

@ -1,6 +1,8 @@
#include "src/MicroCore.h"
#include "src/page.h"
#include "ext/crow/crow.h"
#include "mstch/mstch.hpp"
#include "ext/format.h"
@ -43,9 +45,11 @@ int main() {
"Top block height : {:d}\n", height);
std::string view = xmreg::read("./templates/index.html");
xmreg::page xmrblocks;
mstch::map context {
std::string view = xmrblocks.index();
mstch::map context {
{"height", fmt::format("{:d}", height)},
{"blocks", mstch::array()}
};

View File

@ -12,7 +12,7 @@ set(SOURCE_FILES
MicroCore.cpp
tools.cpp
CmdLineOptions.cpp
tx_details.cpp)
tx_details.cpp page.cpp page.h)
# make static library called libmyxrm
# that we are going to link to

5
src/page.cpp Normal file
View File

@ -0,0 +1,5 @@
//
// Created by mwo on 8/04/16.
//
#include "page.h"

43
src/page.h Normal file
View File

@ -0,0 +1,43 @@
//
// Created by mwo on 8/04/16.
//
#ifndef CROWXMR_PAGE_H
#define CROWXMR_PAGE_H
#include "../ext/minicsv.h"
#include "monero_headers.h"
#include "tools.h"
#define TMPL_DIR "./templates"
#define TMPL_INDEX TMPL_DIR "/index.html"
#define READ_TMPL(tmpl_path) xmreg::read(tmpl_path)
namespace xmreg {
class page {
public:
string
index()
{
std::string view = READ_TMPL(TMPL_INDEX);
return view;
}
private:
};
}
#endif //CROWXMR_PAGE_H