Search progress
This commit is contained in:
@@ -11,23 +11,36 @@ export search
|
||||
proc createSearchRouter*(cfg: Config) =
|
||||
router search:
|
||||
get "/search":
|
||||
if @"text".len == 0 or "." in @"text":
|
||||
resp Http404, showError("Please enter a valid username.", cfg.title)
|
||||
|
||||
if @"text".len > 200:
|
||||
resp Http400, showError("Search input too long.", cfg.title)
|
||||
|
||||
if "," in @"text":
|
||||
redirect("/" & @"text")
|
||||
let kind = parseEnum[QueryKind](@"kind", custom)
|
||||
var query = Query(kind: kind, text: @"text")
|
||||
|
||||
let query = Query(kind: parseEnum[QueryKind](@"kind", custom), text: @"text")
|
||||
if @"retweets".len == 0:
|
||||
query.excludes.add "nativeretweets"
|
||||
else:
|
||||
query.includes.add "nativeretweets"
|
||||
|
||||
if @"replies".len == 0:
|
||||
query.excludes.add "replies"
|
||||
else:
|
||||
query.includes.add "replies"
|
||||
|
||||
for f in validFilters:
|
||||
if "f-" & f in params(request):
|
||||
query.filters.add f
|
||||
if "e-" & f in params(request):
|
||||
query.excludes.add f
|
||||
|
||||
case query.kind
|
||||
of users:
|
||||
if "," in @"text":
|
||||
redirect("/" & @"text")
|
||||
let users = await getSearch[Profile](query, @"after", getAgent())
|
||||
resp renderMain(renderUserSearch(users, Prefs()), Prefs(), path=getPath())
|
||||
of custom:
|
||||
let tweets = await getSearch[Tweet](query, @"after", getAgent())
|
||||
resp renderMain(renderTweetSearch(tweets, Prefs(), getPath()), Prefs(), path=getPath())
|
||||
else:
|
||||
resp Http404
|
||||
resp Http404, showError("Invalid search.", cfg.title)
|
||||
|
||||
@@ -64,7 +64,7 @@ proc showTimeline*(name, after: string; query: Option[Query];
|
||||
else:
|
||||
let
|
||||
timeline = await fetchMultiTimeline(names, after, agent, query)
|
||||
html = renderTweetSearch(timeline, prefs, path)
|
||||
html = renderTimelineSearch(timeline, prefs, path)
|
||||
return renderMain(html, prefs, title, "Multi")
|
||||
|
||||
template respTimeline*(timeline: typed) =
|
||||
|
||||
Reference in New Issue
Block a user