pandemonium_cms/game/addons/web_pages/classes/WebPageEntry.gd

53 lines
1.3 KiB
GDScript3
Raw Normal View History

2022-08-25 01:51:27 +02:00
tool
extends Resource
class_name WebPageEntry, "res://addons/web_pages/icons/icon_web_page_entry.svg"
export(int) var id : int = 0
func handle_request(request : WebServerRequest) -> bool:
return _handle_request(request)
func _handle_request(request : WebServerRequest) -> bool:
return false
2022-08-25 15:35:23 +02:00
func render(request : WebServerRequest):
_render(request)
func _render(request : WebServerRequest):
pass
2022-08-25 15:20:18 +02:00
2022-08-25 20:56:13 +02:00
func handle_edit(request : WebServerRequest) -> void:
_handle_edit(request)
func _handle_edit(request : WebServerRequest) -> void:
2022-08-25 21:18:00 +02:00
request.send_error(404)
2022-08-25 20:56:13 +02:00
func render_edit_bar(request : WebServerRequest) -> void:
_render_edit_bar(request)
func _render_edit_bar(request : WebServerRequest) -> void:
var can_edit : bool = request.can_edit()
var can_delete : bool = request.can_delete()
2022-08-25 21:26:15 +02:00
if !can_edit && !can_delete:
return
var hb : HTMLBuilder = HTMLBuilder.new()
hb.div()
if can_edit:
hb.a(request.get_url_root_add("edit/") + str(id)).f().w("Edit").ca().w(" ")
hb.a(request.get_url_root_add("move_up/") + str(id)).f().w("Move Up").ca().w(" ")
hb.a(request.get_url_root_add("move_down/") + str(id)).f().w("Move Down").ca().w(" ")
if can_delete:
hb.a(request.get_url_root_add("delete/") + str(id)).f().w("Delete").ca()
hb.cdiv()
request.body += hb.result
2022-08-25 15:20:18 +02:00
func get_page_entry_class_name() -> String:
return "WebPageEntry"