mirror of
https://github.com/daylinmorgan/nimpkgs.git
synced 2024-11-09 13:33:15 -06:00
make general search case insensi
This commit is contained in:
parent
62dfd6ff17
commit
52b78b8f60
1 changed files with 11 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
import std/[strutils, sequtils, dom, uri]
|
import std/[strutils, sequtils, uri]
|
||||||
|
|
||||||
import karax/[kbase, karax, karaxdsl, vdom, jstrutils, kdom]
|
import karax/[kbase, karax, karaxdsl, vdom, jstrutils]
|
||||||
|
|
||||||
import ../[packages, style, context]
|
import ../[packages, style, context]
|
||||||
# import ../components/package
|
# import ../components/package
|
||||||
|
@ -33,6 +33,11 @@ proc parseQuery*(s: kstring): Query =
|
||||||
else:
|
else:
|
||||||
result.all &= part
|
result.all &= part
|
||||||
|
|
||||||
|
proc toLowerAscii(ks: kstring): kstring {.inline.} =
|
||||||
|
($ks).toLowerAscii().kstring
|
||||||
|
|
||||||
|
proc genericSearchString(p: NimPackage): kstring =
|
||||||
|
(@[p.url, p.name, p.description, p.tags.join(" ").kstring].join(" ").kstring).toLowerAscii()
|
||||||
|
|
||||||
proc searchPackages*(q: Query): seq[NimPackage] =
|
proc searchPackages*(q: Query): seq[NimPackage] =
|
||||||
if q == Query():
|
if q == Query():
|
||||||
|
@ -40,11 +45,10 @@ proc searchPackages*(q: Query): seq[NimPackage] =
|
||||||
return
|
return
|
||||||
|
|
||||||
for name, pkg in ctx.nimpkgs.packages:
|
for name, pkg in ctx.nimpkgs.packages:
|
||||||
let searchStr = ((pkg.url & " " & pkg.name & " " & pkg.description & " " & (
|
let searchStr = pkg.genericSearchString()
|
||||||
pkg.tags).join(" ").kstring))
|
if (q.name notin pkg.name) or (q.license notin pkg.license) or
|
||||||
if (q.name notin pkg.name) or
|
(q.tag != "".kstring and (q.tag notin pkg.tags)):
|
||||||
(q.license notin pkg.license) or
|
continue
|
||||||
(q.tag != "".kstring and (q.tag notin pkg.tags)): continue
|
|
||||||
|
|
||||||
if q.all in searchStr:
|
if q.all in searchStr:
|
||||||
result.add pkg
|
result.add pkg
|
||||||
|
|
Loading…
Reference in a new issue