personal_site/templates/admin/dashboard.html
2025-07-05 15:29:33 -05:00

76 lines
No EOL
3.3 KiB
HTML

{% extends "base.html" %}
{% block title %}Admin Dashboard - Your Name{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>Admin Dashboard</h1>
<div>
<a href="{{ url_for('admin_new_post') }}" class="btn btn-primary">New Post</a>
<a href="{{ url_for('admin_logout') }}" class="btn btn-outline-secondary">Logout</a>
</div>
</div>
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ 'danger' if category == 'error' else category }} alert-dismissible fade show">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="card">
<div class="card-header">
<h5 class="mb-0">Blog Posts ({{ posts|length }})</h5>
</div>
<div class="card-body">
{% if posts %}
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Title</th>
<th>Category</th>
<th>Date</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for post in posts %}
<tr>
<td>
<strong>{{ post.title }}</strong><br>
<small class="text-muted">{{ post.excerpt[:100] }}...</small>
</td>
<td><span class="badge bg-secondary">{{ post.category }}</span></td>
<td>{{ post.date }}</td>
<td>
<div class="btn-group btn-group-sm">
<a href="{{ url_for('blog_post', post_id=post.id) }}"
class="btn btn-outline-primary" target="_blank">View</a>
<a href="{{ url_for('admin_edit_post', post_id=post.id) }}"
class="btn btn-outline-warning">Edit</a>
<form method="POST" action="{{ url_for('admin_delete_post', post_id=post.id) }}"
style="display: inline;"
onsubmit="return confirm('Are you sure you want to delete this post?')">
<button type="submit" class="btn btn-outline-danger">Delete</button>
</form>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center py-4">
<p class="text-muted">No blog posts yet.</p>
<a href="{{ url_for('admin_new_post') }}" class="btn btn-primary">Create Your First Post</a>
</div>
{% endif %}
</div>
</div>
{% endblock %}