minor changes.

This commit is contained in:
= 2022-05-29 23:32:05 +05:30
parent 3098d31989
commit 237f027c1b
1 changed files with 14 additions and 13 deletions

27
gempost
View File

@ -1,14 +1,18 @@
#!/usr/bin/python
# gempost - gemlog manager for tilde.team, written by ~desertmouse
# gempost - experimental gemlog manager for tilde.team, written by ~desertmouse
from os import system as exec
from os import listdir
from os import getlogin
from sys import argv
from hashlib import sha1
from random import random
import curses
# colored output functions
def prRed(skk): print("\033[91m {}\033[00m" .format(skk))
def prGreen(skk): print("\033[92m {}\033[00m" .format(skk))
@ -125,7 +129,6 @@ def newpost(title, existing_content = None):
exec(f"chmod 745 {wdir}posts.gmi")
exec(f"chmod 745 {wdir}postdir && chmod 745 {wdir}postdir/*")
#print("\nYour post is live!") # yay?
prGreen("\nYour post is live!") # yay?
def manage():
@ -146,10 +149,10 @@ def manage():
for i in postsList:
print(f"{counter}. {i[0]} | {i[1]}")
counter += 1
which = int(input("Select which post to manage: ")) # getting the index of the menu entry the user wants to edit
which = int(input("\nSelect which post to manage (any other key to cancel): ")) # getting the index of the menu entry the user wants to edit
temp = allposts[which]
except:
prRed("\nInvalid selection. Exiting...")
prRed("\n Invalid selection. Exiting...")
return 0
try:
mode = int(input("\nSELECT MODE:\n1 - EDIT\n2 - DELETE\n3 - CANCEL\n-> ")) # what does the user want to do with the selection?
@ -170,15 +173,13 @@ def manage():
print("rebuilt post.gmi, archive.gmi")
prGreen("All done.")
elif (mode == 3):
print("\nReturning to main menu...")
print("\nCancelled.")
else:
pass
# information strings
helpText = """
gempost (v0.6ish) - gemlog manager for tildes
helpText = f"""
gempost (v0.6ish) - *experimental* gemlog manager for tildes
Available arguments:
post - create a new post
@ -195,7 +196,7 @@ Available arguments:
help - display this help text
desc - a brief description of how the program works
qs - Quick Start for new users
\033[93mqs - Quick Start for new users\033[00m
"""
quickStart = """
@ -243,7 +244,7 @@ Directory Structure:
- "postdir/" is where all your gemlog posts are stored.
- "postIndex" is the file that gempost uses to maintain an index of your posts.
- "postPageHeader.gmi" is a file that you can populate with your custom ascii artwork or other text.
This will come before the auto-generated links to your posts written by gempost.
This will come before the auto-generated links to your posts.
Note that this is optional.
- "posts.gmi" is where the program will maintain links to:
- your latest post
@ -296,14 +297,14 @@ elif (arg == "post"):
if (len(title) == 0):
prRed("Post title cannot be empty.")
else:
newpost(input("\nPOST TITLE: "))
newpost(title)
elif (arg == "manage"):
manage()
elif (arg == "purge"): # permanently delete trashed posts
if (len(listdir(f"{wdir}trash/")) == 0):
prYellow("Trash is empty.")
prYellow("Trash is already empty.")
else:
exec(f"rm {wdir}trash/*")
prGreen("Trash cleared.")