comparison lucene/src/luan/modules/lucene/Web_search.luan @ 391:2f5cc9c2cbf0

replace Html.simply_html_page with simply_html_head and simply_html_body_bottom
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 24 Apr 2015 14:05:52 -0600
parents fb18724521d2
children 5b36f663a1b8
comparison
equal deleted inserted replaced
390:bfbbce690bba 391:2f5cc9c2cbf0
8 local Http = require "luan:web/Http" 8 local Http = require "luan:web/Http"
9 local String = require "luan:String" 9 local String = require "luan:String"
10 local Html = require "luan:Html" 10 local Html = require "luan:Html"
11 11
12 12
13 local function form() 13 local function form() %>
14 Html.simply_html_page{ 14 <html>
15 head = function() %> 15 <head>
16 <title>Lucene Query</title> 16 <% Html.simply_html_head() %>
17 <% end; 17 <title>Lucene Query</title>
18 body = function() %> 18 </head>
19 <div container> 19 <body>
20 <h3 margin-top="1.5em">Lucene Query</h3> 20 <div container>
21 <form horizontal name="form0" method="post" margin-top="2em"> 21 <h3 margin-top="1.5em">Lucene Query</h3>
22 <div row> 22 <form horizontal name="form0" method="post" margin-top="2em">
23 <div colspan=2 align="right">
24 <label>Query:</label>
25 </div>
26 <div colspan=10>
27 <input name="query" size="80" value="Query.all_docs" autofocus />
28 <div textcolor="#888">Query examples: <i>Query.term{ type = 'user' }</i> or <i>"type:user AND name:Joe"</i></div>
29 </div>
30 </div>
31 <div row margin-top="1em">
32 <div colspan=2 align="right">
33 <label>Max Rows:</label>
34 </div>
35 <div colspan=10>
36 <input name="rows" value="100" size="3" maxlength="5" /></p>
37 </div>
38 </div>
39 <div row margin-top="1em">
40 <div colspan=2 align="right">
41 <label>Sort:</label>
42 </div>
43 <div colspan=10>
44 <input name="sort" size="60" />
45 <div textcolor="#888">Sort examples: Query.sort{{ field = 'id', type='int' }}</div>
46 </div>
47 </div>
48 <div row margin-top="1em">
49 <div colspan=2></div>
50 <div colspan=10>
51 <input type="submit" textcolor="white" bgcolor="#337ab7" large/>
52 </div>
53 </div>
54 </form>
55 </div>
56 <% end;
57 }
58 end
59
60
61 local function result(query,sort,headers,table)
62 Html.simply_html_page{
63 body = function() %>
64 <div container>
65 <h3 margin-top="1.5em">Lucene Query Results</h3>
66 <div row> 23 <div row>
67 <div colspan=2 align="right"> 24 <div colspan=2 align="right">
68 <label>Query:</label> 25 <label>Query:</label>
69 </div> 26 </div>
70 <div colspan=10> 27 <div colspan=10>
71 <b><%=query%></b></p> 28 <input name="query" size="80" value="Query.all_docs" autofocus />
29 <div textcolor="#888">Query examples: <i>Query.term{ type = 'user' }</i> or <i>"type:user AND name:Joe"</i></div>
72 </div> 30 </div>
73 </div> 31 </div>
74 <div row> 32 <div row margin-top="1em">
33 <div colspan=2 align="right">
34 <label>Max Rows:</label>
35 </div>
36 <div colspan=10>
37 <input name="rows" value="100" size="3" maxlength="5" /></p>
38 </div>
39 </div>
40 <div row margin-top="1em">
75 <div colspan=2 align="right"> 41 <div colspan=2 align="right">
76 <label>Sort:</label> 42 <label>Sort:</label>
77 </div> 43 </div>
78 <div colspan=10> 44 <div colspan=10>
79 <b><%=sort%></b></p> 45 <input name="sort" size="60" />
46 <div textcolor="#888">Sort examples: Query.sort{{ field = 'id', type='int' }}</div>
80 </div> 47 </div>
81 </div> 48 </div>
82 <table border condensed margin-top="1.5em"> 49 <div row margin-top="1em">
50 <div colspan=2></div>
51 <div colspan=10>
52 <input type="submit" textcolor="white" bgcolor="#337ab7" large/>
53 </div>
54 </div>
55 </form>
56 </div>
57 <% Html.simply_html_body_bottom() %>
58 </body>
59 </html>
60 <% end
61
62
63 local function result(query,sort,headers,table) %>
64 <html>
65 <head>
66 <% Html.simply_html_head() %>
67 <title>Lucene Query</title>
68 </head>
69 <body>
70 <div container>
71 <h3 margin-top="1.5em">Lucene Query Results</h3>
72 <div row>
73 <div colspan=2 align="right">
74 <label>Query:</label>
75 </div>
76 <div colspan=10>
77 <b><%=query%></b></p>
78 </div>
79 </div>
80 <div row>
81 <div colspan=2 align="right">
82 <label>Sort:</label>
83 </div>
84 <div colspan=10>
85 <b><%=sort%></b></p>
86 </div>
87 </div>
88 <table border condensed margin-top="1.5em">
89 <tr>
90 <th></th>
91 <% for _, header in ipairs(headers) do %>
92 <th><%=header%></th>
93 <% end %>
94 </tr>
95 <% for i, row in ipairs(table) do %>
83 <tr> 96 <tr>
84 <th></th> 97 <td><%=i%></td>
85 <% for _, header in ipairs(headers) do %> 98 <% for col in range(1, #headers) do %>
86 <th><%=header%></th> 99 <td><%= row[col] or "" %></td>
87 <% end %> 100 <% end %>
88 </tr> 101 </tr>
89 <% for i, row in ipairs(table) do %> 102 <% end %>
90 <tr> 103 </table>
91 <td><%=i%></td> 104 </div>
92 <% for col in range(1, #headers) do %> 105 <% Html.simply_html_body_bottom() %>
93 <td><%= row[col] or "" %></td> 106 </body>
94 <% end %> 107 </html>
95 </tr> 108 <% end
96 <% end %>
97 </table>
98 </div>
99 <% end;
100 }
101 end
102 109
103 110
104 local function index_of(tbl,val) 111 local function index_of(tbl,val)
105 for i, v in ipairs(tbl) do 112 for i, v in ipairs(tbl) do
106 if v == val then 113 if v == val then