blob: 1dfeb812fc28692a923308142c241c466909bace (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "handlers.hpp"
#include <fstream>
#include <memory>
#include <string>
#include "crow/http_response.h"
#include "crow/mustache.h"
#include "maddy/parser.h"
namespace botweb {
crow::response get_wiki_page(const std::string &path) {
std::shared_ptr<maddy::Parser> parser = std::make_shared<maddy::Parser>();
std::ifstream contents("docs/" + path + ".md");
std::string contents_html = parser->Parse(contents);
contents.close();
std::ifstream summary("docs/summary.md");
std::string summary_html = parser->Parse(summary);
summary.close();
auto page = crow::mustache::load("wiki_page.html");
crow::mustache::context ctx;
ctx["content"] = contents_html;
ctx["summary"] = summary_html;
return crow::response(200, page.render(ctx));
}
}
|