nitter/src/routes/list.nim

28 lines
985 B
Nim
Raw Normal View History

2019-09-20 23:08:30 +00:00
import strutils
import jester
import router_utils
import ".."/[query, types, api, agents]
import ../views/[general, timeline, list]
2020-05-26 12:24:41 +00:00
export getListTimeline, getListMembers
2019-09-20 23:08:30 +00:00
template respList*(list, timeline: typed) =
if list.minId.len == 0:
2019-10-21 05:59:22 +00:00
resp Http404, showError("List \"" & @"list" & "\" not found", cfg)
2019-09-20 23:08:30 +00:00
let html = renderList(timeline, list.query, @"name", @"list")
let rss = "/$1/lists/$2/rss" % [@"name", @"list"]
resp renderMain(html, request, cfg, rss=rss)
2019-09-20 23:08:30 +00:00
proc createListRouter*(cfg: Config) =
router list:
get "/@name/lists/@list":
cond '.' notin @"name"
2019-10-23 07:47:02 +00:00
let list = await getListTimeline(@"name", @"list", @"max_position", getAgent())
respList(list, renderTimelineTweets(list, cookiePrefs(), request.path))
2019-09-20 23:08:30 +00:00
get "/@name/lists/@list/members":
cond '.' notin @"name"
2019-10-23 07:47:02 +00:00
let list = await getListMembers(@"name", @"list", @"max_position", getAgent())
respList(list, renderTimelineUsers(list, cookiePrefs(), request.path))