comparison lucene/src/luan/modules/lucene/Web_search.luan @ 286:91be4027b2a8

Improve HTML of some tools. git-svn-id: https://luan-java.googlecode.com/svn/trunk@287 21e917c8-12df-6dd8-5cb6-c86387c605b9
author hugo.tech@gmail.com <hugo.tech@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Wed, 03 Dec 2014 02:26:19 +0000
parents 582e8db4cdb6
children 4d53e9fc1bd9
comparison
equal deleted inserted replaced
285:582e8db4cdb6 286:91be4027b2a8
1 import "luan:Io" 1 import "luan:Io"
2 import "luan:web/Http" 2 import "luan:web/Http"
3 import "luan:String" 3 import "luan:String"
4 4
5 5
6 local function basic_style() %>
7 body {font-family:'Arial',sans-serif;font-size:16px}
8 input {padding:.5em;border-radius:10px;border:1px solid #ccc;font-size:16px}
9 input.btn {background:#3B619D;color:#FFF;padding:.5em 2em;font-size:20px}
10 h1 {font-weight:bold;font-size: 20px}
11 p {margin:1em 0 .2em}
12 span.label {min-width:100px;display:inline-block;text-align:right}
13 div.tip{color:#888;font-size:80%}
14 table.results {margin-top:2em;border-collapse:collapse;font-size:90%}
15 table.results th {background:#eee}
16 table.results th,table.results td {border-left:1px solid #bbb;padding:.4em}
17 <% end
18
6 local function form() %> 19 local function form() %>
7 <html> 20 <!DOCTYPE html>
8 <body> 21 <html lang="en">
9 <form method="post"> 22 <head>
10 <p>Query: <input name="query" size="60" /></p> 23 <title>Lucene Query</title>
11 <p>Rows: <input name="rows" value="20" /></p> 24 <style><% basic_style() %></style>
12 <p>Sort: <input name="sort" size="60" /></p> 25 </head>
13 <p><input type="submit" /></p> 26 <body>
14 </form> 27 <h1>Lucene Query</h1>
15 </body> 28 <form name="form0" method="post">
29 <p>
30 <span class="label">Query:</span> <input name="query" size="60" />
31 <div class="tip"><span class="label"></span> Query examples: { type = 'user' }</div>
32 </p>
33 <p><span class="label">Max Rows:</span> <input name="rows" value="20" maxlength="5" onkeypress="return event.charCode >= 48 && event.charCode <= 57" style="width:3em"/></p>
34 <p><span class="label">Sort:</span> <input name="sort" size="60" /></p>
35 <p><input type="submit" class="btn"/></p>
36 </form>
37 <script>document.form0.query.focus();</script>
38 </body>
16 </html> 39 </html>
17 <% end 40 <% end
18 41
19 42
20 local function result(query,sort,headers,table) %> 43 local function result(query,sort,headers,table) %>
21 <html> 44 <!DOCTYPE html>
22 <body> 45 <html lang="en">
23 <p>Query: <b><%=repr(query)%></b></p> 46 <head>
24 <p>Sort: <b><%=repr(sort)%></b></p> 47 <style><% basic_style() %></style>
25 <table border="1"> 48 </head>
26 <tr><th></th> 49 <body>
27 <% 50 <h1>Lucene Query Results</h1>
28 for _, header in ipairs(headers) do 51 <p><span class="label">Query:</span> <b><%=repr(query)%></b></p>
29 %><th><%=header%></th><% 52 <p><span class="label">Sort:</span> <b><%=repr(sort)%></b></p>
30 end 53 <table class="results">
31 %> 54 <tr>
32 </tr> 55 <th></th>
33 <% 56 <% for _, header in ipairs(headers) do %>
34 for i, row in ipairs(table) do 57 <th><%=header%></th>
35 %> 58 <% end %>
36 <tr><td><%=i%></td> 59 </tr>
37 <% 60 <% for i, row in ipairs(table) do %>
38 for col in range(1,#headers) do 61 <tr>
39 %><td><%= row[col] or "" %></td><% 62 <td><%=i%></td>
40 end 63 <% for col in range(1, #headers) do %>
41 %></tr><% 64 <td><%= row[col] or "" %></td>
42 end 65 <% end %>
43 %> 66 </tr>
44 </body> 67 <% end %>
68 </table>
69 </body>
45 </html> 70 </html>
46 <% end 71 <% end
47 72
48 73
49 local function index_of(tbl,val) 74 local function index_of(tbl,val)