nitter/src/views/user.nimf

146 lines
4.3 KiB
Plaintext
Raw Normal View History

2019-06-20 15:16:20 +01:00
#? stdtmpl(subsChar = '$', metaChar = '#')
2019-06-24 22:25:21 +01:00
#import xmltree, strutils, uri
2019-06-20 15:16:20 +01:00
#import ../types, ../formatters, ../utils
2019-06-24 22:25:21 +01:00
#include "tweet.nimf"
2019-06-20 15:16:20 +01:00
#
#proc renderProfileCard*(profile: Profile): string =
<div class="profile-card">
2019-06-25 02:48:57 +01:00
<a class="profile-card-avatar" href="${profile.getUserPic().getSigUrl("pic")}">
${genImg(profile.getUserpic("_200x200"))}
2019-06-20 15:16:20 +01:00
</a>
<div class="profile-card-tabs">
<div class="profile-card-tabs-name">
${linkUser(profile, class="profile-card-fullname")}
${linkUser(profile, class="profile-card-username")}
2019-06-20 15:16:20 +01:00
</div>
</div>
<div class="profile-card-extra">
2019-06-28 03:42:23 +01:00
#if profile.bio.len > 0:
2019-06-20 15:16:20 +01:00
<div class="profile-bio">
2019-06-28 03:42:23 +01:00
<p>${linkifyText(profile.bio)}</p>
2019-06-20 15:16:20 +01:00
</div>
2019-06-28 03:42:23 +01:00
#end if
2019-06-20 15:16:20 +01:00
<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 02:48:57 +01:00
<a href="${url}">${genImg(profile.banner)}</a>
2019-06-20 15:16:20 +01:00
#end if
#end proc
#
#proc renderTimeline*(timeline: Timeline; profile: Profile; beginning: bool): string =
2019-07-01 02:13:12 +01:00
#var retweets: seq[Tweet]
2019-06-20 15:16:20 +01:00
<div id="tweets">
#if not beginning:
<div class="show-more status-el">
<a href="/${profile.username}">Load newest tweets</a>
</div>
#end if
2019-06-25 12:18:44 +01:00
#
#for tweet in timeline.tweets:
2019-06-25 12:18:44 +01:00
#if tweet in retweets: continue
#elif tweet.retweetBy.isSome: retweets.add tweet
#end if
${renderTweet(tweet, "timeline-tweet")}
2019-06-20 15:16:20 +01:00
#end for
2019-06-25 12:18:44 +01:00
#
#if timeline.hasMore:
2019-06-20 15:16:20 +01:00
<div class="show-more">
<a href="/${profile.username}?after=${timeline.minId}">Load older tweets</a>
2019-06-20 15:16:20 +01:00
</div>
#elif timeline.tweets.len > 0:
<div class="timeline-footer">
<h2 class="timeline-end" style="text-align: center;">No more tweets.</h2>
</div>
#else:
<div class="timeline-header">
#if profile.protected:
<h2 class="timeline-protected">This account's tweets are protected.</h2>
<p>Only confirmed followers have access to @${profile.username}'s tweets.</p>
#else:
<h2 class="timeline-none" style="text-align: center;">No tweets found.</h2>
#end if
</div>
2019-06-20 15:16:20 +01:00
#end if
</div>
#end proc
#
#proc renderProfile*(profile: Profile; timeline: Timeline; beginning: bool): string =
2019-06-20 15:16:20 +01:00
<div class="profile-tabs">
<div class="profile-banner">
${renderBanner(profile)}
</div>
<div class="profile-tab">
${renderProfileCard(profile)}
</div>
<div class="timeline-tab">
${renderTimeline(timeline, profile, beginning)}
2019-06-20 15:16:20 +01:00
</div>
</div>
#end proc
2019-06-24 22:25:21 +01:00
#
#proc renderConversation*(conversation: Conversation): string =
<div class="conversation" id="tweets">
<div class="main-thread">
2019-07-01 02:13:12 +01:00
#if conversation.before.tweets.len > 0:
2019-06-26 20:06:42 +01:00
<div class="before-tweet thread-line">
2019-07-01 02:13:12 +01:00
#for tweet in conversation.before.tweets:
2019-06-24 22:25:21 +01:00
${renderTweet(tweet)}
#end for
</div>
#end if
<div class="main-tweet">
2019-07-01 02:13:12 +01:00
#let afterClass = if conversation.after.tweets.len > 0: "thread thread-line" else: ""
2019-06-25 11:57:19 +01:00
${renderTweet(conversation.tweet, class=afterClass)}
2019-06-24 22:25:21 +01:00
</div>
2019-07-01 02:13:12 +01:00
#if conversation.after.tweets.len > 0:
2019-06-26 20:06:42 +01:00
<div class="after-tweet thread-line">
2019-07-01 02:13:12 +01:00
#for i, tweet in conversation.after.tweets:
${renderTweet(tweet, last=(i == conversation.after.tweets.high))}
2019-06-24 22:25:21 +01:00
#end for
</div>
#end if
</div>
#if conversation.replies.len > 0:
<div class="replies">
#for thread in conversation.replies:
2019-06-26 20:06:42 +01:00
<div class="reply thread thread-line">
2019-07-01 02:13:12 +01:00
#for i, tweet in thread.tweets:
${renderTweet(tweet, last=(i == thread.tweets.high and thread.more == 0))}
2019-06-24 22:25:21 +01:00
#end for
2019-07-01 02:13:12 +01:00
#if thread.more != 0:
#let num = if thread.more != -1: $thread.more & " " else: ""
<div class="status-el more-replies">
<a class="more-replies-text" title="Not implemented yet">${num}more replies</a>
</div>
#end if
2019-06-24 22:25:21 +01:00
</div>
#end for
</div>
#end if
</div>
</div>
#end proc