- 新增内容页外壳 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 移出版本库
20 lines
587 B
Python
20 lines
587 B
Python
# api/renderers.py
|
|
from rest_framework.renderers import BaseRenderer
|
|
|
|
|
|
class MarkdownRenderer(BaseRenderer):
|
|
"""
|
|
自定义 Markdown 渲染器
|
|
告诉 DRF 如何处理 text/markdown 类型的响应
|
|
"""
|
|
media_type = 'text/markdown'
|
|
format = 'markdown'
|
|
charset = 'utf-8'
|
|
|
|
def render(self, data, accepted_media_type=None, renderer_context=None):
|
|
"""
|
|
data 就是我们在视图里传给 Response 的字符串
|
|
"""
|
|
if isinstance(data, str):
|
|
return data.encode(self.charset)
|
|
return str(data).encode(self.charset) |