{% extends "layout.html" %}

{% block content %}
	<article class="media content-section">
		<img class="{{ theme.image }} article-img" src="{{ url_for('static', filename='pics/' + post.author.image_file) }}">
		<div class="media-body">
			<div class="article-metadata">
				<a class="mr-2" href="{{ url_for('users.user_posts', username=post.author.username) }}" >{{ post.author.username }}</a>
				<small class="text-muted">{{ post.date_posted.strftime('%Y-%m-%d') }}</small>
				{% if post.author == current_user %}	
					<div>
						<a class="btn btn-secondary btn-sm m-1" href="{{ url_for('posts.post_update', post_id=post.id) }}">Update</a>
						<button type="button" class="btn btn-danger btn-sm m-1" data-bs-toggle="modal" data-bs-target="#staticBackdrop">Delete</button>
					</div>
				{% endif %}
			</div>
			<h2 class="article-title">{{ post.title }}</h2>
			<p class="article-content">{{ post.content }}</p>
		</div>
	</article>
	<!-- Modal -->
	<div class="modal fade" id="staticBackdrop" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<h5 class="modal-title" id="staticBackdropLabel">Modal title</h5>
					<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
				</div>
				<div class="modal-body">
					Your last chance, are you Sure?
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
					<form action="{{ url_for('posts.post_delete', post_id=post.id) }}" method="POST">
					<input class="btn btn-danger" type="submit" value="Delete">
				</div>
			</div>
		</div>
	</div>
{% endblock content %}
