nitter/src/routes/rss.nim

33 lines
970 B
Nim
Raw Normal View History

import asyncdispatch, strutils
import jester
import router_utils, timeline
2019-09-15 10:57:44 +00:00
import ".."/[cache, agents, search]
import ../views/general
include "../views/rss.nimf"
proc showRss*(name: string; query: Option[Query]): Future[string] {.async.} =
let (profile, timeline, _) = await fetchSingleTimeline(name, "", getAgent(), query)
return renderTimelineRss(timeline.content, profile)
template respRss*(rss: typed) =
if rss.len == 0:
resp Http404, showError("User \"" & @"name" & "\" not found", cfg.title)
resp rss, "application/rss+xml;charset=utf-8"
proc createRssRouter*(cfg: Config) =
router rss:
get "/@name/rss":
cond '.' notin @"name"
respRss(await showRss(@"name", none(Query)))
get "/@name/replies/rss":
cond '.' notin @"name"
respRss(await showRss(@"name", some(getReplyQuery(@"name"))))
get "/@name/media/rss":
cond '.' notin @"name"
respRss(await showRss(@"name", some(getMediaQuery(@"name"))))