Fixes, and editing setup.

This commit is contained in:
Relintai 2022-08-25 20:56:13 +02:00
parent e36310492c
commit cbb9f99273
4 changed files with 28 additions and 10 deletions

View File

@ -84,7 +84,7 @@ func web_editor_handle_add(request : WebServerRequest) -> bool:
if entry:
add_entry(entry)
request.send_redirect(request.get_url_root(), HTTPServerEnums.HTTP_STATUS_CODE_304_NOT_MODIFIED)
request.send_redirect(request.get_url_root(), HTTPServerEnums.HTTP_STATUS_CODE_303_SEE_OTHER)
return true
else:
request.body += "<div>Error processing your request!</div>"
@ -150,7 +150,8 @@ func web_editor_handle_edit(request : WebServerRequest) -> bool:
request.send_error(404)
return true
#entry.handle_edit(request)
request.push_path()
entry.handle_edit(request)
return true
@ -181,7 +182,7 @@ func web_editor_handle_move_up(request : WebServerRequest) -> bool:
move_entry_up(entry)
#TODO binding missing 2nd default param
request.send_redirect(request.get_url_root_parent(1), HTTPServerEnums.HTTP_STATUS_CODE_302_FOUND)
request.send_redirect(request.get_url_root_parent(1), HTTPServerEnums.HTTP_STATUS_CODE_303_SEE_OTHER)
return true
func web_editor_handle_move_down(request : WebServerRequest) -> bool:
@ -211,7 +212,7 @@ func web_editor_handle_move_down(request : WebServerRequest) -> bool:
move_entry_down(entry)
#TODO binding missing 2nd default param
request.send_redirect(request.get_url_root_parent(1), HTTPServerEnums.HTTP_STATUS_CODE_302_FOUND)
request.send_redirect(request.get_url_root_parent(1), HTTPServerEnums.HTTP_STATUS_CODE_303_SEE_OTHER)
return true
func web_editor_handle_delete(request : WebServerRequest) -> bool:
@ -230,7 +231,7 @@ func web_editor_handle_delete(request : WebServerRequest) -> bool:
return true
var resource_id : int = resource_id_str.to_int()
var entry : WebPageEntry = get_entry_with_id(resource_id)
if !entry:
@ -242,7 +243,7 @@ func web_editor_handle_delete(request : WebServerRequest) -> bool:
if accept == "TRUE":
remove_entry(entry)
request.send_redirect(request.get_url_root(), HTTPServerEnums.HTTP_STATUS_CODE_304_NOT_MODIFIED)
request.send_redirect(request.get_url_root_parent(), HTTPServerEnums.HTTP_STATUS_CODE_303_SEE_OTHER)
return true
else:
request.body += "<div>Error processing your request!</div>"
@ -305,9 +306,10 @@ func get_entry_with_index(index : int) -> WebPageEntry:
func get_entry_with_id(id : int) -> WebPageEntry:
for i in range(entries.size()):
var e : WebPageEntry = entries[i]
if e && e.id == id:
return e
if e:
if (e.id == id):
return e
return null

View File

@ -16,6 +16,12 @@ func render(request : WebServerRequest):
func _render(request : WebServerRequest):
pass
func handle_edit(request : WebServerRequest) -> void:
_handle_edit(request)
func _handle_edit(request : WebServerRequest) -> void:
return
func render_edit_bar(request : WebServerRequest) -> void:
_render_edit_bar(request)

View File

@ -11,3 +11,13 @@ func _render(request : WebServerRequest):
func get_page_entry_class_name() -> String:
return "WebPageEntryTitleText"
func _handle_edit(request : WebServerRequest) -> void:
if !request.can_edit():
# TODO add error macro like methods to global scope for scripting (to the engine)
#should be ERR_FAIL_COND
return
if request.get_method() == HTTPServerEnums.HTTP_METHOD_POST:
pass

View File

@ -41,7 +41,7 @@ _global_script_classes=[ {
} ]
_global_script_class_icons={
@"WebPage": "res://addons/web_pages/icons/icon_web_page.svg",
@"WebPageEntryTitleText": "",
@"WebPageEntryTitleText": "res://addons/web_pages/icons/icon_web_page_entry_title_text.svg",
@"WebPageEntry": "res://addons/web_pages/icons/icon_web_page_entry.svg",
@"WebPageList": "res://addons/web_page_list/icons/icon_web_page_list.svg",
@"WebPageEntryImage": "res://addons/web_pages/icons/icon_web_page_entry_image.svg",