#? stdtmpl(subsChar = '$', metaChar = '#') #import xmltree, strutils, times, sequtils, uri #import ../types, ../formatters, ../utils # #proc renderHeading(tweet: Tweet): string = #if tweet.retweetBy != "":
🔄 ${tweet.retweetBy} retweeted
#end if #if tweet.pinned:
📌 Pinned Tweet
#end if
#end proc # #proc renderMediaGroup(tweet: Tweet): string = #let groups = if tweet.photos.len > 2: tweet.photos.distribute(2) else: @[tweet.photos] #let groupStyle = if groups.len == 1 and groups[0].len < 2: "" else: "background-color: #0f0f0f;" #var first = true
#for photos in groups: #let style = if first: "" else: "margin-top: .25em;" #first = false #end for
#end proc # #proc renderGif(tweet: Tweet): string = #let thumbUrl = getGifThumb(tweet).getSigUrl("pic") #let videoUrl = getGifSrc(tweet).getSigUrl("video")
#end proc # #proc renderStats(tweet: Tweet): string =
💬 ${$tweet.replies} 🔄 ${$tweet.retweets} 👍 ${$tweet.likes}
#end proc # #proc renderTweet*(tweet: Tweet; class=""): string =
${renderHeading(tweet)}
${linkifyText(tweet.text)}
#if tweet.photos.len > 0: ${renderMediaGroup(tweet)} #elif tweet.gif.len > 0: ${renderGif(tweet)} #end if ${renderStats(tweet)}
#end proc