user.nimf 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #? stdtmpl(subsChar = '$', metaChar = '#')
  2. #import xmltree, strutils, uri
  3. #import ../types, ../formatters, ../utils
  4. #include "tweet.nimf"
  5. #
  6. #proc renderProfileCard*(profile: Profile): string =
  7. <div class="profile-card">
  8. <a class="profile-card-avatar" href="${profile.getUserPic().getSigUrl("pic")}">
  9. ${genImg(profile.getUserpic("_200x200"))}
  10. </a>
  11. <div class="profile-card-tabs">
  12. <div class="profile-card-tabs-name">
  13. ${linkUser(profile, class="profile-card-fullname")}
  14. ${linkUser(profile, class="profile-card-username")}
  15. </div>
  16. </div>
  17. <div class="profile-card-extra">
  18. <div class="profile-bio">
  19. #if profile.bio.len > 0:
  20. <div class="profile-bio">
  21. <p>${linkifyText(xmltree.escape(profile.bio))}</p>
  22. </div>
  23. #end if
  24. </div>
  25. <div class="profile-card-extra-links">
  26. <ul class="profile-statlist">
  27. <li class="tweets">
  28. <span class="profile-stat-header">Tweets</span>
  29. <span>${$profile.tweets}</span>
  30. </li>
  31. <li class="followers">
  32. <span class="profile-stat-header">Followers</span>
  33. <span>${$profile.followers}</span>
  34. </li>
  35. <li class="following">
  36. <span class="profile-stat-header">Following</span>
  37. <span>${$profile.following}</span>
  38. </li>
  39. </ul>
  40. </div>
  41. </div>
  42. </div>
  43. #end proc
  44. #
  45. #proc renderBanner(profile: Profile): string =
  46. #if "#" in profile.banner:
  47. <div style="${profile.banner}" class="profile-banner-color"></div>
  48. #else:
  49. #let url = getSigUrl(profile.banner, "pic")
  50. <a href="${url}">${genImg(profile.banner)}</a>
  51. #end if
  52. #end proc
  53. #
  54. #proc renderTimeline*(tweets: Tweets; profile: Profile; beginning: bool): string =
  55. <div id="tweets">
  56. #if profile.protected:
  57. <div class="timeline-protected">
  58. <h2 class="timeline-protected-header">This account's Tweets are protected.</h2>
  59. <p class="timeline-protected-explanation">Only confirmed followers have access to @${profile.username}'s Tweets.</p>
  60. </div>
  61. #end if
  62. #if not beginning:
  63. <div class="show-more status-el">
  64. <a href="/${profile.username}">Load newest tweets</a>
  65. </div>
  66. #end if
  67. #var retweets: Tweets
  68. #for tweet in tweets:
  69. #if tweet in retweets: continue
  70. #elif tweet.retweetBy.isSome: retweets.add tweet
  71. #end if
  72. ${renderTweet(tweet, "timeline-tweet")}
  73. #end for
  74. #if tweets.len > 0:
  75. <div class="show-more">
  76. #let retweet = tweets[^1].retweetId.get("")
  77. #let id = if retweet.len > 0: retweet else: tweets[^1].id
  78. <a href="/${profile.username}?after=${$id}">Load older tweets</a>
  79. </div>
  80. #else:
  81. <div class="timeline-protected">
  82. <h2 class="timeline-protected-header" style="text-align: center;">No tweets found.</h2>
  83. </div>
  84. #end if
  85. </div>
  86. #end proc
  87. #
  88. #proc renderProfile*(profile: Profile; tweets: Tweets; beginning: bool): string =
  89. <div class="profile-tabs">
  90. <div class="profile-banner">
  91. ${renderBanner(profile)}
  92. </div>
  93. <div class="profile-tab">
  94. ${renderProfileCard(profile)}
  95. </div>
  96. <div class="timeline-tab">
  97. ${renderTimeline(tweets, profile, beginning)}
  98. </div>
  99. </div>
  100. #end proc
  101. #
  102. #proc renderConversation*(conversation: Conversation): string =
  103. <div class="conversation" id="tweets">
  104. <div class="main-thread">
  105. #if conversation.before.len > 0:
  106. <div class="before-tweet">
  107. #for tweet in conversation.before:
  108. ${renderTweet(tweet)}
  109. #end for
  110. </div>
  111. #end if
  112. <div class="main-tweet">
  113. ${renderTweet(conversation.tweet)}
  114. </div>
  115. #if conversation.after.len > 0:
  116. <div class="after-tweet">
  117. #for tweet in conversation.after:
  118. ${renderTweet(tweet)}
  119. #end for
  120. </div>
  121. #end if
  122. </div>
  123. #if conversation.replies.len > 0:
  124. <div class="replies">
  125. #for thread in conversation.replies:
  126. <div class="thread">
  127. #for tweet in thread:
  128. ${renderTweet(tweet)}
  129. #end for
  130. </div>
  131. #end for
  132. </div>
  133. #end if
  134. </div>
  135. </div>
  136. #end proc