完善了首页和关于前端页面,以及解决了图片存储方案问题

This commit is contained in:
2026-10-20 04:53:06 +08:00
parent 16a75807ee
commit 7e45fa620e
20 changed files with 625 additions and 96 deletions
+55
View File
@@ -0,0 +1,55 @@
{% extends "base.html" %}
{% block title %}关于 - 人,是一根会思考的芦苇{% endblock %}
{% block content %}
<div style="margin-bottom: 2rem;">
<!-- 头像 + 标题 -->
{% if site_info.avatar %}
<div style="text-align: center; margin-bottom: 2rem;">
<img src="{{ site_info.avatar.url }}" alt="头像"
style="width: 120px; height: 120px; border-radius: 50%; object-fit: cover; border: 2px solid var(--border);">
</div>
{% endif %}
<h2 style="
font-size: 1.3rem;
font-weight: 600;
color: var(--text);
margin-bottom: 1.5rem;
text-align: center;
">{{ site_info.about_title }}</h2>
<!-- 关于内容(支持 HTML) -->
<div class="post-body" style="margin-bottom: 2rem;">
{{ site_info.about_content|safe }}
</div>
<!-- 社交链接 -->
{% if site_info.github_url or site_info.email or site_info.wechat %}
<div style="
margin-top: 2rem;
padding-top: 1.5rem;
border-top: 1px solid var(--border);
font-size: 0.9rem;
color: var(--text-light);
font-family: -apple-system, 'Noto Sans SC', sans-serif;
">
<p style="margin-bottom: 0.5rem; font-weight: 600; color: var(--text);">联系方式</p>
{% if site_info.email %}
<p style="margin-bottom: 0.3rem;">📧 <a href="mailto:{{ site_info.email }}" style="color: var(--text-light); text-decoration: none;">{{ site_info.email }}</a></p>
{% endif %}
{% if site_info.github_url %}
<p style="margin-bottom: 0.3rem;">🐙 <a href="{{ site_info.github_url }}" target="_blank" rel="noopener" style="color: var(--text-light); text-decoration: none;">{{ site_info.github_url }}</a></p>
{% endif %}
{% if site_info.wechat %}
<p style="margin-bottom: 0.3rem;">💬 微信:{{ site_info.wechat }}</p>
{% endif %}
</div>
{% endif %}
<div style="margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); font-family: -apple-system, 'Noto Sans SC', sans-serif;">
<a href="/" style="color: var(--text-light); text-decoration: none;">← 返回首页</a>
</div>
</div>
{% endblock %}
+28 -6
View File
@@ -3,14 +3,18 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}郭安的小站{% endblock %}</title>
<title>{% block title %}人,是一根会思考的芦苇{% endblock %}</title>
<!-- highlight.js 样式(护眼低对比主题) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/styles/github.min.css">
<style>
/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* ===== 基础变量 ===== */
/* ===== 基础变量(✅ 背景改为米黄色) ===== */
:root {
--bg: #fefefe;
--bg: #fdfaf3; /* ✅ 米黄色背景 */
--text: #1a1a1a;
--text-light: #6b6b6b;
--text-muted: #9b9b9b;
@@ -183,8 +187,9 @@
margin-bottom: 0.4em;
}
/* ===== 代码块(✅ 优化 + highlight.js 兼容) ===== */
.post-body pre {
background: var(--code-bg);
background: #f4f4f4;
padding: 1.2em;
border-radius: var(--radius);
overflow-x: auto;
@@ -198,12 +203,19 @@
font-size: 0.9em;
}
.post-body p code, .post-body li code {
.post-body p code,
.post-body li code {
background: var(--code-bg);
padding: 0.15em 0.4em;
border-radius: 3px;
}
/* highlight.js 代码块微调 */
.post-body pre code.hljs {
background: transparent;
padding: 0;
}
/* ===== 分类/标签 ===== */
.tags, .categories {
margin-top: 3rem;
@@ -248,7 +260,7 @@
<body>
<div class="container">
<header>
<h1><a href="/">郭安的小站</a></h1>
<h1><a href="/">人,是一根会思考的芦苇</a></h1>
<nav>
<a href="/">首页</a>
<a href="/archive/">归档</a>
@@ -264,5 +276,15 @@
<p>© 2024 郭安的小站 · 用 Django 构建</p>
</footer>
</div>
<!-- highlight.js 核心脚本 -->
<script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.9.0/build/highlight.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('pre code').forEach(function (block) {
hljs.highlightElement(block);
});
});
</script>
</body>
</html>
-23
View File
@@ -1,23 +0,0 @@
{% extends "base.html" %}
{% load static %}
{% block title %}郭安的小站{% endblock %}
{% block content %}
{% for post in posts %}
<div class="post-item">
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<div class="post-date">{{ post.published_at|date:"Y年m月d日" }}</div>
{% if post.excerpt %}
<div class="post-summary">{{ post.excerpt }}</div>
{% endif %}
</div>
{% empty %}
<div class="post-item" style="text-align: center; padding: 4rem 0; color: var(--text-muted);">
<p style="margin-bottom: 0.5rem;">还没有文章</p>
<p style="font-size: 0.9rem;">
<a href="/admin/" style="color: var(--text-light); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;">去管理后台写一篇</a>
</p>
</div>
{% endfor %}
{% endblock %}
+87
View File
@@ -0,0 +1,87 @@
{% extends "base.html" %}
{% block title %}{{ category.name }} - 郭安的小站{% endblock %}
{% block content %}
<div style="margin-bottom: 2rem;">
<h2 style="
font-size: 1.1rem;
font-weight: 600;
color: var(--text);
margin-bottom: 0.3rem;
">{{ category.name }}</h2>
{% if category.description %}
<p style="font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.5rem;">{{ category.description }}</p>
{% endif %}
{% for post in posts %}
<div class="post-item">
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<div class="post-date">{{ post.published_at|date:"Y年m月d日" }}</div>
{% if post.excerpt %}
<div class="post-summary">{{ post.excerpt }}</div>
{% endif %}
</div>
{% empty %}
<div class="post-item" style="text-align: center; padding: 4rem 0; color: var(--text-muted);">
<p>这个分类下还没有文章</p>
</div>
{% endfor %}
<!-- 分页 -->
{% if posts.paginator.num_pages > 1 %}
<nav style="
margin-top: 3rem;
text-align: center;
font-family: -apple-system, 'Noto Sans SC', sans-serif;
font-size: 0.9rem;
">
{% if posts.has_previous %}
<a href="?page=1" style="margin-right: 0.6rem; color: var(--text-light); text-decoration: none;">« 首页</a>
<a href="?page={{ posts.previous_page_number }}" style="margin-right: 1rem; color: var(--text-light); text-decoration: none;">‹ 上一页</a>
{% else %}
<span style="margin-right: 0.6rem; color: var(--text-muted);">« 首页</span>
<span style="margin-right: 1rem; color: var(--text-muted);">‹ 上一页</span>
{% endif %}
{% for num in posts.paginator.page_range %}
{% if posts.paginator.num_pages <= 9 %}
{% if num == posts.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% else %}
{% if num == 1 or num == posts.paginator.num_pages %}
{% if num == posts.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num >= posts.number|add:'-2' and num <= posts.number|add:'2' %}
{% if num == posts.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num == posts.number|add:'-3' or num == posts.number|add:'3' %}
<span style="margin: 0 0.2rem; color: var(--text-muted);">…</span>
{% endif %}
{% endif %}
{% endfor %}
{% if posts.has_next %}
<a href="?page={{ posts.next_page_number }}" style="margin-left: 1rem; color: var(--text-light); text-decoration: none;">下一页 ›</a>
<a href="?page={{ posts.paginator.num_pages }}" style="margin-left: 0.6rem; color: var(--text-light); text-decoration: none;">末页 »</a>
{% else %}
<span style="margin-left: 1rem; color: var(--text-muted);">下一页 ›</span>
<span style="margin-left: 0.6rem; color: var(--text-muted);">末页 »</span>
{% endif %}
</nav>
{% endif %}
<div style="margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted); font-family: -apple-system, 'Noto Sans SC', sans-serif;">
<a href="/" style="color: var(--text-light); text-decoration: none;">← 返回分类列表</a>
</div>
</div>
{% endblock %}
+92
View File
@@ -0,0 +1,92 @@
{% extends "base.html" %}
{% block title %}郭安的小站{% endblock %}
{% block content %}
<div style="margin-bottom: 2rem;">
<h2 style="
font-size: 1.1rem;
font-weight: 600;
color: var(--text);
margin-bottom: 1.5rem;
padding-bottom: 0.8rem;
border-bottom: 1px solid var(--border);
">分类</h2>
{% for category in categories %}
<div class="post-item">
<h2>
<a href="{{ category.get_absolute_url }}">{{ category.name }}</a>
</h2>
<div style="
font-size: 0.85rem;
color: var(--text-muted);
font-family: -apple-system, 'Noto Sans SC', sans-serif;
margin-top: 0.3rem;
">
{{ category.posts.count }} 篇文章
{% if category.description %} · {{ category.description }}{% endif %}
</div>
</div>
{% empty %}
<div class="post-item" style="text-align: center; padding: 4rem 0; color: var(--text-muted);">
<p style="margin-bottom: 0.5rem;">还没有分类</p>
<p style="font-size: 0.9rem;">
<a href="/admin/" style="color: var(--text-light); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;">去管理后台创建一个</a>
</p>
</div>
{% endfor %}
<!-- ✅ 分页 -->
{% if categories.paginator.num_pages > 1 %}
<nav style="
margin-top: 3rem;
text-align: center;
font-family: -apple-system, 'Noto Sans SC', sans-serif;
font-size: 0.9rem;
">
{% if categories.has_previous %}
<a href="?page=1" style="margin-right: 0.6rem; color: var(--text-light); text-decoration: none;">« 首页</a>
<a href="?page={{ categories.previous_page_number }}" style="margin-right: 1rem; color: var(--text-light); text-decoration: none;">‹ 上一页</a>
{% else %}
<span style="margin-right: 0.6rem; color: var(--text-muted);">« 首页</span>
<span style="margin-right: 1rem; color: var(--text-muted);">‹ 上一页</span>
{% endif %}
{% for num in categories.paginator.page_range %}
{% if categories.paginator.num_pages <= 9 %}
{% if num == categories.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% else %}
{% if num == 1 or num == categories.paginator.num_pages %}
{% if num == categories.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num >= categories.number|add:'-2' and num <= categories.number|add:'2' %}
{% if num == categories.number %}
<span style="margin: 0 0.3rem; color: var(--bg); background: var(--text); padding: 0.2rem 0.6rem; border-radius: var(--radius); font-weight: 600;">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num == categories.number|add:'-3' or num == categories.number|add:'3' %}
<span style="margin: 0 0.2rem; color: var(--text-muted);">…</span>
{% endif %}
{% endif %}
{% endfor %}
{% if categories.has_next %}
<a href="?page={{ categories.next_page_number }}" style="margin-left: 1rem; color: var(--text-light); text-decoration: none;">下一页 ›</a>
<a href="?page={{ categories.paginator.num_pages }}" style="margin-left: 0.6rem; color: var(--text-light); text-decoration: none;">末页 »</a>
{% else %}
<span style="margin-left: 1rem; color: var(--text-muted);">下一页 ›</span>
<span style="margin-left: 0.6rem; color: var(--text-muted);">末页 »</span>
{% endif %}
</nav>
{% endif %}
</div>
{% endblock %}
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% load static %}
{% block title %}{{ post.title }} - 郭安的小站{% endblock %}
{% block title %}{{ post.title }} - 人,是一根会思考的芦苇{% endblock %}
{% block content %}
<article>
+117
View File
@@ -0,0 +1,117 @@
{% extends "base.html" %}
{% load static %}
{% block title %}郭安的小站{% endblock %}
{% block content %}
{% for post in posts %}
<div class="post-item">
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<div class="post-date">{{ post.published_at|date:"Y年m月d日" }}</div>
{% if post.excerpt %}
<div class="post-summary">{{ post.excerpt }}</div>
{% endif %}
</div>
{% empty %}
<div class="post-item" style="text-align: center; padding: 4rem 0; color: var(--text-muted);">
<p style="margin-bottom: 0.5rem;">还没有文章</p>
<p style="font-size: 0.9rem;">
<a href="/admin/" style="color: var(--text-light); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px;">去管理后台写一篇</a>
</p>
</div>
{% endfor %}
<!-- ✅ 分页组件(可点击页码 + 智能省略) -->
{% if posts.paginator.num_pages > 1 %}
<nav style="
margin-top: 3rem;
text-align: center;
font-family: -apple-system, 'Noto Sans SC', sans-serif;
font-size: 0.9rem;
">
<!-- 首页 -->
{% if posts.has_previous %}
<a href="?page=1" style="margin-right: 0.6rem; color: var(--text-light); text-decoration: none;">« 首页</a>
{% else %}
<span style="margin-right: 0.6rem; color: var(--text-muted);">« 首页</span>
{% endif %}
<!-- 上一页 -->
{% if posts.has_previous %}
<a href="?page={{ posts.previous_page_number }}" style="margin-right: 1rem; color: var(--text-light); text-decoration: none;">‹ 上一页</a>
{% else %}
<span style="margin-right: 1rem; color: var(--text-muted);">‹ 上一页</span>
{% endif %}
<!-- ✅ 页码列表(智能省略) -->
{% for num in posts.paginator.page_range %}
{% if posts.paginator.num_pages <= 9 %}
<!-- 总页数 ≤ 9:全部显示 -->
{% if num == posts.number %}
<span style="
margin: 0 0.3rem;
color: var(--bg);
background: var(--text);
padding: 0.2rem 0.6rem;
border-radius: var(--radius);
font-weight: 600;
">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% else %}
<!-- 总页数 > 9:智能省略 -->
{% if num == 1 or num == posts.paginator.num_pages %}
<!-- 第一页 & 最后一页始终显示 -->
{% if num == posts.number %}
<span style="
margin: 0 0.3rem;
color: var(--bg);
background: var(--text);
padding: 0.2rem 0.6rem;
border-radius: var(--radius);
font-weight: 600;
">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num >= posts.number|add:'-2' and num <= posts.number|add:'2' %}
<!-- 当前页前后 2 页 -->
{% if num == posts.number %}
<span style="
margin: 0 0.3rem;
color: var(--bg);
background: var(--text);
padding: 0.2rem 0.6rem;
border-radius: var(--radius);
font-weight: 600;
">{{ num }}</span>
{% else %}
<a href="?page={{ num }}" style="margin: 0 0.3rem; color: var(--text-light); text-decoration: none;">{{ num }}</a>
{% endif %}
{% elif num == posts.number|add:'-3' or num == posts.number|add:'3' %}
<!-- 省略号 -->
<span style="margin: 0 0.2rem; color: var(--text-muted);">…</span>
{% endif %}
{% endif %}
{% endfor %}
<!-- 下一页 -->
{% if posts.has_next %}
<a href="?page={{ posts.next_page_number }}" style="margin-left: 1rem; color: var(--text-light); text-decoration: none;">下一页 ›</a>
{% else %}
<span style="margin-left: 1rem; color: var(--text-muted);">下一页 ›</span>
{% endif %}
<!-- 末页 -->
{% if posts.has_next %}
<a href="?page={{ posts.paginator.num_pages }}" style="margin-left: 0.6rem; color: var(--text-light); text-decoration: none;">末页 »</a>
{% else %}
<span style="margin-left: 0.6rem; color: var(--text-muted);">末页 »</span>
{% endif %}
</nav>
{% endif %}
{% endblock %}
+29
View File
@@ -0,0 +1,29 @@
{% extends "base.html" %}
{% block title %}{{ tag.name }} - 郭安的小站{% endblock %}
{% block content %}
<div style="margin-bottom: 2rem;">
<h2 style="font-size: 1.1rem; font-weight: 600; color: var(--text); margin-bottom: 1.5rem;">
🏷 {{ tag.name }}
</h2>
{% for post in posts %}
<div class="post-item">
<h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
<div class="post-date">{{ post.published_at|date:"Y年m月d日" }}</div>
{% if post.excerpt %}
<div class="post-summary">{{ post.excerpt }}</div>
{% endif %}
</div>
{% empty %}
<div class="post-item" style="text-align: center; padding: 4rem 0; color: var(--text-muted);">
<p>这个标签下还没有文章</p>
</div>
{% endfor %}
<div style="margin-top: 2rem; padding-top: 1.5rem; border-top: 1px solid var(--border); font-size: 0.85rem; color: var(--text-muted);">
<a href="/" style="color: var(--text-light); text-decoration: none;">← 返回首页</a>
</div>
</div>
{% endblock %}