Skip to content

Commit

Permalink
Merge pull request #287 from Hopetree/latest
Browse files Browse the repository at this point in the history
Latest
  • Loading branch information
Hopetree authored Jun 26, 2024
2 parents c4a40f6 + e5a654a commit 79069e5
Show file tree
Hide file tree
Showing 76 changed files with 8,933 additions and 76 deletions.
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
FROM python:3.9

# 国内用户构建命令参考
# DOCKER_BUILDKIT=0 docker build --build-arg pip_index_url=http://mirrors.aliyun.com/pypi/simple/ --build-arg pip_trusted_host=mirrors.aliyun.com -t hopetree/izone:lts .

ARG pip_index_url=https://pypi.org/simple
ARG pip_trusted_host=pypi.org
ENV PYTHONUNBUFFERED=1
Expand Down
34 changes: 34 additions & 0 deletions Dockerfile-slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM python:3.9-slim

# 国内用户构建命令参考
# DOCKER_BUILDKIT=0 docker build --build-arg pip_index_url=http://mirrors.aliyun.com/pypi/simple/ --build-arg pip_trusted_host=mirrors.aliyun.com --build-arg debian_host=mirrors.ustc.edu.cn -f Dockerfile-slim -t hopetree/izone:lts .

# 默认的系统源和pypi源都使用国外的,国内构建的时候可以用命令行参数替换成国内源
ARG debian_host=deb.debian.org
ARG pip_index_url=https://pypi.org/simple
ARG pip_trusted_host=pypi.org


ENV PYTHONUNBUFFERED=1
WORKDIR /opt/cloud/izone

# 替换系统源,要注意这里不同版本的debian源文件不同
RUN sed -i "s/deb.debian.org/${debian_host}/g" /etc/apt/sources.list.d/debian.sources

