This repository has been archived on 2026-06-21. You can view files and clone it, but cannot push or open issues or pull requests.
Files
MetaLab/templates/MetaLab-2026/html/posts/index.html
Victor_Jay 8a8d801187 fix: 修复帖子系统5项缺陷 + 代码块插入位置/language-class/分割线占位
- 作者显示 用户名(UID): 修正Post.AuthorName GORM标签从 -:all 改为 -:migration;<-:false;column:author_name
- 审核流程: 帖子详情页新增"提交审核"按钮(draft/rejected时作者可见)
- 图片上传: 新增 POST /api/posts/upload-image 端点,限制5MB/jpg/png/gif/webp
- 代码块语言标注: 工具栏插入代码块时弹出语言输入框,生成 language-xxx class
- 状态中文显示: 管理后台/帖子详情页状态改为 PostStatusDisplayNames 映射
- 修复代码块插入位置错误: init时调用switchMode同步DOM; 无选区时appendChild; 防<pre>嵌套
- 修复 bluemonday.UGCPolicy() 剥离 code/pre 的 class 属性,显式 AllowAttrs("class")
- 修复分割线工具栏插入多余text占位符: hr/link/image以外不强制填占位文本
2026-05-27 19:22:47 +08:00

59 lines
1.8 KiB
HTML

{{template "layout/header.html" .}}
<body>
{{template "layout/nav.html" .}}
<div class="container posts-container">
<div class="posts-header">
<h1>社区帖子</h1>
{{if .IsLoggedIn}}
<a href="/posts/new" class="btn btn-primary">撰写帖子</a>
{{end}}
</div>
{{if .Error}}
<div class="error-message">{{.Error}}</div>
{{end}}
{{if .Keyword}}
<div class="search-hint">搜索:<strong>{{.Keyword}}</strong></div>
{{end}}
<div class="posts-list">
{{if eq (len .Posts) 0}}
<div class="empty-state">暂无帖子</div>
{{else}}
{{range .Posts}}
<article class="post-card">
<h2 class="post-card-title">
<a href="/posts/{{.ID}}">{{.Title}}</a>
</h2>
<div class="post-card-meta">
<span class="post-author">{{if .AuthorName}}{{.AuthorName}}({{.UserID}}){{else}}UID{{.UserID}}{{end}}</span>
<span class="post-time">{{.CreatedAt.Format "2006-01-02 15:04"}}</span>
</div>
<p class="post-card-summary">{{printf "%.200s" .Body}}</p>
</article>
{{end}}
{{end}}
</div>
{{if gt .TotalPages 1}}
<div class="pagination">
{{if gt .Page 1}}
<a href="?page={{.PrevPage}}{{if .Keyword}}&keyword={{.Keyword}}{{end}}" class="page-link">上一页</a>
{{end}}
<span class="page-info">第 {{.Page}} / {{.TotalPages}} 页 (共 {{.Total}} 条)</span>
{{if lt .Page .TotalPages}}
<a href="?page={{.NextPage}}{{if .Keyword}}&keyword={{.Keyword}}{{end}}" class="page-link">下一页</a>
{{end}}
</div>
{{end}}
</div>
{{template "layout/footer.html" .}}
<script src="/static/js/common.js"></script>
</body>
</html>