summaryrefslogtreecommitdiff
path: root/web/src/handlers.cpp
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-05-19 00:16:51 +0500
committerilotterytea <iltsu@alright.party>2024-05-19 00:16:51 +0500
commit4538bc8c7972fa0d9c4c23f038b2c5f2747f8edd (patch)
treecd356ca5dd2259377f91313c835c05fc2d2c9e25 /web/src/handlers.cpp
parentecca9314a53b961f49ae57528e30a3a17f5300dc (diff)
feat: WIKI PAGES
Diffstat (limited to 'web/src/handlers.cpp')
-rw-r--r--web/src/handlers.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/web/src/handlers.cpp b/web/src/handlers.cpp
new file mode 100644
index 0000000..1dfeb81
--- /dev/null
+++ b/web/src/handlers.cpp
@@ -0,0 +1,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));
+ }
+}