Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 26 lines (21 sloc) 0.876 kB
a4e794d @joearms starting
authored
1 %% Copyright (c) 2006-2009 Joe Armstrong
2 %% See MIT-LICENSE for licensing information.
3
4 -module(elib1_webquery).
5 -compile(export_all).
6
7 qu([{"name",Collection},{"query",Str}], Root) ->
8 Name = Collection,
9 Dir = Root,
10 {Hits,Pages} = elib1_indexer:q(Dir,Name,Str),
11 L1 = [[Str,"&nbsp;",integer_to_list(N)," hits<br>"] || {Str,N} <- Hits],
12 L2 = [["<li><a href='/mod?mod=elib1_webquery&func=show_file&name=",
13 Collection,"&pos=",
14 integer_to_list(Pos),"'>",Loc,"</a></li>"] || {Pos,Loc} <- Pages],
15 {response, html,
16 ["<p>Root:",Root,"<p>Query collection:",Collection," str:",Str,
17 "<p>",L1,"<p>",L2]}.
18
19 show_file([{"name",Collection},{"pos",Pos}], Root) ->
20 Dir = Root,
21 Name = Collection,
22 Index = list_to_integer(Pos),
23 {File, Val} = elib1_indexer:extract(Dir, Name, Index),
24 {response, html, ["<pre><b>",Val,"<b></pre>"]}.
25
Something went wrong with that request. Please try again.