This commit is contained in:
跨越晨昏 2024-11-02 14:25:49 +08:00
parent a1099bbbbc
commit 0e6a8ff9ec
9 changed files with 95 additions and 23 deletions

20
Dockerfile Normal file
View File

@ -0,0 +1,20 @@
# 使用官方 Python 基础镜像
FROM python:3.11-slim-buster
# 设置工作目录
WORKDIR /app
# 将项目文件复制到容器中
COPY. /app
# 安装项目依赖
RUN pip install --no-cache-dir -r requirements.txt
# 设置环境变量
ENV DJANGO_SETTINGS_MODULE=your_project_name.settings
# 暴露容器端口
EXPOSE 8000
# 运行 Django 项目
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

View File

@ -7,9 +7,9 @@ BASE_DIR = Path(__file__).resolve().parent.parent
SECRET_KEY = '+f%vbh_8b+(*kp=clju)691popu%a*#60ik99n4(n2ex9g$)_a' SECRET_KEY = '+f%vbh_8b+(*kp=clju)691popu%a*#60ik99n4(n2ex9g$)_a'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = False
ALLOWED_HOSTS = ['*'] ALLOWED_HOSTS = ['crossdark.com']
# Application definition # Application definition

View File

@ -36,9 +36,9 @@ class ArticleInfo(models.Model):
# 在文章每次保存时运行 # 在文章每次保存时运行
self.rendered, meta = CrossDown.main(self.content) # 渲染md self.rendered, meta = CrossDown.main(self.content) # 渲染md
print(meta) print(meta)
if 'title' in meta: if 'title' in meta: # 设置标题
self.title = meta['title'][0] self.title = meta['title'][0]
if 'summary' in meta: if 'summary' in meta: # 设置简介
self.brief = meta['summary'][0] self.brief = meta['summary'][0]
super().save(*args, **kwargs) # 保存 super().save(*args, **kwargs) # 保存

View File

