compose 支持 poll 类型与选项,详情可投票/查看结果/结束。 Co-authored-by: Cursor <cursoragent@cursor.com>
242 lines
12 KiB
Cheetah
242 lines
12 KiB
Cheetah
{{define "post/body"}}
|
||
<article class="j13-post" data-post-id="{{.PostID}}" data-csrf="{{.CSRF}}" data-logged-in="{{if .LoggedIn}}1{{else}}0{{end}}">
|
||
<header class="j13-post__header">
|
||
<h1 class="j13-post__title">{{.PostTitle}}</h1>
|
||
{{if .ShowModerationBanner}}
|
||
<p class="j13-mod-banner j13-mod-banner--{{.Status}}" role="status">
|
||
{{if eq .Status "pending"}}本帖正在审核中,仅你与管理员可见。{{else if eq .Status "rejected"}}本帖未通过审核,仅你与管理员可见。{{else}}{{.StatusLabel}}{{end}}
|
||
</p>
|
||
{{end}}
|
||
<div class="j13-post__meta">
|
||
{{if .StatusLabel}}<span class="j13-tag j13-tag--{{.Status}}">{{.StatusLabel}}</span>{{end}}
|
||
{{if .Pinned}}<span class="j13-tag j13-tag--pin">置顶</span>{{end}}
|
||
{{if .Featured}}<span class="j13-tag j13-tag--feat">精华</span>{{end}}
|
||
{{if .EditLocked}}<span class="j13-tag">禁编</span>{{end}}
|
||
{{if .CommentsLocked}}<span class="j13-tag">已结贴</span>{{end}}
|
||
{{if .PostTypeLabel}}<span class="j13-tag">{{.PostTypeLabel}}</span>{{end}}
|
||
{{if .BoardName}}<a class="j13-tag" href="/board/{{.BoardID}}">{{.BoardName}}</a>{{end}}
|
||
{{if .AuthorID}}<a href="/user/{{.AuthorID}}">{{.AuthorName}}</a>{{else}}<span>{{.AuthorName}}</span>{{end}}
|
||
<span>{{.CreatedLabel}}</span>
|
||
<span>{{.ViewCount}} 阅读</span>
|
||
</div>
|
||
{{if .LoggedIn}}
|
||
<div class="j13-post__actions">
|
||
<form method="post" action="/post/{{.PostID}}/like" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<button type="submit">{{if .Liked}}取消赞{{else}}赞{{end}} ({{.LikeCount}})</button>
|
||
</form>
|
||
<form method="post" action="/post/{{.PostID}}/favorite" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<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>
|
||
<form method="post" action="/post/{{.PostID}}/report" class="j13-report__form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<label>原因
|
||
<select name="reason" required>
|
||
<option value="">请选择</option>
|
||
<option value="spam">垃圾广告</option>
|
||
<option value="abuse">人身攻击 / 辱骂</option>
|
||
<option value="illegal">违法违规</option>
|
||
<option value="irrelevant">内容无关 / 灌水</option>
|
||
<option value="other">其他</option>
|
||
</select>
|
||
</label>
|
||
<label>补充说明(可选)
|
||
<input name="detail" maxlength="500" placeholder="可选"/>
|
||
</label>
|
||
<button type="submit" class="j13-btn j13-btn--sm">提交举报</button>
|
||
</form>
|
||
</details>
|
||
{{end}}
|
||
</div>
|
||
{{end}}
|
||
{{if .IsAdmin}}
|
||
<div class="j13-post__admin" role="group" aria-label="管理操作">
|
||
<form method="post" action="/post/{{.PostID}}/admin/pin" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<input type="hidden" name="enable" value="{{if .GlobalPinned}}0{{else}}1{{end}}"/>
|
||
<button type="submit" class="j13-linkbtn">{{if .GlobalPinned}}取消全局置顶{{else}}全局置顶{{end}}</button>
|
||
</form>
|
||
<form method="post" action="/post/{{.PostID}}/admin/board-pin" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<input type="hidden" name="enable" value="{{if .BoardPinned}}0{{else}}1{{end}}"/>
|
||
<button type="submit" class="j13-linkbtn">{{if .BoardPinned}}取消版内置顶{{else}}版内置顶{{end}}</button>
|
||
</form>
|
||
<form method="post" action="/post/{{.PostID}}/admin/feature" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<input type="hidden" name="enable" value="{{if .Featured}}0{{else}}1{{end}}"/>
|
||
<button type="submit" class="j13-linkbtn">{{if .Featured}}取消精华{{else}}设为精华{{end}}</button>
|
||
</form>
|
||
<form method="post" action="/post/{{.PostID}}/admin/edit-lock" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<input type="hidden" name="enable" value="{{if .EditLocked}}0{{else}}1{{end}}"/>
|
||
<button type="submit" class="j13-linkbtn">{{if .EditLocked}}允许编辑{{else}}禁止编辑{{end}}</button>
|
||
</form>
|
||
<form method="post" action="/post/{{.PostID}}/admin/comments-lock" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<input type="hidden" name="enable" value="{{if .CommentsLocked}}0{{else}}1{{end}}"/>
|
||
<button type="submit" class="j13-linkbtn">{{if .CommentsLocked}}解锁评论{{else}}锁定评论{{end}}</button>
|
||
</form>
|
||
<form method="post" action="/post/{{.PostID}}/admin/delete" class="j13-inline-form" onsubmit="return confirm('确认移入回收站?');">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<button type="submit" class="j13-linkbtn">移入回收站</button>
|
||
</form>
|
||
</div>
|
||
{{end}}
|
||
</header>
|
||
{{if .Poll}}
|
||
<section class="j13-poll" aria-label="投票">
|
||
<h2 class="j13-poll__title">投票</h2>
|
||
<p class="j13-muted">
|
||
{{if .Poll.Multi}}多选(最多 {{.Poll.MaxChoices}} 项){{else}}单选{{end}}
|
||
· 共 {{.Poll.TotalVotes}} 票
|
||
{{if .Poll.EndsLabel}} · 截止 {{.Poll.EndsLabel}}{{end}}
|
||
{{if .Poll.Closed}} · 已结束{{else if .Poll.HasVoted}} · 你已投票{{end}}
|
||
</p>
|
||
{{if .Poll.CanVote}}
|
||
<form method="post" action="/post/{{.PostID}}/poll/vote" class="j13-form j13-poll__form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<ul class="j13-poll__options">
|
||
{{range .Poll.Options}}
|
||
<li>
|
||
<label class="j13-check">
|
||
{{if $.Poll.Multi}}
|
||
<input type="checkbox" name="option_ids" value="{{.ID}}"/>
|
||
{{else}}
|
||
<input type="radio" name="option_id" value="{{.ID}}" required/>
|
||
{{end}}
|
||
{{.Text}}
|
||
</label>
|
||
</li>
|
||
{{end}}
|
||
</ul>
|
||
<button type="submit">提交投票</button>
|
||
</form>
|
||
{{else}}
|
||
<ul class="j13-poll__options">
|
||
{{range .Poll.Options}}
|
||
<li class="j13-poll__option{{if .Selected}} is-selected{{end}}">
|
||
<span class="j13-poll__opt-text">{{.Text}}</span>
|
||
{{if $.Poll.ShowResults}}
|
||
<span class="j13-poll__bar" style="--pct: {{.Percent}}%"></span>
|
||
<span class="j13-muted">{{.Percent}}%({{.VoteCount}})</span>
|
||
{{end}}
|
||
</li>
|
||
{{end}}
|
||
</ul>
|
||
{{if and (not $.LoggedIn) (not .Poll.Closed)}}
|
||
<p class="j13-muted"><a href="/login?redirect={{.PostPath}}">登录</a> 后可投票。</p>
|
||
{{end}}
|
||
{{end}}
|
||
{{if .Poll.CanClose}}
|
||
<form method="post" action="/post/{{.PostID}}/poll/close" class="j13-inline-form" onsubmit="return confirm('确认结束投票?');">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<button type="submit" class="j13-linkbtn">结束投票</button>
|
||
</form>
|
||
{{end}}
|
||
</section>
|
||
{{end}}
|
||
<div class="j13-post__content post-detail-content">{{safeHTML .BodyHTML}}</div>
|
||
</article>
|
||
|
||
<section class="j13-comments" id="comments">
|
||
<h2>评论 ({{.CommentCount}})</h2>
|
||
{{if not .Comments}}
|
||
<p class="j13-empty">暂无评论。</p>
|
||
{{else}}
|
||
<ul class="j13-comment-list">
|
||
{{range .Comments}}
|
||
<li class="j13-comment" id="floor-{{.Floor}}" data-comment-id="{{.ID}}" data-floor="{{.Floor}}" data-author="{{.AuthorName}}">
|
||
<div class="j13-comment__meta">
|
||
<span class="j13-comment__floor">#{{.Floor}}</span>
|
||
{{if .AuthorID}}<a href="/user/{{.AuthorID}}">{{.AuthorName}}</a>{{else}}<span>{{.AuthorName}}</span>{{end}}
|
||
<span>{{.CreatedLabel}}</span>
|
||
{{if .StatusLabel}}<span class="j13-tag j13-tag--{{.Status}}">{{.StatusLabel}}</span>{{end}}
|
||
{{if .IsPrivate}}<span class="j13-tag">私密</span>{{end}}
|
||
{{if .ReplyToFloor}}
|
||
<span class="j13-comment__reply-to">回复 <a href="#floor-{{.ReplyToFloor}}">#{{.ReplyToFloor}}</a>{{if .ReplyToAuthor}} {{.ReplyToAuthor}}{{end}}</span>
|
||
{{end}}
|
||
</div>
|
||
{{if .ContentHidden}}
|
||
<p class="j13-muted">(私密评论不可见)</p>
|
||
{{else}}
|
||
<div class="j13-comment__body">{{safeHTML .Content}}</div>
|
||
{{end}}
|
||
{{if $.LoggedIn}}
|
||
<div class="j13-comment__actions">
|
||
<form method="post" action="/post/{{$.PostID}}/comments/{{.ID}}/like" class="j13-inline-form">
|
||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||
<button type="submit" class="j13-linkbtn">{{if .Liked}}取消赞{{else}}赞{{end}} ({{.LikeCount}})</button>
|
||
</form>
|
||
{{if not $.CommentsLocked}}
|
||
<button type="button" class="j13-linkbtn j13-comment__reply-btn" data-reply-to="{{.ID}}" data-reply-floor="{{.Floor}}" data-reply-author="{{.AuthorName}}">回复</button>
|
||
{{end}}
|
||
{{if .CanEdit}}
|
||
<a class="j13-linkbtn" href="/post/{{$.PostID}}/comments/{{.ID}}/edit">编辑</a>
|
||
{{end}}
|
||
{{if .CanDelete}}
|
||
<form method="post" action="/post/{{$.PostID}}/comments/{{.ID}}/delete" class="j13-inline-form" onsubmit="return confirm('确定删除该评论?回复也会一并移入回收站。');">
|
||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||
<button type="submit" class="j13-linkbtn">删除</button>
|
||
</form>
|
||
{{end}}
|
||
{{if .CanReport}}
|
||
<details class="j13-report">
|
||
<summary class="j13-linkbtn">举报</summary>
|
||
<form method="post" action="/post/{{$.PostID}}/comments/{{.ID}}/report" class="j13-report__form">
|
||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||
<label>原因
|
||
<select name="reason" required>
|
||
<option value="">请选择</option>
|
||
<option value="spam">垃圾广告</option>
|
||
<option value="abuse">人身攻击 / 辱骂</option>
|
||
<option value="illegal">违法违规</option>
|
||
<option value="irrelevant">内容无关 / 灌水</option>
|
||
<option value="other">其他</option>
|
||
</select>
|
||
</label>
|
||
<label>补充说明(可选)
|
||
<input name="detail" maxlength="500" placeholder="可选"/>
|
||
</label>
|
||
<button type="submit" class="j13-btn j13-btn--sm">提交举报</button>
|
||
</form>
|
||
</details>
|
||
{{end}}
|
||
</div>
|
||
{{end}}
|
||
</li>
|
||
{{end}}
|
||
</ul>
|
||
{{end}}
|
||
|
||
{{if .LoggedIn}}
|
||
{{if .CommentsLocked}}
|
||
<p class="j13-muted">评论已锁定。</p>
|
||
{{else}}
|
||
<form class="j13-comment-form" method="post" action="/post/{{.PostID}}/comments" id="comment-form">
|
||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||
<input type="hidden" name="reply_to" id="comment-reply-to" value=""/>
|
||
<p class="j13-muted j13-comment-reply-hint" id="comment-reply-hint" hidden></p>
|
||
<label for="comment-content">发表评论</label>
|
||
<textarea id="comment-content" name="content" rows="4" required maxlength="8000"></textarea>
|
||
<label class="j13-check">
|
||
<input type="checkbox" name="is_private" value="1"/>
|
||
私密评论(仅相关可见)
|
||
</label>
|
||
<div class="j13-form__row">
|
||
<button type="submit">提交</button>
|
||
<button type="button" class="j13-btn-secondary" id="comment-reply-clear" hidden>取消回复</button>
|
||
</div>
|
||
</form>
|
||
{{end}}
|
||
{{else}}
|
||
<p><a href="/login?redirect={{.PostPath}}">登录</a> 后回复。</p>
|
||
{{end}}
|
||
</section>
|
||
{{end}}
|