Level 2 comments

This commit is contained in:
Sam Ireland 2021-01-02 23:40:17 +00:00
parent 301e95b450
commit 61015c6087
2 changed files with 14 additions and 6 deletions

View File

@ -1,6 +1,9 @@
<div class="comment">
<div class="user"><!--user--></div>
<div class="score"><!--score--></div>
<a href="<!--link-->"><time title="<!--timestamp-->"><!--date--></time></a>
<div class="body"><!--body--></div>
<div class="user"><!--user--></div>
<div class="score"><!--score--></div>
<a href="<!--link-->"><time title="<!--timestamp-->"><!--date--></time></a>
<div class="body"><!--body--></div>
<div class="child-comments">
<!--children-->
</div>
</div>

View File

@ -28,7 +28,7 @@ def get_saved_posts(client):
"""Gets a list of posts that the user has saved."""
return [
saved for saved in client.user.me().saved(limit=20)
saved for saved in client.user.me().saved(limit=None)
if saved.__class__.__name__ == "Submission"
]
@ -175,7 +175,7 @@ def create_post_page_html(post, post_html):
return html
def get_comment_html(comment):
def get_comment_html(comment, children=True):
with open(os.path.join("html", "comment-div.html")) as f:
html = f.read()
dt = datetime.utcfromtimestamp(comment.created_utc)
@ -185,4 +185,9 @@ def get_comment_html(comment):
html = html.replace("<!--link-->", f"https://reddit.com{comment.permalink}")
html = html.replace("<!--timestamp-->", str(dt))
html = html.replace("<!--date-->", dt.strftime("%H:%M - %d %B, %Y"))
if children:
children_html = []
for child in comment.replies:
children_html.append(get_comment_html(child, children=False))
html = html.replace("<!--children-->", "\n".join(children_html))
return html