change markdown_edit_app && support media
This commit is contained in:
@@ -36,7 +36,7 @@ INSTALLED_APPS = [
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'blog',
|
||||
'martor',
|
||||
'mdeditor',
|
||||
]
|
||||
|
||||
MIDDLEWARE = [
|
||||
@@ -111,6 +111,12 @@ USE_TZ = True
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
|
||||
# 添加媒体文件配置
|
||||
import os
|
||||
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/5.2/ref/settings/#default-auto-field
|
||||
|
||||
@@ -122,3 +128,32 @@ CSRF_TRUSTED_ORIGINS = [
|
||||
"http://yuangyaa.com",
|
||||
"https://yuangyaa.com",
|
||||
]
|
||||
|
||||
# 添加 MDEditor 配置
|
||||
MDEDITOR_CONFIGS = {
|
||||
'default': {
|
||||
'width': '100%',
|
||||
'height': 700,
|
||||
'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"],
|
||||
'upload_image_formats': ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
|
||||
'image_folder': 'editor',
|
||||
'theme': 'default',
|
||||
'preview_theme': 'default',
|
||||
'editor_theme': 'default',
|
||||
'toolbar_autofixed': True,
|
||||
'search_replace': True,
|
||||
'emoji': True,
|
||||
'tex': False,
|
||||
'language': 'zh',
|
||||
'focus': False,
|
||||
'auto_height': False,
|
||||
}
|
||||
}
|
||||
|
||||
X_FRAME_OPTIONS = 'SAMEORIGIN'
|
||||
|
||||
@@ -16,12 +16,16 @@ Including another URLconf
|
||||
"""
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.static import static
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
# 添加martor的URL配置以支持Markdown编辑器
|
||||
path('martor/', include('martor.urls')),
|
||||
path('mdeditor/', include('mdeditor.urls')),
|
||||
# 包含blog应用的URL
|
||||
path('', include('blog.urls')),
|
||||
]
|
||||
|
||||
# 添加媒体文件URL配置 - 确保在DEBUG和生产环境都能正确处理媒体文件
|
||||
if settings.DEBUG:
|
||||
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
|
||||
Reference in New Issue
Block a user