Improve search and list error messages
This commit is contained in:
parent
b8a3ffb0c4
commit
1ce6ff2b2f
|
@ -9,8 +9,8 @@ import ../views/[general, timeline, list]
|
||||||
export getListTimeline, getGraphList
|
export getListTimeline, getGraphList
|
||||||
|
|
||||||
template respList*(list, timeline, title, vnode: typed) =
|
template respList*(list, timeline, title, vnode: typed) =
|
||||||
if list.id.len == 0:
|
if list.id.len == 0 or list.name.len == 0:
|
||||||
resp Http404, showError("List \"" & @"id" & "\" not found", cfg)
|
resp Http404, showError("List " & @"id" & " not found", cfg)
|
||||||
|
|
||||||
let
|
let
|
||||||
html = renderList(vnode, timeline.query, list)
|
html = renderList(vnode, timeline.query, list)
|
||||||
|
|
|
@ -36,12 +36,18 @@ proc timelineRss*(req: Request; cfg: Config; query: Query): Future[Rss] {.async.
|
||||||
return Rss(feed: profile.username, cursor: "suspended")
|
return Rss(feed: profile.username, cursor: "suspended")
|
||||||
|
|
||||||
if profile.fullname.len > 0:
|
if profile.fullname.len > 0:
|
||||||
let rss = compress renderTimelineRss(timeline, profile, cfg, multi=(names.len > 1))
|
let rss = compress renderTimelineRss(timeline, profile, cfg,
|
||||||
|
multi=(names.len > 1))
|
||||||
return Rss(feed: rss, cursor: timeline.bottom)
|
return Rss(feed: rss, cursor: timeline.bottom)
|
||||||
|
|
||||||
template respRss*(rss) =
|
template respRss*(rss, page) =
|
||||||
if rss.cursor.len == 0:
|
if rss.cursor.len == 0:
|
||||||
resp Http404, showError("User \"" & @"name" & "\" not found", cfg)
|
let info = case page
|
||||||
|
of "User": " \"$1\" " % @"name"
|
||||||
|
of "List": " $1 " % @"id"
|
||||||
|
else: " "
|
||||||
|
|
||||||
|
resp Http404, showError(page & info & "not found", cfg)
|
||||||
elif rss.cursor.len == 9 and rss.cursor == "suspended":
|
elif rss.cursor.len == 9 and rss.cursor == "suspended":
|
||||||
resp Http404, showError(getSuspended(rss.feed), cfg)
|
resp Http404, showError(getSuspended(rss.feed), cfg)
|
||||||
|
|
||||||
|
@ -66,7 +72,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
|
|
||||||
var rss = await getCachedRss(key)
|
var rss = await getCachedRss(key)
|
||||||
if rss.cursor.len > 0:
|
if rss.cursor.len > 0:
|
||||||
respRss(rss)
|
respRss(rss, "Search")
|
||||||
|
|
||||||
let tweets = await getSearch[Tweet](query, cursor)
|
let tweets = await getSearch[Tweet](query, cursor)
|
||||||
rss.cursor = tweets.bottom
|
rss.cursor = tweets.bottom
|
||||||
|
@ -74,7 +80,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
genQueryUrl(query), cfg)
|
genQueryUrl(query), cfg)
|
||||||
|
|
||||||
await cacheRss(key, rss)
|
await cacheRss(key, rss)
|
||||||
respRss(rss)
|
respRss(rss, "Search")
|
||||||
|
|
||||||
get "/@name/rss":
|
get "/@name/rss":
|
||||||
cond cfg.enableRss
|
cond cfg.enableRss
|
||||||
|
@ -86,12 +92,12 @@ proc createRssRouter*(cfg: Config) =
|
||||||
|
|
||||||
var rss = await getCachedRss(key)
|
var rss = await getCachedRss(key)
|
||||||
if rss.cursor.len > 0:
|
if rss.cursor.len > 0:
|
||||||
respRss(rss)
|
respRss(rss, "User")
|
||||||
|
|
||||||
rss = await timelineRss(request, cfg, Query(fromUser: @[name]))
|
rss = await timelineRss(request, cfg, Query(fromUser: @[name]))
|
||||||
|
|
||||||
await cacheRss(key, rss)
|
await cacheRss(key, rss)
|
||||||
respRss(rss)
|
respRss(rss, "User")
|
||||||
|
|
||||||
get "/@name/@tab/rss":
|
get "/@name/@tab/rss":
|
||||||
cond cfg.enableRss
|
cond cfg.enableRss
|
||||||
|
@ -112,12 +118,12 @@ proc createRssRouter*(cfg: Config) =
|
||||||
|
|
||||||
var rss = await getCachedRss(key)
|
var rss = await getCachedRss(key)
|
||||||
if rss.cursor.len > 0:
|
if rss.cursor.len > 0:
|
||||||
respRss(rss)
|
respRss(rss, "User")
|
||||||
|
|
||||||
rss = await timelineRss(request, cfg, query)
|
rss = await timelineRss(request, cfg, query)
|
||||||
|
|
||||||
await cacheRss(key, rss)
|
await cacheRss(key, rss)
|
||||||
respRss(rss)
|
respRss(rss, "User")
|
||||||
|
|
||||||
get "/@name/lists/@slug/rss":
|
get "/@name/lists/@slug/rss":
|
||||||
cond cfg.enableRss
|
cond cfg.enableRss
|
||||||
|
@ -146,7 +152,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
|
|
||||||
var rss = await getCachedRss(key)
|
var rss = await getCachedRss(key)
|
||||||
if rss.cursor.len > 0:
|
if rss.cursor.len > 0:
|
||||||
respRss(rss)
|
respRss(rss, "List")
|
||||||
|
|
||||||
let
|
let
|
||||||
list = await getCachedList(id=(@"id"))
|
list = await getCachedList(id=(@"id"))
|
||||||
|
@ -155,4 +161,4 @@ proc createRssRouter*(cfg: Config) =
|
||||||
rss.feed = compress renderListRss(timeline.content, list, cfg)
|
rss.feed = compress renderListRss(timeline.content, list, cfg)
|
||||||
|
|
||||||
await cacheRss(key, rss)
|
await cacheRss(key, rss)
|
||||||
respRss(rss)
|
respRss(rss, "List")
|
||||||
|
|
Loading…
Reference in New Issue