Post banners using blogpostHeader.gmi

This commit is contained in:
= 2022-06-01 18:47:09 +05:30
parent 8b7c20484f
commit 1dd3208f0b

28
gempost
View File

@ -115,12 +115,19 @@ def newpost(title, existing_content = None):
exec(f"touch {wdir + filename}.gmi") # creating empty file 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
if modified: # add content to file using the existing_content list instead of opening editor if modified: # add content to file using the existing_content list instead of opening editor
with open(f"{wdir+filename}.gmi", 'w') as o: with open(f"{wdir+filename}.gmi", 'w') as o:
o.writelines(existing_content) o.writelines(existing_content)
else: else:
temp = "# " + title # adding title to empty file temp = "# " + title # adding title to empty file
exec(f'echo "{temp}" | cat > {wdir + filename}.gmi') exec(f'echo "{temp}" | cat >> {wdir + filename}.gmi')
exec(f"{editor} {wdir+filename}.gmi") # opening editor exec(f"{editor} {wdir+filename}.gmi") # opening editor
@ -228,7 +235,7 @@ proceed with the given steps.
Quickstart: Quickstart:
STEP 1 STEP 1
Wih only your index.gmi file in public_gemini/ (and optionally "postPageHeader.gmi"), run the following to set everyting up: Wih only your index.gmi file in public_gemini/ , run the following to set everyting up:
gempost init gempost init
@ -241,7 +248,9 @@ Quickstart:
CONGRATULATIONS! CONGRATULATIONS!
You are ready to use gempost. Please just use "gempost help" from now on to only get a list of commands. You are ready to use gempost. Please just use "gempost help" from now on to only get a list of commands.
You may run "gempost desc" to get to know a bit more about how gempost works, along with a single optional feature. You may run "gempost desc" to get to know a bit more about how gempost works, along with two optional features:
- postPageHeader.gmi , and
- blogpostHeader.gmi
""" """
description = """ description = """
@ -253,6 +262,7 @@ Directory Structure:
├── postdir/ ├── postdir/
├── postIndex ├── postIndex
├── postPageHeader.gmi (optional) ├── postPageHeader.gmi (optional)
├── blogpostHeader.gmi (optional)
├── posts.gmi ├── posts.gmi
└── trash/ └── trash/
@ -260,13 +270,15 @@ Directory Structure:
- "postdir/" is where all your gemlog posts are stored. - "postdir/" is where all your gemlog posts are stored.
- "postIndex" is the file that gempost uses to maintain an index of your posts. - "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. - "postPageHeader.gmi" should contain a text banner that will show on your Posts page.
Note that this is optional. - "blogpostHeader.gmi" contains a text banner that will show on top of each of your posts.
- "posts.gmi" is where the program will maintain links to: - "posts.gmi" is where the program will maintain links to:
- your latest post - your latest post
- your 5 most recent posts - your 5 most recent posts
- a link to "archive.gmi" that contains a list of all your posts - a link to "archive.gmi" that contains a list of all your posts
- "trash/" is the directory where gempost keeps your deleted posts. use "gempost purge" to delete its contents. - "trash/" is the directory where gempost keeps your deleted posts. use "gempost purge" to delete its contents.
""" """
@ -330,7 +342,7 @@ elif (arg == "purge"): # permanently delete trashed posts
prGreen("Trash cleared.") prGreen("Trash cleared.")
elif (arg == "init"): # initialize public_gemini/ for use with gempost elif (arg == "init"): # initialize public_gemini/ for use with gempost
if (len(listdir(f"{wdir}")) <= 2): if (len(listdir(f"{wdir}")) <= 1):
exec(f"touch {wdir}postIndex && mkdir {wdir}postdir/ {wdir}trash/ && chmod 745 {wdir}* && chmod 700 {wdir}trash/") 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]) ") ch = input("Also create index.gmi ? (y/[n]) ")
if (ch == 'y' or ch == 'Y'): if (ch == 'y' or ch == 'Y'):
@ -340,7 +352,7 @@ elif (arg == "init"): # initialize public_gemini/ for use with gempost
i.writelines(index_init) i.writelines(index_init)
prGreen('Done. Use "gempost help" to view available arguments.') prGreen('Done. Use "gempost help" to view available arguments.')
else: else:
prRed('Only your "index.gmi" (and optionally "postPageHeader.gmi") should be there in public_gemini/') prRed('Only your "index.gmi" should be there in public_gemini/')
elif (arg == "reset"): # delete all posts and re-initialize public_gemini/ for use with gempost elif (arg == "reset"): # delete all posts and re-initialize public_gemini/ for use with gempost
prRed("Warning: This will delete all your posts.") prRed("Warning: This will delete all your posts.")