From f5437ff3ce062463b3831f0f418141872723e157 Mon Sep 17 00:00:00 2001 From: alyssa Date: Tue, 9 Mar 2021 01:49:04 +0000 Subject: [PATCH] add showing spoilers --- renderer/renderer.go | 6 +----- static/style.css | 40 ++++++++++++++++++++++++++++++++++++++++ templates/status.tmpl | 9 ++++++++- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/renderer/renderer.go b/renderer/renderer.go index 067632f..7d488de 100644 --- a/renderer/renderer.go +++ b/renderer/renderer.go @@ -48,14 +48,10 @@ func emojiFilter(content string, emojis []mastodon.Emoji) string { return strings.NewReplacer(replacements...).Replace(content) } -func statusContentFilter(spoiler string, content string, - emojis []mastodon.Emoji, mentions []mastodon.Mention) string { +func statusContentFilter(content string, emojis []mastodon.Emoji, mentions []mastodon.Mention) string { var replacements []string var r string - if len(spoiler) > 0 { - content = spoiler + "
" + content - } for _, e := range emojis { r = fmt.Sprintf("\":%s:\"", e.URL, e.ShortCode, e.ShortCode) diff --git a/static/style.css b/static/style.css index b51b439..3d5bafb 100644 --- a/static/style.css +++ b/static/style.css @@ -609,3 +609,43 @@ kbd { border-color: #444444; color: #eaeaea; } + +summary { + outline: none; +} + +details summary span:hover:after { + color: #9899c4; +} + +details summary span::after { + color: #464acc; + content: "[show spoiler] " +} + +details[open] summary span:hover:after { + color: #9899c4; +} + +details[open] summary span::after { + content: "[hide spoiler] "; + color: #464acc; +} + +.dark details summary span:hover:after { + color: #497091; +} + +.dark details summary span::after { + color: #81a2be; + content: "[show spoiler] " +} + +.dark details[open] summary span:hover:after { + color: #497091; +} + +.dark details[open] summary span::after { + content: "[hide spoiler] "; + color: #81a2be; +} \ No newline at end of file diff --git a/templates/status.tmpl b/templates/status.tmpl index a1e2d9f..1ba1dda 100644 --- a/templates/status.tmpl +++ b/templates/status.tmpl @@ -88,7 +88,14 @@ {{end}} {{if .Content}} -
{{StatusContentFilter .SpoilerText .Content .Emojis .Mentions}}
+ {{if .SpoilerText}} +
+ {{.SpoilerText}} + {{StatusContentFilter .Content .Emojis .Mentions}} +
+ {{else}} + {{StatusContentFilter .Content .Emojis .Mentions}} + {{end}} {{end}} {{if .MediaAttachments}}