#? stdtmpl(subsChar = '$', metaChar = '#') #import xmltree, strutils, times, sequtils, uri #import ../types, ../formatters, ../utils # #proc renderHeading(tweet: Tweet): string = #if tweet.retweetBy.isSome:
🔄 ${tweet.retweetBy.get()} 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] #var first = true
#for photos in groups: #let margin = if not first: "margin-top: .25em;" else: "" #let flex = if photos.len > 1 or groups.len > 1: "display: flex;" else: "" #first = false #end for
#end proc # #proc renderVideo(tweet: Tweet): string =
#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 = #if class.len > 0:
#end if
${renderHeading(tweet)}
${linkifyText(xmltree.escape(tweet.text))}
#if tweet.photos.len > 0: ${renderMediaGroup(tweet)} #elif tweet.videoThumb.isSome: ${renderVideo(tweet)} #elif tweet.gif.isSome: ${renderGif(tweet)} #end if ${renderStats(tweet)}
#if class.len > 0:
#end if #end proc