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"),
|
userpic: node.getAvatar(".profile-picture img"),
|
||||||
verified: isVerified(profile),
|
verified: isVerified(profile),
|
||||||
protected: isProtected(profile),
|
protected: isProtected(profile),
|
||||||
banner: getTimelineBanner(node)
|
banner: getTimelineBanner(node),
|
||||||
|
media: getMediaCount(node)
|
||||||
)
|
)
|
||||||
|
|
||||||
result.getProfileStats(node.select(".ProfileNav-list"))
|
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):
|
if style.find(re"a:active \{\n +color: (#[A-Z0-9]+)", m):
|
||||||
return style[m.group(0)[0]]
|
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) =
|
proc getProfileStats*(profile: var Profile; node: XmlNode) =
|
||||||
for s in node.selectAll( ".ProfileNav-stat"):
|
for s in node.selectAll( ".ProfileNav-stat"):
|
||||||
let text = s.attr("title").split(" ")[0]
|
let text = s.attr("title").split(" ")[0]
|
||||||
|
|
|
@ -21,6 +21,7 @@ db("cache.db", "", "", ""):
|
||||||
followers*: string
|
followers*: string
|
||||||
tweets*: string
|
tweets*: string
|
||||||
likes*: string
|
likes*: string
|
||||||
|
media*: string
|
||||||
verified* {.
|
verified* {.
|
||||||
dbType: "STRING",
|
dbType: "STRING",
|
||||||
parseIt: parseBool(it.s)
|
parseIt: parseBool(it.s)
|
||||||
|
|
|
@ -45,16 +45,16 @@ proc renderProfileCard*(profile: Profile): VNode =
|
||||||
renderStat(profile.following, "following")
|
renderStat(profile.following, "following")
|
||||||
renderStat(profile.likes, "likes")
|
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")):
|
buildHtml(tdiv(class="photo-rail-card")):
|
||||||
tdiv(class="photo-rail-header"):
|
tdiv(class="photo-rail-header"):
|
||||||
a(href=(&"/{username}/media")):
|
a(href=(&"/{profile.username}/media")):
|
||||||
text "🖼 Photos and videos"
|
text &"🖼 {profile.media} Photos and videos"
|
||||||
|
|
||||||
tdiv(class="photo-rail-grid"):
|
tdiv(class="photo-rail-grid"):
|
||||||
for i, photo in photoRail:
|
for i, photo in photoRail:
|
||||||
if i == 16: break
|
if i == 16: break
|
||||||
a(href=(&"/{username}/status/{photo.tweetId}"),
|
a(href=(&"/{profile.username}/status/{photo.tweetId}"),
|
||||||
style={backgroundColor: photo.color}):
|
style={backgroundColor: photo.color}):
|
||||||
genImg(photo.url & ":thumb")
|
genImg(photo.url & ":thumb")
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ proc renderProfile*(profile: Profile; timeline: Timeline;
|
||||||
tdiv(class="profile-tab"):
|
tdiv(class="profile-tab"):
|
||||||
renderProfileCard(profile)
|
renderProfileCard(profile)
|
||||||
if photoRail.len > 0:
|
if photoRail.len > 0:
|
||||||
renderPhotoRail(profile.username, photoRail)
|
renderPhotoRail(profile, photoRail)
|
||||||
|
|
||||||
tdiv(class="timeline-tab"):
|
tdiv(class="timeline-tab"):
|
||||||
renderTimeline(timeline, profile.username, profile.protected)
|
renderTimeline(timeline, profile.username, profile.protected)
|
||||||
|
|
Loading…
Reference in a new issue