-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.gd
54 lines (36 loc) · 1.25 KB
/
main.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
extends Control
var posttitle
var posttext
var postdesc
var button
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
posttitle = $title
postdesc = $description
posttext = $text
button = $Button
func _on_button_pressed() -> void:
var file = FileAccess.open("posts-template.html", FileAccess.READ)
var content = file.get_as_text()
var time = Time.get_date_dict_from_system()
var datefolder = Time.get_date_string_from_system()
content = content.replace("{{title}}",posttitle.text)
content = content.replace("{{description}}",postdesc.text)
content = content.replace("{{article}}",posttext.text)
content = content.replace("{{date}}",datefolder)
var postFolderToSave = "posts/%s" % [datefolder]
var postFileName = posttitle.text.replace(" ","-")
DirAccess.make_dir_absolute(postFolderToSave)
var postfile = FileAccess.open("%s/%s.html" % [postFolderToSave, postFileName], FileAccess.WRITE)
postfile.store_string(content)
button.text = "Done!"
button.disabled = true
func turnButtonOn():
button.text = "Submit"
button.disabled = false
func _on_text_text_changed() -> void:
turnButtonOn()
func _on_description_text_changed() -> void:
turnButtonOn()
func _on_title_text_changed() -> void:
turnButtonOn()