put other post content behind spoiler

This commit is contained in:
alyssa rose 2021-03-24 01:19:47 +00:00 committed by alyssa
parent dd27b1e875
commit 44ca9a290e
2 changed files with 104 additions and 93 deletions

102
templates/postcontent.tmpl Normal file
View File

@ -0,0 +1,102 @@
{{ with $s := .Data }}
{{StatusContentFilter .Content .Emojis .Mentions}}
{{if .MediaAttachments}}
<div class="status-media-container">
{{range .MediaAttachments}}
{{if eq .Type "image"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[image]{{end}}
</a>
{{else}}
<a class="img-link" href="{{.URL}}" target="_blank" title="{{.Description}}">
<img class="status-image" src="{{.URL}}" alt="status-image" height="240" />
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</a>
{{end}}
{{else if eq .Type "audio"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[audio]{{end}}
</a>
{{else}}
<audio class="status-audio" controls title="{{.Description}}">
<source src="{{.URL}}">
<a href="{{.URL}}" target="_blank"> [audio] </a>
</audio>
{{end}}
{{else if eq .Type "video"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[video]{{end}}
</a>
{{else}}
<div class="status-video-container" title="{{.Description}}">
<video class="status-video" controls height="240">
<source src="{{.URL}}">
<a href="{{.URL}}" target="_blank"> [video] </a>
</video>
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</div>
{{end}}
{{else}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[attachment]{{end}}
</a>
{{end}}
{{end}}
</div>
{{end}}
{{if .Poll}}
<!-- lol does any of this work -->
<form class="poll-form" action="/vote/{{.Poll.ID}}" method="POST" target="_self">
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
<input type="hidden" name="status_id" value="{{$s.ID}}">
{{range $i, $o := .Poll.Options}}
<div class="poll-option">
{{if (or $s.Poll.Expired $s.Poll.Voted)}}
<div> {{EmojiFilter $o.Title $s.Emojis}} - {{$o.VotesCount}} votes </div>
{{else}}
<input type="{{if $s.Poll.Multiple}}checkbox{{else}}radio{{end}}" name="choices"
id="poll-{{$s.ID}}-{{$i}}" value="{{$i}}">
<label for="poll-{{$s.ID}}-{{$i}}">
{{EmojiFilter $o.Title $s.Emojis}}
</label>
{{end}}
</div>
{{end}}
{{if not (or .Poll.Expired .Poll.Voted)}}
<button type="submit"> Vote </button>
{{end}}
<div class="poll-info">
<span>{{.Poll.VotesCount}} votes</span>
{{if .Poll.Expired}}
<span> - poll expired </span>
{{else if .Poll.ExpiresAt}}
<span>
- poll ends in
<time datetime="{{FormatTimeRFC3339 .Poll.ExpiresAt}}" title="{{FormatTimeRFC822 .Poll.ExpiresAt}}">
{{TimeUntil .Poll.ExpiresAt}}
</time>
</span>
{{end}}
</div>
</form>
{{end}}
{{ end }}

View File

@ -91,103 +91,12 @@
{{if .SpoilerText}}
<details>
<summary><span></span>{{.SpoilerText}}</summary>
{{StatusContentFilter .Content .Emojis .Mentions}}
{{template "postcontent.tmpl" (WithContext $s $.Ctx)}}
</details>
{{else}}
{{StatusContentFilter .Content .Emojis .Mentions}}
{{template "postcontent.tmpl" (WithContext $s $.Ctx)}}
{{end}}
{{end}}
{{if .MediaAttachments}}
<div class="status-media-container">
{{range .MediaAttachments}}
{{if eq .Type "image"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[image]{{end}}
</a>
{{else}}
<a class="img-link" href="{{.URL}}" target="_blank" title="{{.Description}}">
<img class="status-image" src="{{.URL}}" alt="status-image" height="240" />
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</a>
{{end}}
{{else if eq .Type "audio"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[audio]{{end}}
</a>
{{else}}
<audio class="status-audio" controls title="{{.Description}}">
<source src="{{.URL}}">
<a href="{{.URL}}" target="_blank"> [audio] </a>
</audio>
{{end}}
{{else if eq .Type "video"}}
{{if $.Ctx.HideAttachments}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[video]{{end}}
</a>
{{else}}
<div class="status-video-container" title="{{.Description}}">
<video class="status-video" controls height="240">
<source src="{{.URL}}">
<a href="{{.URL}}" target="_blank"> [video] </a>
</video>
{{if (and $.Ctx.MaskNSFW $s.Sensitive)}}
<div class="status-nsfw-overlay"></div>
{{end}}
</div>
{{end}}
{{else}}
<a href="{{.URL}}" target="_blank">
{{if .Description}}[{{.Description}}]{{else}}[attachment]{{end}}
</a>
{{end}}
{{end}}
</div>
{{end}}
{{if .Poll}}
<form class="poll-form" action="/vote/{{.Poll.ID}}" method="POST" target="_self">
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
<input type="hidden" name="referrer" value="{{$.Ctx.Referrer}}">
<input type="hidden" name="status_id" value="{{$s.ID}}">
{{range $i, $o := .Poll.Options}}
<div class="poll-option">
{{if (or $s.Poll.Expired $s.Poll.Voted)}}
<div> {{EmojiFilter $o.Title $s.Emojis}} - {{$o.VotesCount}} votes </div>
{{else}}
<input type="{{if $s.Poll.Multiple}}checkbox{{else}}radio{{end}}" name="choices"
id="poll-{{$s.ID}}-{{$i}}" value="{{$i}}">
<label for="poll-{{$s.ID}}-{{$i}}">
{{EmojiFilter $o.Title $s.Emojis}}
</label>
{{end}}
</div>
{{end}}
{{if not (or .Poll.Expired .Poll.Voted)}}
<button type="submit"> Vote </button>
{{end}}
<div class="poll-info">
<span>{{.Poll.VotesCount}} votes</span>
{{if .Poll.Expired}}
<span> - poll expired </span>
{{else if .Poll.ExpiresAt}}
<span>
- poll ends in
<time datetime="{{FormatTimeRFC3339 .Poll.ExpiresAt}}" title="{{FormatTimeRFC822 .Poll.ExpiresAt}}">
{{TimeUntil .Poll.ExpiresAt}}
</time>
</span>
{{end}}
</div>
</form>
{{end}}
<div class="status-action-container">
<div class="status-action">
<a href="/thread/{{.ID}}?reply=true#status-{{.ID}}">