Added custom header and footer support for the Admin Panel.

This commit is contained in:
Relintai 2021-11-14 22:11:35 +01:00
parent 6f7b413e08
commit 7485a80d12
2 changed files with 28 additions and 2 deletions

View File

@ -32,7 +32,9 @@ void AdminPanel::handle_request_main(Request *request) {
return;
}
render_headers(request);
render_controller_panel(request, c);
render_footer(request);
//request->pop_path();
@ -44,7 +46,7 @@ void AdminPanel::handle_request_main(Request *request) {
}
void AdminPanel::render_admin_panel_list(Request *request) {
//set up headers
render_headers(request);
String rootlink = request->get_url_root();
@ -80,7 +82,7 @@ void AdminPanel::render_admin_panel_list(Request *request) {
b.cdiv();
//set up footers
render_footer(request);
request->body += b.result;
request->compile_and_send_body();
@ -106,6 +108,21 @@ void AdminPanel::clear() {
_controllers.clear();
}
void AdminPanel::render_headers(Request *request) {
request->head += _default_headers;
}
void AdminPanel::render_footer(Request *request) {
request->body += _default_footer;
}
void AdminPanel::set_default_header(const String &val) {
_default_headers = val;
}
void AdminPanel::set_default_footer(const String &val) {
_default_footer = val;
}
AdminPanel *AdminPanel::get_singleton() {
return _self;
}

View File

@ -22,6 +22,12 @@ public:
void register_admin_controller(const String &section, AdminController *controller);
void clear();
virtual void render_headers(Request *request);
virtual void render_footer(Request *request);
void set_default_header(const String &val);
void set_default_footer(const String &val);
static AdminPanel *get_singleton();
AdminPanel();
@ -37,6 +43,9 @@ protected:
static AdminPanel *_self;
Vector<AdminPanelSection> _controllers;
String _default_headers;
String _default_footer;
};
#endif