2019-06-20 14:16:20 +00:00
|
|
|
#? stdtmpl(subsChar = '$', metaChar = '#')
|
2019-06-24 21:25:21 +00:00
|
|
|
#import xmltree, strutils, uri
|
2019-06-20 14:16:20 +00:00
|
|
|
#import ../types, ../formatters, ../utils
|
2019-06-24 21:25:21 +00:00
|
|
|
#include "tweet.nimf"
|
2019-06-20 14:16:20 +00:00
|
|
|
#
|
|
|
|
#proc renderProfileCard*(profile: Profile): string =
|
|
|
|
<div class="profile-card">
|
2019-06-25 01:48:57 +00:00
|
|
|
<a class="profile-card-avatar" href="${profile.getUserPic().getSigUrl("pic")}">
|
|
|
|
${genImg(profile.getUserpic("_200x200"))}
|
2019-06-20 14:16:20 +00:00
|
|
|
</a>
|
|
|
|
<div class="profile-card-tabs">
|
|
|
|
<div class="profile-card-tabs-name">
|
2019-06-24 18:45:03 +00:00
|
|
|
${linkUser(profile, class="profile-card-fullname")}
|
|
|
|
${linkUser(profile, class="profile-card-username")}
|
2019-06-20 14:16:20 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="profile-card-extra">
|
|
|
|
<div class="profile-bio">
|
2019-06-24 00:09:32 +00:00
|
|
|
#if profile.bio.len > 0:
|
|
|
|
<div class="profile-bio">
|
2019-06-25 02:52:38 +00:00
|
|
|
<p>${linkifyText(profile.bio)}</p>
|
2019-06-20 14:16:20 +00:00
|
|
|
</div>
|
|
|
|
#end if
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="profile-card-extra-links">
|
|
|
|
<ul class="profile-statlist">
|
|
|
|
<li class="tweets">
|
|
|
|
<span class="profile-stat-header">Tweets</span>
|
|
|
|
<span>${$profile.tweets}</span>
|
|
|
|
</li>
|
|
|
|
<li class="followers">
|
|
|
|
<span class="profile-stat-header">Followers</span>
|
|
|
|
<span>${$profile.followers}</span>
|
|
|
|
</li>
|
|
|
|
<li class="following">
|
|
|
|
<span class="profile-stat-header">Following</span>
|
|
|
|
<span>${$profile.following}</span>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
#end proc
|
|
|
|
#
|
|
|
|
#proc renderBanner(profile: Profile): string =
|
|
|
|
#if "#" in profile.banner:
|
|
|
|
<div style="${profile.banner}" class="profile-banner-color"></div>
|
|
|
|
#else:
|
|
|
|
#let url = getSigUrl(profile.banner, "pic")
|
2019-06-25 01:48:57 +00:00
|
|
|
<a href="${url}">${genImg(profile.banner)}</a>
|
2019-06-20 14:16:20 +00:00
|
|
|
#end if
|
|
|
|
#end proc
|
|
|
|
#
|
|
|
|
#proc renderTimeline*(tweets: Tweets; profile: Profile; beginning: bool): string =
|
|
|
|
<div id="tweets">
|
|
|
|
#if profile.protected:
|
|
|
|
<div class="timeline-protected">
|
|
|
|
<h2 class="timeline-protected-header">This account's Tweets are protected.</h2>
|
2019-06-24 06:44:37 +00:00
|
|
|
<p class="timeline-protected-explanation">Only confirmed followers have access to @${profile.username}'s Tweets.</p>
|
2019-06-20 14:16:20 +00:00
|
|
|
</div>
|
|
|
|
#end if
|
|
|
|
#if not beginning:
|
|
|
|
<div class="show-more status-el">
|
|
|
|
<a href="/${profile.username}">Load newest tweets</a>
|
|
|
|
</div>
|
|
|
|
#end if
|
|
|
|
#var retweets: Tweets
|
|
|
|
#for tweet in tweets:
|
|
|
|
#if tweet in retweets: continue
|
2019-06-24 02:41:23 +00:00
|
|
|
#elif tweet.retweetBy.isSome: retweets.add tweet
|
2019-06-20 14:16:20 +00:00
|
|
|
#end if
|
|
|
|
${renderTweet(tweet, "timeline-tweet")}
|
|
|
|
#end for
|
|
|
|
#if tweets.len > 0:
|
|
|
|
<div class="show-more">
|
2019-06-24 02:41:23 +00:00
|
|
|
#let retweet = tweets[^1].retweetId.get("")
|
|
|
|
#let id = if retweet.len > 0: retweet else: tweets[^1].id
|
|
|
|
<a href="/${profile.username}?after=${$id}">Load older tweets</a>
|
2019-06-20 14:16:20 +00:00
|
|
|
</div>
|
2019-06-24 06:44:37 +00:00
|
|
|
#else:
|
|
|
|
<div class="timeline-protected">
|
|
|
|
<h2 class="timeline-protected-header" style="text-align: center;">No tweets found.</h2>
|
|
|
|
</div>
|
2019-06-20 14:16:20 +00:00
|
|
|
#end if
|
|
|
|
</div>
|
|
|
|
#end proc
|
|
|
|
#
|
|
|
|
#proc renderProfile*(profile: Profile; tweets: Tweets; beginning: bool): string =
|
|
|
|
<div class="profile-tabs">
|
|
|
|
<div class="profile-banner">
|
|
|
|
${renderBanner(profile)}
|
|
|
|
</div>
|
|
|
|
<div class="profile-tab">
|
|
|
|
${renderProfileCard(profile)}
|
|
|
|
</div>
|
|
|
|
<div class="timeline-tab">
|
|
|
|
${renderTimeline(tweets, profile, beginning)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
#end proc
|
2019-06-24 21:25:21 +00:00
|
|
|
#
|
|
|
|
#proc renderConversation*(conversation: Conversation): string =
|
|
|
|
<div class="conversation" id="tweets">
|
|
|
|
<div class="main-thread">
|
|
|
|
#if conversation.before.len > 0:
|
|
|
|
<div class="before-tweet">
|
|
|
|
#for tweet in conversation.before:
|
|
|
|
${renderTweet(tweet)}
|
|
|
|
#end for
|
|
|
|
</div>
|
|
|
|
#end if
|
|
|
|
<div class="main-tweet">
|
|
|
|
${renderTweet(conversation.tweet)}
|
|
|
|
</div>
|
|
|
|
#if conversation.after.len > 0:
|
|
|
|
<div class="after-tweet">
|
|
|
|
#for tweet in conversation.after:
|
|
|
|
${renderTweet(tweet)}
|
|
|
|
#end for
|
|
|
|
</div>
|
|
|
|
#end if
|
|
|
|
</div>
|
|
|
|
#if conversation.replies.len > 0:
|
|
|
|
<div class="replies">
|
|
|
|
#for thread in conversation.replies:
|
|
|
|
<div class="thread">
|
|
|
|
#for tweet in thread:
|
|
|
|
${renderTweet(tweet)}
|
|
|
|
#end for
|
|
|
|
</div>
|
|
|
|
#end for
|
|
|
|
</div>
|
|
|
|
#end if
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
#end proc
|