You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
283 lines
6.3 KiB
283 lines
6.3 KiB
{% extends 'base.html' %}
|
|
|
|
{% block content %}
|
|
<article class="post-detail heritage-item">
|
|
<header class="post-header">
|
|
<h1 class="post-title">{{ post.title }}</h1>
|
|
<div class="post-meta">
|
|
<span><i>👁️</i> {{ post.views }} 次阅读</span>
|
|
<span><i>💬</i> {{ post.comments.count }} 条评论</span>
|
|
<span><i>📅</i> {{ post.created_time|date:"Y-m-d" }}</span>
|
|
<span><i>🏷️</i> {{ post.category.name }}</span>
|
|
<span><i>✍️</i> {{ post.author.username }}</span>
|
|
</div>
|
|
|
|
{% if post.featured_image %}
|
|
<div class="post-image">
|
|
<img src="{{ post.featured_image.url }}" alt="{{ post.title }}" loading="lazy">
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- 非遗徽章 -->
|
|
<div class="post-tags" style="margin-top: 15px;">
|
|
<span class="heritage-badge">非遗传承</span>
|
|
{% for tag in post.primary_tags.all %}
|
|
<span class="tag">{{ tag.name }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
</header>
|
|
|
|
<div class="post-content">
|
|
{{ post.content|linebreaks }}
|
|
</div>
|
|
|
|
<div class="post-footer">
|
|
<div class="post-tags">
|
|
<span class="heritage-badge">{{ post.category.name }}</span>
|
|
{% for tag in post.primary_tags.all %}
|
|
<span class="tag">{{ tag.name }}</span>
|
|
{% endfor %}
|
|
{% for tag in post.secondary_tags.all %}
|
|
<span class="tag">#{{ tag.name }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
</div>
|
|
</article>
|
|
|
|
<!-- 评论区域 -->
|
|
<section class="comments-section">
|
|
<h3 style="color: var(--primary-color); margin-bottom: 25px; font-size: 1.5em;">
|
|
<i>💬</i> 评论 ({{ comments.count }})
|
|
</h3>
|
|
|
|
<!-- 评论表单 -->
|
|
{% if user.is_authenticated %}
|
|
<form method="post" action="{% url 'comments:add_comment' post.id %}" class="comment-form">
|
|
{% csrf_token %}
|
|
<div class="form-group">
|
|
{{ comment_form.content }}
|
|
</div>
|
|
<button type="submit" class="submit-btn">发表评论</button>
|
|
</form>
|
|
{% else %}
|
|
<div class="login-prompt">
|
|
<p>请 <a href="{% url 'login' %}?next={{ request.path }}">登录</a> 后发表评论,或 <a href="{% url 'register' %}?next={{ request.path }}">注册</a> 账号</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- 评论列表 -->
|
|
<div class="comments-list">
|
|
{% for comment in comments %}
|
|
<div class="comment-item">
|
|
<div class="comment-header">
|
|
<span class="comment-author">{{ comment.author.username }}</span>
|
|
<span class="comment-time">{{ comment.created_time|date:"Y-m-d H:i" }}</span>
|
|
</div>
|
|
<div class="comment-content">
|
|
{{ comment.content|linebreaks }}
|
|
</div>
|
|
</div>
|
|
{% empty %}
|
|
<div class="no-comments">
|
|
<p>暂无评论,快来抢沙发吧~</p>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
</section>
|
|
|
|
<style>
|
|
.post-detail {
|
|
padding: 40px;
|
|
margin: 0;
|
|
}
|
|
|
|
.post-header {
|
|
text-align: center;
|
|
margin-bottom: 40px;
|
|
border-bottom: 2px solid var(--border-color);
|
|
padding-bottom: 30px;
|
|
}
|
|
|
|
.post-title {
|
|
font-size: 2.2em;
|
|
color: var(--text-dark);
|
|
margin-bottom: 20px;
|
|
line-height: 1.3;
|
|
}
|
|
|
|
.post-meta {
|
|
color: var(--text-light);
|
|
font-size: 14px;
|
|
margin-bottom: 20px;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 25px;
|
|
flex-wrap: wrap;
|
|
justify-content: center;
|
|
}
|
|
|
|
.post-meta span {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
}
|
|
|
|
.post-image img {
|
|
max-width: 100%;
|
|
height: auto;
|
|
border-radius: 10px;
|
|
margin-top: 20px;
|
|
box-shadow: 0 5px 15px rgba(0,0,0,0.1);
|
|
}
|
|
|
|
.post-content {
|
|
font-size: 16px;
|
|
line-height: 1.8;
|
|
color: var(--text-light);
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.post-content p {
|
|
margin-bottom: 20px;
|
|
text-align: justify;
|
|
}
|
|
|
|
.post-footer {
|
|
color: var(--text-light);
|
|
font-size: 13px;
|
|
margin-top: 25px;
|
|
padding-top: 20px;
|
|
border-top: 1px dashed var(--border-color);
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 15px;
|
|
align-items: center;
|
|
}
|
|
|
|
.comments-section {
|
|
margin-top: 50px;
|
|
padding-top: 30px;
|
|
border-top: 2px solid var(--border-color);
|
|
}
|
|
|
|
.comment-form {
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.comment-form textarea {
|
|
width: 100%;
|
|
padding: 15px;
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 8px;
|
|
resize: vertical;
|
|
min-height: 100px;
|
|
font-family: inherit;
|
|
font-size: 14px;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
.comment-form textarea:focus {
|
|
outline: none;
|
|
border-color: var(--primary-color);
|
|
}
|
|
|
|
.submit-btn {
|
|
background: var(--primary-color);
|
|
color: white;
|
|
border: none;
|
|
padding: 12px 30px;
|
|
border-radius: 25px;
|
|
cursor: pointer;
|
|
margin-top: 15px;
|
|
font-weight: 600;
|
|
transition: all 0.3s;
|
|
}
|
|
|
|
.submit-btn:hover {
|
|
background: var(--secondary-color);
|
|
transform: translateY(-2px);
|
|
}
|
|
|
|
.comment-item {
|
|
background: var(--bg-light);
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
margin-bottom: 15px;
|
|
border-left: 4px solid var(--accent-color);
|
|
transition: transform 0.3s;
|
|
}
|
|
|
|
.comment-item:hover {
|
|
transform: translateX(5px);
|
|
}
|
|
|
|
.comment-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
margin-bottom: 10px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.comment-author {
|
|
font-weight: 600;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
.comment-time {
|
|
color: var(--text-light);
|
|
}
|
|
|
|
.comment-content {
|
|
line-height: 1.6;
|
|
color: var(--text-dark);
|
|
}
|
|
|
|
.no-comments {
|
|
text-align: center;
|
|
color: var(--text-light);
|
|
padding: 40px;
|
|
font-style: italic;
|
|
background: var(--bg-light);
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.login-prompt {
|
|
text-align: center;
|
|
padding: 20px;
|
|
background: var(--bg-light);
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.login-prompt a {
|
|
color: var(--primary-color);
|
|
text-decoration: none;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.login-prompt a:hover {
|
|
text-decoration: underline;
|
|
}
|
|
|
|
/* 响应式设计 */
|
|
@media (max-width: 768px) {
|
|
.post-detail {
|
|
padding: 20px;
|
|
}
|
|
|
|
.post-title {
|
|
font-size: 1.8em;
|
|
}
|
|
|
|
.post-meta {
|
|
gap: 15px;
|
|
font-size: 12px;
|
|
}
|
|
|
|
.comment-header {
|
|
flex-direction: column;
|
|
gap: 5px;
|
|
}
|
|
}
|
|
</style>
|
|
{% endblock %} |