Use a single form for new posts and replies

This commit is contained in:
r 2019-12-21 08:36:44 +00:00
parent df875381d4
commit 39c57a6b65
7 changed files with 42 additions and 34 deletions

16
templates/postform.tmpl Normal file
View file

@ -0,0 +1,16 @@
<form class="post-form" action="/post" method="POST" enctype="multipart/form-data">
{{if .}}
<input type="hidden" name="reply_to_id" value="{{.InReplyToID}}" />
<label for="post-content"> Reply to {{.InReplyToName}} </label>
{{else}}
<label for="post-content"> New post </label>
{{end}}
<div class="post-form-content-container">
<textarea id="post-content" name="content" class="post-content" cols="50" rows="5">{{if .}}{{.ReplyContent}}{{end}}</textarea>
</div>
<div>
Attachments <input id="post-file-picker" type="file" name="attachments" multiple>
</div>
<button type="submit"> Post </button>
</form>

View file

@ -3,21 +3,11 @@
<div class="page-title"> Thread </div>
{{range .Statuses}}
{{template "status.tmpl" .}}
{{if eq .ID $.ReplyToID}}
<form class="timeline-post-form" action="/post" method="POST" enctype="multipart/form-data">
<input type="hidden" name="reply_to_id" value="{{$.ReplyToID}}" />
<label for="post-content"> reply to {{.Account.DisplayName}} </label>
<div class="post-form-content-container">
<textarea id="post-content" name="content" class="post-content" cols="50" rows="5">{{$.ReplyContent}}</textarea>
</div>
<div>
Attachments <input id="post-file-picker" type="file" name="attachments" multiple>
</div>
<button type="submit"> Post </button>
</form>
{{end}}
{{template "status.tmpl" .}}
{{if $.ReplyContext}}{{if eq .ID $.ReplyContext.InReplyToID}}
{{template "postform.tmpl" $.ReplyContext}}
{{end}}{{end}}
{{end}}

View file

@ -2,16 +2,8 @@
{{template "navigation.tmpl" .NavbarData}}
<div class="page-title"> Timeline </div>
<form class="timeline-post-form" action="/post" method="POST" enctype="multipart/form-data">
<label for="post-content"> New Post </label>
<div class="post-content-container">
<textarea id="post-content" name="content" class="post-content" cols="50" rows="5"></textarea>
</div>
<div class="post-attachment-div">
Attachments <input id="post-file-picker" type="file" name="attachments" multiple>
</div>
<button type="submit"> Post </button>
</form>
{{template "postform.tmpl" }}
{{range .Statuses}}
{{template "status.tmpl" .}}