diff --git a/game/Main.tscn b/game/Main.tscn index d7b5242..82b0bdb 100644 --- a/game/Main.tscn +++ b/game/Main.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://Main.gd" type="Script" id=1] [ext_resource path="res://addons/web_pages/classes/WebPage.gd" type="Script" id=2] @@ -9,11 +9,6 @@ script = ExtResource( 3 ) text = "asdasdasd" hsize = 1 -[sub_resource type="Resource" id=4] -script = ExtResource( 3 ) -text = "rerer" -hsize = 1 - [sub_resource type="Resource" id=3] script = ExtResource( 3 ) text = "rtrtrtrttrtA" @@ -31,9 +26,9 @@ script = ExtResource( 1 ) [node name="index" type="StaticWebPage" parent="WebRoot"] uri_segment = "/" -data = "Blog" +data = "Page" -[node name="Asdasd" type="WebNode" parent="WebRoot"] -uri_segment = "asda" +[node name="page" type="WebNode" parent="WebRoot"] +uri_segment = "page" script = ExtResource( 2 ) -entries = [ SubResource( 1 ), SubResource( 4 ), SubResource( 3 ), SubResource( 2 ) ] +entries = [ SubResource( 1 ), SubResource( 3 ), SubResource( 2 ) ] diff --git a/game/addons/web_pages/classes/WebPage.gd b/game/addons/web_pages/classes/WebPage.gd index a3b48f1..a7f0f4a 100644 --- a/game/addons/web_pages/classes/WebPage.gd +++ b/game/addons/web_pages/classes/WebPage.gd @@ -2,10 +2,24 @@ tool extends WebNode class_name WebPage, "res://addons/web_pages/icons/icon_web_page.svg" +export(bool) var sohuld_render_menu : bool = true + export(Array, Resource) var entries : Array signal entries_changed() +func _handle_request(request : WebServerRequest): + if sohuld_render_menu: + render_menu(request) + + for i in range(entries.size()): + var e : WebPageEntry = entries[i] + + if e: + e.render(request) + + request.compile_and_send_body() + func add_entry(var entry : WebPageEntry, var after : WebPageEntry = null) -> void: if after != null: for i in range(entries.size()): diff --git a/game/addons/web_pages/classes/WebPageEntry.gd b/game/addons/web_pages/classes/WebPageEntry.gd index fc1fb78..1786e33 100644 --- a/game/addons/web_pages/classes/WebPageEntry.gd +++ b/game/addons/web_pages/classes/WebPageEntry.gd @@ -2,7 +2,11 @@ tool extends Resource class_name WebPageEntry, "res://addons/web_pages/icons/icon_web_page_entry.svg" - +func render(request : WebServerRequest): + _render(request) + +func _render(request : WebServerRequest): + pass func get_page_entry_class_name() -> String: return "WebPageEntry" diff --git a/game/addons/web_pages/classes/post_entries/WebPageEntryTitleText.gd b/game/addons/web_pages/classes/post_entries/WebPageEntryTitleText.gd index c49c2fb..5084e4a 100644 --- a/game/addons/web_pages/classes/post_entries/WebPageEntryTitleText.gd +++ b/game/addons/web_pages/classes/post_entries/WebPageEntryTitleText.gd @@ -5,6 +5,8 @@ class_name WebPageEntryTitleText, "res://addons/web_pages/icons/icon_web_page_en export(String) var text : String export(int) var hsize : int = 1 +func _render(request : WebServerRequest): + request.body += "