Add back search
This commit is contained in:
@@ -27,7 +27,7 @@ proc timelineRss*(req: Request; cfg: Config; query: Query): Future[Rss] {.async.
|
||||
else:
|
||||
var q = query
|
||||
q.fromUser = names
|
||||
profile = await getGraphSearch(q, after)
|
||||
profile.tweets = await getTweetSearch(q, after)
|
||||
# this is kinda dumb
|
||||
profile.user = User(
|
||||
username: name,
|
||||
@@ -59,29 +59,29 @@ template respRss*(rss, page) =
|
||||
|
||||
proc createRssRouter*(cfg: Config) =
|
||||
router rss:
|
||||
# get "/search/rss":
|
||||
# cond cfg.enableRss
|
||||
# if @"q".len > 200:
|
||||
# resp Http400, showError("Search input too long.", cfg)
|
||||
get "/search/rss":
|
||||
cond cfg.enableRss
|
||||
if @"q".len > 200:
|
||||
resp Http400, showError("Search input too long.", cfg)
|
||||
|
||||
# let query = initQuery(params(request))
|
||||
# if query.kind != tweets:
|
||||
# resp Http400, showError("Only Tweet searches are allowed for RSS feeds.", cfg)
|
||||
let query = initQuery(params(request))
|
||||
if query.kind != tweets:
|
||||
resp Http400, showError("Only Tweet searches are allowed for RSS feeds.", cfg)
|
||||
|
||||
# let
|
||||
# cursor = getCursor()
|
||||
# key = redisKey("search", $hash(genQueryUrl(query)), cursor)
|
||||
let
|
||||
cursor = getCursor()
|
||||
key = redisKey("search", $hash(genQueryUrl(query)), cursor)
|
||||
|
||||
# var rss = await getCachedRss(key)
|
||||
# if rss.cursor.len > 0:
|
||||
# respRss(rss, "Search")
|
||||
var rss = await getCachedRss(key)
|
||||
if rss.cursor.len > 0:
|
||||
respRss(rss, "Search")
|
||||
|
||||
# let tweets = await getGraphSearch(query, cursor)
|
||||
# rss.cursor = tweets.bottom
|
||||
# rss.feed = renderSearchRss(tweets.content, query.text, genQueryUrl(query), cfg)
|
||||
let tweets = await getTweetSearch(query, cursor)
|
||||
rss.cursor = tweets.bottom
|
||||
rss.feed = renderSearchRss(tweets.content, query.text, genQueryUrl(query), cfg)
|
||||
|
||||
# await cacheRss(key, rss)
|
||||
# respRss(rss, "Search")
|
||||
await cacheRss(key, rss)
|
||||
respRss(rss, "Search")
|
||||
|
||||
get "/@name/rss":
|
||||
cond cfg.enableRss
|
||||
|
||||
@@ -34,15 +34,11 @@ proc createSearchRouter*(cfg: Config) =
|
||||
users = Result[User](beginning: true, query: query)
|
||||
resp renderMain(renderUserSearch(users, prefs), request, cfg, prefs, title)
|
||||
of tweets:
|
||||
# let
|
||||
# tweets = await getGraphSearch(query, getCursor())
|
||||
# rss = "/search/rss?" & genQueryUrl(query)
|
||||
# resp renderMain(renderTweetSearch(tweets, prefs, getPath()),
|
||||
# request, cfg, prefs, title, rss=rss)
|
||||
var fakeTimeline = Timeline(beginning: true)
|
||||
fakeTimeline.content.add Tweet(tombstone: "Tweet search is unavailable for now")
|
||||
|
||||
resp renderMain(renderTweetSearch(fakeTimeline, prefs, getPath()), request, cfg, prefs, title)
|
||||
let
|
||||
tweets = await getTweetSearch(query, getCursor())
|
||||
rss = "/search/rss?" & genQueryUrl(query)
|
||||
resp renderMain(renderTweetSearch(tweets, prefs, getPath()),
|
||||
request, cfg, prefs, title, rss=rss)
|
||||
else:
|
||||
resp Http404, showError("Invalid search", cfg)
|
||||
|
||||
|
||||
@@ -56,8 +56,7 @@ proc fetchProfile*(after: string; query: Query; skipRail=false;
|
||||
of posts: await getGraphUserTweets(userId, TimelineKind.tweets, after)
|
||||
of replies: await getGraphUserTweets(userId, TimelineKind.replies, after)
|
||||
of media: await getGraphUserTweets(userId, TimelineKind.media, after)
|
||||
else: Profile(tweets: Timeline(beginning: true, content: @[@[Tweet(tombstone: "Tweet search is unavailable for now")]]))
|
||||
# else: await getGraphSearch(query, after)
|
||||
else: Profile(tweets: await getTweetSearch(query, after))
|
||||
|
||||
result.user = await user
|
||||
result.photoRail = await rail
|
||||
@@ -71,9 +70,8 @@ proc showTimeline*(request: Request; query: Query; cfg: Config; prefs: Prefs;
|
||||
rss, after: string): Future[string] {.async.} =
|
||||
if query.fromUser.len != 1:
|
||||
let
|
||||
# timeline = await getGraphSearch(query, after)
|
||||
timeline = Profile(tweets: Timeline(beginning: true, content: @[@[Tweet(tombstone: "This features is unavailable for now")]]))
|
||||
html = renderTweetSearch(timeline.tweets, prefs, getPath())
|
||||
timeline = await getTweetSearch(query, after)
|
||||
html = renderTweetSearch(timeline, prefs, getPath())
|
||||
return renderMain(html, request, cfg, prefs, "Multi", rss=rss)
|
||||
|
||||
var profile = await fetchProfile(after, query, skipPinned=prefs.hidePins)
|
||||
|
||||
Reference in New Issue
Block a user