# 安装sqlclient的依赖,slim镜像中缺少
RUN apt-get update && apt-get install -y \
default-libmysqlclient-dev \
build-essential \
&& rm -rf /var/lib/apt/lists/*

RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
COPY requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt --index-url $pip_index_url --trusted-host $pip_trusted_host
RUN mkdir -p log && chmod -R 755 log

COPY . .

# 设置镜像的创建时间,当做网站更新时间
RUN sed -i "s/web_update_time=\"\"/web_update_time=\"$(date +'%Y-%m-%d %H:%M')\"/g" ./apps/blog/templates/blog/base.html

CMD ["supervisord", "-n", "-c", "supervisord.conf"]
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@

![PC 专题页,按文章归类](https://github.com/Hopetree/izone/assets/30201215/c0a828cc-2201-438b-a983-0c6c04a429c4)

- 云监控服务,提供服务器的监控能力,客户端提供 Golang 版本,也可以自行编写 Python 版本的客户端用来上报数据

![20240404_232431 (1)](https://github.com/Hopetree/izone/assets/30201215/038200c3-1ada-4ab2-9ac5-42848a80ee21)

- PC 友情链接页,定时任务自动校验网址有效性

![PC 友情链接页](https://github.com/Hopetree/izone/assets/30201215/033cdd61-75cf-41b4-bb45-9b45948daf3a)
Expand Down
11 changes: 9 additions & 2 deletions apps/blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from .models import (Article, Tag, Category, Timeline,
Carousel, Silian, Keyword, FriendLink,
AboutBlog, Subject, Topic, ArticleView,
PageView, FeedHub)
PageView, FeedHub, MenuLink)


@admin.register(Subject)
Expand Down Expand Up @@ -42,7 +42,7 @@ class ArticleAdmin(admin.ModelAdmin):
# 字段归类显示
fieldsets = (
('文章信息', {'fields': (('title', 'slug'), 'summary', 'body', 'img_link',
('is_top', 'is_publish'))}),
('is_top', 'is_publish'))}),
('文章关系信息', {'fields': ('author', 'category', 'tags', 'keywords')}),
('文章专题信息', {'fields': (('topic', 'topic_order'), 'topic_short_title')}),
)
Expand Down Expand Up @@ -175,3 +175,10 @@ class PageViewAdmin(admin.ModelAdmin):
date_hierarchy = 'create_date'
ordering = ('sort_order',)
list_editable = ('is_active', 'sort_order')


@admin.register(MenuLink)
class MenuLinkViewAdmin(admin.ModelAdmin):
list_display = ('name', 'icon', 'link', 'title', 'active', 'sort_order')
ordering = ('sort_order',)
list_editable = ('active', 'sort_order')
5 changes: 2 additions & 3 deletions apps/blog/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# todo 可以做成自动化,每次拉git代码的时候检查是否更新了某个静态文件,自动更新版本
STATIC_VERSION = {
'css_blog_base': '20240305.02',
'css_blog_detail': '20240131.01',
'css_blog_night': '20240115.01',
'css_blog_detail': '20240324.01',
'css_blog_night': '20240615.01',

'js_blog_base': '20240305.01',
'js_blog_article': '20240115.01',
Expand Down Expand Up @@ -39,6 +39,5 @@ def settings_info(request):
'my_github': settings.MY_GITHUB,
'site_verification': settings.MY_SITE_VERIFICATION,
'site_url': site_full_url(),
'private_links': json.loads(settings.PRIVATE_LINKS),
'static_version': STATIC_VERSION,
}
30 changes: 30 additions & 0 deletions apps/blog/migrations/0019_menulink.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 2.2.28 on 2024-03-26 09:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blog', '0018_auto_20240101_1903'),
]

operations = [
migrations.CreateModel(
name='MenuLink',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text='如:Github 主页', max_length=20, unique=True, verbose_name='名称')),
('icon', models.CharField(help_text='如:fa-github', max_length=20, unique=True, verbose_name='图标')),
('link', models.CharField(max_length=200, unique=True, verbose_name='链接')),
('title', models.CharField(help_text='外链的描述', max_length=50, unique=True, verbose_name='标题')),
('active', models.BooleanField(default=True, help_text='是展示有效的链接', verbose_name='是否有效')),
('sort_order', models.IntegerField(default=99, help_text='作为显示的时候的顺序', verbose_name='排序')),
],
options={
'verbose_name': '菜单外链',
'verbose_name_plural': '菜单外链',
'ordering': ['sort_order'],
},
),
]
18 changes: 18 additions & 0 deletions apps/blog/migrations/0020_auto_20240409_1309.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.2.28 on 2024-04-09 13:09

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('blog', '0019_menulink'),
]

operations = [
migrations.AlterField(
model_name='carousel',
name='content',
field=models.CharField(blank=True, max_length=80, null=True, verbose_name='描述'),
),
]
45 changes: 36 additions & 9 deletions apps/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ class Topic(models.Model):
name = models.CharField('主题名称', max_length=50)
create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)
update_date = models.DateTimeField(verbose_name='修改时间', auto_now=True)
sort_order = models.IntegerField('排序', default=99, help_text='仅作为主题在专题中的排序,类似目录')
sort_order = models.IntegerField('排序', default=99,
help_text='仅作为主题在专题中的排序,类似目录')

subject = models.ForeignKey(Subject, verbose_name='所属专题', on_delete=models.PROTECT,
related_name='topics')
Expand All @@ -163,7 +164,8 @@ class Article(models.Model):
author = models.ForeignKey(settings.AUTH_USER_MODEL, verbose_name='作者',
on_delete=models.PROTECT)
title = models.CharField(max_length=150, verbose_name='文章标题')
summary = models.TextField('文章摘要', max_length=230, default='文章摘要等同于网页description内容,请务必填写...')
summary = models.TextField('文章摘要', max_length=230,
default='文章摘要等同于网页description内容,请务必填写...')
body = models.TextField(verbose_name='文章内容')
img_link = ProcessedImageField(upload_to='article/upload/%Y/%m/%d/',
default='article/default/default.png',
Expand Down Expand Up @@ -230,7 +232,7 @@ def update_views(self):

def get_pre(self):
"""
有主题则只能返回这个主题所属专题下的文章,否则返回空,没有主题则按照pk返回
有主题则只能返回这个主题所属专题下的文章,否则返回空,没有主题则按照pk返回同样没有主题的
@return:
"""
if self.topic:
Expand All @@ -240,7 +242,10 @@ def get_pre(self):
return subject_articles[index - 1]
return

return Article.objects.filter(id__lt=self.id, is_publish=True).order_by('-id').first()
return Article.objects.filter(id__lt=self.id,
is_publish=True,
topic__isnull=True
).order_by('-id').first()

def get_next(self):
if self.topic:
Expand All @@ -250,7 +255,10 @@ def get_next(self):
return subject_articles[index + 1]
return

return Article.objects.filter(id__gt=self.id, is_publish=True).order_by('id').first()
return Article.objects.filter(id__gt=self.id,
is_publish=True,
topic__isnull=True
).order_by('id').first()

def get_topic_title(self):
"""仅当有主题的时候优先使用短标题,这个函数给专题使用"""
Expand Down Expand Up @@ -306,9 +314,10 @@ def content_to_markdown(self):
class Carousel(models.Model):
number = models.IntegerField('编号', help_text='编号决定图片播放的顺序,图片不要多于5张')
title = models.CharField('标题', max_length=20, blank=True, null=True, help_text='标题可以为空')
content = models.CharField('描述', max_length=80)
content = models.CharField('描述', blank=True, null=True, max_length=80)
img_url = models.CharField('图片地址', max_length=200)
url = models.CharField('跳转链接', max_length=200, default='#', help_text='图片跳转的超链接,默认#表示不跳转')
url = models.CharField('跳转链接', max_length=200, default='#',
help_text='图片跳转的超链接,默认#表示不跳转')

class Meta:
verbose_name = '图片轮播'
Expand All @@ -317,12 +326,13 @@ class Meta:
ordering = ['number', '-id']

def __str__(self):
return self.content[:25]
return self.title or ''


# 死链
class Silian(models.Model):
badurl = models.CharField('死链地址', max_length=200, help_text='注意:地址是以http开头的完整链接格式')
badurl = models.CharField('死链地址', max_length=200,
help_text='注意:地址是以http开头的完整链接格式')
remark = models.CharField('死链说明', max_length=50, blank=True, null=True)
add_date = models.DateTimeField('提交日期', auto_now_add=True)

Expand Down Expand Up @@ -450,3 +460,20 @@ class Meta:
def update_data(self, data):
self.data = data
self.save(update_fields=['data'])


class MenuLink(models.Model):
name = models.CharField('名称', max_length=20, unique=True, help_text='如:Github 主页')
icon = models.CharField('图标', max_length=20, unique=True, help_text='如:fa-github')
link = models.CharField('链接', max_length=200, unique=True)
title = models.CharField('标题', max_length=50, unique=True, help_text='外链的描述')
active = models.BooleanField('是否有效', help_text='是展示有效的链接', default=True)
sort_order = models.IntegerField('排序', default=99, help_text='作为显示的时候的顺序')

def __str__(self):
return self.name

class Meta:
verbose_name = "菜单外链"
verbose_name_plural = verbose_name
ordering = ['sort_order']
5 changes: 5 additions & 0 deletions apps/blog/static/blog/css/detail.css
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@

blockquote {
margin: 0 0 .5em;
font-style: italic;
}

blockquote p {
margin-bottom: 0;
}

pre {
Expand Down
48 changes: 48 additions & 0 deletions apps/blog/static/blog/css/night.css
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,54 @@ pre {
color: #333;
}

/*监控页面-start*/
.monitor > .table > tbody > tr.odd > td,
.monitor > .table > tbody > tr.odd > th,
.monitor > .table > tbody > tr.even > td,
.monitor > .table > tbody > tr.even > th {
color: var(--izone-font-default);
background-color: var(--izone-background-container);
}

