重做文章详情页:拾光阅读版式与目录/代码/灯箱交互
- 新增内容页外壳 base_content.html 与 reading.css / reading.js - 重写 post_detail.html:分类胶囊、阅读进度、首字下沉、代码块复制、 侧栏目录、上下篇、图片灯箱、明暗主题 - post_detail 视图补充上下篇、字数与阅读时长 - base.html 补 extra_css / extra_js block,修复脑图详情页样式不加载 - 加入 mindmaps、api、首页静态资源与模板 - 忽略 __pycache__ / *.pyc / *.back,并将已跟踪的 .pyc 移出版本库
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
from django.contrib import admin
|
||||
from django import forms
|
||||
from .models import MindMap
|
||||
|
||||
|
||||
@admin.register(MindMap)
|
||||
class MindMapAdmin(admin.ModelAdmin):
|
||||
list_display = ("title", "created_at", "has_mindmap")
|
||||
search_fields = ("title",)
|
||||
prepopulated_fields = {"slug": ("title",)}
|
||||
readonly_fields = ("updated_at",)
|
||||
|
||||
def has_mindmap(self, obj):
|
||||
return bool(obj.mindmap_data and obj.mindmap_data.get("data"))
|
||||
has_mindmap.boolean = True
|
||||
has_mindmap.short_description = "已解析"
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
is_new = not obj.pk
|
||||
super().save_model(request, obj, form, change)
|
||||
|
||||
if "xmind_file" in form.changed_data and obj.xmind_file:
|
||||
try:
|
||||
obj.parse_and_store(obj.xmind_file.path)
|
||||
self.message_user(request, f"脑图「{obj.title}」解析成功")
|
||||
except Exception as e:
|
||||
self.message_user(
|
||||
request, f"解析失败: {e}", level="error"
|
||||
)
|
||||
Reference in New Issue
Block a user