pull/8/head
“3063176711@qq.com” 4 months ago
commit 32296a1d2e

@ -1,2 +0,0 @@
# django

@ -0,0 +1,521 @@
/* ==========================================================================
========================================================================== */
.breadcrumb
div {
display: inline;
font-size: 13px;
margin-left: -3px;
}
/* ==========================================================================
========================================================================== */
/* 回到顶部按钮容器定位 */
#wp-auto-top {
position: fixed;
top: 45%;
right: 50%;
display: block;
margin-right: -540px;
z-index: 9999;
}
/* 回到顶部按钮通用样式 */
#wp-auto-top-top, #wp-auto-top-comment, #wp-auto-top-bottom {
background: url(https://www.lylinux.org/wp-content/plugins/wp-auto-top/img/1.png) no-repeat;
position: relative;
cursor: pointer;
height: 25px;
width: 29px;
margin: 10px 0 0;
}
/* 评论按钮特定样式 */
#wp-auto-top-comment {
background-position: left -30px;
height: 32px;
}
/* 底部按钮特定样式 */
#wp-auto-top-bottom {
background-position: left -68px;
}
/* 按钮悬停效果 */
#wp-auto-top-comment:hover {
background-position: right -30px;
}
#wp-auto-top-top:hover {
background-position: right 0;
}
#wp-auto-top-bottom:hover {
background-position: right -68px;
}
/* ==========================================================================
========================================================================== */
.widget-login {
margin-top: 15px !important;
}
/* ==========================================================================
========================================================================== */
/* 评论区域顶部间距 */
#comments {
margin-top: 20px;
}
/* 隐藏pingback列表容器 */
#pinglist-container {
display: none;
}
/* 评论标签页样式 */
.comment-tabs {
margin-bottom: 20px;
font-size: 15px;
border-bottom: 2px solid #e5e5e5;
}
.comment-tabs li {
float: left;
margin-bottom: -2px;
}
.comment-tabs li a {
display: block;
padding: 0 10px 10px;
font-weight: 600;
color: #aaa;
border-bottom: 2px solid #e5e5e5;
}
.comment-tabs li a:hover {
color: #444;
border-color: #ccc;
}
.comment-tabs li span {
margin-left: 8px;
padding: 0 6px;
border-radius: 4px;
background-color: #e5e5e5;
}
.comment-tabs li i {
margin-right: 6px;
}
.comment-tabs li.active a {
color: #e8554e;
border-bottom-color: #e8554e;
}
/* 评论列表样式 */
.commentlist, .pinglist {
margin-bottom: 20px;
}
.commentlist li, .pinglist li {
padding-left: 60px;
font-size: 14px;
line-height: 22px;
font-weight: 400;
}
.commentlist .comment-body, .pinglist li {
position: relative;
padding-bottom: 20px;
clear: both;
word-break: break-all;
}
.commentlist .comment-author,
.commentlist .comment-meta,
.commentlist .comment-awaiting-moderation {
float: left;
display: block;
font-size: 13px;
line-height: 22px;
}
.commentlist .comment-author {
margin-right: 6px;
}
.commentlist .fn, .pinglist .ping-link {
color: #444;
font-size: 13px;
font-style: normal;
font-weight: 600;
}
.commentlist .says {
display: none;
}
.commentlist .avatar {
position: absolute;
left: -60px;
top: 0;
width: 48px;
height: 48px;
border-radius: 100%;
}
.commentlist .comment-meta:before, .pinglist .ping-meta:before {
vertical-align: 4%;
margin-right: 3px;
font-size: 10px;
font-family: FontAwesome;
color: #ccc;
}
.commentlist .comment-meta a, .pinglist .ping-meta {
color: #aaa;
}
.commentlist .reply {
font-size: 13px;
line-height: 16px;
}
.commentlist .reply a,
.commentlist .comment-reply-chain {
color: #aaa;
}
.commentlist .reply a:hover,
.commentlist .comment-reply-chain:hover {
color: #444;
}
.comment-awaiting-moderation {
color: #e8554e;
font-style: normal;
}
/* pingback 列表样式 */
.pinglist li {
padding-left: 0;
}
/* 评论文本样式 */
.commentlist .comment-body p {
margin-bottom: 8px;
color: #777;
clear: both;
}
.commentlist .comment-body strong {
font-weight: 600;
}
.commentlist .comment-body ol li {
margin-left: 2em;
padding: 0;
list-style: decimal;
}
.commentlist .comment-body ul li {
margin-left: 2em;
padding: 0;
list-style: square;
}
/* 文章作者和管理员评论样式 */
.commentlist li.bypostauthor > .comment-body:after,
.commentlist li.comment-author-admin > .comment-body:after {
display: block;
position: absolute;
content: "\f040";
width: 12px;
line-height: 12px;
font-style: normal;
font-family: FontAwesome;
text-align: center;
color: #fff;
background-color: #e8554e;
}
.commentlist li.comment-author-admin > .comment-body:after {
content: "\f005"; /* 管理员使用星形图标 */
}
.commentlist li.bypostauthor > .comment-body:after,
.commentlist li.comment-author-admin > .comment-body:after {
padding: 3px;
top: 32px;
left: -28px;
font-size: 12px;
border-radius: 100%;
}
.commentlist li li.bypostauthor > .comment-body:after,
.commentlist li li.comment-author-admin > .comment-body:after {
padding: 2px;
top: 22px;
left: -26px;
font-size: 10px;
border-radius: 100%;
}
/* 子评论样式 */
.commentlist li ul {
}
.commentlist li li {
margin: 0;
padding-left: 48px;
}
.commentlist li li .avatar {
top: 0;
left: -48px;
width: 36px;
height: 36px;
}
.commentlist li li .comment-meta {
left: 70px;
}
/* 评论导航样式 */
.comments-nav {
margin-bottom: 20px;
}
.comments-nav a {
font-weight: 600;
}
.comments-nav .nav-previous {
float: left;
}
.comments-nav .nav-next {
float: right;
}
/* 评论表单样式 */
.logged-in-as,
.comment-notes,
.form-allowed-tags {
display: none;
}
/* 设置评论容器相对定位 */
#respond {
position: relative;
}
/* 回复标题的默认下边距 */
#reply-title {
margin-bottom: 20px;
}
/* 针对列表项中的回复标题进行特殊处理:隐藏并重置尺寸 */
li #reply-title {
margin: 0 !important;
padding: 0;
height: 0;
font-size: 0;
border-top: 0;
}
/* 取消回复链接的基本样式设置 */
#cancel-comment-reply-link {
float: right;
bottom: 26px;
right: 20px;
font-size: 12px;
color: #999;
}
/* 取消回复链接悬停时的颜色变化 */
#cancel-comment-reply-link:hover {
color: #777;
}
/* 评论表单整体样式 */
#commentform {
margin-bottom: 20px;
padding: 10px 20px 20px;
border-radius: 4px;
background-color: #e5e5e5;
}
/* 表单作者字段左浮动占宽48% */
#commentform p.comment-form-author {
float: left;
width: 48%;
}
/* 表单邮箱字段右浮动占宽48% */
#commentform p.comment-form-email {
float: right;
width: 48%;
}
/* URL 和评论正文字段清除浮动并独占一行 */
#commentform p.comment-form-url,
#commentform p.comment-form-comment {
clear: both;
}
/* 表单标签统一显示为块级元素,并设置上下内边距与字体加粗 */
#commentform label {
display: block;
padding: 6px 0;
font-weight: 600;
}
/* 输入框和文本域最大宽度限制为父容器100%,且默认撑满 */
#commentform input[type="text"],
#commentform textarea {
max-width: 100%;
width: 100%;
}
/* 文本域高度固定为100像素 */
#commentform textarea {
height: 100px;
}
/* 提交按钮段落上外边距调整 */
#commentform p.form-submit {
margin-top: 10px;
}
/* 登录状态下回复标题保持标准间距 */
.logged-in #reply-title {
margin-bottom: 20px;
}
/* 登录状态下的评论正文字段增加顶部间距 */
.logged-in #commentform p.comment-form-comment {
margin-top: 10px;
}
/* 登录状态下评论正文标签隐藏 */
.logged-in #commentform p.comment-form-comment label {
display: none;
}
/* 统一标题类(包括回复标题)的基础样式 */
.heading,
#reply-title {
margin-bottom: 1em;
font-size: 18px;
font-weight: 600;
text-transform: uppercase;
color: #222;
}
/* 标题图标样式设置 */
.heading i {
margin-right: 6px;
font-size: 22px;
}
/* 清除浮动伪类 before */
.group:before {
content: "";
display: table;
}
/* 清除浮动伪类 after */
.group:after {
content: "";
display: table;
clear: both;
}
/* 取消评论按钮基础样式重置 */
.cancel-comment {
margin: 0;
padding: 0;
border: 0;
font: inherit;
vertical-align: baseline;
}
/* 返回顶部火箭图标的初始位置及基本属性 */
#rocket {
position: fixed;
right: 50px;
bottom: 50px;
display: block;
visibility: hidden;
width: 26px;
height: 48px;
background: url("data:image/png;base64,...") no-repeat 50% 0;
cursor: pointer;
-webkit-transition: all 0s;
transition: all 0s;
}
/* 火箭图标鼠标悬停时背景图片偏移以切换状态 */
#rocket:hover {
background-position: 50% -62px;
}
/* 显示火箭图标 */
#rocket.show {
visibility: visible;
opacity: 1;
}
/* 触发动画时火箭图标的状态更新与动画绑定 */
#rocket.move {
background-position: 50% -62px;
-webkit-animation: toTop .8s ease-in;
animation: toTop .8s ease-in;
animation-fill-mode: forwards;
-webkit-animation-fill-mode: forwards;
}
/* Markdown提示文字样式设置 */
.comment-markdown {
float: right;
font-size: small;
}
/* 面包屑导航容器样式 */
.breadcrumb {
margin-bottom: 20px;
list-style: none;
border-radius: 4px;
}
/* 面包屑导航项横向排列 */
.breadcrumb > li {
display: inline-block;
}
/* 面包屑导航项之间的分隔符 */
.breadcrumb > li + li:before {
color: #ccc;
content: "/\00a0";
}
/* 当前激活的面包屑导航项颜色 */
.breadcrumb > .active {
color: #777;
}
/* 分割线样式(当前被注释掉) */
.break_line {
height: 1px;
border: none;
/*border-top: 1px dashed #f5d6d6;*/
}

