Show content warning in status
authorr <r@freesoftwareextremist.com>
Sat, 21 Dec 2019 07:22:21 +0000 (07:22 +0000)
committerr <r@freesoftwareextremist.com>
Sat, 21 Dec 2019 07:22:21 +0000 (07:22 +0000)
renderer/renderer.go
templates/status.tmpl

index c9cae2840f4245570fef68b58520bbc99563df60..cabf92dbcc3dafa5dd3c359e70163cb1286053a9 100644 (file)
@@ -84,7 +84,10 @@ func EmojiFilter(content string, emojis []mastodon.Emoji) string {
        return strings.NewReplacer(replacements...).Replace(content)
 }
 
-func StatusContentFilter(content string, emojis []mastodon.Emoji, mentions []mastodon.Mention) string {
+func StatusContentFilter(spoiler string, content string, emojis []mastodon.Emoji, mentions []mastodon.Mention) string {
+       if len(spoiler) > 0 {
+               content = spoiler + "<br />" + content
+       }
        var replacements []string
        for _, e := range emojis {
                replacements = append(replacements, ":"+e.ShortCode+":", "<img class=\"status-emoji\" src=\""+e.URL+"\" alt=\""+e.ShortCode+"\" />")
index b1babf6c440b6115397f0daee33564f3d8a5e74c..0e6f0c0ba71f5223096a9aafbdf45bf6dc37d7f7 100644 (file)
@@ -41,7 +41,7 @@
                                {{end}}
                                {{end}}
                        </div>
-                       <div class="status-content"> {{StatusContentFilter .Content .Emojis .Mentions}} </div>
+                       <div class="status-content"> {{StatusContentFilter .SpoilerText .Content .Emojis .Mentions}} </div>
                        <div class="status-media-container">
                        {{range .MediaAttachments}}
                        {{if eq .Type "image"}}