added option to also initialize index.gmi on init and reset

This commit is contained in:
= 2022-05-30 03:01:04 +05:30
parent fa77564b44
commit 1a76f6abd8
1 changed files with 12 additions and 0 deletions

12
gempost
View File

@ -332,6 +332,12 @@ elif (arg == "purge"): # permanently delete trashed posts
elif (arg == "init"): # initialize public_gemini/ for use with gempost
if (len(listdir(f"{wdir}")) <= 2):
exec(f"touch {wdir}postIndex && mkdir {wdir}postdir/ {wdir}trash/ && chmod 745 {wdir}* && chmod 700 {wdir}trash/")
ch = input("Also create index.gmi ? (y/[n]) ")
if (ch == 'y' or ch == 'Y'):
index_init = [f"# {getlogin()}'s page\n", "\nThis is your homepage. You can customize it however you want by editing this file.\n", "\nJust remember keeping around the link below to point your visitors to your posts!\n", "\n=> ./posts.gmi Posts"]
exec(f"touch {wdir}index.gmi")
with open(f"{wdir}index.gmi", 'w') as i:
i.writelines(index_init)
prGreen('Done. Use "gempost help" to view available arguments.')
else:
prRed('Only your "index.gmi" (and optionally "postPageHeader.gmi") should be there in public_gemini/')
@ -341,6 +347,12 @@ elif (arg == "reset"): # delete all posts and re-initialize public_gemini/ for u
if (input('Type "yes, I understand" to continue: ') == "yes, I understand"):
exec(f"rm -rf {wdir}postdir/ {wdir}trash/ && rm -f {wdir}posts.gmi {indexFile}")
exec(f"touch {wdir}postIndex && mkdir {wdir}postdir/ {wdir}trash/ && chmod 745 {wdir}* && chmod 700 {wdir}trash/")
ch = input("Also create index.gmi ? (y/[n]) ")
if (ch == 'y' or ch == 'Y'):
index_init = [f"# {getlogin()}'s page\n", "\nThis is your homepage. You can customize it however you want by editing this file.\n", "\nJust remember keeping around the link below to point your visitors to your posts!\n", "\n=> ./posts.gmi Posts"]
exec(f"touch {wdir}index.gmi")
with open(f"{wdir}index.gmi", 'w') as i:
i.writelines(index_init)
prYellow("public_gemini/ has been re-initialized successfully.")
else:
print("Cancelled.")