user.nimf 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #if profile.bio.len > 0:
  19. <div class="profile-bio">
  20. <p>${linkifyText(profile.bio)}</p>
  21. </div>
  22. #end if
  23. <div class="profile-card-extra-links">
  24. <ul class="profile-statlist">
  25. <li class="tweets">
  26. <span class="profile-stat-header">Tweets</span>
  27. <span>${$profile.tweets}</span>
  28. </li>
  29. <li class="followers">
  30. <span class="profile-stat-header">Followers</span>
  31. <span>${$profile.followers}</span>
  32. </li>
  33. <li class="following">
  34. <span class="profile-stat-header">Following</span>
  35. <span>${$profile.following}</span>
  36. </li>
  37. </ul>
  38. </div>
  39. </div>
  40. </div>
  41. #end proc
  42. #
  43. #proc renderBanner(profile: Profile): string =
  44. #if "#" in profile.banner:
  45. <div style="${profile.banner}" class="profile-banner-color"></div>
  46. #else:
  47. #let url = getSigUrl(profile.banner, "pic")
  48. <a href="${url}">${genImg(profile.banner)}</a>
  49. #end if
  50. #end proc
  51. #
  52. #proc renderTimeline*(timeline: Timeline; profile: Profile; beginning: bool): string =
  53. #var retweets: seq[string]
  54. <div id="tweets">
  55. #if not beginning:
  56. <div class="show-more status-el">
  57. <a href="/${profile.username}">Load newest tweets</a>
  58. </div>
  59. #end if
  60. #
  61. #for tweet in timeline.tweets:
  62. #if tweet.id in retweets: continue
  63. #elif tweet.retweet.isSome: retweets.add tweet.id
  64. #end if
  65. ${renderTweet(tweet, "timeline-tweet")}
  66. #end for
  67. #
  68. #if timeline.hasMore:
  69. <div class="show-more">
  70. <a href="/${profile.username}?after=${timeline.minId}">Load older tweets</a>
  71. </div>
  72. #elif timeline.tweets.len > 0:
  73. <div class="timeline-footer">
  74. <h2 class="timeline-end" style="text-align: center;">No more tweets.</h2>
  75. </div>
  76. #else:
  77. <div class="timeline-header">
  78. #if profile.protected:
  79. <h2 class="timeline-protected">This account's tweets are protected.</h2>
  80. <p>Only confirmed followers have access to @${profile.username}'s tweets.</p>
  81. #else:
  82. <h2 class="timeline-none" style="text-align: center;">No tweets found.</h2>
  83. #end if
  84. </div>
  85. #end if
  86. </div>
  87. #end proc
  88. #
  89. #proc renderProfile*(profile: Profile; timeline: Timeline; beginning: bool): string =
  90. <div class="profile-tabs">
  91. <div class="profile-banner">
  92. ${renderBanner(profile)}
  93. </div>
  94. <div class="profile-tab">
  95. ${renderProfileCard(profile)}
  96. </div>
  97. <div class="timeline-tab">
  98. ${renderTimeline(timeline, profile, beginning)}
  99. </div>
  100. </div>
  101. #end proc
  102. #
  103. #proc renderConversation*(conversation: Conversation): string =
  104. <div class="conversation" id="tweets">
  105. <div class="main-thread">
  106. #if conversation.before.tweets.len > 0:
  107. <div class="before-tweet thread-line">
  108. #for i, tweet in conversation.before.tweets:
  109. ${renderTweet(tweet, first=(i == 0))}
  110. #end for
  111. </div>
  112. #end if
  113. <div class="main-tweet">
  114. #let afterClass = if conversation.after.tweets.len > 0: "thread thread-line" else: ""
  115. ${renderTweet(conversation.tweet, class=afterClass)}
  116. </div>
  117. #if conversation.after.tweets.len > 0:
  118. <div class="after-tweet thread-line">
  119. #for i, tweet in conversation.after.tweets:
  120. ${renderTweet(tweet, first=(i == 0), last=(i == conversation.after.tweets.high))}
  121. #end for
  122. </div>
  123. #end if
  124. </div>
  125. #if conversation.replies.len > 0:
  126. <div class="replies">
  127. #for thread in conversation.replies:
  128. <div class="reply thread thread-line">
  129. #for i, tweet in thread.tweets:
  130. #let last = (i == thread.tweets.high and thread.more == 0)
  131. ${renderTweet(tweet, first=(i == 0), last=last)}
  132. #end for
  133. #if thread.more != 0:
  134. #let num = if thread.more != -1: $thread.more & " " else: ""
  135. <div class="status-el more-replies">
  136. <a class="more-replies-text" title="Not implemented yet">${num}more replies</a>
  137. </div>
  138. #end if
  139. </div>
  140. #end for
  141. </div>
  142. #end if
  143. </div>
  144. </div>
  145. #end proc