mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2025-01-11 13:21:10 +01:00
Added a new AliasWebPage WebNode.
This commit is contained in:
parent
db70692e73
commit
853480a492
@ -61,6 +61,7 @@ sources = [
|
||||
#"nodes/paged_article/paged_articles_md_index_web_page.cpp",
|
||||
|
||||
"nodes/redirect/redirect_web_page.cpp",
|
||||
"nodes/redirect/alias_web_page.cpp",
|
||||
]
|
||||
|
||||
if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes':
|
||||
|
@ -76,6 +76,7 @@ def get_doc_classes():
|
||||
"PagedArticlesWebPageMDIndex",
|
||||
|
||||
"RedirectWebPage",
|
||||
"AliasWebPage",
|
||||
]
|
||||
|
||||
|
||||
|
40
modules/web/nodes/redirect/alias_web_page.cpp
Normal file
40
modules/web/nodes/redirect/alias_web_page.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
#include "alias_web_page.h"
|
||||
|
||||
#include "../../http/http_server_enums.h"
|
||||
#include "../../http/web_server_request.h"
|
||||
#include "core/os/file_access.h"
|
||||
|
||||
NodePath AliasWebPage::get_alias_path() {
|
||||
return _alias_path;
|
||||
}
|
||||
void AliasWebPage::set_alias_path(const NodePath &val) {
|
||||
_alias_path = val;
|
||||
}
|
||||
|
||||
void AliasWebPage::_handle_request(Ref<WebServerRequest> request) {
|
||||
ERR_FAIL_COND(!_alias);
|
||||
ERR_FAIL_COND(!ObjectDB::instance_validate(_alias));
|
||||
|
||||
_alias->handle_request(request);
|
||||
}
|
||||
|
||||
AliasWebPage::AliasWebPage() {
|
||||
_alias = nullptr;
|
||||
}
|
||||
|
||||
AliasWebPage::~AliasWebPage() {
|
||||
}
|
||||
|
||||
void AliasWebPage::_notification(int p_what) {
|
||||
if (p_what == NOTIFICATION_ENTER_TREE) {
|
||||
_alias = Object::cast_to<WebNode>(get_node_or_null(_alias_path));
|
||||
} else if (p_what == NOTIFICATION_EXIT_TREE) {
|
||||
_alias = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void AliasWebPage::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_alias_path"), &AliasWebPage::get_alias_path);
|
||||
ClassDB::bind_method(D_METHOD("set_alias_path", "val"), &AliasWebPage::set_alias_path);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "alias_path"), "set_alias_path", "get_alias_path");
|
||||
}
|
34
modules/web/nodes/redirect/alias_web_page.h
Normal file
34
modules/web/nodes/redirect/alias_web_page.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef ALIAS_WEB_PAGE_H
|
||||
#define ALIAS_WEB_PAGE_H
|
||||
|
||||
#include "core/ustring.h"
|
||||
|
||||
#include "../../http/web_node.h"
|
||||
|
||||
class WebServerRequest;
|
||||
|
||||
class AliasWebPage : public WebNode {
|
||||
GDCLASS(AliasWebPage, WebNode);
|
||||
|
||||
public:
|
||||
NodePath get_alias_path();
|
||||
void set_alias_path(const NodePath &val);
|
||||
|
||||
int get_code();
|
||||
void set_code(const int val);
|
||||
|
||||
void _handle_request(Ref<WebServerRequest> request);
|
||||
|
||||
AliasWebPage();
|
||||
~AliasWebPage();
|
||||
|
||||
protected:
|
||||
void _notification(int p_what);
|
||||
|
||||
static void _bind_methods();
|
||||
|
||||
NodePath _alias_path;
|
||||
WebNode *_alias;
|
||||
};
|
||||
|
||||
#endif
|
@ -60,6 +60,7 @@ SOFTWARE.
|
||||
#include "nodes/paged_article/paged_articles_web_page.h"
|
||||
//#include "nodes/paged_article/paged_articles_md_index.h"
|
||||
|
||||
#include "nodes/redirect/alias_web_page.h"
|
||||
#include "nodes/redirect/redirect_web_page.h"
|
||||
|
||||
void register_web_types() {
|
||||
@ -126,6 +127,7 @@ void register_web_types() {
|
||||
//ClassDB::register_class<PagedArticlesWebPageMDIndex>();
|
||||
|
||||
ClassDB::register_class<RedirectWebPage>();
|
||||
ClassDB::register_class<AliasWebPage>();
|
||||
}
|
||||
|
||||
void unregister_web_types() {
|
||||
|
Loading…
Reference in New Issue
Block a user