mirror of
https://github.com/zedeus/nitter.git
synced 2025-04-21 08:24:05 +00:00
fix: search pai (#6)
This commit is contained in:
commit
6205218f13
2 changed files with 8 additions and 6 deletions
src
|
@ -3,6 +3,8 @@ import strutils, uri
|
|||
|
||||
import jester
|
||||
|
||||
import timeline, list
|
||||
|
||||
import ".."/routes/[router_utils, timeline]
|
||||
import ".."/[query, types, api, formatters]
|
||||
import ../views/[general, search]
|
||||
|
@ -17,12 +19,11 @@ proc createJsonApiSearchRouter*(cfg: Config) =
|
|||
let
|
||||
prefs = cookiePrefs()
|
||||
query = initQuery(params(request))
|
||||
title = "Search" & (if q.len > 0: " (" & q & ")" else: "")
|
||||
|
||||
case query.kind
|
||||
of users:
|
||||
if "," in q:
|
||||
redirect("/" & q)
|
||||
respJsonError "Invalid search input"
|
||||
var users: Result[User]
|
||||
try:
|
||||
users = await getGraphUserSearch(query, getCursor())
|
||||
|
@ -30,9 +31,9 @@ proc createJsonApiSearchRouter*(cfg: Config) =
|
|||
users = Result[User](beginning: true, query: query)
|
||||
respJsonSuccess formatUsersAsJson(users)
|
||||
of tweets:
|
||||
let
|
||||
tweets = await getGraphTweetSearch(query, getCursor())
|
||||
respJsonSuccess formatTweetsAsJson(tweets)
|
||||
let timeline = await getGraphTweetSearch(query, getCursor())
|
||||
if timeline.content.len == 0: respJsonError "No results found"
|
||||
respJsonSuccess formatTimelineAsJson(timeline)
|
||||
else:
|
||||
respJsonError "Invalid search"
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import views/[general, about]
|
|||
import routes/[
|
||||
preferences, timeline, status, media, search, rss, list, debug,
|
||||
unsupported, embed, resolver, router_utils]
|
||||
import jsons/[health, timeline, list]
|
||||
import jsons/[health, timeline, list, search]
|
||||
|
||||
const instancesUrl = "https://github.com/zedeus/nitter/wiki/Instances"
|
||||
const issuesUrl = "https://github.com/zedeus/nitter/issues"
|
||||
|
@ -110,6 +110,7 @@ routes:
|
|||
extend jsonapi_health, ""
|
||||
extend jsonapi_list, ""
|
||||
extend jsonapi_timeline, ""
|
||||
extend jsonapi_search, ""
|
||||
extend rss, ""
|
||||
extend status, ""
|
||||
extend search, ""
|
||||
|
|
Loading…
Reference in a new issue