Add support for scopes

- Add scope selection for for new post
- Save new post scope in db
- Copy scope on reply
- Show scope icon on posts
This commit is contained in:
r 2019-12-21 13:26:31 +00:00
parent 3af4361927
commit 2678f33157
13 changed files with 126 additions and 70 deletions

View file

@ -1,15 +1,25 @@
<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>
{{if .ReplyContext}}
<input type="hidden" name="reply_to_id" value="{{.ReplyContext.InReplyToID}}" />
<label for="post-content"> Reply to {{.ReplyContext.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>
<textarea id="post-content" name="content" class="post-content" cols="50" rows="5">{{if .ReplyContext}}{{.ReplyContext.ReplyContent}}{{end}}</textarea>
</div>
<div>
Attachments <input id="post-file-picker" type="file" name="attachments" multiple>
<label for ="post-visilibity"> Visibility </label>
<select id="post-visilibity" type="file" name="visibility">
<option value="public" {{if eq .DefaultVisibility "public"}}selected{{end}}>Public</option>
<option value="unlisted" {{if eq .DefaultVisibility "unlisted"}}selected{{end}}>Unlisted</option>
<option value="private" {{if eq .DefaultVisibility "private"}}selected{{end}}>Private</option>
<option value="direct" {{if eq .DefaultVisibility "direct"}}selected{{end}}>Direct</option>
</select>
</div>
<div>
<label for ="post-file-picker"> Attachments </label>
<input id="post-file-picker" type="file" name="attachments" multiple>
</div>
<button type="submit"> Post </button>
</form>

View file

@ -26,6 +26,17 @@
<a href="/user/{{.Account.ID}}" >
<span class="status-uname"> {{.Account.Acct}} </span>
</a>
<a class="status-visibility" href="{{.URL}}" target="_blank">
{{if eq .Visibility "public"}}
<span class="icon dripicons-web" title="Public"></span>
{{else if eq .Visibility "unlisted"}}
<span class="icon dripicons-lock-open" title="Unlisted"></span>
{{else if eq .Visibility "private"}}
<span class="icon dripicons-lock" title="Private"></span>
{{else if eq .Visibility "direct"}}
<span class="icon dripicons-mail" title="Direct"></span>
{{end}}
</a>
</div>
{{end}}
<div class="status-reply-container">
@ -68,16 +79,23 @@
<span class="icon dripicons-reply"></span>
<span> {{DisplayInteractionCount .RepliesCount}} </span>
</a>
{{if .Reblogged}}
<a class="status-retweet" href="/unretweet/{{.ID}}" title="undo repost">
<span class="icon dripicons-retweet retweeted"></span>
<span> {{DisplayInteractionCount .ReblogsCount}} </span>
</a>
{{else}}
<a class="status-retweet" href="/retweet/{{.ID}}" title="repost">
{{if or (eq .Visibility "private") (eq .Visibility "direct")}}
<a class="status-retweet" title="this status cannot be retweeted">
<span class="icon dripicons-retweet"></span>
<span> {{DisplayInteractionCount .ReblogsCount}} </span>
</a>
{{else}}
{{if .Reblogged}}
<a class="status-retweet" href="/unretweet/{{.ID}}" title="undo retweet">
<span class="icon dripicons-retweet retweeted"></span>
<span> {{DisplayInteractionCount .ReblogsCount}} </span>
</a>
{{else}}
<a class="status-retweet" href="/retweet/{{.ID}}" title="retweet">
<span class="icon dripicons-retweet"></span>
<span> {{DisplayInteractionCount .ReblogsCount}} </span>
</a>
{{end}}
{{end}}
{{if .Favourited}}
<a class="status-like" href="/unlike/{{.ID}}" title="unlike">

View file

@ -5,8 +5,8 @@
{{range .Statuses}}
{{template "status.tmpl" .}}
{{if $.ReplyContext}}{{if eq .ID $.ReplyContext.InReplyToID}}
{{template "postform.tmpl" $.ReplyContext}}
{{if $.PostContext.ReplyContext}}{{if eq .ID $.PostContext.ReplyContext.InReplyToID}}
{{template "postform.tmpl" $.PostContext}}
{{end}}{{end}}
{{end}}

View file

@ -3,7 +3,7 @@
<div class="page-title"> Timeline </div>
{{template "postform.tmpl" }}
{{template "postform.tmpl" .PostContext}}
{{range .Statuses}}
{{template "status.tmpl" .}}