feat: SSR 友链页与最小 Admin 审核
公开 /links 列表与申请/取消,导航页脚可配入口;后台品牌增删与通过/拒绝。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
95
templates/admin/friend_links.tmpl
Normal file
95
templates/admin/friend_links.tmpl
Normal file
@@ -0,0 +1,95 @@
|
||||
{{define "admin/friend_links"}}
|
||||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
<main class="j13-main j13-admin">
|
||||
<h1>友链管理</h1>
|
||||
{{template "admin/nav" .}}
|
||||
{{template "base/alert" .}}
|
||||
|
||||
<section>
|
||||
<h2>入口与检测</h2>
|
||||
<form method="post" action="/admin/friend-links/settings" class="j13-form j13-admin-form">
|
||||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||||
<label class="j13-check"><input type="checkbox" name="nav_show" value="1"{{if .NavShow}} checked{{end}}/> 导航显示友链入口</label>
|
||||
<label class="j13-check"><input type="checkbox" name="footer_show" value="1"{{if .FooterShow}} checked{{end}}/> 页脚显示友链入口</label>
|
||||
<label class="j13-check"><input type="checkbox" name="reciprocal_check" value="1"{{if .ReciprocalCheck}} checked{{end}}/> 启用回链检测</label>
|
||||
<button type="submit">保存设置</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>品牌友链({{len .BrandLinks}}/20)</h2>
|
||||
{{if .BrandLinks}}
|
||||
<table class="j13-admin-table">
|
||||
<thead><tr><th>名称</th><th>URL</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
{{range .BrandLinks}}
|
||||
<tr>
|
||||
<td>{{if .Logo}}<img src="{{.Logo}}" alt="" class="j13-links__logo j13-links__logo--sm"/> {{end}}{{.Name}}</td>
|
||||
<td><a href="{{.URL}}" target="_blank" rel="noopener noreferrer">{{.URL}}</a></td>
|
||||
<td>
|
||||
<form method="post" action="/admin/friend-links/brand/delete" class="j13-inline-form">
|
||||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||||
<input type="hidden" name="url" value="{{.URL}}"/>
|
||||
<button type="submit" class="j13-linkbtn">删除</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="j13-muted">暂无品牌友链</p>
|
||||
{{end}}
|
||||
<form method="post" action="/admin/friend-links/brand" class="j13-form j13-admin-form">
|
||||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||||
<h3>添加品牌友链</h3>
|
||||
<label>名称 <input name="name" maxlength="32" required/></label>
|
||||
<label>URL <input name="url" type="url" required placeholder="https://"/></label>
|
||||
<label>LOGO(可选) <input name="logo" type="text" placeholder="https:// 或 /uploads/..."/></label>
|
||||
<button type="submit">添加</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>申请队列{{if gt .PendingCount 0}}(待审 {{.PendingCount}}){{end}}</h2>
|
||||
{{if .Applies}}
|
||||
<table class="j13-admin-table">
|
||||
<thead>
|
||||
<tr><th>时间</th><th>申请人</th><th>站点</th><th>状态</th><th>操作</th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .Applies}}
|
||||
<tr>
|
||||
<td>{{.CreatedAt}}</td>
|
||||
<td>{{if .Username}}{{.Username}}{{else}}#{{.UserID}}{{end}}</td>
|
||||
<td>
|
||||
{{if .Logo}}<img src="{{.Logo}}" alt="" class="j13-links__logo j13-links__logo--sm"/>{{end}}
|
||||
<a href="{{.URL}}" target="_blank" rel="noopener noreferrer">{{.Name}}</a>
|
||||
<div class="j13-muted">回链:{{if .Reciprocal}}<a href="{{.Reciprocal}}" target="_blank" rel="noopener noreferrer">页面</a>{{else}}—{{end}}{{if .RecipOK}} · 已验证{{else if .RecipNote}} · {{.RecipNote}}{{end}}</div>
|
||||
</td>
|
||||
<td>{{.StatusLabel}}</td>
|
||||
<td>
|
||||
{{if .CanReview}}
|
||||
<form method="post" action="/admin/friend-links/applies/{{.ID}}/approve" class="j13-inline-form">
|
||||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||||
<button type="submit">通过</button>
|
||||
</form>
|
||||
<form method="post" action="/admin/friend-links/applies/{{.ID}}/reject" class="j13-admin-reject">
|
||||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||||
<input name="note" placeholder="拒绝原因(可选)"/>
|
||||
<button type="submit">拒绝</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="j13-muted">暂无申请</p>
|
||||
{{end}}
|
||||
</section>
|
||||
</main>
|
||||
{{template "base/footer" .}}
|
||||
{{end}}
|
||||
@@ -3,6 +3,7 @@
|
||||
<a href="/admin/dashboard"{{if eq .NavActive "dashboard"}} class="is-active"{{end}}>仪表盘</a>
|
||||
<a href="/admin/boards"{{if eq .NavActive "boards"}} class="is-active"{{end}}>板块</a>
|
||||
<a href="/admin/moderation"{{if eq .NavActive "moderation"}} class="is-active"{{end}}>审核</a>
|
||||
<a href="/admin/friend-links"{{if eq .NavActive "friend-links"}} class="is-active"{{end}}>友链</a>
|
||||
<a href="/admin/settings"{{if eq .NavActive "settings"}} class="is-active"{{end}}>设置</a>
|
||||
<a href="/">返回前台</a>
|
||||
</nav>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{{define "base/footer"}}
|
||||
<footer class="j13-footer">
|
||||
<p>{{.SiteName}}</p>
|
||||
<p>
|
||||
{{.SiteName}}
|
||||
{{if .ShowFriendLinksFooter}} · <a href="/links">友情链接</a>{{end}}
|
||||
</p>
|
||||
</footer>
|
||||
<script src="/ssr-assets/site.js" defer></script>
|
||||
</body>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
</span>
|
||||
</a>
|
||||
<nav class="j13-nav">
|
||||
{{if .ShowFriendLinksNav}}<a href="/links">友链</a>{{end}}
|
||||
{{if .LoggedIn}}
|
||||
<a href="/compose">发帖</a>
|
||||
<a href="/messages">私信{{if gt .UnreadCount 0}} <span class="j13-badge">{{.UnreadCount}}</span>{{end}}</a>
|
||||
|
||||
@@ -2,5 +2,5 @@ package templates
|
||||
|
||||
import "embed"
|
||||
|
||||
//go:embed *.tmpl base/*.tmpl home/*.tmpl post/*.tmpl shared/*.tmpl status/*.tmpl auth/*.tmpl admin/*.tmpl profile/*.tmpl user/*.tmpl favorites/*.tmpl messages/*.tmpl
|
||||
//go:embed *.tmpl base/*.tmpl home/*.tmpl post/*.tmpl shared/*.tmpl status/*.tmpl auth/*.tmpl admin/*.tmpl profile/*.tmpl user/*.tmpl favorites/*.tmpl messages/*.tmpl links/*.tmpl
|
||||
var FS embed.FS
|
||||
|
||||
84
templates/links/list.tmpl
Normal file
84
templates/links/list.tmpl
Normal file
@@ -0,0 +1,84 @@
|
||||
{{define "links/list"}}
|
||||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
<main class="j13-main j13-links">
|
||||
<h1>友情链接</h1>
|
||||
{{template "base/alert" .}}
|
||||
|
||||
<section class="j13-links__list">
|
||||
{{if .Links}}
|
||||
<ul class="j13-links__grid">
|
||||
{{range .Links}}
|
||||
<li>
|
||||
<a href="{{.URL}}" target="_blank" rel="noopener noreferrer" class="j13-links__item">
|
||||
{{if .Logo}}<img src="{{.Logo}}" alt="" class="j13-links__logo"/>{{end}}
|
||||
<span>{{.Name}}</span>
|
||||
</a>
|
||||
</li>
|
||||
{{end}}
|
||||
</ul>
|
||||
{{else}}
|
||||
<p class="j13-muted">暂无友情链接</p>
|
||||
{{end}}
|
||||
</section>
|
||||
|
||||
{{if .LoggedIn}}
|
||||
<section class="j13-links__apply">
|
||||
<h2>申请友链</h2>
|
||||
<form method="post" action="/links/apply" enctype="multipart/form-data" class="j13-form j13-admin-form" data-logo-upload="/links/logo">
|
||||
<input type="hidden" name="_csrf" value="{{.CSRF}}"/>
|
||||
<label>站点名称 <input name="name" value="{{.FormName}}" maxlength="32" required/></label>
|
||||
<label>站点 URL <input name="url" type="url" value="{{.FormURL}}" placeholder="https://" required/></label>
|
||||
<label>LOGO 地址 <input name="logo" id="fl-logo-url" type="text" value="{{.FormLogo}}" placeholder="https:// 或先上传"/></label>
|
||||
<label>或上传 LOGO(最大 {{.AvatarMaxMB}} MB)
|
||||
<input type="file" name="logo_file" id="fl-logo-file" accept="image/*"/>
|
||||
</label>
|
||||
<label class="j13-check">
|
||||
<input type="checkbox" name="link_on_homepage" value="1"{{if .FormOnHome}} checked{{end}}/>
|
||||
已在对方首页放置本站链接
|
||||
</label>
|
||||
<label>回链页 URL(未勾选上一项时必填)
|
||||
<input name="reciprocal_page_url" type="url" value="{{.FormRecip}}" placeholder="https://"/>
|
||||
</label>
|
||||
<button type="submit">提交申请</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="j13-links__mine">
|
||||
<h2>我的申请</h2>
|
||||
{{if .MyApplies}}
|
||||
<table class="j13-profile__ledger">
|
||||
<thead>
|
||||
<tr><th>时间</th><th>站点</th><th>状态</th><th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{range .MyApplies}}
|
||||
<tr>
|
||||
<td>{{.CreatedAt}}</td>
|
||||
<td>
|
||||
<a href="{{.URL}}" target="_blank" rel="noopener noreferrer">{{.Name}}</a>
|
||||
{{if .ReviewNote}}<div class="j13-muted">{{.ReviewNote}}</div>{{end}}
|
||||
</td>
|
||||
<td>{{.StatusLabel}}</td>
|
||||
<td>
|
||||
{{if .CanCancel}}
|
||||
<form method="post" action="/links/apply/{{.ID}}/cancel" class="j13-inline-form">
|
||||
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
|
||||
<button type="submit" class="j13-linkbtn">取消</button>
|
||||
</form>
|
||||
{{end}}
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{else}}
|
||||
<p class="j13-muted">暂无申请记录</p>
|
||||
{{end}}
|
||||
</section>
|
||||
{{else}}
|
||||
<p class="j13-muted"><a href="/login?redirect=/links">登录</a> 后可申请友情链接。</p>
|
||||
{{end}}
|
||||
</main>
|
||||
{{template "base/footer" .}}
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user