mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-12 11:06:30 +00:00
Add text field to search queries
This commit is contained in:
parent
12695b393e
commit
0c1b8b0190
3 changed files with 10 additions and 3 deletions
|
@ -84,7 +84,7 @@ proc createTimelineRouter*(cfg: Config) =
|
||||||
|
|
||||||
get "/@name/search":
|
get "/@name/search":
|
||||||
cond '.' notin @"name"
|
cond '.' notin @"name"
|
||||||
let query = initQuery(@"filter", @"include", @"not", @"sep", @"name")
|
let query = initQuery(@"filter", @"include", @"not", @"sep", @"text", @"name")
|
||||||
respTimeline(await showTimeline(@"name", @"after", some(query),
|
respTimeline(await showTimeline(@"name", @"after", some(query),
|
||||||
cookiePrefs(), getPath(), cfg.title, ""))
|
cookiePrefs(), getPath(), cfg.title, ""))
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,12 @@ const
|
||||||
posPrefix = "thGAVUV0VFVBa"
|
posPrefix = "thGAVUV0VFVBa"
|
||||||
posSuffix = "EjUAFQAlAFUAFQAA"
|
posSuffix = "EjUAFQAlAFUAFQAA"
|
||||||
|
|
||||||
proc initQuery*(filters, includes, excludes, separator: string; name=""): Query =
|
proc initQuery*(filters, includes, excludes, separator, text: string;
|
||||||
|
name=""): Query =
|
||||||
var sep = separator.strip().toUpper()
|
var sep = separator.strip().toUpper()
|
||||||
Query(
|
Query(
|
||||||
kind: custom,
|
kind: custom,
|
||||||
|
text: text,
|
||||||
filters: filters.split(",").filterIt(it in validFilters),
|
filters: filters.split(",").filterIt(it in validFilters),
|
||||||
includes: includes.split(",").filterIt(it in validFilters),
|
includes: includes.split(",").filterIt(it in validFilters),
|
||||||
excludes: excludes.split(",").filterIt(it in validFilters),
|
excludes: excludes.split(",").filterIt(it in validFilters),
|
||||||
|
@ -60,7 +62,9 @@ proc genQueryParam*(query: Query): string =
|
||||||
for e in query.excludes:
|
for e in query.excludes:
|
||||||
filters.add "-filter:" & e
|
filters.add "-filter:" & e
|
||||||
|
|
||||||
return strip(param & filters.join(&" {query.sep} "))
|
result = strip(param & filters.join(&" {query.sep} "))
|
||||||
|
if query.text.len > 0:
|
||||||
|
result &= " " & query.text
|
||||||
|
|
||||||
proc genQueryUrl*(query: Query): string =
|
proc genQueryUrl*(query: Query): string =
|
||||||
if query.kind == multi: return "?"
|
if query.kind == multi: return "?"
|
||||||
|
@ -77,6 +81,8 @@ proc genQueryUrl*(query: Query): string =
|
||||||
params &= "not=" & query.excludes.join(",")
|
params &= "not=" & query.excludes.join(",")
|
||||||
if query.sep.len > 0:
|
if query.sep.len > 0:
|
||||||
params &= "sep=" & query.sep
|
params &= "sep=" & query.sep
|
||||||
|
if query.text.len > 0:
|
||||||
|
params &= "text=" & query.text
|
||||||
if params.len > 0:
|
if params.len > 0:
|
||||||
result &= params.join("&") & "&"
|
result &= params.join("&") & "&"
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,7 @@ type
|
||||||
|
|
||||||
Query* = object
|
Query* = object
|
||||||
kind*: QueryKind
|
kind*: QueryKind
|
||||||
|
text*: string
|
||||||
filters*: seq[string]
|
filters*: seq[string]
|
||||||
includes*: seq[string]
|
includes*: seq[string]
|
||||||
excludes*: seq[string]
|
excludes*: seq[string]
|
||||||
|
|
Loading…
Reference in a new issue