Test static page image handling implementation.

This commit is contained in:
Relintai 2023-01-03 23:45:51 +01:00
parent 4d6d0eadae
commit 17132860f5
4 changed files with 31 additions and 0 deletions

View File

@ -48,6 +48,12 @@ func copy_folder(path_from : String, path_to : String) -> void:
else:
print("An error occurred when trying to access the path: %s " % path_from)
func copy_file(path_from : String, path_to : String) -> void:
var dir : Directory = Directory.new()
dir.make_dir_recursive(path_to.get_base_dir())
dir.copy(path_from, path_to)
func write_index(n : WebNode, path : String) -> void:
var request : WebServerRequestScriptable = StaticWebServerRequest.new()
request._set_server(self)
@ -77,6 +83,15 @@ func evaluate_web_node(n : WebNode, web_node_path : String, path : String) -> vo
else:
write_index(n, path)
if n.has_method("_get_served_file_list"):
var file_arr : Array = Array()
n._get_served_file_list(file_arr)
for i in range(file_arr.size()):
var f : Array = file_arr[i]
copy_file(f[0], path.plus_file(f[1]))
for c in n.get_children():
if c is WebNode:
if c.uri_segment.empty() || c.uri_segment == "/":

View File

@ -54,6 +54,13 @@ func _handle_request(request : WebServerRequest):
request.compile_and_send_body()
func _get_served_file_list(files_arr : Array):
for i in range(entries.size()):
var e : WebPageEntry = entries[i]
if e:
e._get_served_file_list(files_arr)
func web_editor_try_handle(request : WebServerRequest) -> bool:
var path_segment : String = request.get_current_path_segment()

View File

@ -16,6 +16,9 @@ func render(request : WebServerRequest):
func _render(request : WebServerRequest):
pass
func _get_served_file_list(arr : Array):
pass
func to_dict() -> Dictionary:
return _to_dict()

View File

@ -23,6 +23,12 @@ func _handle_request(request : WebServerRequest) -> bool:
return false
func _get_served_file_list(files_arr : Array):
if image_url.empty() || image_path.empty():
return
files_arr.push_back([ image_path, image_url ])
func _render(request : WebServerRequest):
if image_url.empty() || image_path.empty():
return