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:
|
||||
#
|
||||
# / -- 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
|
||||
@ -29,7 +29,7 @@ from datetime import datetime
|
||||
|
||||
def create_user_page(userID, username):
|
||||
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")
|
||||
userfile.write(f"# {username}:\n")
|
||||
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)
|
||||
userfile.write(post_content)
|
||||
except:
|
||||
print(f"Unable to open {username}.gmi")
|
||||
print(f"Unable to open {username}.{config.file_extension}")
|
||||
initialise.initialise()
|
||||
|
||||
def create_post_page(post_index):
|
||||
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(posts.posts[post_index])
|
||||
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.write(postfile_content)
|
||||
except:
|
||||
print(f"Unable to open {post_index}.gmi")
|
||||
print(f"Unable to open {post_index}.{config.file_extension}")
|
||||
initialise.initialise()
|
||||
|
||||
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")
|
||||
for current_post_index in range(len(posts.posts)-1,-1,-1):
|
||||
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("%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("%L", f"{config.site_url}/post/{post_index}.gmi")
|
||||
post = post.replace("%U", f"{config.site_url}/user/{username}.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}.{config.file_extension}")
|
||||
post = post.replace("%N", username)
|
||||
|
||||
return post
|
||||
|
Loading…
x
Reference in New Issue
Block a user