mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-02-20 15:14:26 +01:00
Added get_parent_webnode, get_full_uri, and get_full_uri_parent helpers to WebNode.
This commit is contained in:
parent
53238c1265
commit
65892ddd5a
@ -22,6 +22,35 @@ void WebNode::set_uri_segment(const String &val) {
|
||||
_uri_segment = val;
|
||||
}
|
||||
|
||||
String WebNode::get_full_uri(const bool slash_at_the_end) {
|
||||
if (slash_at_the_end) {
|
||||
return get_full_uri_parent(true) + _uri_segment + '/';
|
||||
} else {
|
||||
return get_full_uri_parent(true) + _uri_segment;
|
||||
}
|
||||
}
|
||||
String WebNode::get_full_uri_parent(const bool slash_at_the_end) {
|
||||
String uri = "/";
|
||||
|
||||
WebNode *n = get_parent_webnode();
|
||||
|
||||
while (n) {
|
||||
if (n->_uri_segment == "" || n->_uri_segment == '/') {
|
||||
break;
|
||||
}
|
||||
|
||||
uri = "/" + n->_uri_segment + uri;
|
||||
|
||||
n = n->get_parent_webnode();
|
||||
}
|
||||
|
||||
if (!slash_at_the_end) {
|
||||
uri.pop_back();
|
||||
}
|
||||
|
||||
return uri;
|
||||
}
|
||||
|
||||
Settings *WebNode::get_settings() {
|
||||
if (_settings) {
|
||||
return _settings;
|
||||
@ -147,6 +176,10 @@ WebNode *WebNode::get_root() {
|
||||
return s->get_web_root();
|
||||
}
|
||||
|
||||
WebNode *WebNode::get_parent_webnode() {
|
||||
return Object::cast_to<WebNode>(get_parent());
|
||||
}
|
||||
|
||||
WebNode::WebNode() :
|
||||
Node() {
|
||||
// should look this up in parents when parented (and node parenting is implemented)
|
||||
|
@ -22,6 +22,9 @@ public:
|
||||
String get_uri_segment();
|
||||
void set_uri_segment(const String &val);
|
||||
|
||||
virtual String get_full_uri(const bool slash_at_the_end = true);
|
||||
virtual String get_full_uri_parent(const bool slash_at_the_end = true);
|
||||
|
||||
Settings *get_settings();
|
||||
void set_settings(Settings *settings);
|
||||
|
||||
@ -50,6 +53,7 @@ public:
|
||||
|
||||
WebServer *get_server();
|
||||
WebNode *get_root();
|
||||
WebNode *get_parent_webnode();
|
||||
|
||||
WebNode();
|
||||
~WebNode();
|
||||
|
Loading…
Reference in New Issue
Block a user