#include "mourne_root.h" #include "web/http/request.h" #include #include "web/file_cache.h" #include "core/os/arg_parser.h" #include "core/os/platform.h" #include "database/database_manager.h" #include "web/html/html_builder.h" #include "web/http/http_session.h" #include "web/http/session_manager.h" #include "web_modules/admin_panel/admin_panel.h" #include "web_modules/users/user.h" #include "web_modules/users/user_controller.h" #include "mourne_user_controller.h" #include "assignments/assignment_initializer.h" #include "buildings/building_initializer.h" #include "weather/weather_initializer.h" #include "village/village_node.h" void MourneRoot::handle_request_main(Request *request) { if (process_middlewares(request)) { return; } if (try_send_wwwroot_file(request)) { return; } // this is a hack, until I have a simple index node, or port contentcontroller. if (request->get_path_segment_count() == 0) { index(request); return; } WebNode *handler = get_request_handler_child(request); if (!handler) { request->send_error(404); return; } add_menu(request, MENUENTRY_NEWS); request->push_path(); handler->handle_request_main(request); } bool MourneRoot::is_logged_in(Request *request) { if (!request->session.is_valid()) { return false; } Ref u = request->reference_data["user"]; return u.is_valid(); } void MourneRoot::index(Request *request) { ENSURE_LOGIN(request); add_menu(request, MENUENTRY_NEWS); /* 2): ?> */ // dynamic_cast(instance)->index(request); request->body += "test"; request->compile_and_send_body(); } void MourneRoot::add_menu(Request *request, const MenuEntries index) { request->head += menu_head; HTMLBuilder b; HTMLTag *t; int userlevel = 0; if (request->session.is_valid()) { Ref user = request->reference_data["user"]; if (user.is_valid()) { userlevel = user->rank; } } if (userlevel > 4) { request->head += admin_headers; } /*