More cleanups.

This commit is contained in:
Relintai 2021-11-21 14:50:03 +01:00
parent 3d5e5795a0
commit 1044749d2a
4 changed files with 13 additions and 19 deletions

1
.gitignore vendored
View File

@ -12,7 +12,6 @@ game/.prop_tool_temp/**
settings.ini settings.ini
www/**
data/** data/**
export/** export/**
release/** release/**

View File

@ -36,35 +36,32 @@ void WPApplication::routing_middleware(Object *instance, Request *request) {
return; return;
} }
HandlerInstance handler_data;
handler_data.instance = instance;
if (request->get_path_segment_count() == 0) { if (request->get_path_segment_count() == 0) {
handler_data.handler_func = index; request->handler_instance = app->index_func;
} else { } else {
const std::string main_route = request->get_current_path_segment(); const std::string main_route = request->get_current_path_segment();
request->push_path(); request->push_path();
if (main_route == "blog") { if (main_route == "blog") {
handler_data.handler_func = blog; request->handler_instance = app->blog_func;
} }
} }
if (!handler_data.handler_func) { if (!request->handler_instance.handler_func) {
app->send_error(404, request); app->send_error(404, request);
return; return;
} }
request->handler_instance = handler_data;
request->next_stage(); request->next_stage();
} }
void WPApplication::setup_routes() { void WPApplication::setup_routes() {
DWebApplication::setup_routes(); DWebApplication::setup_routes();
index_func = HandlerInstance(index); index_func = HandlerInstance(index, this);
blog_func = HandlerInstance(blog, this);
} }
void WPApplication::setup_middleware() { void WPApplication::setup_middleware() {
@ -78,17 +75,14 @@ void WPApplication::compile_menu() {
HTMLBuilder bh; HTMLBuilder bh;
bh.meta()->charset_utf_8(); bh.meta()->charset_utf_8();
bh.meta()->name("description")->content("RPG browsergame");
bh.meta()->name("keywords")->content("RPG,browsergame,Mourne,game,play");
bh.title(); bh.title();
bh.w("Mourne"); bh.w("WPSaver");
bh.ctitle(); bh.ctitle();
bh.link()->rel_stylesheet()->href("/css/base.css"); bh.link()->rel_stylesheet()->href("site.css");
bh.link()->rel_stylesheet()->href("/css/menu.css");
bh.write_tag(); bh.write_tag();
menu_head = bh.result; header = bh.result;
HTMLBuilder bf; HTMLBuilder bf;
@ -108,5 +102,3 @@ WPApplication::WPApplication() :
WPApplication::~WPApplication() { WPApplication::~WPApplication() {
} }
std::string WPApplication::menu_head = "";
std::string WPApplication::footer = "";

View File

@ -4,6 +4,7 @@
//#include "core/http/web_application.h" //#include "core/http/web_application.h"
#include "core/object.h" #include "core/object.h"
#include "modules/drogon/web_application.h" #include "modules/drogon/web_application.h"
#include "core/string.h"
#undef LOG_TRACE #undef LOG_TRACE
#undef LOG_WARN #undef LOG_WARN
@ -27,8 +28,10 @@ public:
WPApplication(); WPApplication();
~WPApplication(); ~WPApplication();
static std::string menu_head; HandlerInstance blog_func;
static std::string footer;
String header;
String footer;
}; };
#endif #endif

0
www/site.css Normal file
View File