feat: SSR 帖子修订历史列表与快照

作者与管理员可查看编辑前版本,帖详情增加修订入口。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-29 22:28:04 +08:00
parent c32c81d1ca
commit f10ba99012
9 changed files with 186 additions and 2 deletions

View File

@@ -24,6 +24,7 @@
<button type="submit">{{if .Favorited}}取消收藏{{else}}收藏{{end}}</button>
</form>
{{if .CanEdit}}<a class="j13-linkbtn" href="/post/{{.PostID}}/edit">编辑</a>{{end}}
{{if .CanViewRevisions}}<a class="j13-linkbtn" href="/post/{{.PostID}}/revisions">修订历史</a>{{end}}
{{if .CanReportPost}}
<details class="j13-report">
<summary class="j13-linkbtn">举报</summary>

View File

@@ -0,0 +1,19 @@
{{define "post/revision_detail"}}
{{template "base/head" .}}
{{template "base/navbar" .}}
<main class="j13-main j13-main--solo">
<p class="j13-muted">
<a href="/post/{{.PostID}}/revisions">← 修订列表</a>
· <a href="/post/{{.PostID}}">当前帖子</a>
</p>
<h1>修订 #{{.RevID}}</h1>
<p class="j13-muted">{{.EditorName}} · {{.CreatedLabel}}</p>
{{template "base/alert" .}}
<article class="j13-post j13-rev-snapshot">
<h2 class="j13-post__title">{{.Title}}</h2>
{{if .Tags}}<p class="j13-muted">标签:{{.Tags}}</p>{{end}}
<div class="j13-post__body">{{safeHTML .BodyHTML}}</div>
</article>
</main>
{{template "base/footer" .}}
{{end}}

View File

@@ -0,0 +1,24 @@
{{define "post/revisions"}}
{{template "base/head" .}}
{{template "base/navbar" .}}
<main class="j13-main j13-main--solo">
<h1>修订历史</h1>
<p class="j13-muted"><a href="/post/{{.PostID}}">← {{.PostTitle}}</a></p>
{{template "base/alert" .}}
{{if .Revisions}}
<ul class="j13-rev-list">
{{range .Revisions}}
<li class="j13-rev-item">
<a href="/post/{{$.PostID}}/revisions/{{.ID}}">
<strong>{{.Title}}</strong>
<span class="j13-muted">{{.EditorName}} · {{.CreatedLabel}}</span>
</a>
</li>
{{end}}
</ul>
{{else}}
<p class="j13-empty">暂无修订记录。编辑帖子后会在此保存旧版本。</p>
{{end}}
</main>
{{template "base/footer" .}}
{{end}}