Mercurial Hosting > luan
changeset 294:5652cdea25f5
Improve html code of core tools.
git-svn-id: https://luan-java.googlecode.com/svn/trunk@295 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | hugo.tech@gmail.com <hugo.tech@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Thu, 11 Dec 2014 03:12:26 +0000 |
parents | a50e88d3547c |
children | 1f4cc8505308 |
files | dist/jars/luan-core-trunk.jar dist/jars/luan-logging-trunk.jar dist/jars/luan-lucene-trunk.jar dist/jars/luan-mail-trunk.jar dist/jars/luan-web-trunk.jar lucene/src/luan/modules/lucene/Ab_testing.luan lucene/src/luan/modules/lucene/Web_search.luan web/src/luan/modules/web/web_run.luan web/src/luan/modules/web/web_shell.luan |
diffstat | 9 files changed, 74 insertions(+), 62 deletions(-) [+] |
line wrap: on
line diff
--- a/lucene/src/luan/modules/lucene/Ab_testing.luan Thu Dec 11 01:44:38 2014 +0000 +++ b/lucene/src/luan/modules/lucene/Ab_testing.luan Thu Dec 11 03:12:26 2014 +0000 @@ -95,11 +95,11 @@ return test end - + function ab_testing.value(test_name,values) return values[test_name] or ab_testing.test_map[test_name].values[1] end - + -- returns map from test name to value function ab_testing.from_doc(doc) local values = {} @@ -179,68 +179,79 @@ end end +local function basic_style() %> + body {font-family:'Arial',sans-serif;font-size:16px;padding:1em 2em} + h1 {font-weight:bold;font-size:20px} + h2 {margin:2em 0 0em;font-size:18px;color:#3589B1} + table.results {margin-top:.5em;border-collapse:collapse;font-size:90%} + table.results th {background:#eee} + table.results th,table.results td {border-left:1px solid #bbb;padding:.4em 2em} + table.results tr:nth-child(odd) td {background:#f8f8f8} +<% end + +local function format(v) + v = v .. '' + return v.gsub('(\d+.\d{1})\d+','$1') +end function html(test_names,tests,results) %> -<html> -<body> -<h2>A/B Tests</h2> -<% - for _, test_name in ipairs(test_names) do - local test = tests[test_name] - local result = results[test_name] - local n = #test.values - %> - <h3><%=test_name%></h3> - <table> - <tr> - <th>Event</th> - <th class="top" colspan="<%=n%>">Count</th> - <th class="top" colspan="<%=n%>">% of total</th> - <th class="top" colspan="<%=n%>">% of prev</th> - </tr> - <tr> - <th></th> - <% - for _ in range(1,3) do - for _, value in ipairs(test.values) do - %> - <th class="top"><%=value%></th> - <% - end - end - %> - </tr> - <% - for _, event in ipairs(test.events) do - local event_values = result[event] - %> +<!DOCTYPE html> +<html lang="en"> + <head> + <title>A/B Test Results</title> + <style><% basic_style() %></style> + </head> + <body> + <h1>A/B Test Results</h1> + <% + for _, test_name in ipairs(test_names) do + local test = tests[test_name] + local result = results[test_name] + local n = #test.values + %> + <h2><%=test_name%></h2> + <table class="results"> <tr> - <td><%=event%></td> + <th>Event</th> + <th class="top" colspan="<%=n%>">Count</th> + <th class="top" colspan="<%=n%>">% of total</th> + <th class="top" colspan="<%=n%>">% of prev</th> + </tr> + <tr> + <th></th> <% - for _, value in ipairs(test.values) do - %> - <td><%=event_values[value].count%></th> - <% - end - for _, value in ipairs(test.values) do - %> - <td><%=event_values[value].pct_of_total%></th> - <% - end - for _, value in ipairs(test.values) do - %> - <td><%=event_values[value].pct_of_prev%></th> - <% + for _ in range(1,3) do + for _, value in ipairs(test.values) do + %><th class="top"><%=value%></th><% + end end %> </tr> <% - end - %> - </table> - <% - end -%> -</body> + for _, event in ipairs(test.events) do + local event_values = result[event] + %> + <tr> + <td><%=event%></td> + <% + for _, value in ipairs(test.values) do + %><td><%=format(event_values[value].count)%></th><% + end + for _, value in ipairs(test.values) do + %><td><%=format(event_values[value].pct_of_total)%></th><% + end + for _, value in ipairs(test.values) do + %><td><%=format(event_values[value].pct_of_prev)%></th><% + end + %> + </tr> + <% + end + %> + </table> + <% + end + %> + </body> </html> -<% end +<% end \ No newline at end of file
--- a/lucene/src/luan/modules/lucene/Web_search.luan Thu Dec 11 01:44:38 2014 +0000 +++ b/lucene/src/luan/modules/lucene/Web_search.luan Thu Dec 11 03:12:26 2014 +0000 @@ -4,7 +4,7 @@ local function basic_style() %> - body {font-family:'Arial',sans-serif;font-size:16px} + body {font-family:'Arial',sans-serif;font-size:16px;padding:1em 2em} input {padding:.5em;border-radius:10px;border:1px solid #ccc;font-size:16px} input.btn {background:#3B619D;color:#FFF;padding:.5em 2em;font-size:20px} h1 {font-weight:bold;font-size: 20px} @@ -14,6 +14,7 @@ table.results {margin-top:2em;border-collapse:collapse;font-size:90%} table.results th {background:#eee} table.results th,table.results td {border-left:1px solid #bbb;padding:.4em} + table.results tr:nth-child(odd) td {background:#f8f8f8} <% end local function form() %> @@ -30,7 +31,7 @@ <span class="label">Query:</span> <input name="query" size="60" value="Query.all_docs" /> <div class="tip"><span class="label"></span> Query examples: Query.term{ type = 'user' }</div> </p> - <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> + <p><span class="label">Max Rows:</span> <input name="rows" value="100" maxlength="5" onkeypress="return event.charCode >= 48 && event.charCode <= 57" style="width:3em"/></p> <p> <span class="label">Sort:</span> <input name="sort" size="60" /> <div class="tip"><span class="label"></span> Sort examples: Query.sort{{ field = 'id', type='int' }}</div>
--- a/web/src/luan/modules/web/web_run.luan Thu Dec 11 01:44:38 2014 +0000 +++ b/web/src/luan/modules/web/web_run.luan Thu Dec 11 03:12:26 2014 +0000 @@ -19,7 +19,7 @@ end local function basic_style() %> - body {font-family:'Arial',sans-serif;font-size:16px;text-align:center} + body {font-family:'Arial',sans-serif;font-size:16px;text-align:center;padding:1em 2em} input,textarea {padding:.5em;border-radius:10px;border:1px solid #ccc;font-size:16px;display:block} textarea {width:50%;margin:0 auto} input.btn {background:#3B619D;color:#FFF;padding:.5em 2em;font-size:20px;margin:.5em auto}
--- a/web/src/luan/modules/web/web_shell.luan Thu Dec 11 01:44:38 2014 +0000 +++ b/web/src/luan/modules/web/web_shell.luan Thu Dec 11 03:12:26 2014 +0000 @@ -38,7 +38,7 @@ <head> <title>Luan Shell</title> <style> - body {font-family:'Arial',sans-serif;font-size:16px} + body {font-family:'Arial',sans-serif;font-size:16px;padding:1em 2em} input {padding:.5em;border-radius:10px;border:1px solid #ccc;font-size:16px} input.btn {background:#3B619D;color:#FFF;padding:.3em 0;font-size:20px;min-width:4em;} h1 {font-weight:bold;font-size: 20px}