53 lines
1.7 KiB
HTML
53 lines
1.7 KiB
HTML
{% extends 'base.html' %}
|
|
|
|
{% block content %}
|
|
<div class="container">
|
|
<h2>{{ post.post_name }}</h2>
|
|
<p>Created by {{ post.created_by }} - {{ post.creation_date.strftime('%Y-%m-%d %H:%M') }}</p>
|
|
<hr>
|
|
<div>
|
|
<p>{{ post.text }}</p>
|
|
{% for media in post.media %}
|
|
<div class="mt-4">
|
|
<img src="/uploads/{{ media.filename }}" alt="Media" class="img-fluid">
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mt-4">
|
|
<div>
|
|
<a href="{{ url_for('upvote_post', post_id=post.id) }}" class="btn btn-sm btn-success"><i class="fas fa-arrow-up"></i> Upvote ({{ post.upvotes }})</a>
|
|
<a href="{{ url_for('downvote_post', post_id=post.id) }}" class="btn btn-sm btn-danger"><i class="fas fa-arrow-down"></i> Downvote ({{ post.downvotes }})</a>
|
|
</div>
|
|
<div>
|
|
{% if post.comments %}
|
|
<h3 class="mt-4">{{ post.comments.count() }} Comments</h3>
|
|
{% else %}
|
|
<h3>0 Comments</h4>
|
|
{% endif %}
|
|
</div>
|
|
{% if comments %}
|
|
<ul class="list-group">
|
|
{% for comment in comments %}
|
|
<li class="list-group-item">
|
|
<strong>{{ comment.created_by }}</strong>: {{ comment.text }}
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% else %}
|
|
<p>No comments yet. Be the first to comment!</p>
|
|
{% endif %}
|
|
|
|
{% if g.user %}
|
|
<form method="POST">
|
|
<div>
|
|
<textarea class="form-control" id="comment" name="comment" rows="3"></textarea>
|
|
</div>
|
|
<button type="submit" class="btn btn-primary mt-3">Submit</button>
|
|
</form>
|
|
{% else %}
|
|
<p>Log in to leave a comment.</p>
|
|
{% endif %}
|
|
</div>
|
|
{% endblock %}
|