Compare commits

...

3 Commits

Author SHA1 Message Date
6cfd3334d0 修改文章编辑器为mdeditor 2025-07-01 21:51:17 +08:00
d6384df8c7 修改文章编辑器为mdeditor 2025-07-01 21:50:13 +08:00
8fced69160 修改文章编辑器为mdeditor 2025-07-01 21:48:23 +08:00
27 changed files with 62 additions and 168 deletions

View File

@ -9,7 +9,7 @@ https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
import os
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
@ -42,6 +42,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'mdeditor',
]
MIDDLEWARE = [
@ -136,4 +137,35 @@ SIMPLEUI_CONFIG = {
}],
}
Echo_Z_version = "1.2.3"
Echo_Z_version = "1.2.3"
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
# 设置前缀
MEDIA_URL = '/media/'
MDEDITOR_CONFIGS = {
'default': {
'width': 690, # Custom edit box width
'heigth': 500, # Custom edit box height
'toolbar': ["undo", "redo", "|",
"bold", "del", "italic", "quote", "ucwords", "uppercase", "lowercase", "|",
"h1", "h2", "h3", "h5", "h6", "|",
"list-ul", "list-ol", "hr", "|",
"link", "reference-link", "image", "code", "preformatted-text", "code-block", "table", "datetime"
"emoji",
"html-entities", "pagebreak", "goto-line", "|",
"help", "info",
"||", "preview", "watch", "fullscreen"], # custom edit box toolbar
'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"], # image upload format type
'image_floder': 'editor', # image save the folder name
'theme': 'default', # edit box theme, dark / default
'preview_theme': 'default', # Preview area theme, dark / default
'editor_theme': 'default', # edit area theme, pastel-on-dark / default
'toolbar_autofixed': True, # Whether the toolbar capitals
'search_replace': True, # Whether to open the search for replacement
'emoji': True, # whether to open the expression function
'tex': True, # whether to open the tex chart function
'flow_chart': True, # whether to open the flow chart function
'sequence': True # Whether to open the sequence diagram function
}
}

View File

@ -1,11 +1,15 @@
from django.contrib import admin
from django.urls import path,include
from django.urls import re_path
from django.conf.urls.static import static
from django.conf import settings
admin.site.site_title = 'Echo-Z'
admin.site.site_header = '后台管理'
urlpatterns = [
path('admin/', admin.site.urls),
path('api/', include('api.urls')),
path('', include('home.urls')),
re_path(r'mdeditor/', include('mdeditor.urls')),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -59,8 +59,13 @@ python manage.py runserver 9999
2.站点设置
###### 1.2.3
2025年6月234日
2025年6月24日
新增
1.分类管理
2.文章分类的设置
3.分类文章的列表
3.分类文章的列表
###### 1.2.4
2025年7月1日
修改
1.后台文章编辑使用mdeditor

Binary file not shown.

View File

@ -1,13 +1,14 @@
from django.contrib import admin
from home.models import *
# Register your models here.
@admin.register(Articles)
class DepartmentAdmin(admin.ModelAdmin):
# 要显示的字段
list_display = ('title', 'abstract', 'created','stat')
search_fields = ('title','abstract',)
exclude = ('content',)
# 不可编辑字段
readonly_fields = ('stat','read')
# 分页显示,一页的数量

View File

@ -1,25 +0,0 @@
# Generated by Django 4.2.23 on 2025-06-19 03:17
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='articles',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=100, verbose_name='文章标题')),
('content', models.TextField(verbose_name='文章内容')),
('abstract', models.TextField(verbose_name='文章摘要')),
('created', models.DateTimeField(auto_now_add=True, verbose_name='发布时间')),
('stat', models.IntegerField(default=False, verbose_name='点赞数量')),
],
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 4.2.23 on 2025-06-19 03:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='articles',
name='created',
field=models.DateTimeField(verbose_name='发布时间'),
),
]

View File

@ -1,22 +0,0 @@
# Generated by Django 4.2.23 on 2025-06-19 07:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0002_alter_articles_created'),
]
operations = [
migrations.AlterModelOptions(
name='articles',
options={'verbose_name': '文章', 'verbose_name_plural': '文章管理'},
),
migrations.AddField(
model_name='articles',
name='read',
field=models.IntegerField(default=0, verbose_name='阅读数量'),
),
]

View File

@ -1,18 +0,0 @@
# Generated by Django 4.2.23 on 2025-06-19 08:54
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0003_alter_articles_options_articles_read'),
]
operations = [
migrations.AddField(
model_name='articles',
name='author',
field=models.TextField(default='admin', verbose_name='文章作者'),
),
]

View File

@ -1,25 +0,0 @@
# Generated by Django 4.2.23 on 2025-06-22 18:14
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0004_articles_author'),
]
operations = [
migrations.CreateModel(
name='ArticlesLike',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('articles_id', models.IntegerField(default=0, verbose_name='文章id')),
('uuid', models.CharField(max_length=100, verbose_name='点赞用户标识')),
],
options={
'verbose_name': '点赞',
'verbose_name_plural': '点赞管理',
},
),
]

View File

@ -1,21 +0,0 @@
# Generated by Django 4.2.23 on 2025-06-23 03:17
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('home', '0005_articleslike'),
]
operations = [
migrations.AlterModelTable(
name='articles',
table='Articles',
),
migrations.AlterModelTable(
name='articleslike',
table='ArticlesLike',
),
]

View File

@ -1,31 +0,0 @@
# Generated by Django 4.2.23 on 2025-06-24 01:37
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('home', '0006_alter_articles_table_alter_articleslike_table'),
]
operations = [
migrations.CreateModel(
name='ArticleTag',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('tag', models.CharField(max_length=120)),
],
options={
'verbose_name': '标签',
'verbose_name_plural': '标签管理',
'db_table': 'ArticleTag',
},
),
migrations.AddField(
model_name='articles',
name='tag_id',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='home.articletag', verbose_name='文章标签'),
),
]

View File

@ -1,4 +1,6 @@
from django.db import models
import markdown
from mdeditor.fields import MDTextField
# Create your models here.
@ -14,7 +16,8 @@ class ArticleTag(models.Model):
class Articles(models.Model):
title = models.CharField(max_length=100,verbose_name="文章标题")
content = models.TextField(verbose_name="文章内容")
content_raw = MDTextField(verbose_name='文章内容', default='', config_name='default')
content = models.TextField(verbose_name='呈现内容', null=True, blank=True, default='')
abstract = models.TextField(verbose_name="文章摘要")
author = models.TextField(default="admin", verbose_name="文章作者")
created = models.DateTimeField(verbose_name="发布时间")
@ -22,6 +25,14 @@ class Articles(models.Model):
read = models.IntegerField(default=0,verbose_name="阅读数量")
tag_id = models.ForeignKey(ArticleTag, on_delete=models.SET_NULL, null=True, blank=True, verbose_name="文章标签")
def save(self, *args, **kwargs):
# 将Markdown格式 转为html页面上显示
self.content = markdown.markdown(self.content_raw, extensions=[
'markdown.extensions.extra',
'markdown.extensions.codehilite',
'markdown.extensions.toc',
])
super(Articles, self).save(*args, **kwargs)
class Meta:
verbose_name = "文章"

View File

@ -13,3 +13,4 @@ sqlparse==0.5.3
tablib==3.8.0
typing_extensions==4.14.0
zipp==3.23.0
mdeditor