mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-27 06:07:14 +01:00
Added a simple page rendering customization api for UserWebPages.
This commit is contained in:
parent
3bf2b79d88
commit
b83c4f7ff8
@ -19,6 +19,15 @@
|
||||
<description>
|
||||
</description>
|
||||
</method>
|
||||
<method name="_render_user_page" qualifiers="virtual">
|
||||
<return type="void" />
|
||||
<argument index="0" name="request" type="WebServerRequest" />
|
||||
<argument index="1" name="data" type="Dictionary" />
|
||||
<description>
|
||||
Implementing this method will make the system call it instead of the normal built in html rendering methods on the engine side.
|
||||
This is when you want to only customize the rendered html. If you need to change backend logic, look at the other available virtuals.
|
||||
</description>
|
||||
</method>
|
||||
<method name="handle_logged_in">
|
||||
<return type="void" />
|
||||
<argument index="0" name="request" type="WebServerRequest" />
|
||||
|
@ -54,7 +54,16 @@ void UserLoginWebPage::_render_index(Ref<WebServerRequest> request) {
|
||||
|
||||
emit_signal("user_logged_in", request, user);
|
||||
|
||||
if (has_method("_render_user_page")) {
|
||||
Dictionary d;
|
||||
|
||||
d["type"] = "render_login_success";
|
||||
d["user"] = user;
|
||||
|
||||
call("_render_user_page", request, d);
|
||||
} else {
|
||||
render_login_success(request);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@ -63,8 +72,19 @@ void UserLoginWebPage::_render_index(Ref<WebServerRequest> request) {
|
||||
}
|
||||
}
|
||||
|
||||
if (has_method("_render_user_page")) {
|
||||
Dictionary d;
|
||||
|
||||
d["type"] = "render_login_request_default";
|
||||
d["error_str"] = data.error_str;
|
||||
d["uname_val"] = data.uname_val;
|
||||
d["pass_val"] = data.pass_val;
|
||||
|
||||
call("_render_user_page", request, d);
|
||||
} else {
|
||||
render_login_request_default(request, &data);
|
||||
}
|
||||
}
|
||||
|
||||
void UserLoginWebPage::render_login_request_default(Ref<WebServerRequest> request, LoginRequestData *data) {
|
||||
HTMLBuilder b;
|
||||
|
@ -29,12 +29,20 @@ void UserLogoutWebPage::_render_index(Ref<WebServerRequest> request) {
|
||||
|
||||
emit_signal("user_logged_out", request, user);
|
||||
|
||||
if (has_method("_render_user_page")) {
|
||||
Dictionary d;
|
||||
|
||||
d["user"] = user;
|
||||
|
||||
call("_render_user_page", request, d);
|
||||
} else {
|
||||
HTMLBuilder b;
|
||||
b.w("Logout successful!");
|
||||
request->body += b.result;
|
||||
|
||||
request->compile_and_send_body();
|
||||
}
|
||||
}
|
||||
|
||||
UserLogoutWebPage::UserLogoutWebPage() {
|
||||
}
|
||||
|
@ -63,13 +63,36 @@ void UserRegisterWebPage::_render_index(Ref<WebServerRequest> request) {
|
||||
|
||||
emit_signal("user_registered", request, user);
|
||||
|
||||
if (has_method("_render_user_page")) {
|
||||
Dictionary d;
|
||||
|
||||
d["type"] = "render_register_success";
|
||||
d["user"] = user;
|
||||
|
||||
call("_render_user_page", request, d);
|
||||
} else {
|
||||
render_register_success(request);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_method("_render_user_page")) {
|
||||
Dictionary d;
|
||||
|
||||
d["type"] = "render_register_request_default";
|
||||
d["error_str"] = data.error_str;
|
||||
d["uname_val"] = data.uname_val;
|
||||
d["email_val"] = data.email_val;
|
||||
d["pass_val"] = data.pass_val;
|
||||
d["pass_check_val"] = data.pass_check_val;
|
||||
|
||||
call("_render_user_page", request, d);
|
||||
} else {
|
||||
render_register_request_default(request, &data);
|
||||
}
|
||||
}
|
||||
|
||||
void UserRegisterWebPage::render_register_success(Ref<WebServerRequest> request) {
|
||||
HTMLBuilder b;
|
||||
|
@ -84,8 +84,21 @@ void UserSettingsWebPage::_render_index(Ref<WebServerRequest> request) {
|
||||
}
|
||||
}
|
||||
|
||||
if (has_method("_render_user_page")) {
|
||||
Dictionary d;
|
||||
|
||||
d["user"] = user;
|
||||
d["error_str"] = data.error_str;
|
||||
d["uname_val"] = data.uname_val;
|
||||
d["email_val"] = data.email_val;
|
||||
d["pass_val"] = data.pass_val;
|
||||
d["pass_check_val"] = data.pass_check_val;
|
||||
|
||||
call("_render_user_page", request, d);
|
||||
} else {
|
||||
render_settings_request(user, request, &data);
|
||||
}
|
||||
}
|
||||
|
||||
void UserSettingsWebPage::render_settings_request(Ref<User> &user, Ref<WebServerRequest> request, SettingsRequestData *data) {
|
||||
HTMLBuilder b;
|
||||
|
@ -137,6 +137,8 @@ UserWebPage::~UserWebPage() {
|
||||
}
|
||||
|
||||
void UserWebPage::_bind_methods() {
|
||||
BIND_VMETHOD(MethodInfo("_render_user_page", PropertyInfo(Variant::OBJECT, "request", PROPERTY_HINT_RESOURCE_TYPE, "WebServerRequest"), PropertyInfo(Variant::DICTIONARY, "data")));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_logged_out_render_type"), &UserWebPage::get_logged_out_render_type);
|
||||
ClassDB::bind_method(D_METHOD("set_logged_out_render_type", "val"), &UserWebPage::set_logged_out_render_type);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "logged_out_render_type", PROPERTY_HINT_ENUM, "Render,Redirect,Error"), "set_logged_out_render_type", "get_logged_out_render_type");
|
||||
|
Loading…
Reference in New Issue
Block a user