Save post content
This commit is contained in:
parent
6a171ad2d5
commit
92d25dc356
@ -1,4 +1,10 @@
|
||||
<div class="post">
|
||||
<h2><!--title--></h2>
|
||||
<time title="<!--timestamp-->"><!--date--></time>
|
||||
<a href="<!--link-->">Link</a>
|
||||
<div class="subreddit"><!--subreddit--></div>
|
||||
<div class="user"><!--user--></div>
|
||||
<div class="body">
|
||||
<!--body-->
|
||||
</div>
|
||||
</div>
|
@ -31,6 +31,10 @@ def get_post_html(post):
|
||||
html = f.read()
|
||||
dt = datetime.utcfromtimestamp(post.created_utc)
|
||||
html = html.replace("<!--title-->", post.title)
|
||||
html = html.replace("<!--subreddit-->", f"/r/{str(post.subreddit)}")
|
||||
html = html.replace("<!--user-->", f"/u/{post.author.name}" if post.author else "[deleted]")
|
||||
html = html.replace("<!--link-->", f"https://reddit.com{post.permalink}")
|
||||
html = html.replace("<!--body-->", post.selftext_html or "")
|
||||
html = html.replace("<!--timestamp-->", str(dt))
|
||||
html = html.replace("<!--date-->", dt.strftime("%d %B, %Y"))
|
||||
return html
|
Loading…
Reference in New Issue
Block a user