Content links

This commit is contained in:
Sam Ireland 2020-12-30 23:54:04 +00:00
parent 6f55b74c26
commit e078fbb8b9
2 changed files with 2 additions and 0 deletions

View File

@ -2,6 +2,7 @@
<h2><!--title--></h2>
<time title="<!--timestamp-->"><!--date--></time>
<a href="<!--link-->">Link</a>
<a href="<!--content-link-->">Content Link</a>
<div class="subreddit"><!--subreddit--></div>
<div class="user"><!--user--></div>
<div class="body">

View File

@ -34,6 +34,7 @@ def get_post_html(post):
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("<!--content-link-->", post.url)
html = html.replace("<!--body-->", post.selftext_html or "")
html = html.replace("<!--timestamp-->", str(dt))
html = html.replace("<!--date-->", dt.strftime("%d %B, %Y"))