From a808ec07cbbb4fc6118d97b8e7985debe1274a5f Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Sun, 19 May 2024 00:58:38 +0500 Subject: feat: use cfg to replace placeholders --- web/src/main.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'web/src/main.cpp') diff --git a/web/src/main.cpp b/web/src/main.cpp index b63151c..314d2bf 100644 --- a/web/src/main.cpp +++ b/web/src/main.cpp @@ -9,15 +9,22 @@ int main(int argc, char *argv[]) { crow::SimpleApp app; CROW_ROUTE(app, "/") - ([]() { + ([&cfg]() { auto page = crow::mustache::load("index.html"); - return page.render(); + crow::mustache::context ctx; + ctx["contact_url"] = (*cfg).contact_url; + ctx["contact_name"] = (*cfg).contact_name; + + return page.render(ctx); }); - CROW_ROUTE(app, "/wiki")([]() { return botweb::get_wiki_page("/README"); }); + CROW_ROUTE(app, "/wiki") + ([&cfg]() { return botweb::get_wiki_page("/README", cfg); }); CROW_ROUTE(app, "/wiki/") - ([](const std::string &path) { return botweb::get_wiki_page(path); }); + ([&cfg](const std::string &path) { + return botweb::get_wiki_page(path, cfg); + }); app.multithreaded().port(18083).run(); return 0; -- cgit v1.2.3