Fixed errors regarding blogpostHeader.gmi , added choice to not add ASCII header.

This commit is contained in:
= 2022-06-01 19:36:29 +05:30
parent 1dd3208f0b
commit 4eb2fe8dca
1 changed files with 12 additions and 6 deletions

18
gempost
View File

@ -115,12 +115,18 @@ def newpost(title, existing_content = None):
exec(f"touch {wdir + filename}.gmi") # creating empty file
try:
with open(f"{wdir}blogpostHeader.gmi") as a: # checking if header for each post has been defined
postHeader = a.read()
except FileNotFoundError:
postHeader = ""
exec(f'echo "{postHeader}" | cat > {wdir + filename}.gmi') # header is added to every post if found
ch = input("Add an ASCII Art header to your post? (define it in blogpostHeader.gmi): ([y]/n) ")
if (ch == 'n' or ch == 'N'):
pass
else:
try:
with open(f"{wdir}blogpostHeader.gmi") as a: # checking if header for each post has been defined
postHeader = a.readlines()
postHeader.append(' ')
with open(f"{wdir + filename}.gmi",'w') as f:
f.writelines(postHeader)
except FileNotFoundError:
postHeader = ""
if modified: # add content to file using the existing_content list instead of opening editor
with open(f"{wdir+filename}.gmi", 'w') as o: