#? stdtmpl(subsChar = '$', metaChad = '#') #import strutils, xmltree, strformat, options #import ../types, ../utils, ../formatters # #proc getTitle(tweet: Tweet; prefs: Prefs; hostname: string): string = #if tweet.pinned: result = "Pinned: " #elif tweet.retweet.isSome: result = "RT: " #end if #result &= xmltree.escape(stripHtml(tweet.text)) #if result.len > 0: return #end if #if tweet.photos.len > 0: # result &= "Image" #elif tweet.video.isSome: # result &= "Video" #elif tweet.gif.isSome: # result &= "Gif" #end if #end proc # #proc renderRssTweet(tweet: Tweet; prefs: Prefs; hostname: string): string = #let text = replaceUrl(tweet.text, prefs, absolute=hostname) #if tweet.quote.isSome and get(tweet.quote).available: #let quoteLink = hostname & getLink(get(tweet.quote))

${text}
${quoteLink}

#else:

${text}

#end if #if tweet.photos.len > 0: #for photo in tweet.photos: #end for #elif tweet.video.isSome: #elif tweet.gif.isSome: #let thumb = &"https://{hostname}{getPicUrl(get(tweet.gif).thumb)}" #let url = &"https://{hostname}{getGifUrl(get(tweet.gif).url)}" #end if #end proc # #proc renderRssTweets(tweets: seq[Tweet]; prefs: Prefs; hostname: string): string = #var links: seq[string] #for tweet in tweets: #let link = getLink(tweet) #if link in links: continue #end if #links.add link ${getTitle(tweet, prefs, hostname)} @${tweet.profile.username} ${getRfc822Time(tweet)} https://${hostname & link} https://${hostname & link} #end for #end proc # #proc renderTimelineRss*(timeline: Timeline; profile: Profile; hostname: string; multi=false): string = #let prefs = Prefs(replaceTwitter: hostname, replaceYoutube: "invidio.us") #result = "" #let user = (if multi: "" else: "@") & profile.username #var title = profile.fullname #if not multi: title &= " / " & user #end if ${title} https://${hostname}/${profile.username} Twitter feed for: ${user}. Generated by ${hostname} en-us 40 ${title} https://${hostname}/${profile.username} https://${hostname}${getPicUrl(profile.getUserPic(style="_400x400"))} 128 128 #if timeline != nil: ${renderRssTweets(timeline.content, prefs, hostname)} #end if #end proc # #proc renderListRss*(tweets: seq[Tweet]; name, list, hostname: string): string = #let prefs = Prefs(replaceTwitter: hostname, replaceYoutube: "invidio.us") #let link = &"https://{hostname}/{name}/lists/{list}" #result = "" ${list} / @${name} ${link} Twitter feed for: ${list} by @${name}. Generated by ${hostname} en-us 40 ${renderRssTweets(tweets, prefs, hostname)} #end proc # #proc renderSearchRss*(tweets: seq[Tweet]; name, param, hostname: string): string = #let prefs = Prefs(replaceTwitter: hostname, replaceYoutube: "invidio.us") #let link = &"https://{hostname}/search" #result = "" Search results for "${name}" ${link} Twitter feed for search "${name}". Generated by ${hostname} en-us 40 ${renderRssTweets(tweets, prefs, hostname)} #end proc