功能特性: - 前端文章展示 (Markdown渲染、代码高亮) - 后台管理系统 (文章、分类、标签、作者管理) - 图片上传 (点击、拖拽、粘贴) - 网站设置 (Logo、底部宣传图片上传) - 访问统计 (IP记录、趋势图表) - 参考来源、附件支持 - 单端口部署 (16012) 技术栈: - Flask 3.0 + SQLAlchemy - SQLite数据库 - marked.js + highlight.js (Markdown渲染) - Chart.js (统计图表)
112 lines
4.2 KiB
HTML
112 lines
4.2 KiB
HTML
{% extends 'admin/base.html' %}
|
|
|
|
{% block title %}文章管理{% endblock %}
|
|
{% block page_title %}文章管理{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="toolbar">
|
|
<a href="{{ url_for('admin.article_create') }}" class="btn btn-primary">+ 新建文章</a>
|
|
|
|
<div class="filter-group">
|
|
<a href="{{ url_for('admin.articles') }}"
|
|
class="btn {% if current_status is none %}btn-primary{% else %}btn-secondary{% endif %}">
|
|
全部
|
|
</a>
|
|
<a href="{{ url_for('admin.articles', status='published') }}"
|
|
class="btn {% if current_status == 'published' %}btn-primary{% else %}btn-secondary{% endif %}">
|
|
已发布
|
|
</a>
|
|
<a href="{{ url_for('admin.articles', status='draft') }}"
|
|
class="btn {% if current_status == 'draft' %}btn-primary{% else %}btn-secondary{% endif %}">
|
|
草稿
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
{% if articles.items %}
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th width="40%">标题</th>
|
|
<th width="15%">分类</th>
|
|
<th width="10%">状态</th>
|
|
<th width="10%">阅读量</th>
|
|
<th width="15%">更新时间</th>
|
|
<th width="10%">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{% for article in articles.items %}
|
|
<tr>
|
|
<td>
|
|
<a href="{{ url_for('admin.article_edit', article_id=article.id) }}">
|
|
{{ article.title }}
|
|
</a>
|
|
</td>
|
|
<td>{{ article.category.name if article.category else '-' }}</td>
|
|
<td>
|
|
{% if article.is_published %}
|
|
<span class="badge badge-success">已发布</span>
|
|
{% else %}
|
|
<span class="badge badge-warning">草稿</span>
|
|
{% endif %}
|
|
</td>
|
|
<td>{{ article.view_count }}</td>
|
|
<td>{{ article.updated_at|datetime_format('%Y-%m-%d %H:%M') }}</td>
|
|
<td>
|
|
<div class="action-buttons">
|
|
<a href="{{ url_for('admin.article_edit', article_id=article.id) }}"
|
|
class="btn btn-sm">编辑</a>
|
|
<form action="{{ url_for('admin.article_toggle_publish', article_id=article.id) }}"
|
|
method="POST" style="display:inline">
|
|
<button type="submit" class="btn btn-sm btn-secondary">
|
|
{% if article.is_published %}取消发布{% else %}发布{% endif %}
|
|
</button>
|
|
</form>
|
|
<form action="{{ url_for('admin.article_delete', article_id=article.id) }}"
|
|
method="POST" style="display:inline"
|
|
onconfirm="return confirm('确定要删除这篇文章吗?')">
|
|
<button type="submit" class="btn btn-sm btn-danger">删除</button>
|
|
</form>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
|
|
<!-- 分页 -->
|
|
{% if articles.pages > 1 %}
|
|
<div class="pagination">
|
|
{% if articles.has_prev %}
|
|
<a href="{{ url_for('admin.articles', page=articles.prev_num, status=current_status) }}"
|
|
class="page-link">上一页</a>
|
|
{% endif %}
|
|
|
|
{% for page in articles.iter_pages(left_edge=1, right_edge=1, left_current=2, right_current=2) %}
|
|
{% if page %}
|
|
{% if page == articles.page %}
|
|
<span class="page-link active">{{ page }}</span>
|
|
{% else %}
|
|
<a href="{{ url_for('admin.articles', page=page, status=current_status) }}"
|
|
class="page-link">{{ page }}</a>
|
|
{% endif %}
|
|
{% else %}
|
|
<span class="page-link ellipsis">...</span>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if articles.has_next %}
|
|
<a href="{{ url_for('admin.articles', page=articles.next_num, status=current_status) }}"
|
|
class="page-link">下一页</a>
|
|
{% endif %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% else %}
|
|
<div class="empty-state">
|
|
<p>暂无文章</p>
|
|
<a href="{{ url_for('admin.article_create') }}" class="btn btn-primary">创建第一篇文章</a>
|
|
</div>
|
|
{% endif %}
|
|
{% endblock %} |