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