parent
53a7113905
commit
8cae23dc7e
|
@ -25,7 +25,7 @@ template `@`(param: string): untyped =
|
|||
proc initQuery*(pms: Table[string, string]; name=""): Query =
|
||||
result = Query(
|
||||
kind: parseEnum[QueryKind](@"kind", custom),
|
||||
text: @"text",
|
||||
text: @"q",
|
||||
filters: validFilters.filterIt("f-" & it in pms),
|
||||
excludes: validFilters.filterIt("e-" & it in pms),
|
||||
since: @"since",
|
||||
|
@ -88,7 +88,7 @@ proc genQueryUrl*(query: Query): string =
|
|||
|
||||
var params = @[&"kind={query.kind}"]
|
||||
if query.text.len > 0:
|
||||
params.add "text=" & encodeUrl(query.text)
|
||||
params.add "q=" & encodeUrl(query.text)
|
||||
for f in query.filters:
|
||||
params.add "f-" & f & "=on"
|
||||
for e in query.excludes:
|
||||
|
|
|
@ -20,7 +20,7 @@ template respRss*(rss: typed) =
|
|||
proc createRssRouter*(cfg: Config) =
|
||||
router rss:
|
||||
get "/search/rss":
|
||||
if @"text".len > 200:
|
||||
if @"q".len > 200:
|
||||
resp Http400, showError("Search input too long.", cfg.title)
|
||||
|
||||
let query = initQuery(params(request))
|
||||
|
|
|
@ -11,7 +11,7 @@ export search
|
|||
proc createSearchRouter*(cfg: Config) =
|
||||
router search:
|
||||
get "/search/?":
|
||||
if @"text".len > 200:
|
||||
if @"q".len > 200:
|
||||
resp Http400, showError("Search input too long.", cfg.title)
|
||||
|
||||
let prefs = cookiePrefs()
|
||||
|
@ -19,8 +19,8 @@ proc createSearchRouter*(cfg: Config) =
|
|||
|
||||
case query.kind
|
||||
of userSearch:
|
||||
if "," in @"text":
|
||||
redirect("/" & @"text")
|
||||
if "," in @"q":
|
||||
redirect("/" & @"q")
|
||||
let users = await getSearch[Profile](query, @"after", getAgent())
|
||||
resp renderMain(renderUserSearch(users, prefs), request, cfg.title)
|
||||
of custom:
|
||||
|
@ -32,4 +32,4 @@ proc createSearchRouter*(cfg: Config) =
|
|||
resp Http404, showError("Invalid search.", cfg.title)
|
||||
|
||||
get "/hashtag/@hash":
|
||||
redirect("/search?text=" & encodeUrl("#" & @"hash"))
|
||||
redirect("/search?q=" & encodeUrl("#" & @"hash"))
|
||||
|
|
|
@ -24,7 +24,7 @@ proc renderSearch*(): VNode =
|
|||
tdiv(class="search-bar"):
|
||||
form(`method`="get", action="/search"):
|
||||
hiddenField("kind", "userSearch")
|
||||
input(`type`="text", name="text", autofocus="", placeholder="Enter username...")
|
||||
input(`type`="text", name="q", autofocus="", placeholder="Enter username...")
|
||||
button(`type`="submit"): icon "search"
|
||||
|
||||
proc renderProfileTabs*(query: Query; username: string): VNode =
|
||||
|
@ -58,7 +58,7 @@ proc renderSearchPanel*(query: Query): VNode =
|
|||
let action = if user.len > 0: &"/{user}/search" else: "/search"
|
||||
buildHtml(form(`method`="get", action=action, class="search-field")):
|
||||
hiddenField("kind", "custom")
|
||||
genInput("text", "", query.text, "Enter search...",
|
||||
genInput("q", "", query.text, "Enter search...",
|
||||
class="pref-inline", autofocus=true)
|
||||
button(`type`="submit"): icon "search"
|
||||
if isPanelOpen(query):
|
||||
|
@ -110,7 +110,7 @@ proc renderUserSearch*(users: Result[Profile]; prefs: Prefs): VNode =
|
|||
tdiv(class="timeline-header"):
|
||||
form(`method`="get", action="/search", class="search-field"):
|
||||
hiddenField("kind", "userSearch")
|
||||
genInput("text", "", users.query.text, "Enter username...", class="pref-inline")
|
||||
genInput("q", "", users.query.text, "Enter username...", class="pref-inline")
|
||||
button(`type`="submit"): icon "search"
|
||||
|
||||
renderSearchTabs(users.query)
|
||||
|
|
Loading…
Reference in New Issue