Add "Search (...)" to tab title

Fixes #247
This commit is contained in:
Zed 2022-11-27 16:19:30 +01:00
parent 096d44856f
commit 78b6877b02
2 changed files with 8 additions and 6 deletions

View File

@ -14,25 +14,27 @@ export search
proc createSearchRouter*(cfg: Config) = proc createSearchRouter*(cfg: Config) =
router search: router search:
get "/search/?": get "/search/?":
if @"q".len > 500: let q = @"q"
if q.len > 500:
resp Http400, showError("Search input too long.", cfg) resp Http400, showError("Search input too long.", cfg)
let let
prefs = cookiePrefs() prefs = cookiePrefs()
query = initQuery(params(request)) query = initQuery(params(request))
title = "Search" & (if q.len > 0: " (" & q & ")" else: "")
case query.kind case query.kind
of users: of users:
if "," in @"q": if "," in q:
redirect("/" & @"q") redirect("/" & q)
let users = await getSearch[User](query, getCursor()) let users = await getSearch[User](query, getCursor())
resp renderMain(renderUserSearch(users, prefs), request, cfg, prefs) resp renderMain(renderUserSearch(users, prefs), request, cfg, prefs, title)
of tweets: of tweets:
let let
tweets = await getSearch[Tweet](query, getCursor()) tweets = await getSearch[Tweet](query, getCursor())
rss = "/search/rss?" & genQueryUrl(query) rss = "/search/rss?" & genQueryUrl(query)
resp renderMain(renderTweetSearch(tweets, prefs, getPath()), resp renderMain(renderTweetSearch(tweets, prefs, getPath()),
request, cfg, prefs, rss=rss) request, cfg, prefs, title, rss=rss)
else: else:
resp Http404, showError("Invalid search", cfg) resp Http404, showError("Invalid search", cfg)

View File

@ -50,7 +50,7 @@ proc renderUserCard*(user: User; prefs: Prefs): VNode =
span: span:
let url = replaceUrls(user.website, prefs) let url = replaceUrls(user.website, prefs)
icon "link" icon "link"
a(href=url): text shortLink(url) a(href=url): text url.shortLink
tdiv(class="profile-joindate"): tdiv(class="profile-joindate"):
span(title=getJoinDateFull(user)): span(title=getJoinDateFull(user)):