初始提交:姜十三论坛 Jiang13 Forum
轻量自用论坛,Go 单二进制 + React SPA 内嵌 + SQLite。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
37
embed_static/templates/post_new.html
Normal file
37
embed_static/templates/post_new.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{{define "post_new.html"}}{{template "layout" .}}{{end}}
|
||||
{{define "content"}}
|
||||
<h3>发布新帖</h3>
|
||||
<form id="postForm">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">选择板块</label>
|
||||
<select name="board_id" class="form-select" required>
|
||||
{{range .Boards}}<option value="{{.ID}}">{{.Name}}</option>{{end}}
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">标题</label>
|
||||
<input type="text" name="title" class="form-control" required maxlength="256">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">标签(逗号分隔)</label>
|
||||
<input type="text" name="tags" class="form-control" placeholder="Go,技术,交流">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">内容(支持 HTML 富文本)</label>
|
||||
<textarea name="content" class="form-control" rows="12" required></textarea>
|
||||
<div class="form-text">可使用 <b>、<i>、<a>、<img> 等 HTML 标签</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success">发布</button>
|
||||
</form>
|
||||
{{end}}
|
||||
{{define "scripts"}}
|
||||
<script>
|
||||
document.getElementById('postForm').addEventListener('submit',function(e){
|
||||
e.preventDefault();
|
||||
apiPost('/api/posts',this,true).then(d=>{
|
||||
if(d.error){showToast(d.error,'danger');return;}
|
||||
location.href='/post/'+d.post_id;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
Reference in New Issue
Block a user