From 22e98edf4e8b2ff4c0dcc92072c52c3bce453d8c Mon Sep 17 00:00:00 2001 From: Zed Date: Thu, 20 Jun 2019 17:57:31 +0200 Subject: [PATCH] Improve verified badges --- public/style.css | 14 ++++++++++++++ src/formatters.nim | 7 +++---- src/parser.nim | 4 ++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/public/style.css b/public/style.css index f0cae67..a0a7141 100644 --- a/public/style.css +++ b/public/style.css @@ -109,6 +109,16 @@ a:hover { color: #f8f8f2; } +.verified-icon { + color: #fff; + background-color: #1da1f2; + border-radius: 50%; + display: inline-block; + text-align: center; + margin-left: 4px; + width: 18px; +} + .status-el .media-heading .heading-right { display: flex; flex-shrink: 0; @@ -391,6 +401,10 @@ nav { text-overflow: ellipsis; } +.profile-card-name span { + width: 22px; +} + .profile-card-username { font-size: 14px; } diff --git a/src/formatters.nim b/src/formatters.nim index 0cd05b4..b07668b 100644 --- a/src/formatters.nim +++ b/src/formatters.nim @@ -69,13 +69,12 @@ proc getGifSrc*(tweet: Tweet): string = proc getGifThumb*(tweet: Tweet): string = fmt"https://pbs.twimg.com/tweet_video_thumb/{tweet.gif}.jpg" -proc formatName(profile: Profile): string = - result = profile.fullname +proc formatName*(profile: Profile): string = + result = xmltree.escape(profile.fullname) if profile.verified: - result &= " 🔹" + result &= htmlgen.span("✔", class="verified-icon") elif profile.protected: result &= " 🔒" - result = xmltree.escape(result) proc linkUser*(profile: Profile; h: string; username=true; class=""): string = let text = diff --git a/src/parser.nim b/src/parser.nim index e3d9127..76715f2 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -17,10 +17,10 @@ proc selectText(node: XmlNode; selector: string): string = proc parseProfile*(node: XmlNode): Profile = let profile = node.querySelector(".profile-card") - result.fullname = profile.selectText(".fullname") + result.fullname = profile.selectText(".fullname").strip() result.username = profile.selectText(".username").strip(chars={'@', ' '}) result.description = profile.selectText(".bio") - result.verified = profile.selectText("li.verified").len > 0 + result.verified = profile.selectText(".Icon.Icon--verified").len > 0 result.protected = profile.selectText(".Icon.Icon--protected").len > 0 result.userpic = profile.selectAttr(".ProfileCard-avatarImage", "src").getUserpic() result.banner = profile.selectAttr("svg > image", "xlink:href").replace("600x200", "1500x500")