Files
runnerspace/templates/pages/post.html
Xevion f8e8d0fbaf Add likes/comment counts + like button to individual post viewer
- Only render in jQuery and likes script when a user is logged in
- Possibly we should show the like button but redirect to login page?
2022-03-30 16:49:59 -05:00

40 lines
1.8 KiB
HTML

{% extends 'layouts/index.html' %}
{% set use_jquery = true %}
{% set use_likes = true %}
{% block content %}
<div id="post-{{ post.id }}" class="post-box">
{% if current_user.is_authenticated %}
<i class="fas fa-heart {% if current_user.has_liked_post(post.id) %}liked{% endif %}" onclick="like({{ post.id }})"></i>
{% endif %}
{{ post.text }}
<br>
<div class="post-author">
{% with comment_count = post.comments|length %}
<em>Posted by <a href="{{ url_for('main.view_user', username=post.author.username) }}">{{ post.author.name }}</a></em>
<span title="{{ post.date_posted }}">{{ post.get_time_ago() }} ago</span>. |
<a href="{{ url_for('main.view_post', post_id=post.id) }}"><span> {{ comment_count }} comment{{ comment_count|pluralize }}</span></a>
| <span class="post-like-status">{{ post.get_like_text()|safe }}</span>
{% endwith %}
</div>
<div class="post-comments">
{% if current_user.is_authenticated %}
<div class="post-comment add-comment">
<form method="POST" action="{{ url_for('forms.add_comment', post_id=post.id) }}">
{{ form.csrf_token }}
{{ form.text()|safe }}<input type=submit value="Add Comment">
</form>
</div>
{% endif %}
{% for comment in post.comments %}
<div class="post-comment">
<span class="comment-text">"{{ comment.text }}"</span>
<a class="comment-author"
href="{{ url_for('main.view_user', username=comment.author) }}">{{ comment.author.name }}
</a>
</div>
{% endfor %}
</div>
</div>
{% endblock %}