Commit 389f6b3e authored by 郭阔's avatar 郭阔

feat(panel): 新增「接入指南」页——渲染 docs/add-new-source.md

- 导航「添加栏目」后新增 /guide:markdown 实时渲染仓库文档(单一事实源,文档更新自动同步)
- web-venv 补装 markdown(阿里镜像);缺库时降级显示原文并提示
parent d410a743
......@@ -1288,6 +1288,24 @@ def _next_fire(times, now):
return min(cands) if cands else None
@app.route("/guide")
@require_auth
def guide():
"""接入指南:渲染仓库 docs/add-new-source.md(单一事实源,文档更新页面自动同步)。"""
doc = Path(__file__).resolve().parent.parent / "docs" / "add-new-source.md"
try:
text = doc.read_text(encoding="utf-8")
except OSError:
text = "# 指南缺失\n\n未找到 docs/add-new-source.md。"
body = None
try:
import markdown
body = markdown.markdown(text, extensions=["tables", "fenced_code"])
except ImportError:
pass
return render_template("guide.html", body=body, raw=text)
@app.route("/latest")
@require_auth
def latest_content():
......
......@@ -218,6 +218,7 @@
<a href="{{ url_for('index') }}">栏目列表</a>
<a href="{{ url_for('schedule_board') }}">调度中心</a>
<a href="{{ url_for('add_source') }}">添加栏目</a>
<a href="{{ url_for('guide') }}">接入指南</a>
<a href="{{ url_for('provider_list') }}">Provider</a>
<a href="{{ url_for('login_list') }}">站点登录</a>
<a href="{{ url_for('latest_content') }}">最近抓取</a>
......
{% extends "base.html" %}
{% block title %}接入指南 — News Harvester{% endblock %}
{% block extra_head %}
<style>
.md { max-width:1000px; line-height:1.75; font-size:14px; }
.md h1 { font-size:22px; border-bottom:1px solid #2a2d37; padding-bottom:8px; }
.md h2 { font-size:18px; margin-top:30px; color:#e8c34a; }
.md h3 { font-size:15px; margin-top:22px; color:#9ec1f0; }
.md p { margin:10px 0; }
.md ul, .md ol { margin:8px 0; padding-left:26px; }
.md li { margin:4px 0; }
.md table { border-collapse:collapse; width:100%; margin:12px 0; font-size:13px; }
.md th, .md td { border:1px solid #2a2d37; padding:6px 10px; text-align:left; vertical-align:top; }
.md th { background:#1a1d27; }
.md code { background:#1a1d27; border-radius:3px; padding:1px 5px; font-size:12.5px; }
.md pre { background:#141722; border:1px solid #2a2d37; border-radius:6px; padding:12px 14px; overflow-x:auto; margin:10px 0; }
.md pre code { background:none; padding:0; font-size:12.5px; }
.md blockquote { border-left:3px solid #3f7d52; margin:10px 0; padding:6px 14px; color:#aaa; background:#161923; border-radius:0 4px 4px 0; }
.md a { color:#6b9ef1; }
.md hr { border:none; border-top:1px solid #2a2d37; margin:18px 0; }
</style>
{% endblock %}
{% block content %}
<h1>接入指南</h1>
<p style="color:#666;font-size:13px">内容实时读取仓库 docs/add-new-source.md,文档更新本页自动同步。</p>
<div class="md">
{% if body %}{{ body|safe }}
{% else %}<pre>{{ raw }}</pre>
<p style="color:#888">提示:web-venv 缺 markdown 库,以上为原文;在 web-venv 安装 markdown 后自动恢复排版。</p>{% endif %}
</div>
{% endblock %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment