Merge feature/rss into develop
This commit is contained in:
96
myblog/blog/feeds.py
Normal file
96
myblog/blog/feeds.py
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
from django.contrib.syndication.views import Feed
|
||||||
|
from django.urls import reverse
|
||||||
|
from django.shortcuts import get_object_or_404
|
||||||
|
from .models import Post, Category
|
||||||
|
|
||||||
|
|
||||||
|
class LatestPostsFeed(Feed):
|
||||||
|
title = "六桂流芳的com"
|
||||||
|
link = "/rss/"
|
||||||
|
description = "最新博客文章"
|
||||||
|
# 添加content_type使浏览器能正确显示RSS内容
|
||||||
|
content_type = 'application/xml; charset=utf-8'
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
return Post.objects.order_by('-publish_date')[:10]
|
||||||
|
|
||||||
|
def item_title(self, item):
|
||||||
|
return item.title
|
||||||
|
|
||||||
|
def item_description(self, item):
|
||||||
|
return item.get_markdown_content()
|
||||||
|
|
||||||
|
def item_link(self, item):
|
||||||
|
return reverse('detail', args=[item.pk])
|
||||||
|
|
||||||
|
|
||||||
|
# 添加分类RSS Feed
|
||||||
|
class CategoryPostsFeed(Feed):
|
||||||
|
# 添加content_type使浏览器能正确显示RSS内容
|
||||||
|
content_type = 'application/xml; charset=utf-8'
|
||||||
|
|
||||||
|
def get_object(self, request, category_id):
|
||||||
|
return get_object_or_404(Category, pk=category_id)
|
||||||
|
|
||||||
|
def title(self, obj):
|
||||||
|
return f"六桂流芳的com - {obj.name}分类"
|
||||||
|
|
||||||
|
def link(self, obj):
|
||||||
|
return reverse('category_feed', args=[obj.pk])
|
||||||
|
|
||||||
|
def description(self, obj):
|
||||||
|
return f"{obj.name}分类的最新博客文章"
|
||||||
|
|
||||||
|
def items(self, obj):
|
||||||
|
return Post.objects.filter(category=obj).order_by('-publish_date')[:10]
|
||||||
|
|
||||||
|
def item_title(self, item):
|
||||||
|
return item.title
|
||||||
|
|
||||||
|
def item_description(self, item):
|
||||||
|
return item.get_markdown_content()
|
||||||
|
|
||||||
|
def item_link(self, item):
|
||||||
|
return reverse('detail', args=[item.pk])
|
||||||
|
|
||||||
|
|
||||||
|
# 添加最新RSS Feed (与全部的区别在于数量限制)
|
||||||
|
class RecentPostsFeed(Feed):
|
||||||
|
title = "六桂流芳的com - 最新文章"
|
||||||
|
link = "/rss/recent/"
|
||||||
|
description = "最新的博客文章"
|
||||||
|
# 添加content_type使浏览器能正确显示RSS内容
|
||||||
|
content_type = 'application/xml; charset=utf-8'
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
return Post.objects.order_by('-publish_date')[:20]
|
||||||
|
|
||||||
|
def item_title(self, item):
|
||||||
|
return item.title
|
||||||
|
|
||||||
|
def item_description(self, item):
|
||||||
|
return item.get_markdown_content()
|
||||||
|
|
||||||
|
def item_link(self, item):
|
||||||
|
return reverse('detail', args=[item.pk])
|
||||||
|
|
||||||
|
|
||||||
|
# 添加全部RSS Feed
|
||||||
|
class AllPostsFeed(Feed):
|
||||||
|
title = "六桂流芳的com - 全部文章"
|
||||||
|
link = "/rss/all/"
|
||||||
|
description = "全部博客文章"
|
||||||
|
# 添加content_type使浏览器能正确显示RSS内容
|
||||||
|
content_type = 'application/xml; charset=utf-8'
|
||||||
|
|
||||||
|
def items(self):
|
||||||
|
return Post.objects.order_by('-publish_date')
|
||||||
|
|
||||||
|
def item_title(self, item):
|
||||||
|
return item.title
|
||||||
|
|
||||||
|
def item_description(self, item):
|
||||||
|
return item.get_markdown_content()
|
||||||
|
|
||||||
|
def item_link(self, item):
|
||||||
|
return reverse('detail', args=[item.pk])
|
||||||
325
myblog/blog/templates/blog/contact.html
Normal file
325
myblog/blog/templates/blog/contact.html
Normal file
@@ -0,0 +1,325 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>联系我 - 六桂流芳的com</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
width: 250px;
|
||||||
|
padding-right: 20px;
|
||||||
|
border-right: 1px solid #eee;
|
||||||
|
position: -webkit-sticky;
|
||||||
|
position: sticky;
|
||||||
|
top: 20px;
|
||||||
|
align-self: flex-start;
|
||||||
|
height: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar h3 {
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 2px solid #007cba;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul li {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul li a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #666;
|
||||||
|
display: block;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul li a:hover,
|
||||||
|
.sidebar ul li a.active {
|
||||||
|
background-color: #007cba;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box input[type="submit"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
background-color: #007cba;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box input[type="submit"]:hover {
|
||||||
|
background-color: #005a87;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-type {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-type label {
|
||||||
|
display: block;
|
||||||
|
margin: 5px 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-type input[type="radio"] {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content h1 {
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 2px solid #eee;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
background-color: white;
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-info {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
padding: 15px;
|
||||||
|
border-radius: 5px;
|
||||||
|
margin-top: 20px;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-info h3 {
|
||||||
|
margin-top: 0;
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 2px solid #007cba;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-info ul {
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-info li {
|
||||||
|
margin: 10px 0;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加联系我主内容区域样式 */
|
||||||
|
.contact-main {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-main h2 {
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 2px solid #007cba;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-description {
|
||||||
|
margin: 15px 0;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-details {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-details li {
|
||||||
|
padding: 10px 0;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-details li:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-label {
|
||||||
|
font-weight: bold;
|
||||||
|
color: #333;
|
||||||
|
display: inline-block;
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.contact-value {
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加导航栏样式 */
|
||||||
|
.top-nav {
|
||||||
|
background-color: #007cba;
|
||||||
|
padding: 10px 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li {
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li a {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li a:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- 添加网站标题和导航栏 -->
|
||||||
|
<div class="top-nav">
|
||||||
|
<div class="nav-container">
|
||||||
|
<h1 style="text-align: left; margin: 0; padding: 0;">
|
||||||
|
<a href="{% url 'index' %}" style="text-decoration: none; color: white;">六桂流芳的com</a>
|
||||||
|
</h1>
|
||||||
|
<ul class="nav-links">
|
||||||
|
<li><a href="{% url 'index' %}">首页</a></li>
|
||||||
|
<li><a href="{% url 'rss_page' %}">RSS订阅</a></li>
|
||||||
|
<li><a href="{% url 'contact_page' %}">联系我</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="search-box">
|
||||||
|
<form method="get" action="{% url 'index' %}">
|
||||||
|
<input type="text" name="q" placeholder="搜索文章..." value="{{ query|default:'' }}">
|
||||||
|
<div class="search-type">
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="search_type" value="all" checked>
|
||||||
|
全文搜索
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="search_type" value="title">
|
||||||
|
标题搜索
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="search_type" value="content">
|
||||||
|
内容搜索
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" value="搜索">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>文章分类</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="{% url 'index' %}">全部文章</a></li>
|
||||||
|
{% for category in categories %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'index' %}?category={{ category.id }}">
|
||||||
|
{{ category.name }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main-content">
|
||||||
|
<div class="contact-main">
|
||||||
|
<h2>联系我</h2>
|
||||||
|
<div class="contact-description">
|
||||||
|
如果您有任何问题或想与我交流,可以通过以下方式联系我:
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="contact-details">
|
||||||
|
{% if site_settings.contact_email %}
|
||||||
|
<li>
|
||||||
|
<span class="contact-label">邮箱:</span>
|
||||||
|
<span class="contact-value">{{ site_settings.contact_email }}</span>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if site_settings.contact_wechat %}
|
||||||
|
<li>
|
||||||
|
<span class="contact-label">微信:</span>
|
||||||
|
<span class="contact-value">{{ site_settings.contact_wechat }}</span>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if site_settings.contact_linkedin %}
|
||||||
|
<li>
|
||||||
|
<span class="contact-label">LinkedIn:</span>
|
||||||
|
<span class="contact-value">{{ site_settings.contact_linkedin }}</span>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% if site_settings.contact_github %}
|
||||||
|
<li>
|
||||||
|
<span class="contact-label">GitHub:</span>
|
||||||
|
<span class="contact-value">{{ site_settings.contact_github }}</span>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<a href="https://beian.miit.gov.cn/" target="_blank">闽ICP备2023010767号-2</a>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -15,14 +15,14 @@
|
|||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
/ / 修改: 确保容器支持sticky定位 min-height: 100 vh;
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
width: 250px;
|
width: 250px;
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
border-right: 1px solid #eee;
|
border-right: 1px solid #eee;
|
||||||
/ / 修改: 添加侧边栏固定定位相关样式 position: -webkit-sticky;
|
position: -webkit-sticky;
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 20px;
|
top: 20px;
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
@@ -160,35 +160,56 @@
|
|||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info {
|
/* 添加导航栏样式 */
|
||||||
background-color: #f9f9f9;
|
.top-nav {
|
||||||
padding: 15px;
|
background-color: #007cba;
|
||||||
border-radius: 5px;
|
padding: 10px 0;
|
||||||
margin-top: 20px;
|
margin-bottom: 20px;
|
||||||
border: 1px solid #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info h3 {
|
.nav-container {
|
||||||
margin-top: 0;
|
max-width: 1200px;
|
||||||
color: #333;
|
margin: 0 auto;
|
||||||
border-bottom: 2px solid #007cba;
|
padding: 0 20px;
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info ul {
|
.nav-links {
|
||||||
padding-left: 20px;
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info li {
|
.nav-links li {
|
||||||
margin: 10px 0;
|
margin-right: 20px;
|
||||||
color: #666;
|
}
|
||||||
|
|
||||||
|
.nav-links li a {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li a:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.2);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- 添加网站标题 -->
|
<!-- 添加网站标题和导航栏 -->
|
||||||
<div style="max-width: 1200px; margin: 0 auto; padding: 0 20px;">
|
<div class="top-nav">
|
||||||
<h1 style="text-align: left;"><a href="{% url 'index' %}" style="text-decoration: none; color: inherit;">六桂流芳的com</a></h1>
|
<div class="nav-container">
|
||||||
|
<h1 style="text-align: left; margin: 0; padding: 0;">
|
||||||
|
<a href="{% url 'index' %}" style="text-decoration: none; color: white;">六桂流芳的com</a>
|
||||||
|
</h1>
|
||||||
|
<ul class="nav-links">
|
||||||
|
<li><a href="{% url 'index' %}">首页</a></li>
|
||||||
|
<li><a href="{% url 'rss_page' %}">RSS订阅</a></li>
|
||||||
|
<li><a href="{% url 'contact_page' %}">联系我</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -227,25 +248,6 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- 添加联系我模块 -->
|
|
||||||
<div class="contact-info">
|
|
||||||
<h3>联系我</h3>
|
|
||||||
<ul>
|
|
||||||
{% if site_settings.contact_email %}
|
|
||||||
<li>邮箱: {{ site_settings.contact_email }}</li>
|
|
||||||
{% endif %}
|
|
||||||
{% if site_settings.contact_wechat %}
|
|
||||||
<li>微信: {{ site_settings.contact_wechat }}</li>
|
|
||||||
{% endif %}
|
|
||||||
{% if site_settings.contact_linkedin %}
|
|
||||||
<li>LinkedIn: {{ site_settings.contact_linkedin }}</li>
|
|
||||||
{% endif %}
|
|
||||||
{% if site_settings.contact_github %}
|
|
||||||
<li>GitHub: {{ site_settings.contact_github }}</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
|
|||||||
@@ -160,35 +160,56 @@
|
|||||||
footer {
|
footer {
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info {
|
/* 添加导航栏样式 */
|
||||||
background-color: #f9f9f9;
|
.top-nav {
|
||||||
padding: 15px;
|
background-color: #007cba;
|
||||||
border-radius: 5px;
|
padding: 10px 0;
|
||||||
margin-top: 20px;
|
margin-bottom: 20px;
|
||||||
border: 1px solid #eee;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info h3 {
|
.nav-container {
|
||||||
margin-top: 0;
|
max-width: 1200px;
|
||||||
color: #333;
|
margin: 0 auto;
|
||||||
border-bottom: 2px solid #007cba;
|
padding: 0 20px;
|
||||||
padding-bottom: 10px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info ul {
|
.nav-links {
|
||||||
padding-left: 20px;
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
.contact-info li {
|
.nav-links li {
|
||||||
margin: 10px 0;
|
margin-right: 20px;
|
||||||
color: #666;
|
}
|
||||||
|
|
||||||
|
.nav-links li a {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li a:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.2);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<!-- 添加网站标题 -->
|
<!-- 添加网站标题和导航栏 -->
|
||||||
<div style="max-width: 1200px; margin: 0 auto; padding: 0 20px;">
|
<div class="top-nav">
|
||||||
<h1 style="text-align: left;"><a href="{% url 'index' %}" style="text-decoration: none; color: inherit;">六桂流芳的com</a></h1>
|
<div class="nav-container">
|
||||||
|
<h1 style="text-align: left; margin: 0; padding: 0;">
|
||||||
|
<a href="{% url 'index' %}" style="text-decoration: none; color: white;">六桂流芳的com</a>
|
||||||
|
</h1>
|
||||||
|
<ul class="nav-links">
|
||||||
|
<li><a href="{% url 'index' %}">首页</a></li>
|
||||||
|
<li><a href="{% url 'rss_page' %}">RSS订阅</a></li>
|
||||||
|
<li><a href="{% url 'contact_page' %}">联系我</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -231,25 +252,6 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<!-- 添加联系我模块 -->
|
|
||||||
<div class="contact-info">
|
|
||||||
<h3>联系我</h3>
|
|
||||||
<ul>
|
|
||||||
{% if site_settings.contact_email %}
|
|
||||||
<li>邮箱: {{ site_settings.contact_email }}</li>
|
|
||||||
{% endif %}
|
|
||||||
{% if site_settings.contact_wechat %}
|
|
||||||
<li>微信: {{ site_settings.contact_wechat }}</li>
|
|
||||||
{% endif %}
|
|
||||||
{% if site_settings.contact_linkedin %}
|
|
||||||
<li>LinkedIn: {{ site_settings.contact_linkedin }}</li>
|
|
||||||
{% endif %}
|
|
||||||
{% if site_settings.contact_github %}
|
|
||||||
<li>GitHub: {{ site_settings.contact_github }}</li>
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="main-content">
|
<div class="main-content">
|
||||||
|
|||||||
302
myblog/blog/templates/blog/rss.html
Normal file
302
myblog/blog/templates/blog/rss.html
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="zh">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>RSS订阅 - 六桂流芳的com</title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
display: flex;
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 20px;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar {
|
||||||
|
width: 250px;
|
||||||
|
padding-right: 20px;
|
||||||
|
border-right: 1px solid #eee;
|
||||||
|
position: -webkit-sticky;
|
||||||
|
position: sticky;
|
||||||
|
top: 20px;
|
||||||
|
align-self: flex-start;
|
||||||
|
height: fit-content;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar h3 {
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 2px solid #007cba;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul li {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul li a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #666;
|
||||||
|
display: block;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sidebar ul li a:hover,
|
||||||
|
.sidebar ul li a.active {
|
||||||
|
background-color: #007cba;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box input[type="text"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
border: 1px solid #ddd;
|
||||||
|
border-radius: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box input[type="submit"] {
|
||||||
|
width: 100%;
|
||||||
|
padding: 8px;
|
||||||
|
background-color: #007cba;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
border-radius: 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box input[type="submit"]:hover {
|
||||||
|
background-color: #005a87;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-type {
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-type label {
|
||||||
|
display: block;
|
||||||
|
margin: 5px 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-type input[type="radio"] {
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content {
|
||||||
|
flex: 1;
|
||||||
|
padding-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.main-content h1 {
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 2px solid #eee;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
|
width: 100%;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #999;
|
||||||
|
background-color: white;
|
||||||
|
padding: 5px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 添加导航栏样式 */
|
||||||
|
.top-nav {
|
||||||
|
background-color: #007cba;
|
||||||
|
padding: 10px 0;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li {
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li a {
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 4px;
|
||||||
|
transition: background-color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-links li a:hover {
|
||||||
|
background-color: rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* RSS主内容区域样式 */
|
||||||
|
.rss-main {
|
||||||
|
background-color: #f9f9f9;
|
||||||
|
padding: 20px;
|
||||||
|
border-radius: 5px;
|
||||||
|
border: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-main h2 {
|
||||||
|
color: #333;
|
||||||
|
border-bottom: 2px solid #ff6600;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-description {
|
||||||
|
margin: 15px 0;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: #666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-feed-list {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-feed-list li {
|
||||||
|
padding: 10px 0;
|
||||||
|
border-bottom: 1px solid #eee;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-feed-list li:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-feed-link {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #007cba;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-feed-link:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.rss-feed-description {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- 添加网站标题和导航栏 -->
|
||||||
|
<div class="top-nav">
|
||||||
|
<div class="nav-container">
|
||||||
|
<h1 style="text-align: left; margin: 0; padding: 0;">
|
||||||
|
<a href="{% url 'index' %}" style="text-decoration: none; color: white;">六桂流芳的com</a>
|
||||||
|
</h1>
|
||||||
|
<ul class="nav-links">
|
||||||
|
<li><a href="{% url 'index' %}">首页</a></li>
|
||||||
|
<li><a href="{% url 'rss_page' %}">RSS订阅</a></li>
|
||||||
|
<li><a href="{% url 'contact_page' %}">联系我</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="search-box">
|
||||||
|
<form method="get" action="{% url 'index' %}">
|
||||||
|
<input type="text" name="q" placeholder="搜索文章..." value="{{ query|default:'' }}">
|
||||||
|
<div class="search-type">
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="search_type" value="all" checked>
|
||||||
|
全文搜索
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="search_type" value="title">
|
||||||
|
标题搜索
|
||||||
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="radio" name="search_type" value="content">
|
||||||
|
内容搜索
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input type="submit" value="搜索">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3>文章分类</h3>
|
||||||
|
<ul>
|
||||||
|
<li><a href="{% url 'index' %}">全部文章</a></li>
|
||||||
|
{% for category in categories %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'index' %}?category={{ category.id }}">
|
||||||
|
{{ category.name }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="main-content">
|
||||||
|
<div class="rss-main">
|
||||||
|
<h2>RSS订阅</h2>
|
||||||
|
<div class="rss-description">
|
||||||
|
RSS是一种用于发布经常更新的内容的网页格式。通过RSS阅读器,您可以订阅我们的内容,及时获取最新文章更新。
|
||||||
|
点击下面的链接可以在浏览器中查看RSS内容,使用RSS阅读器订阅时请复制链接地址。
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul class="rss-feed-list">
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'rss_feed' %}" class="rss-feed-link" target="_blank">最新文章</a>
|
||||||
|
<div class="rss-feed-description">包含最新的10篇博客文章</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'recent_feed' %}" class="rss-feed-link" target="_blank">最近更新</a>
|
||||||
|
<div class="rss-feed-description">包含最新的20篇博客文章</div>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'all_feed' %}" class="rss-feed-link" target="_blank">全部文章</a>
|
||||||
|
<div class="rss-feed-description">包含所有博客文章</div>
|
||||||
|
</li>
|
||||||
|
{% for category in categories %}
|
||||||
|
<li>
|
||||||
|
<a href="{% url 'category_feed' category.id %}" class="rss-feed-link" target="_blank">{{ category.name }}分类</a>
|
||||||
|
<div class="rss-feed-description">{{ category.name }}分类下的最新博客文章</div>
|
||||||
|
</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer>
|
||||||
|
<a href="https://beian.miit.gov.cn/" target="_blank">闽ICP备2023010767号-2</a>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,7 +1,16 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
from .feeds import LatestPostsFeed, CategoryPostsFeed, RecentPostsFeed, AllPostsFeed
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.index, name='index'),
|
path('', views.index, name='index'),
|
||||||
path('post/<int:post_id>/', views.detail, name='detail'),
|
path('post/<int:post_id>/', views.detail, name='detail'),
|
||||||
]
|
# 添加RSS页面路由
|
||||||
|
path('rss/page/', views.rss_page, name='rss_page'),
|
||||||
|
# 添加联系我页面路由
|
||||||
|
path('contact/', views.contact_page, name='contact_page'),
|
||||||
|
path('rss/', LatestPostsFeed(), name='rss_feed'),
|
||||||
|
path('rss/category/<int:category_id>/', CategoryPostsFeed(), name='category_feed'),
|
||||||
|
path('rss/recent/', RecentPostsFeed(), name='recent_feed'),
|
||||||
|
path('rss/all/', AllPostsFeed(), name='all_feed'),
|
||||||
|
]
|
||||||
@@ -67,3 +67,27 @@ def detail(request, post_id):
|
|||||||
except SiteSettings.DoesNotExist:
|
except SiteSettings.DoesNotExist:
|
||||||
site_settings = None
|
site_settings = None
|
||||||
return render(request, 'blog/detail.html', {'post': post, 'categories': categories, 'site_settings': site_settings})
|
return render(request, 'blog/detail.html', {'post': post, 'categories': categories, 'site_settings': site_settings})
|
||||||
|
|
||||||
|
|
||||||
|
# 添加RSS页面视图
|
||||||
|
def rss_page(request):
|
||||||
|
categories = Category.objects.all()
|
||||||
|
try:
|
||||||
|
site_settings = SiteSettings.objects.first()
|
||||||
|
except SiteSettings.DoesNotExist:
|
||||||
|
site_settings = None
|
||||||
|
return render(request, 'blog/rss.html', {
|
||||||
|
'categories': categories,
|
||||||
|
'site_settings': site_settings
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
# 添加联系我页面视图
|
||||||
|
def contact_page(request):
|
||||||
|
try:
|
||||||
|
site_settings = SiteSettings.objects.first()
|
||||||
|
except SiteSettings.DoesNotExist:
|
||||||
|
site_settings = None
|
||||||
|
return render(request, 'blog/contact.html', {
|
||||||
|
'site_settings': site_settings
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user