@ -1,47 +1,49 @@
from django.contrib import admin
from django.urls import reverse
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _
from django.contrib import admin# 导入Django admin相关模块用于自定义后台管理
from django.urls import reverse# 导入reverse函数用于生成URL反向解析
from django.utils.html import format_html# 导入format_html用于安全生成HTML内容防止XSS攻击
from django.utils.translation import gettext_lazy as _# 导入gettext_lazy用于国际化翻译惰性加载优化性能
def disable_commentstatus(modeladmin, request, queryset):
queryset.update(is_enable=False)
def disable_commentstatus(modeladmin, request, queryset):# 自定义批量操作:禁用评论状态
queryset.update(is_enable=False)# 将选中的评论记录批量更新is_enable字段为False禁用
def enable_commentstatus(modeladmin, request, queryset):
queryset.update(is_enable=True)
def enable_commentstatus(modeladmin, request, queryset):# 自定义批量操作:启用评论状态
queryset.update(is_enable=True) # 将选中的评论记录批量更新is_enable字段为True启用
disable_commentstatus.short_description = _('Disable comments')
disable_commentstatus.short_description = _('Disable comments')# 为批量操作设置显示名称(支持国际化)
enable_commentstatus.short_description = _('Enable comments')
# 自定义评论模型的Admin管理类控制后台评论的展示和操作
class CommentAdmin(admin.ModelAdmin):
list_per_page = 20
list_display = (
list_per_page = 20# 每页显示20条评论记录
list_display = (# 列表页展示的字段(自定义字段需在类中定义对应方法)
'id',
'body',
'link_to_userinfo',
'link_to_article',
'is_enable',
'creation_time')
list_display_links = ('id', 'body', 'is_enable')
list_filter = ('is_enable',)
exclude = ('creation_time', 'last_modify_time')
actions = [disable_commentstatus, enable_commentstatus]
def link_to_userinfo(self, obj):
info = (obj.author._meta.app_label, obj.author._meta.model_name)
link = reverse('admin:%s_%s_change' % info, args=(obj.author.id,))
return format_html(
list_display_links = ('id', 'body', 'is_enable')# 列表页中可点击跳转编辑页的字段
list_filter = ('is_enable',)# 右侧过滤条件(按是否启用筛选)
exclude = ('creation_time', 'last_modify_time')# 编辑页排除的字段(创建时间和最后修改时间通常自动生成,不允许手动编辑)
actions = [disable_commentstatus, enable_commentstatus]# 注册批量操作(将上面定义的两个函数加入到后台操作中)
def link_to_userinfo(self, obj):# 自定义字段:生成关联用户的后台编辑链接
info = (obj.author._meta.app_label, obj.author._meta.model_name)# 获取用户模型的app标签和模型名称用于生成admin URL
# obj.author表示评论关联的用户对象
link = reverse('admin:%s_%s_change' % info, args=(obj.author.id,))# 反向解析生成用户模型的编辑页URL格式admin:app_label_model_name_change
return format_html( # 生成HTML链接显示用户昵称若无昵称则显示邮箱
u'<a href="%s">%s</a>' %
(link, obj.author.nickname if obj.author.nickname else obj.author.email))
def link_to_article(self, obj):
info = (obj.article._meta.app_label, obj.article._meta.model_name)
link = reverse('admin:%s_%s_change' % info, args=(obj.article.id,))
return format_html(
def link_to_article(self, obj):# 自定义字段:生成关联文章的后台编辑链接
info = (obj.article._meta.app_label, obj.article._meta.model_name)# 获取文章模型的app标签和模型名称
# obj.article表示评论关联的文章对象
link = reverse('admin:%s_%s_change' % info, args=(obj.article.id,))# 反向解析生成文章模型的编辑页URL
return format_html(# 生成HTML链接显示文章标题
u'<a href="%s">%s</a>' % (link, obj.article.title))
link_to_userinfo.short_description = _('User')
link_to_article.short_description = _('Article')
# 自定义字段的显示名称(支持国际化)
link_to_userinfo.short_description = _('User')# 显示为"用户"
link_to_article.short_description = _('Article')# 显示为"文章"

@ -6,7 +6,7 @@ from django.utils.feedgenerator import Rss201rev2Feed
from blog.models import Article
from djangoblog.utils import CommonMarkdown
/*注释*/
class DjangoBlogFeed(Feed):
feed_type = Rss201rev2Feed

@ -0,0 +1,521 @@
/* ==========================================================================
========================================================================== */
.breadcrumb
div {
display: inline;
font-size: 13px;
margin-left: -3px;
}
/* ==========================================================================
========================================================================== */
/* 回到顶部按钮容器定位 */
#wp-auto-top {
position: fixed;
top: 45%;
right: 50%;
display: block;
margin-right: -540px;
z-index: 9999;
}
/* 回到顶部按钮通用样式 */
#wp-auto-top-top, #wp-auto-top-comment, #wp-auto-top-bottom {
background: url(https://www.lylinux.org/wp-content/plugins/wp-auto-top/img/1.png) no-repeat;
position: relative;
cursor: pointer;
height: 25px;
width: 29px;
margin: 10px 0 0;
}
/* 评论按钮特定样式 */
#wp-auto-top-comment {
background-position: left -30px;
height: 32px;
}
/* 底部按钮特定样式 */
#wp-auto-top-bottom {
background-position: left -68px;
}
/* 按钮悬停效果 */
#wp-auto-top-comment:hover {
background-position: right -30px;
}
#wp-auto-top-top:hover {
background-position: right 0;
}
#wp-auto-top-bottom:hover {
background-position: right -68px;
}
/* ==========================================================================
========================================================================== */
.widget-login {
margin-top: 15px !important;
}
/* ==========================================================================
========================================================================== */
/* 评论区域顶部间距 */
#comments {
margin-top: 20px;
}
/* 隐藏pingback列表容器 */
#pinglist-container {
display: none;
}
/* 评论标签页样式 */
.comment-tabs {
margin-bottom: 20px;
font-size: 15px;
border-bottom: 2px solid #e5e5e5;
}
.comment-tabs li {
float: left;
margin-bottom: -2px;
}
.comment-tabs li a {
display: block;
padding: 0 10px 10px;
font-weight: 600;
color: #aaa;
border-bottom: 2px solid #e5e5e5;
}
.comment-tabs li a:hover {
color: #444;
border-color: #ccc;
}
.comment-tabs li span {
margin-left: 8px;
padding: 0 6px;
border-radius: 4px;
background-color: #e5e5e5;
}
.comment-tabs li i {
margin-right: 6px;
}
.comment-tabs li.active a {
color: #e8554e;
border-bottom-color: #e8554e;
}
/* 评论列表样式 */
.commentlist, .pinglist {
margin-bottom: 20px;
}
.commentlist li, .pinglist li {
padding-left: 60px;
font-size: 14px;
line-height: 22px;
font-weight: 400;
}
.commentlist .comment-body, .pinglist li {
position: relative;
padding-bottom: 20px;
clear: both;
word-break: break-all;
}
.commentlist .comment-author,
.commentlist .comment-meta,
.commentlist .comment-awaiting-moderation {
float: left;
display: block;
font-size: 13px;
line-height: 22px;
}
.commentlist .comment-author {
margin-right: 6px;
}
.commentlist .fn, .pinglist .ping-link {
color: #444;
font-size: 13px;
font-style: normal;
font-weight: 600;
}
.commentlist .says {
display: none;
}
.commentlist .avatar {
position: absolute;
left: -60px;
top: 0;
width: 48px;
height: 48px;
border-radius: 100%;
}
.commentlist .comment-meta:before, .pinglist .ping-meta:before {
vertical-align: 4%;
margin-right: 3px;
font-size: 10px;
font-family: FontAwesome;
color: #ccc;
}
.commentlist .comment-meta a, .pinglist .ping-meta {
color: #aaa;
}
.commentlist .reply {
font-size: 13px;
line-height: 16px;
}
.commentlist .reply a,
.commentlist .comment-reply-chain {
color: #aaa;
}
.commentlist .reply a:hover,
.commentlist .comment-reply-chain:hover {
color: #444;
}
.comment-awaiting-moderation {
color: #e8554e;
font-style: normal;
}
/* pingback 列表样式 */
.pinglist li {
padding-left: 0;
}
/* 评论文本样式 */
.commentlist .comment-body p {
margin-bottom: 8px;
color: #777;
clear: both;
}
.commentlist .comment-body strong {
font-weight: 600;
}
.commentlist .comment-body ol li {
margin-left: 2em;
padding: 0;
list-style: decimal;
}
.commentlist .comment-body ul li {
margin-left: 2em;
padding: 0;
list-style: square;
}
/* 文章作者和管理员评论样式 */
.commentlist li.bypostauthor > .comment-body:after,
.commentlist li.comment-author-admin > .comment-body:after {
display: block;
position: absolute;
content: "\f040";
width: 12px;
line-height: 12px;
font-style: normal;
font-family: FontAwesome;
text-align: center;
color: #fff;
background-color: #e8554e;
}
.commentlist li.comment-author-admin > .comment-body:after {
content: "\f005"; /* 管理员使用星形图标 */
}
.commentlist li.bypostauthor > .comment-body:after,
.commentlist li.comment-author-admin > .comment-body:after {
padding: 3px;
top: 32px;
left: -28px;
font-size: 12px;
border-radius: 100%;
}
.commentlist li li.bypostauthor > .comment-body:after,
.commentlist li li.comment-author-admin > .comment-body:after {
padding: 2px;
top: 22px;
left: -26px;
font-size: 10px;
border-radius: 100%;
}
/* 子评论样式 */
.commentlist li ul {
}
.commentlist li li {
margin: 0;
padding-left: 48px;
}
.commentlist li li .avatar {
top: 0;
left: -48px;
width: 36px;
height: 36px;
}
.commentlist li li .comment-meta {
left: 70px;
}
/* 评论导航样式 */
.comments-nav {
margin-bottom: 20px;
}
.comments-nav a {
font-weight: 600;
}
.comments-nav .nav-previous {
float: left;
}
.comments-nav .nav-next {
float: right;
}
/* 评论表单样式 */
.logged-in-as,
.comment-notes,
.form-allowed-tags {
display: none;
}
/* 设置评论容器相对定位 */
#respond {
position: relative;
}
/* 回复标题的默认下边距 */
#reply-title {
margin-bottom: 20px;
}
/* 针对列表项中的回复标题进行特殊处理:隐藏并重置尺寸 */
li #reply-title {
margin: 0 !important;
padding: 0;
height: 0;
font-size: 0;
border-top: 0;
}
/* 取消回复链接的基本样式设置 */
#cancel-comment-reply-link {
float: right;
bottom: 26px;
right: 20px;
font-size: 12px;
color: #999;
}
/* 取消回复链接悬停时的颜色变化 */
#cancel-comment-reply-link:hover {
color: #777;
}
/* 评论表单整体样式 */
#commentform {
margin-bottom: 20px;
padding: 10px 20px 20px;
border-radius: 4px;
background-color: #e5e5e5;
}
/* 表单作者字段左浮动占宽48% */
#commentform p.comment-form-author {
float: left;
width: 48%;
}
/* 表单邮箱字段右浮动占宽48% */
#commentform p.comment-form-email {
float: right;
width: 48%;
}
/* URL 和评论正文字段清除浮动并独占一行 */
#commentform p.comment-form-url,
#commentform p.comment-form-comment {
clear: both;
}
/* 表单标签统一显示为块级元素,并设置上下内边距与字体加粗 */
#commentform label {
display: block;
padding: 6px 0;
font-weight: 600;
}
/* 输入框和文本域最大宽度限制为父容器100%,且默认撑满 */
#commentform input[type="text"],
#commentform textarea {
max-width: 100%;
width: 100%;
}
/* 文本域高度固定为100像素 */
#commentform textarea {
height: 100px;
}
/* 提交按钮段落上外边距调整 */
#commentform p.form-submit {
margin-top: 10px;
}
/* 登录状态下回复标题保持标准间距 */
.logged-in #reply-title {
margin-bottom: 20px;
}
/* 登录状态下的评论正文字段增加顶部间距 */
.logged-in #commentform p.comment-form-comment {
margin-top: 10px;
}
/* 登录状态下评论正文标签隐藏 */
.logged-in #commentform p.comment-form-comment label {
display: none;
}
/* 统一标题类(包括回复标题)的基础样式 */
.heading,
#reply-title {
margin-bottom: 1em;
font-size: 18px;
font-weight: 600;
text-transform: uppercase;
color: #222;
}
/* 标题图标样式设置 */
.heading i {
margin-right: 6px;
font-size: 22px;
}
/* 清除浮动伪类 before */
.group:before {
content: "";
display: table;
}
/* 清除浮动伪类 after */
.group:after {
content: "";
display: table;
clear: both;
}
/* 取消评论按钮基础样式重置 */
.cancel-comment {
margin: 0;
padding: 0;
border: 0;
font: inherit;
vertical-align: baseline;
}
/* 返回顶部火箭图标的初始位置及基本属性 */
#rocket {
position: fixed;
right: 50px;
bottom: 50px;
display: block;
visibility: hidden;
width: 26px;
height: 48px;
background: url("data:image/png;base64,...") no-repeat 50% 0;
cursor: pointer;
-webkit-transition: all 0s;
transition: all 0s;
}
/* 火箭图标鼠标悬停时背景图片偏移以切换状态 */
#rocket:hover {
background-position: 50% -62px;
}
/* 显示火箭图标 */
#rocket.show {
visibility: visible;
opacity: 1;
}
/* 触发动画时火箭图标的状态更新与动画绑定 */
#rocket.move {
background-position: 50% -62px;
-webkit-animation: toTop .8s ease-in;
animation: toTop .8s ease-in;
animation-fill-mode: forwards;
-webkit-animation-fill-mode: forwards;
}
/* Markdown提示文字样式设置 */
.comment-markdown {
float: right;
font-size: small;
}
/* 面包屑导航容器样式 */
.breadcrumb {
margin-bottom: 20px;
list-style: none;
border-radius: 4px;
}
/* 面包屑导航项横向排列 */
.breadcrumb > li {
display: inline-block;
}
/* 面包屑导航项之间的分隔符 */
.breadcrumb > li + li:before {
color: #ccc;
content: "/\00a0";
}
/* 当前激活的面包屑导航项颜色 */
.breadcrumb > .active {
color: #777;
}
/* 分割线样式(当前被注释掉) */
.break_line {
height: 1px;
border: none;
/*border-top: 1px dashed #f5d6d6;*/
}
Loading…
Cancel
Save