-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
86 lines (63 loc) · 1.68 KB
/
main.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
from tkinter import *
import os
root = Tk()
postsDirectory = ""
username = ""
password = ""
repository = ""
def gitPush(repository, username, password):
os.chdir(postsDirectory)
#commit
commit=os.popen('git add . && git commit -m "New post"')
print(commit.read())
commit.close()
#push
push=os.popen("git push")
result=push.read()
push.close()
return result
def makePost(x, y, z):
global file
os.chdir(postsDirectory + "/_posts")
print("Making file...")
file = open(x + ".md", "a")
print("Made file.")
print("Adding front...")
file.write("---\nlayout: post\ntitle: " + y + "\n---\n\n")
print("Added front.")
print("Adding content...")
file.write(z)
gitPush(repository, username, password)
def retrieve_input():
global x
global y
global z
# date
xTemp = textBox.get("1.0", "end-1c")
# title
y = textBox2.get("1.0", "end-1c")
# content
z = textBox3.get("1.0", "end-1c")
# file name
x = xTemp + "-" + y
makePost(x, y, z)
T = Text(root, height=2, width=30)
T.pack()
T.insert(END, "Enter the date\nYYYY-MM-DD\n")
textBox = Text(root, height=1, width=40)
textBox.pack()
X = Text(root, height=1, width=30)
X.pack()
X.insert(END, "Enter the title")
textBox2 = Text(root, height=1, width=40)
textBox2.pack()
Y = Text(root, height=1, width=30)
Y.pack()
Y.insert(END, "Enter the content")
textBox3 = Text(root, height=40, width=120)
textBox3.pack()
buttonMake = Button(root, height=1, width=10, text="Finish",
command=lambda: retrieve_input())
#command=lambda: retrieve_input() >>> just means do this when i press the button
buttonMake.pack()
mainloop()