# File tree: # # / -- index.{config.file_extension} # | # |- post/ -- 1.{config.file_extension} # | | # | |- 2.{config.file_extension} # | | # | |- 3.{config.file_extension} # | # |- user/ -- deadvey.{config.file_extension} # | # |- max.{config.file_extension} # import config import parse_post import output import initialise try: import posts except: print("No posts database") try: import users except: print("No users database") from datetime import datetime def create_user_page(userID, username): try: 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): post_content = config.user_page_post_format post_content = parse_post.parse_post_format(post_content, post_index, username) userfile.write(post_content) except: 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}.{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}.{config.file_extension}") initialise.initialise() def create_timeline(): 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"]] post = config.timeline_post_format post = parse_post.parse_post_format(post, current_post_index, username) timeline_file.write(post)