nitter/src/views/user.nimf

146 lines
4.1 KiB
Plaintext
Raw Normal View History

2019-06-20 16:16:20 +02:00
#? stdtmpl(subsChar = '$', metaChar = '#')
2019-06-24 23:25:21 +02:00
#import xmltree, strutils, uri
2019-06-20 16:16:20 +02:00
#import ../types, ../formatters, ../utils
2019-06-24 23:25:21 +02:00
#include "tweet.nimf"
2019-06-20 16:16:20 +02:00
#
#proc renderProfileCard*(profile: Profile): string =
<div class="profile-card">
2019-06-25 03:48:57 +02:00
<a class="profile-card-avatar" href="${profile.getUserPic().getSigUrl("pic")}">
${genImg(profile.getUserpic("_200x200"))}
2019-06-20 16:16:20 +02: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 16:16:20 +02:00
</div>
</div>
<div class="profile-card-extra">
<div class="profile-bio">
2019-06-24 02:09:32 +02:00
#if profile.bio.len > 0:
<div class="profile-bio">
2019-06-25 04:52:38 +02:00
<p>${linkifyText(profile.bio)}</p>
2019-06-20 16:16:20 +02: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 03:48:57 +02:00
<a href="${url}">${genImg(profile.banner)}</a>
2019-06-20 16:16:20 +02:00
#end if
#end proc
#
#proc renderTimeline*(timeline: Timeline; profile: Profile; beginning: bool): string =
2019-06-25 13:18:44 +02:00
#var retweets: Tweets
2019-06-20 16:16:20 +02:00
<div id="tweets">
#if profile.protected:
<div class="timeline-protected">
<h2 class="timeline-protected-header">This account's Tweets are protected.</h2>
<p class="timeline-protected-explanation">Only confirmed followers have access to @${profile.username}'s Tweets.</p>
2019-06-20 16:16:20 +02:00
</div>
#end if
2019-06-25 13:18:44 +02:00
#
2019-06-20 16:16:20 +02:00
#if not beginning:
<div class="show-more status-el">
<a href="/${profile.username}">Load newest tweets</a>
</div>
#end if
2019-06-25 13:18:44 +02:00
#
#for tweet in timeline.tweets:
2019-06-25 13:18:44 +02:00
#if tweet in retweets: continue
#elif tweet.retweetBy.isSome: retweets.add tweet
#end if
${renderTweet(tweet, "timeline-tweet")}
2019-06-20 16:16:20 +02:00
#end for
2019-06-25 13:18:44 +02:00
#
#if timeline.hasMore:
2019-06-20 16:16:20 +02:00
<div class="show-more">
<a href="/${profile.username}?after=${timeline.minId}">Load older tweets</a>
2019-06-20 16:16:20 +02:00
</div>
#else:
<div class="timeline-protected">
<h2 class="timeline-end" style="text-align: center;">No more tweets.</h2>
</div>
#end if
2019-06-25 13:18:44 +02:00
#
#if timeline.tweets.len == 0:
<div class="timeline-protected">
<h2 class="timeline-protected-header" style="text-align: center;">No tweets found.</h2>
</div>
2019-06-20 16:16:20 +02:00
#end if
</div>
#end proc
#
#proc renderProfile*(profile: Profile; timeline: Timeline; beginning: bool): string =
2019-06-20 16:16:20 +02: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 16:16:20 +02:00
</div>
</div>
#end proc
2019-06-24 23:25:21 +02: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">
2019-06-25 13:07:12 +02:00
#let afterClass = if conversation.after.len > 0: "thread" else: ""
2019-06-25 12:57:19 +02:00
${renderTweet(conversation.tweet, class=afterClass)}
2019-06-24 23:25:21 +02:00
</div>
#if conversation.after.len > 0:
<div class="after-tweet">
2019-06-25 12:57:19 +02:00
#for i, tweet in conversation.after:
2019-06-25 13:07:12 +02:00
${renderTweet(tweet, last=(i == conversation.after.high))}
2019-06-24 23:25:21 +02:00
#end for
</div>
#end if
</div>
#if conversation.replies.len > 0:
<div class="replies">
#for thread in conversation.replies:
2019-06-25 12:57:19 +02:00
<div class="reply thread">
#for i, tweet in thread:
2019-06-25 13:07:12 +02:00
${renderTweet(tweet, last=(i == thread.high))}
2019-06-24 23:25:21 +02:00
#end for
</div>
#end for
</div>
#end if
</div>
</div>
#end proc