18 lines
754 B
Python
18 lines
754 B
Python
import config
|
|
from datetime import datetime
|
|
import posts
|
|
|
|
def parse_post_format(post, post_index, username):
|
|
post_data = posts.posts[post_index]
|
|
post = post.replace("%S", config.post_seperator)
|
|
post = post.replace("%T", post_data["title"])
|
|
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("%N", username)
|
|
|
|
return post
|
|
|