Improve verified badges

This commit is contained in:
Zed 2019-06-20 17:57:31 +02:00
parent a9826151e9
commit 22e98edf4e
3 changed files with 19 additions and 6 deletions

View File

@ -109,6 +109,16 @@ a:hover {
color: #f8f8f2; 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 { .status-el .media-heading .heading-right {
display: flex; display: flex;
flex-shrink: 0; flex-shrink: 0;
@ -391,6 +401,10 @@ nav {
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.profile-card-name span {
width: 22px;
}
.profile-card-username { .profile-card-username {
font-size: 14px; font-size: 14px;
} }

View File

@ -69,13 +69,12 @@ proc getGifSrc*(tweet: Tweet): string =
proc getGifThumb*(tweet: Tweet): string = proc getGifThumb*(tweet: Tweet): string =
fmt"https://pbs.twimg.com/tweet_video_thumb/{tweet.gif}.jpg" fmt"https://pbs.twimg.com/tweet_video_thumb/{tweet.gif}.jpg"
proc formatName(profile: Profile): string = proc formatName*(profile: Profile): string =
result = profile.fullname result = xmltree.escape(profile.fullname)
if profile.verified: if profile.verified:
result &= " 🔹" result &= htmlgen.span("", class="verified-icon")
elif profile.protected: elif profile.protected:
result &= " 🔒" result &= " 🔒"
result = xmltree.escape(result)
proc linkUser*(profile: Profile; h: string; username=true; class=""): string = proc linkUser*(profile: Profile; h: string; username=true; class=""): string =
let text = let text =

View File

@ -17,10 +17,10 @@ proc selectText(node: XmlNode; selector: string): string =
proc parseProfile*(node: XmlNode): Profile = proc parseProfile*(node: XmlNode): Profile =
let profile = node.querySelector(".profile-card") 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.username = profile.selectText(".username").strip(chars={'@', ' '})
result.description = profile.selectText(".bio") 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.protected = profile.selectText(".Icon.Icon--protected").len > 0
result.userpic = profile.selectAttr(".ProfileCard-avatarImage", "src").getUserpic() result.userpic = profile.selectAttr(".ProfileCard-avatarImage", "src").getUserpic()
result.banner = profile.selectAttr("svg > image", "xlink:href").replace("600x200", "1500x500") result.banner = profile.selectAttr("svg > image", "xlink:href").replace("600x200", "1500x500")