1
0
mirror of https://github.com/zedeus/nitter.git synced 2025-12-08 04:55:37 -05:00

Support RSS feeds for /media and /replies

This commit is contained in:
Zed
2019-09-15 12:10:43 +02:00
parent e72b48defc
commit 36484c73fd
3 changed files with 64 additions and 53 deletions

35
src/routes/rss.nim Normal file
View File

@@ -0,0 +1,35 @@
import asyncdispatch, strutils
import jester
import router_utils, timeline
import ".."/[types, utils, cache, agents, search]
import ../views/general
include "../views/rss.nimf"
export uri
export cache, search, agents
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"))))