From 94b21874531f5ee73a05fe41b55b8cca756dc669 Mon Sep 17 00:00:00 2001 From: Zed Date: Tue, 25 Jun 2019 02:58:33 +0200 Subject: [PATCH] Display sensitive quotes properly --- public/style.css | 20 ++++++++++++++++++++ src/parserutils.nim | 5 +++++ src/types.nim | 1 + src/views/tweet.nimf | 10 ++++++++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/public/style.css b/public/style.css index 2d70e3c..cefd973 100644 --- a/public/style.css +++ b/public/style.css @@ -652,6 +652,7 @@ video { .quote-media { display: flex; justify-content: center; + pointer-events: none; } .quote-media img { @@ -676,3 +677,22 @@ video { font-size: 12px; font-weight: bold; } + +.quote-sensitive { + background: #353535; + width: 102px; + height: 102px; + border-radius: 12px; + display: flex; + justify-content: center; + align-items: center; +} + +.quote-sensitive-icon { + font-size: 25px; + width: 37px; + height: 32px; + background-color: #4e4e4e; + padding-bottom: 5px; + margin: 0; +} diff --git a/src/parserutils.nim b/src/parserutils.nim index b670cc1..0771eb3 100644 --- a/src/parserutils.nim +++ b/src/parserutils.nim @@ -135,6 +135,11 @@ proc getTweetMedia*(tweet: Tweet; node: XmlNode) = tweet.video = some(Video()) proc getQuoteMedia*(quote: var Quote; node: XmlNode) = + let sensitive = node.querySelector(".QuoteTweet--sensitive") + if not sensitive.isNil: + quote.sensitive = true + return + let media = node.querySelector(".QuoteMedia") if not media.isNil: quote.thumb = some(media.selectAttr("img", "src")) diff --git a/src/types.nim b/src/types.nim index 85a0b0b..58e3f85 100644 --- a/src/types.nim +++ b/src/types.nim @@ -48,6 +48,7 @@ type profile*: Profile link*: string text*: string + sensitive*: bool thumb*: Option[string] badge*: Option[string] diff --git a/src/views/tweet.nimf b/src/views/tweet.nimf index 869162d..782e45d 100644 --- a/src/views/tweet.nimf +++ b/src/views/tweet.nimf @@ -30,19 +30,25 @@ #end proc # #proc renderQuote(quote: Quote): string = -#let hasMedia = quote.thumb.isSome() +#let hasMedia = quote.thumb.isSome() or quote.sensitive
#if hasMedia:
+ #if quote.thumb.isSome(): - #if quote.badge.isSome: + #if quote.badge.isSome():
${quote.badge.get()}
#end if + #elif quote.sensitive: +
+ +
+ #end if
#end if