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]
|
|
|
|
|
|
|
|
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"]
|
2019-10-21 03:19:00 +00:00
|
|
|
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"
|
|
|
|
let
|
2019-10-08 13:15:47 +00:00
|
|
|
list = await getListTimeline(@"name", @"list", getAgent(), @"max_position")
|
2019-09-20 23:08:30 +00:00
|
|
|
tweets = renderTimelineTweets(list, cookiePrefs(), request.path)
|
|
|
|
respList list, tweets
|
|
|
|
|
|
|
|
get "/@name/lists/@list/members":
|
|
|
|
cond '.' notin @"name"
|
|
|
|
let list =
|
2019-10-08 13:15:47 +00:00
|
|
|
if @"max_position".len == 0:
|
2019-09-20 23:08:30 +00:00
|
|
|
await getListMembers(@"name", @"list", getAgent())
|
|
|
|
else:
|
2019-10-08 13:15:47 +00:00
|
|
|
await getListMembersSearch(@"name", @"list", getAgent(), @"max_position")
|
2019-09-20 23:08:30 +00:00
|
|
|
|
|
|
|
let users = renderTimelineUsers(list, cookiePrefs(), request.path)
|
|
|
|
respList list, users
|