Display media count above photo rail
This commit is contained in:
parent
7171486f03
commit
60986ecc88
4 changed files with 12 additions and 6 deletions
|
@ -17,7 +17,8 @@ proc parseTimelineProfile*(node: XmlNode): Profile =
|
|||
userpic: node.getAvatar(".profile-picture img"),
|
||||
verified: isVerified(profile),
|
||||
protected: isProtected(profile),
|
||||
banner: getTimelineBanner(node)
|
||||
banner: getTimelineBanner(node),
|
||||
media: getMediaCount(node)
|
||||
)
|
||||
|
||||
result.getProfileStats(node.select(".ProfileNav-list"))
|
||||
|
|
|
@ -114,6 +114,10 @@ proc getTimelineBanner*(node: XmlNode): string =
|
|||
if style.find(re"a:active \{\n +color: (#[A-Z0-9]+)", m):
|
||||
return style[m.group(0)[0]]
|
||||
|
||||
proc getMediaCount*(node: XmlNode): string =
|
||||
let text = node.selectText(".PhotoRail-headingWithCount")
|
||||
return text.stripText().split(" ")[0]
|
||||
|
||||
proc getProfileStats*(profile: var Profile; node: XmlNode) =
|
||||
for s in node.selectAll( ".ProfileNav-stat"):
|
||||
let text = s.attr("title").split(" ")[0]
|
||||
|
|
|
@ -21,6 +21,7 @@ db("cache.db", "", "", ""):
|
|||
followers*: string
|
||||
tweets*: string
|
||||
likes*: string
|
||||
media*: string
|
||||
verified* {.
|
||||
dbType: "STRING",
|
||||
parseIt: parseBool(it.s)
|
||||
|
|
|
@ -45,16 +45,16 @@ proc renderProfileCard*(profile: Profile): VNode =
|
|||
renderStat(profile.following, "following")
|
||||
renderStat(profile.likes, "likes")
|
||||
|
||||
proc renderPhotoRail(username: string; photoRail: seq[GalleryPhoto]): VNode =
|
||||
proc renderPhotoRail(profile: Profile; photoRail: seq[GalleryPhoto]): VNode =
|
||||
buildHtml(tdiv(class="photo-rail-card")):
|
||||
tdiv(class="photo-rail-header"):
|
||||
a(href=(&"/{username}/media")):
|
||||
text "🖼 Photos and videos"
|
||||
a(href=(&"/{profile.username}/media")):
|
||||
text &"🖼 {profile.media} Photos and videos"
|
||||
|
||||
tdiv(class="photo-rail-grid"):
|
||||
for i, photo in photoRail:
|
||||
if i == 16: break
|
||||
a(href=(&"/{username}/status/{photo.tweetId}"),
|
||||
a(href=(&"/{profile.username}/status/{photo.tweetId}"),
|
||||
style={backgroundColor: photo.color}):
|
||||
genImg(photo.url & ":thumb")
|
||||
|
||||
|
@ -75,7 +75,7 @@ proc renderProfile*(profile: Profile; timeline: Timeline;
|
|||
tdiv(class="profile-tab"):
|
||||
renderProfileCard(profile)
|
||||
if photoRail.len > 0:
|
||||
renderPhotoRail(profile.username, photoRail)
|
||||
renderPhotoRail(profile, photoRail)
|
||||
|
||||
tdiv(class="timeline-tab"):
|
||||
renderTimeline(timeline, profile.username, profile.protected)
|
||||
|
|
Loading…
Reference in a new issue