.monitor .progress {
background: rgb(54, 59, 64);
}

.monitor .progress-bar {
color: var(--izone-font-default);
}

.monitor > .table > thead > tr > th {
border-bottom: 1px solid var(--izone-font-default);
}

.monitor > .table > tbody > tr:hover > td {
background: rgba(47, 46, 46, 0.5) !important;
}

.monitor tr.even.expandRow > :hover {
background: var(--izone-background-container) !important;
}

.monitor tr.odd.expandRow > :hover {
background: var(--izone-background-container) !important;
}

.monitor > .table > tbody > tr > td {
border-top: 1px solid #25303e;
}


/*监控页面-end*/

/*端口信息*/
#ports-container .pagination a {
background-color: #22303f;
color: #9caec7;
}

/*端口信息*/

/*全局样式参数start*/
.dark-theme, body {
--izone-layer-golden-1: rgba(209, 171, 97, 0.23);
Expand Down
2 changes: 1 addition & 1 deletion apps/blog/templates/blog/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
dataset: {
source: [['product', '用户总数']].concat(myUserData)
},
xAxis: {type: 'category'},
xAxis: {type: 'category', axisLabel: {showMaxLabel: true}},
yAxis: {type: 'value'},
series: [
{
Expand Down
8 changes: 1 addition & 7 deletions apps/blog/templates/blog/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h1 class="card-title text-center font-weight-bold text-info">{{ article.title }
</div>
<div class="tag-cloud my-4">
{% for tag in article.tags.all %}
<a class="tags f-16" href="{{ tag.get_absolute_url }}">#{{ tag.name }}</a>
<a class="tags f-16" href="{{ tag.get_absolute_url }}"><i class="fa fa-tags mr-1"></i>{{ tag.name }}</a>
{% endfor %}
</div>
{% include 'blog/tags/reward.html' %}
Expand All @@ -101,12 +101,6 @@ <h1 class="card-title text-center font-weight-bold text-info">{{ article.title }
{% include 'comment/comment_list.html' %}
</div>
</div>
<div class="col-lg-3">
<div class="article-toc d-none d-lg-block f-14 rounded-6">
<div class="toc-title f-15"><strong>大纲</strong></div>
{{ article.toc|safe }}
</div>
</div>
</div>
</div>
<!--图片预览-->
Expand Down
2 changes: 1 addition & 1 deletion apps/blog/templates/blog/subject.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ <h1 class="card-title text-center font-weight-bold text-info">{{ subject.name }}
<span>{{ subject.get_article_count }}</span>
</span>
</div>
<div class="alert alert-info my-3 mx-1" role="alert">
<div class="alert alert-primary my-3 mx-1" role="alert">
<h3>专题简介</h3>
<hr class="mt-0">
<p class="mb-0">{{ subject.description }}</p>
Expand Down
Loading

0 comments on commit 79069e5

Please sign in to comment.