Skip to content

Instantly share code, notes, and snippets.

@m-2k

m-2k/search.erl Secret

Created August 20, 2015 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save m-2k/81fce3ac277039db37be to your computer and use it in GitHub Desktop.
Save m-2k/81fce3ac277039db37be to your computer and use it in GitHub Desktop.
event(#render_event{event=search}) ->
QueryList=re:split(wf:q(q),<<" +">>,[unicode]),
Results=[ #panel{body=Name} || #theme{name=Name} <- kvs:all(theme),
lists:all(fun(Entry) ->
re:run(Name,Entry,[unicode,caseless]) =/= nomatch
end,QueryList) ],
wf:update(results,#panel{id=results,body=Results});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment