2019-07-10 22:42:31 +00:00
|
|
|
import strutils, strformat
|
|
|
|
import karax/[karaxdsl, vdom, vstyles]
|
|
|
|
|
|
|
|
import ../types, ../utils, ../formatters
|
|
|
|
import tweet, timeline, renderutils
|
|
|
|
|
2019-08-06 13:57:47 +00:00
|
|
|
proc renderStat(num, class: string; text=""): VNode =
|
|
|
|
let t = if text.len > 0: text else: class
|
|
|
|
buildHtml(li(class=class)):
|
|
|
|
span(class="profile-stat-header"): text capitalizeAscii(t)
|
2019-08-11 21:30:33 +00:00
|
|
|
span(class="profile-stat-num"):
|
|
|
|
text if num.len == 0: "?" else: num
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
proc renderProfileCard*(profile: Profile): VNode =
|
|
|
|
buildHtml(tdiv(class="profile-card")):
|
|
|
|
a(class="profile-card-avatar", href=profile.getUserPic().getSigUrl("pic")):
|
|
|
|
genImg(profile.getUserpic("_200x200"))
|
|
|
|
|
2019-08-11 19:26:55 +00:00
|
|
|
tdiv(class="profile-card-tabs-name"):
|
|
|
|
linkUser(profile, class="profile-card-fullname")
|
|
|
|
linkUser(profile, class="profile-card-username")
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
tdiv(class="profile-card-extra"):
|
|
|
|
if profile.bio.len > 0:
|
|
|
|
tdiv(class="profile-bio"):
|
|
|
|
p: verbatim linkifyText(profile.bio)
|
|
|
|
|
2019-08-11 19:26:55 +00:00
|
|
|
if profile.location.len > 0:
|
|
|
|
tdiv(class="profile-location"):
|
|
|
|
span: text "📍 " & profile.location
|
|
|
|
|
|
|
|
if profile.website.len > 0:
|
|
|
|
tdiv(class="profile-website"):
|
|
|
|
span:
|
|
|
|
text "🔗 "
|
2019-08-12 01:32:27 +00:00
|
|
|
linkText(profile.website)
|
2019-08-11 19:26:55 +00:00
|
|
|
|
|
|
|
tdiv(class="profile-joindate"):
|
|
|
|
span(title=getJoinDateFull(profile)):
|
|
|
|
text "📅 " & getJoinDate(profile)
|
|
|
|
|
2019-07-10 22:42:31 +00:00
|
|
|
tdiv(class="profile-card-extra-links"):
|
|
|
|
ul(class="profile-statlist"):
|
2019-08-06 13:57:47 +00:00
|
|
|
renderStat(profile.tweets, "posts", text="Tweets")
|
2019-07-10 22:42:31 +00:00
|
|
|
renderStat(profile.followers, "followers")
|
|
|
|
renderStat(profile.following, "following")
|
2019-08-11 19:26:55 +00:00
|
|
|
renderStat(profile.likes, "likes")
|
2019-07-10 22:42:31 +00:00
|
|
|
|
2019-08-11 21:24:02 +00:00
|
|
|
proc renderPhotoRail(profile: Profile; photoRail: seq[GalleryPhoto]): VNode =
|
2019-07-10 22:42:31 +00:00
|
|
|
buildHtml(tdiv(class="photo-rail-card")):
|
|
|
|
tdiv(class="photo-rail-header"):
|
2019-08-11 21:24:02 +00:00
|
|
|
a(href=(&"/{profile.username}/media")):
|
|
|
|
text &"🖼 {profile.media} Photos and videos"
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
tdiv(class="photo-rail-grid"):
|
|
|
|
for i, photo in photoRail:
|
|
|
|
if i == 16: break
|
2019-08-11 21:24:02 +00:00
|
|
|
a(href=(&"/{profile.username}/status/{photo.tweetId}"),
|
2019-07-10 22:42:31 +00:00
|
|
|
style={backgroundColor: photo.color}):
|
|
|
|
genImg(photo.url & ":thumb")
|
|
|
|
|
|
|
|
proc renderBanner(profile: Profile): VNode =
|
|
|
|
buildHtml():
|
|
|
|
if "#" in profile.banner:
|
|
|
|
tdiv(class="profile-banner-color", style={backgroundColor: profile.banner})
|
|
|
|
else:
|
|
|
|
a(href=getSigUrl(profile.banner, "pic")):
|
|
|
|
genImg(profile.banner)
|
|
|
|
|
|
|
|
proc renderProfile*(profile: Profile; timeline: Timeline;
|
|
|
|
photoRail: seq[GalleryPhoto]): VNode =
|
|
|
|
buildHtml(tdiv(class="profile-tabs")):
|
|
|
|
tdiv(class="profile-banner"):
|
|
|
|
renderBanner(profile)
|
|
|
|
|
|
|
|
tdiv(class="profile-tab"):
|
|
|
|
renderProfileCard(profile)
|
|
|
|
if photoRail.len > 0:
|
2019-08-11 21:24:02 +00:00
|
|
|
renderPhotoRail(profile, photoRail)
|
2019-07-10 22:42:31 +00:00
|
|
|
|
|
|
|
tdiv(class="timeline-tab"):
|
2019-08-06 15:41:06 +00:00
|
|
|
renderTimeline(timeline, profile.username, profile.protected)
|
|
|
|
|
|
|
|
proc renderMulti*(timeline: Timeline; usernames: string): VNode =
|
|
|
|
buildHtml(tdiv(class="multi-timeline")):
|
|
|
|
tdiv(class="timeline-tab"):
|
|
|
|
renderTimeline(timeline, usernames, false, multi=true)
|