mirror of
https://github.com/Relintai/pandemonium_cms.git
synced 2024-11-12 09:35:02 +01:00
Also moved editing itself to commands.
This commit is contained in:
parent
a0f280fe3f
commit
7ac04c81d1
@ -154,7 +154,11 @@ func web_editor_handle_edit(request : WebServerRequest) -> bool:
|
||||
return true
|
||||
|
||||
request.push_path()
|
||||
entry.handle_edit(request)
|
||||
|
||||
var e : WebPageEntry = entry.handle_edit(request)
|
||||
|
||||
if e:
|
||||
edit_entry_command(entry, e)
|
||||
|
||||
return true
|
||||
|
||||
@ -494,6 +498,8 @@ func _notification(what):
|
||||
if !Engine.editor_hint:
|
||||
_pending_array_mutex.lock()
|
||||
|
||||
var changed : bool = _pending_commands.size() > 0
|
||||
|
||||
for i in range(_pending_commands.size()):
|
||||
var e : WebPageEditCommand = _pending_commands[i] as WebPageEditCommand
|
||||
|
||||
@ -502,6 +508,10 @@ func _notification(what):
|
||||
_pending_commands.clear()
|
||||
|
||||
_pending_array_mutex.unlock()
|
||||
|
||||
if changed:
|
||||
#todo save
|
||||
on_entries_changed()
|
||||
|
||||
func _on_entry_changed():
|
||||
on_entries_changed()
|
||||
|
@ -16,11 +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) -> WebPageEntry:
|
||||
return _handle_edit(request)
|
||||
|
||||
func _handle_edit(request : WebServerRequest) -> void:
|
||||
func _handle_edit(request : WebServerRequest) -> WebPageEntry:
|
||||
request.send_error(404)
|
||||
return null
|
||||
|
||||
func render_edit_bar(request : WebServerRequest) -> void:
|
||||
_render_edit_bar(request)
|
||||
|
@ -40,21 +40,23 @@ func _render(request : WebServerRequest):
|
||||
|
||||
request.body += '>'
|
||||
|
||||
func _handle_edit(request : WebServerRequest) -> void:
|
||||
func _handle_edit(request : WebServerRequest) -> WebPageEntry:
|
||||
if !request.can_edit():
|
||||
#should be ERR_FAIL_COND
|
||||
return
|
||||
return null
|
||||
|
||||
var b : HTMLBuilder = HTMLBuilder.new()
|
||||
|
||||
if request.get_method() == HTTPServerEnums.HTTP_METHOD_POST:
|
||||
image_url = request.get_parameter("image_url")
|
||||
alt = request.get_parameter("image_alt")
|
||||
var e : WebPageEntry = duplicate()
|
||||
|
||||
e.image_url = request.get_parameter("image_url")
|
||||
e.alt = request.get_parameter("image_alt")
|
||||
|
||||
var imgssx : String = request.get_parameter("image_size_x")
|
||||
var imgssy : String = request.get_parameter("image_size_y")
|
||||
|
||||
image_size = Vector2i(imgssx.to_int(), imgssy.to_int())
|
||||
e.image_size = Vector2i(imgssx.to_int(), imgssy.to_int())
|
||||
|
||||
if request.get_file_count() > 0:
|
||||
var fd : PoolByteArray = request.get_file_data(0)
|
||||
@ -66,12 +68,11 @@ func _handle_edit(request : WebServerRequest) -> void:
|
||||
f.store_buffer(fd)
|
||||
f.close()
|
||||
|
||||
image_path = "user://" + fn
|
||||
e.image_path = "user://" + fn
|
||||
|
||||
|
||||
#b.div().f().w("Save successful!").cdiv()
|
||||
emit_changed()
|
||||
request.send_redirect(request.get_url_root_parent(2))
|
||||
return e
|
||||
|
||||
b.div().f().a(request.get_url_root_parent(2)).f().w("<-- back").ca().cdiv()
|
||||
b.br()
|
||||
@ -110,6 +111,7 @@ func _handle_edit(request : WebServerRequest) -> void:
|
||||
|
||||
request.body += b.result
|
||||
request.compile_and_send_body()
|
||||
return null
|
||||
|
||||
func _get_editor() -> Control:
|
||||
var WebPageEntryImageEditor : PackedScene = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryImageEditor.tscn", "PackedScene")
|
||||
|
@ -16,19 +16,21 @@ func set_text(t : String) -> void:
|
||||
func _render(request : WebServerRequest):
|
||||
request.body += compiled_text
|
||||
|
||||
func _handle_edit(request : WebServerRequest) -> void:
|
||||
func _handle_edit(request : WebServerRequest) -> WebPageEntry:
|
||||
if !request.can_edit():
|
||||
#should be ERR_FAIL_COND
|
||||
return
|
||||
return null
|
||||
|
||||
var b : HTMLBuilder = HTMLBuilder.new()
|
||||
|
||||
if request.get_method() == HTTPServerEnums.HTTP_METHOD_POST:
|
||||
set_text(request.get_parameter("text"))
|
||||
var e : WebPageEntry = duplicate()
|
||||
|
||||
e.set_text(request.get_parameter("text"))
|
||||
|
||||
#b.div().f().w("Save successful!").cdiv()
|
||||
emit_changed()
|
||||
request.send_redirect(request.get_url_root_parent(2))
|
||||
return e
|
||||
|
||||
|
||||
b.div().f().a(request.get_url_root_parent(2)).f().w("<-- back").ca().cdiv()
|
||||
b.br()
|
||||
@ -48,6 +50,7 @@ func _handle_edit(request : WebServerRequest) -> void:
|
||||
|
||||
request.body += b.result
|
||||
request.compile_and_send_body()
|
||||
return null
|
||||
|
||||
func _get_editor() -> Control:
|
||||
var WebPageEntryTextEditor : PackedScene = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTextEditor.tscn", "PackedScene")
|
||||
|
@ -11,20 +11,22 @@ func _render(request : WebServerRequest):
|
||||
func get_page_entry_class_name() -> String:
|
||||
return "WebPageEntryTitleText"
|
||||
|
||||
func _handle_edit(request : WebServerRequest) -> void:
|
||||
func _handle_edit(request : WebServerRequest) -> WebPageEntry:
|
||||
if !request.can_edit():
|
||||
#should be ERR_FAIL_COND
|
||||
return
|
||||
return null
|
||||
|
||||
var b : HTMLBuilder = HTMLBuilder.new()
|
||||
|
||||
if request.get_method() == HTTPServerEnums.HTTP_METHOD_POST:
|
||||
text = request.get_parameter("text")
|
||||
var e : WebPageEntry = duplicate()
|
||||
|
||||
#b.div().f().w("Save successful!").cdiv()
|
||||
emit_changed()
|
||||
e.text = request.get_parameter("text")
|
||||
|
||||
request.send_redirect(request.get_url_root_parent(2))
|
||||
|
||||
return e
|
||||
|
||||
b.div().f().a(request.get_url_root_parent(2)).f().w("<-- back").ca().cdiv()
|
||||
b.br()
|
||||
|
||||
@ -40,6 +42,7 @@ func _handle_edit(request : WebServerRequest) -> void:
|
||||
|
||||
request.body += b.result
|
||||
request.compile_and_send_body()
|
||||
return null
|
||||
|
||||
func _get_editor() -> Control:
|
||||
var WebPageEntryTitleTextEditor : PackedScene = ResourceLoader.load("res://addons/web_pages/editor/post_entries/WebPageEntryTitleTextEditor.tscn", "PackedScene")
|
||||
|
Loading…
Reference in New Issue
Block a user