From 28a7df74e0d6b46c12220beffebf70a71e6d9509 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 8 Apr 2016 14:54:04 +0800 Subject: [PATCH] xmreg:page --- main.cpp | 8 ++++++-- src/CMakeLists.txt | 2 +- src/page.cpp | 5 +++++ src/page.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 src/page.cpp create mode 100644 src/page.h diff --git a/main.cpp b/main.cpp index 1d64f92..520f6ac 100644 --- a/main.cpp +++ b/main.cpp @@ -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()} }; diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 68f37db..4d576f3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/page.cpp b/src/page.cpp new file mode 100644 index 0000000..56698ee --- /dev/null +++ b/src/page.cpp @@ -0,0 +1,5 @@ +// +// Created by mwo on 8/04/16. +// + +#include "page.h" diff --git a/src/page.h b/src/page.h new file mode 100644 index 0000000..86f6c29 --- /dev/null +++ b/src/page.h @@ -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