Post banners using blogpostHeader.gmi
This commit is contained in:
parent
8b7c20484f
commit
1dd3208f0b
28
gempost
28
gempost
|
@ -115,12 +115,19 @@ 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
|
||||
|
||||
if modified: # add content to file using the existing_content list instead of opening editor
|
||||
with open(f"{wdir+filename}.gmi", 'w') as o:
|
||||
o.writelines(existing_content)
|
||||
else:
|
||||
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
|
||||
|
||||
|
@ -228,7 +235,7 @@ proceed with the given steps.
|
|||
|
||||
Quickstart:
|
||||
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
|
||||
|
||||
|
@ -241,7 +248,9 @@ Quickstart:
|
|||
CONGRATULATIONS!
|
||||
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 = """
|
||||
|
@ -253,6 +262,7 @@ Directory Structure:
|
|||
├── postdir/
|
||||
├── postIndex
|
||||
├── postPageHeader.gmi (optional)
|
||||
├── blogpostHeader.gmi (optional)
|
||||
├── posts.gmi
|
||||
└── trash/
|
||||
|
||||
|
@ -260,13 +270,15 @@ 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.
|
||||
Note that this is optional.
|
||||
|
||||
- "postPageHeader.gmi" should contain a text banner that will show on your Posts page.
|
||||
- "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:
|
||||
- your latest post
|
||||
- your 5 most recent 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.
|
||||
"""
|
||||
|
||||
|
@ -330,7 +342,7 @@ elif (arg == "purge"): # permanently delete trashed posts
|
|||
prGreen("Trash cleared.")
|
||||
|
||||
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/")
|
||||
ch = input("Also create index.gmi ? (y/[n]) ")
|
||||
if (ch == 'y' or ch == 'Y'):
|
||||
|
@ -340,7 +352,7 @@ elif (arg == "init"): # initialize public_gemini/ for use with gempost
|
|||
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/')
|
||||
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
|
||||
prRed("Warning: This will delete all your posts.")
|
||||
|
|
Loading…
Reference in New Issue