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.
DjangoBlog/templates/base.html

887 lines
26 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
{% if category_info.name == '非遗传承' %}
金陵非遗 - 南京非物质文化遗产传承与创新
{% else %}
{{ category_info.name }} - 金陵非遗
{% endif %}
</title>
<style>
/* 南京非遗主题自定义样式 */
:root {
--nj-red: #c62f2f;
--nj-gold: #d4af37;
--nj-brown: #8b4513;
--nj-light-brown: #a0522d;
--primary-color: var(--nj-brown);
--secondary-color: var(--nj-light-brown);
--accent-color: var(--nj-gold);
--text-dark: #2c1810;
--text-light: #5d4037;
--bg-light: #faf3e8;
--bg-white: #fffaf0;
--border-color: #e8d5c4;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Noto Serif SC", "Source Han Serif SC", "Microsoft YaHei", serif;
line-height: 1.7;
color: var(--text-dark);
background: linear-gradient(135deg, #faf3e8 0%, #fffaf0 100%);
min-height: 100vh;
}
/* 头部样式 - 中国风设计 */
.header {
background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
padding: 0;
box-shadow: 0 4px 20px rgba(139, 69, 19, 0.3);
position: relative;
overflow: visible; /* 修复改为visible */
min-height: 180px; /* 确保有足够高度 */
}
.header::before {
content: "";
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4px;
background: linear-gradient(90deg, var(--nj-gold), var(--nj-red), var(--nj-gold));
animation: shimmer 3s infinite;
}
@keyframes shimmer {
0% { background-position: -200% 0; }
100% { background-position: 200% 0; }
}
.nav-container {
max-width: 1400px;
margin: 0 auto;
padding: 0 30px;
position: relative; /* 确保相对定位 */
min-height: 160px; /* 增加最小高度 */
}
.site-brand {
text-align: center;
padding: 20px 0;
border-bottom: 1px solid rgba(255,255,255,0.2);
}
.site-title {
color: #fff;
font-size: 2.5em;
font-weight: 700;
text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
letter-spacing: 4px;
}
.site-subtitle {
color: var(--nj-gold);
font-size: 1.1em;
margin-top: 8px;
font-style: italic;
}
.main-nav {
display: flex;
justify-content: center;
list-style: none;
padding: 15px 0;
}
.main-nav a {
display: block;
padding: 12px 25px;
color: #fff;
text-decoration: none;
font-size: 16px;
font-weight: 500;
transition: all 0.3s ease;
border-radius: 25px;
margin: 0 8px;
position: relative;
overflow: hidden;
}
.main-nav a::before {
content: "";
position: absolute;
top: 0;
left: -100%;
width: 100%;
height: 100%;
background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
transition: left 0.5s;
}
.main-nav a:hover::before {
left: 100%;
}
.main-nav a:hover {
background: rgba(255,255,255,0.1);
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}
/* 当前分类高亮样式 */
.current-category {
background: rgba(255, 255, 255, 0.25);
border: 2px solid var(--nj-gold);
font-weight: 600;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
/* 搜索框样式 */
.search-box {
text-align: center;
padding: 15px 0;
border-top: 1px solid rgba(255,255,255,0.2);
}
.search-box form {
display: inline-flex;
max-width: 500px;
width: 100%;
}
.search-box input {
flex: 1;
padding: 12px 20px;
border: none;
border-radius: 25px 0 0 25px;
font-size: 14px;
outline: none;
}
.search-box button {
background: var(--nj-gold);
color: var(--text-dark);
border: none;
padding: 12px 25px;
border-radius: 0 25px 25px 0;
cursor: pointer;
font-weight: 600;
transition: background 0.3s;
}
.search-box button:hover {
background: #ffd700;
}
/* 用户菜单样式 - 修复版 */
.user-menu {
position: absolute;
top: 20px;
right: 30px;
z-index: 9999;
}
.user-dropdown {
position: relative;
display: inline-block;
}
.user-btn {
display: flex;
align-items: center;
gap: 8px;
background: rgba(255, 255, 255, 0.15);
border: 1px solid rgba(255, 255, 255, 0.3);
color: white;
padding: 10px 18px;
border-radius: 25px;
cursor: pointer;
transition: all 0.3s ease;
backdrop-filter: blur(10px);
font-family: inherit;
}
.user-btn:hover {
background: rgba(255, 255, 255, 0.25);
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.user-avatar {
width: 36px;
height: 36px;
border-radius: 50%;
object-fit: cover;
border: 2px solid var(--nj-gold);
}
.user-avatar-placeholder {
width: 36px;
height: 36px;
border-radius: 50%;
background: linear-gradient(135deg, var(--nj-gold), var(--nj-red));
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
font-size: 16px;
border: 2px solid var(--nj-gold);
}
.username {
font-size: 14px;
font-weight: 500;
}
.dropdown-arrow {
font-size: 10px;
transition: transform 0.3s ease;
margin-left: 5px;
}
.user-dropdown:hover .dropdown-arrow {
transform: rotate(180deg);
}
.dropdown-menu {
position: absolute;
top: 100%;
right: 0;
background: var(--bg-white);
min-width: 220px;
border-radius: 12px;
box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
padding: 10px 0;
margin-top: 8px;
opacity: 0;
visibility: hidden;
transform: translateY(-10px);
transition: all 0.3s ease;
z-index: 10001;
border: 1px solid var(--border-color);
}
.user-dropdown:hover .dropdown-menu {
opacity: 1;
visibility: visible;
transform: translateY(0);
}
.dropdown-item {
display: flex;
align-items: center;
gap: 12px;
padding: 12px 20px;
color: var(--text-dark);
text-decoration: none;
font-size: 14px;
transition: all 0.3s ease;
border: none;
background: none;
width: 100%;
text-align: left;
font-family: inherit;
}
.dropdown-item:hover {
background: var(--bg-light);
color: var(--primary-color);
}
.dropdown-item.logout {
color: var(--nj-red);
}
.dropdown-item.logout:hover {
background: rgba(198, 47, 47, 0.1);
}
.item-icon {
font-size: 16px;
width: 20px;
text-align: center;
}
.dropdown-divider {
height: 1px;
background: var(--border-color);
margin: 8px 15px;
}
/* 未登录状态样式 */
.auth-links {
display: flex;
gap: 15px;
align-items: center;
}
.auth-link {
color: white;
text-decoration: none;
font-size: 14px;
font-weight: 500;
padding: 10px 20px;
border-radius: 20px;
transition: all 0.3s ease;
font-family: inherit;
}
.auth-link:hover {
background: rgba(255, 255, 255, 0.15);
transform: translateY(-2px);
}
.auth-link.register {
background: var(--nj-gold);
color: var(--text-dark);
font-weight: 600;
}
.auth-link.register:hover {
background: #ffd700;
box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}
/* 主要内容布局 */
.main-container {
max-width: 1400px;
margin: 40px auto;
padding: 0 30px;
display: grid;
grid-template-columns: 1fr 350px;
gap: 40px;
}
/* 文章内容区域 */
.content {
background: var(--bg-white);
border-radius: 15px;
box-shadow: 0 10px 30px rgba(139, 69, 19, 0.1);
overflow: hidden;
border: 1px solid var(--border-color);
}
.content-header {
background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
color: white;
padding: 25px 30px;
text-align: center;
}
/* 分类标签样式 */
.category-label {
display: inline-block;
background: rgba(255, 255, 255, 0.2);
padding: 6px 16px;
border-radius: 20px;
font-size: 0.9em;
margin-bottom: 12px;
border: 1px solid var(--nj-gold);
font-weight: 500;
}
.content-header h1 {
font-size: 2em;
margin-bottom: 8px;
text-shadow: 1px 1px 3px rgba(0,0,0,0.3);
}
.content-intro {
font-size: 1.1em;
opacity: 0.95;
max-width: 800px;
margin: 0 auto;
line-height: 1.6;
padding: 0 20px;
}
.posts-list {
padding: 0;
}
/* 文章项样式 */
.post-item {
padding: 35px 30px;
border-bottom: 1px solid var(--border-color);
transition: all 0.3s ease;
position: relative;
}
.post-item::before {
content: "";
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 4px;
background: linear-gradient(to bottom, var(--primary-color), var(--accent-color));
opacity: 0;
transition: opacity 0.3s ease;
}
.post-item:hover {
background: linear-gradient(135deg, #fffaf0, #faf3e8);
transform: translateX(5px);
}
.post-item:hover::before {
opacity: 1;
}
.post-item:last-child {
border-bottom: none;
}
.post-title {
margin-bottom: 20px;
}
.post-title a {
color: var(--text-dark);
text-decoration: none;
font-size: 1.8em;
font-weight: 600;
line-height: 1.3;
transition: color 0.3s ease;
display: block;
}
.post-title a:hover {
color: var(--primary-color);
text-decoration: underline;
text-underline-offset: 3px;
}
.post-meta {
color: var(--text-light);
font-size: 14px;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 25px;
flex-wrap: wrap;
}
.post-meta span {
display: flex;
align-items: center;
gap: 6px;
}
.post-meta i {
font-style: normal;
opacity: 0.7;
}
.post-content {
color: var(--text-light);
font-size: 16px;
line-height: 1.8;
margin-bottom: 25px;
text-align: justify;
}
.read-more {
color: var(--primary-color);
text-decoration: none;
font-weight: 600;
font-size: 15px;
display: inline-flex;
align-items: center;
gap: 8px;
transition: all 0.3s ease;
padding: 8px 16px;
border: 2px solid var(--primary-color);
border-radius: 25px;
}
.read-more:hover {
background: var(--primary-color);
color: white;
transform: translateX(5px);
}
.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;
}
.post-tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.tag {
background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
color: white;
padding: 4px 12px;
border-radius: 15px;
font-size: 12px;
font-weight: 500;
}
/* 非遗徽章样式 */
.heritage-badge {
background: linear-gradient(135deg, var(--nj-red), var(--nj-brown));
color: white;
padding: 4px 12px;
border-radius: 20px;
font-size: 12px;
font-weight: bold;
border: 1px solid var(--nj-gold);
}
.heritage-item {
border-left: 3px solid var(--nj-red);
background: linear-gradient(135deg, #fffaf0, #faf3e8);
}
/* 侧边栏样式 */
.sidebar {
display: flex;
flex-direction: column;
gap: 25px;
}
.sidebar-widget {
background: var(--bg-white);
border-radius: 15px;
box-shadow: 0 8px 25px rgba(139, 69, 19, 0.1);
padding: 25px;
border: 1px solid var(--border-color);
}
.widget-title {
color: var(--primary-color);
font-size: 1.3em;
font-weight: 600;
margin-bottom: 20px;
padding-bottom: 12px;
border-bottom: 2px solid var(--accent-color);
display: flex;
align-items: center;
gap: 10px;
}
.widget-title::before {
content: "◆";
color: var(--secondary-color);
}
.views-list {
list-style: none;
}
.views-list li {
padding: 12px 0;
border-bottom: 1px solid var(--border-color);
color: var(--text-light);
font-size: 14px;
transition: all 0.3s ease;
display: flex;
justify-content: space-between;
align-items: center;
}
.views-list li:hover {
color: var(--primary-color);
transform: translateX(5px);
}
.views-list li:last-child {
border-bottom: none;
}
.view-count {
background: var(--accent-color);
color: white;
padding: 2px 8px;
border-radius: 10px;
font-size: 12px;
font-weight: 500;
}
/* 分类标签云 */
.tag-cloud {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.cloud-tag {
background: linear-gradient(135deg, #e8d5c4, #d7ccc8);
color: var(--text-light);
padding: 6px 12px;
border-radius: 15px;
font-size: 12px;
text-decoration: none;
transition: all 0.3s ease;
}
.cloud-tag:hover {
background: linear-gradient(135deg, var(--accent-color), var(--secondary-color));
color: white;
transform: translateY(-2px);
}
/* 响应式设计 */
@media (max-width: 1024px) {
.main-container {
grid-template-columns: 1fr;
gap: 25px;
}
.sidebar {
width: 100%;
}
}
@media (max-width: 768px) {
.nav-container {
padding: 0 15px;
}
.main-nav {
flex-wrap: wrap;
}
.main-nav a {
padding: 10px 15px;
font-size: 14px;
margin: 4px;
}
.site-title {
font-size: 2em;
}
.main-container {
padding: 0 15px;
margin: 20px auto;
}
.post-item {
padding: 25px 20px;
}
.post-title a {
font-size: 1.5em;
}
.content-header {
padding: 20px;
}
.content-header h1 {
font-size: 1.6em;
}
/* 移动端用户菜单调整 */
.user-menu {
position: static;
margin-top: 15px;
text-align: center;
}
.user-btn {
justify-content: center;
width: 100%;
max-width: 200px;
margin: 0 auto;
}
.dropdown-menu {
right: 50%;
transform: translateX(50%) translateY(-10px);
min-width: 180px;
}
.user-dropdown:hover .dropdown-menu {
transform: translateX(50%) translateY(0);
}
.auth-links {
justify-content: center;
flex-wrap: wrap;
}
}
/* 页脚样式 */
.footer {
background: linear-gradient(135deg, var(--primary-color), var(--text-dark));
color: white;
text-align: center;
padding: 30px 20px;
margin-top: 60px;
}
.footer p {
opacity: 0.8;
font-size: 14px;
}
.logout-form {
margin: 0;
padding: 0;
}
.logout-form button {
width: 100%;
text-align: left;
background: none;
border: none;
cursor: pointer;
font-family: inherit;
font-size: inherit;
}
</style>
</head>
<body>
<header class="header">
<div class="nav-container">
<div class="site-brand">
<h1 class="site-title">金陵非遗</h1>
<div class="site-subtitle">南京非物质文化遗产传承与创新</div>
</div>
<nav class="main-nav">
<a href="{% url 'index' %}" class="{% if current_path == '/' %}current-category{% endif %}">首页</a>
<a href="{% url 'category' 1 %}" class="{% if current_category_id == 1 %}current-category{% endif %}">巧夺天工·工艺</a>
<a href="{% url 'category' 2 %}" class="{% if current_category_id == 2 %}current-category{% endif %}">梨园雅韵·表演</a>
<a href="{% url 'category' 3 %}" class="{% if current_category_id == 3 %}current-category{% endif %}">人间烟火·民俗</a>
<a href="{% url 'category' 4 %}" class="{% if current_category_id == 4 %}current-category{% endif %}">口传心授·文学</a>
<a href="{% url 'category' 5 %}" class="{% if current_category_id == 5 %}current-category{% endif %}">匠心传承·人物</a>
</nav>
<!-- 搜索框 -->
<div class="search-box">
<form action="{% url 'search' %}" method="get">
<input type="text" name="q" placeholder="搜索非遗文章..." value="{{ search_query|default:'' }}">
<button type="submit">搜索</button>
</form>
</div>
<!-- 用户菜单 -->
<div class="user-menu">
{% if user.is_authenticated %}
<div class="user-dropdown">
<button class="user-btn">
{% if user.avatar %}
<img src="{{ user.avatar.url }}" alt="头像" class="user-avatar">
{% else %}
<div class="user-avatar-placeholder">
{{ user.username|first|upper }}
</div>
{% endif %}
<span class="username">{{ user.username }}</span>
<span class="dropdown-arrow"></span>
</button>
<div class="dropdown-menu">
<a href="{% url 'profile' %}" class="dropdown-item">
<span class="item-icon">👤</span>
个人资料
</a>
<a href="{% url 'profile_edit' %}" class="dropdown-item">
<span class="item-icon">⚙️</span>
编辑资料
</a>
<a href="{% url 'create_post' %}" class="dropdown-item">
<span class="item-icon">✍️</span>
发表文章
</a>
<a href="{% url 'user_posts' %}" class="dropdown-item">
<span class="item-icon">📚</span>
我的文章
</a>
<!-- 修改退出登录链接为表单 -->
<div class="dropdown-divider"></div>
<form method="post" action="{% url 'logout' %}" class="logout-form">
{% csrf_token %}
<button type="submit" class="dropdown-item logout">
<span class="item-icon">🚪</span>
退出登录
</button>
</form>
</div>
</div>
{% else %}
<div class="auth-links">
<a href="{% url 'login' %}" class="auth-link">登录</a>
<a href="{% url 'register' %}" class="auth-link register">注册</a>
</div>
{% endif %}
</div>
</div>
</header>
<div class="main-container">
<main class="content">
<div class="content-header">
{% if category_info.label %}
<div class="category-label">{{ category_info.label }}</div>
{% endif %}
<h1>{{ category_info.name }}</h1>
<div class="content-intro">{{ category_info.desc }}</div>
</div>
<div class="posts-list">
{% block content %}
{% endblock %}
</div>
</main>
<aside class="sidebar">
<div class="sidebar-widget">
<h3 class="widget-title">热门文章</h3>
<ul class="views-list">
{% for post in hot_posts %}
<li>
<a href="{% url 'detail' post.id %}" style="color: inherit; text-decoration: none;">
{{ post.title }}
</a>
<span class="view-count">{{ post.views }}</span>
</li>
{% empty %}
<li>暂无热门文章</li>
{% endfor %}
</ul>
</div>
<div class="sidebar-widget">
<h3 class="widget-title">非遗项目</h3>
<div class="tag-cloud">
<a href="{% url 'category' 1 %}" class="cloud-tag">南京云锦</a>
<a href="{% url 'category' 1 %}" class="cloud-tag">南京白局</a>
<a href="{% url 'category' 1 %}" class="cloud-tag">南京评话</a>
<a href="{% url 'category' 1 %}" class="cloud-tag">秦淮灯会</a>
<a href="{% url 'category' 1 %}" class="cloud-tag">南京板鸭</a>
<a href="{% url 'category' 1 %}" class="cloud-tag">南京白话</a>
</div>
</div>
</aside>
</div>
<footer class="footer">
<p>© 2025 金陵非遗文化传承中心 | 传承非物质文化遗产,弘扬中华优秀传统文化</p>
</footer>
</body>
</html>