nitter/src/routes/rss.nim

33 lines
966 B
Nim
Raw Normal View History

import asyncdispatch, strutils
import jester
import router_utils, timeline
2019-09-13 21:28:20 +00:00
import ".."/[cache, agents, query]
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"
2019-09-18 18:54:07 +00:00
respRss(await showRss(@"name", none Query))
get "/@name/replies/rss":
cond '.' notin @"name"
2019-09-18 18:54:07 +00:00
respRss(await showRss(@"name", some getReplyQuery(@"name")))
get "/@name/media/rss":
cond '.' notin @"name"
2019-09-18 18:54:07 +00:00
respRss(await showRss(@"name", some getMediaQuery(@"name")))