file extension option in config to allow for usage on a html server
This commit is contained in:
parent
ff180bf11e
commit
ecc41e86cd
@ -1,16 +1,16 @@
|
|||||||
# File tree:
|
# File tree:
|
||||||
#
|
#
|
||||||
# / -- index.gmi
|
# / -- index.{config.file_extension}
|
||||||
# |
|
# |
|
||||||
# |- post/ -- 1.gmi
|
# |- post/ -- 1.{config.file_extension}
|
||||||
# | |
|
# | |
|
||||||
# | |- 2.gmi
|
# | |- 2.{config.file_extension}
|
||||||
# | |
|
# | |
|
||||||
# | |- 3.gmi
|
# | |- 3.{config.file_extension}
|
||||||
# |
|
# |
|
||||||
# |- user/ -- deadvey.gmi
|
# |- user/ -- deadvey.{config.file_extension}
|
||||||
# |
|
# |
|
||||||
# |- max.gmi
|
# |- max.{config.file_extension}
|
||||||
#
|
#
|
||||||
|
|
||||||
import config
|
import config
|
||||||
@ -29,7 +29,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
def create_user_page(userID, username):
|
def create_user_page(userID, username):
|
||||||
try:
|
try:
|
||||||
with open(f"{config.webroot}/user/{username}.gmi", "w") as userfile:
|
with open(f"{config.webroot}/user/{username}.{config.file_extension}", "w") as userfile:
|
||||||
output.log("Writing posts to userfile")
|
output.log("Writing posts to userfile")
|
||||||
userfile.write(f"# {username}:\n")
|
userfile.write(f"# {username}:\n")
|
||||||
for post_index in range(len(posts.posts)-1,-1,-1):
|
for post_index in range(len(posts.posts)-1,-1,-1):
|
||||||
@ -37,23 +37,23 @@ def create_user_page(userID, username):
|
|||||||
post_content = parse_post.parse_post_format(post_content, post_index, username)
|
post_content = parse_post.parse_post_format(post_content, post_index, username)
|
||||||
userfile.write(post_content)
|
userfile.write(post_content)
|
||||||
except:
|
except:
|
||||||
print(f"Unable to open {username}.gmi")
|
print(f"Unable to open {username}.{config.file_extension}")
|
||||||
initialise.initialise()
|
initialise.initialise()
|
||||||
|
|
||||||
def create_post_page(post_index):
|
def create_post_page(post_index):
|
||||||
try:
|
try:
|
||||||
with open(f"{config.webroot}/post/{post_index}.gmi", "w") as postfile:
|
with open(f"{config.webroot}/post/{post_index}.{config.file_extension}", "w") as postfile:
|
||||||
output.log("Writing post to postfile")
|
output.log("Writing post to postfile")
|
||||||
output.log(posts.posts[post_index])
|
output.log(posts.posts[post_index])
|
||||||
postfile_content = config.post_page_post_format
|
postfile_content = config.post_page_post_format
|
||||||
postfile_content = parse_post.parse_post_format(postfile_content, post_index, users.users[posts.posts[post_index]["userID"]])
|
postfile_content = parse_post.parse_post_format(postfile_content, post_index, users.users[posts.posts[post_index]["userID"]])
|
||||||
postfile.write(postfile_content)
|
postfile.write(postfile_content)
|
||||||
except:
|
except:
|
||||||
print(f"Unable to open {post_index}.gmi")
|
print(f"Unable to open {post_index}.{config.file_extension}")
|
||||||
initialise.initialise()
|
initialise.initialise()
|
||||||
|
|
||||||
def create_timeline():
|
def create_timeline():
|
||||||
with open(f"{config.webroot}/index.gmi", "w") as timeline_file:
|
with open(f"{config.webroot}/index.{config.file_extension}", "w") as timeline_file:
|
||||||
output.log("Writing posts to timeline")
|
output.log("Writing posts to timeline")
|
||||||
for current_post_index in range(len(posts.posts)-1,-1,-1):
|
for current_post_index in range(len(posts.posts)-1,-1,-1):
|
||||||
username = users.users[posts.posts[current_post_index]["userID"]]
|
username = users.users[posts.posts[current_post_index]["userID"]]
|
||||||
|
@ -9,8 +9,8 @@ def parse_post_format(post, post_index, username):
|
|||||||
post = post.replace("%D", datetime.strptime(str(post_data["pubdate"]),"%d%m%YZ%H%M%ST").strftime(config.date_format))
|
post = post.replace("%D", datetime.strptime(str(post_data["pubdate"]),"%d%m%YZ%H%M%ST").strftime(config.date_format))
|
||||||
post = post.replace("%E", datetime.strptime(str(post_data["editdate"]),"%d%m%YZ%H%M%ST").strftime(config.date_format))
|
post = post.replace("%E", datetime.strptime(str(post_data["editdate"]),"%d%m%YZ%H%M%ST").strftime(config.date_format))
|
||||||
post = post.replace("%C", post_data["content"])
|
post = post.replace("%C", post_data["content"])
|
||||||
post = post.replace("%L", f"{config.site_url}/post/{post_index}.gmi")
|
post = post.replace("%L", f"{config.site_url}/post/{post_index}.{config.file_extension}")
|
||||||
post = post.replace("%U", f"{config.site_url}/user/{username}.gmi")
|
post = post.replace("%U", f"{config.site_url}/user/{username}.{config.file_extension}")
|
||||||
post = post.replace("%N", username)
|
post = post.replace("%N", username)
|
||||||
|
|
||||||
return post
|
return post
|
||||||
|
Loading…
x
Reference in New Issue
Block a user