@ -1,12 +1,21 @@
@charset "UTF-8"; @charset "UTF-8";
@font-face {
font-family: 'DuanNing'; /* 定义字体名称 */
src: url('../fonts/段宁毛笔小楷.ttf') format('truetype'); /* 指定字体文件路径和格式 */
}
@font-face {
font-family: 'SetoFont'; /* 定义字体名称 */
src: url('../fonts/小濑字体.ttf') format('truetype'); /* 指定字体文件路径和格式 */
}
/* css */ /* css */
* { margin: 0; padding: 0 } * { margin: 0; padding: 0 }
body { body {
font: 15px "Microsoft YaHei", Arial, Helvetica, sans-serif; /* 设置字体大小和字体族 */ font: 15px "DuanNing", "Microsoft YaHei", Arial, Helvetica, sans-serif; /* 设置字体大小和字体族 */
background-image: url('../images/盐湖.png'); /* 设置背景图片 */ background-image: url('../images/盐湖.png'); /* 设置背景图片 */
line-height: 1.5; /* 设置行高为字体大小的1.5倍 */ line-height: 1.5; /* 设置行高为字体大小的1.5倍 */
background-size: cover; /* 背景图片覆盖整个元素区域,可能会被裁剪以保持宽高比 */ background-size: cover; /* 背景图片覆盖整个元素区域,可能会被裁剪以保持宽高比 */
background-repeat: no-repeat; /* 背景图片不重复 */ background-repeat: no-repeat; /* 背景图片不重复 */
background-attachment: fixed; /* 背景图片固定,不随页面滚动 */
} }
img { border: 0; display: block } img { border: 0; display: block }
ul, li { list-style: none; } ul, li { list-style: none; }
@ -16,10 +25,48 @@ a:hover { text-decoration: none; color: #000; }
.blank { height: 20px; overflow: hidden; width: 100%; margin: auto; clear: both } .blank { height: 20px; overflow: hidden; width: 100%; margin: auto; clear: both }
.f_l { float: left } .f_l { float: left }
.f_r { float: right } .f_r { float: right }
article { width: 1000px; margin: 80px auto 0; overflow: hidden; zoom: 1; } .grid-container {
aside { width: 30%; float: left; overflow: hidden; display: block; position: relative; z-index: 1 } display: grid;
grid-template-columns: 1fr 3fr 1fr; /* 左侧和右侧各占1份空间中间占2份 */
grid-gap: 10px; /* 网格间隙 */
width: 90%; /* 确保容器宽度为父元素的100% */
margin: 80px
}
main { overflow: hidden; width: 68%; float: right; display: block; } .lb_box{
/* 左侧占位用 */
}
.rb_box{
/* 右侧占位用 */
}
.md_box{
/* 中间占位用 */
position: fixed;
}
.l_box {
/* 左侧内容样式 */
position: fixed;
width: 18%;
left: 5%;
}
.l_box {
/* 左侧内容样式 */
position: fixed;
width: 18%;
right: 5%;
}
.main {
overflow: hidden;
width: 100%;
margin: 0 auto; /* 添加左右自动外边距以实现水平居中 */
display: block; /* 已经是默认值,但保持清晰 */
}
.container { width: 1000px; margin: auto } .container { width: 1000px; margin: auto }
nav { width: 1000px; margin: auto } nav { width: 1000px; margin: auto }
.logo { float: left; font-size: 22px } .logo { float: left; font-size: 22px }

View File

@ -1,4 +1,4 @@
@charset "gb2312"; @charset "UTF-8";
.l_box h2 { color: #333; font-size: 14px; line-height: 30px; padding-left: 20px; background: #fff } .l_box h2 { color: #333; font-size: 14px; line-height: 30px; padding-left: 20px; background: #fff }
.l_box div { background: rgba(255,255,255,0.5); margin-bottom: 20px; overflow: hidden } .l_box div { background: rgba(255,255,255,0.5); margin-bottom: 20px; overflow: hidden }
.l_box div ul { padding: 10px; overflow: hidden } .l_box div ul { padding: 10px; overflow: hidden }
@ -12,18 +12,20 @@
.tuijian li { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; margin-bottom: 5px; background: url(../images/li.png) left center no-repeat; padding-left: 20px } .tuijian li { text-overflow: ellipsis; white-space: nowrap; overflow: hidden; margin-bottom: 5px; background: url(../images/li.png) left center no-repeat; padding-left: 20px }
.links a { display: block; float: left; margin: 0 10px 5px 0 } .links a { display: block; float: left; margin: 0 10px 5px 0 }
.guanzhu img { width: 100% } .guanzhu img { width: 100% }
.tools a { display: block; float: left; margin: 0 10px 5px 0 }
.l_box .search { border: 1px solid #000; background: #000; border-radius: 0 5px 5px 0; position: relative; } .l_box .search { border: 1px solid #000; background: #000; border-radius: 0 5px 5px 0; position: relative; }
.search input.input_submit { border: 0; background: 0; color: #fff; outline: none; position: absolute; top: 10px; right: 8% } .search input.input_submit { border: 0; background: 0; color: #fff; outline: none; position: absolute; top: 10px; right: 8% }
.search input.input_text { border: 0; line-height: 36px; height: 36px; width: 72%; padding-left: 10px; outline: none } .search input.input_text { border: 0; line-height: 36px; height: 36px; width: 72%; padding-left: 10px; outline: none }
.r_box li { background: rgba(255,255,255,0.8); padding: 15px; overflow: hidden; color: #797b7c; margin-bottom: 20px } .rt_box .search { border: 1px solid #000; background: #000; border-radius: 0 5px 5px 0; position: relative; }
.r_box li h3 { font-size: 16px; line-height: 25px; text-shadow: #FFF 1px 1px 1px } .main li { background: rgba(255,255,255,0.8); padding: 15px; overflow: hidden; color: #797b7c; margin-bottom: 20px }
.r_box li h3 a { color: #222 } .main li h3 { font-size: 16px; line-height: 25px; text-shadow: #FFF 1px 1px 1px }
.r_box li h3 a:hover { color: #000; text-decoration: underline } .main li h3 a { color: #222 }
.r_box li img { float: right; clear: right; width: 100%;height:100%; -webkit-transition: all 0.5s; -moz-transition: all 0.5s; transition: all 0.5s; } .main li h3 a:hover { color: #000; text-decoration: underline }
.r_box li i { width: 150px; display: block; max-height: 100px; overflow: hidden; float: right; margin-left: 20px } .main li img { float: right; clear: right; width: 100%;height:100%; -webkit-transition: all 0.5s; -moz-transition: all 0.5s; transition: all 0.5s; }
.r_box li p { margin: 20px 0 0 0; line-height: 22px; overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 2; } .main li i { width: 150px; display: block; max-height: 100px; overflow: hidden; float: right; margin-left: 20px }
.r_box li:hover img { transform: scale(1.05) } .main li p { margin: 20px 0 0 0; line-height: 22px; overflow: hidden; text-overflow: ellipsis; -webkit-box-orient: vertical; display: -webkit-box; -webkit-line-clamp: 2; }
.r_box li:hover h3 a { color: #19585d; } .main li:hover img { transform: scale(1.05) }
.main li:hover h3 a { color: #19585d; }
.pagelist { text-align: center; color: #666; width: 100%; clear: both; margin: 20px 0; padding-top: 20px } .pagelist { text-align: center; color: #666; width: 100%; clear: both; margin: 20px 0; padding-top: 20px }
.pagelist a { color: #666; margin: 0 2px 5px 2px; display: inline-block; border: 1px solid #fff; padding: 5px 10px; background: #FFF } .pagelist a { color: #666; margin: 0 2px 5px 2px; display: inline-block; border: 1px solid #fff; padding: 5px 10px; background: #FFF }
.pagelist a:hover { color: #19585d; } .pagelist a:hover { color: #19585d; }

View File

@ -1,4 +1,4 @@
@charset "gb2312"; @charset "UTF-8";
.infosbox { overflow: hidden; background: rgba(255,255,255,0.8); margin-bottom: 20px } .infosbox { overflow: hidden; background: rgba(255,255,255,0.8); margin-bottom: 20px }
.newsview { padding: 0 30px } .newsview { padding: 0 30px }
.news_con a { color: #0e6dad } .news_con a { color: #0e6dad }

View File

@ -1,4 +1,4 @@
@charset "gb2312"; @charset "UTF-8";
@media screen and (min-width: 1024px) and (max-width: 1199px) { @media screen and (min-width: 1024px) and (max-width: 1199px) {
header { width: 96%; margin: auto } header { width: 96%; margin: auto }
} }

View File

@ -1,3 +0,0 @@
django>=5.1.1
django-mdeditor>=0.1.20
CrossDown>=0.11.0

6
requirements.txt Normal file
View File

@ -0,0 +1,6 @@
CrossDown==2.2.0
Django==5.1.1
django-ckeditor==6.7.1
django-js-asset==2.2.0
django-mdeditor==0.1.20
emoji==2.13.2