comparison web/src/luan/modules/web/web_run.luan @ 325:78a6a71afbfd

use SimplyHTML git-svn-id: https://luan-java.googlecode.com/svn/trunk@326 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Tue, 03 Mar 2015 06:00:59 +0000
parents 7f7708e8fdd4
children db37d6aee4db
comparison
equal deleted inserted replaced
324:b24a35612947 325:78a6a71afbfd
2 local load = Luan.load 2 local load = Luan.load
3 local Io = require "luan:Io" 3 local Io = require "luan:Io"
4 local print = Io.print 4 local print = Io.print
5 local Http = require "luan:web/Http" 5 local Http = require "luan:web/Http"
6 local String = require "luan:String" 6 local String = require "luan:String"
7 local Html = require "luan:Html"
7 8
8 local function lines(s) 9 local function lines(s)
9 local matcher = s.gmatch "([^\n]*)\n|([^\n])+$" 10 local matcher = s.gmatch "([^\n]*)\n|([^\n])+$"
10 return function() 11 return function()
11 local m1, m2 = matcher() 12 local m1, m2 = matcher()
19 print(i,line) 20 print(i,line)
20 i = i + 1 21 i = i + 1
21 end 22 end
22 end 23 end
23 24
24 local function basic_style() %> 25 local function form()
25 body {font-family:'Arial',sans-serif;font-size:16px;text-align:center;padding:1em 2em} 26 Html.simple_html_page{
26 input,textarea {padding:.5em;border-radius:10px;border:1px solid #ccc;font-size:16px;display:block} 27 head = function() %>
27 textarea {width:50%;margin:0 auto} 28 <title>Run Luan Code</title>
28 input.btn {background:#3B619D;color:#FFF;padding:.5em 2em;font-size:20px;margin:.5em auto} 29 <% end;
29 h1 {font-weight:bold;font-size: 20px} 30 body = function() %>
30 p {margin:1em 0 .2em} 31 <center margin-top=10>
31 <% end 32 <h3>Run Luan Code</h3>
32 33 </center>
33 local function form() %> 34 <form name="form0" method="post">
34 <!DOCTYPE html> 35 <input type="hidden" name="content_type" value="text/plain" />
35 <html lang="en"> 36 <center>
36 <head> 37 <textarea name="code" rows="20" cols="90" wrap="off" autofocus></textarea>
37 <title>Run Luan Code</title> 38 </center>
38 <style><% basic_style() %></style> 39 <center margin-top=5>
39 </head> 40 <input type="submit" value="Execute Luan Code" textcolor="white" bgcolor="#337ab7"/>
40 <body> 41 </center>
41 <h1>Run Luan Code</h1> 42 </form>
42 <form name="form0" method="post"> 43 <% end;
43 <input type="hidden" name="content_type" value="text/plain" /> 44 }
44 <textarea name="code" rows="20" cols="90" wrap="off"></textarea> 45 end
45 <input type="submit" class="btn" value="Execute Luan Code"/>
46 </form>
47 <script>document.form0.code.focus();</script>
48 </body>
49 </html>
50 <% end
51 46
52 function service() 47 function service()
53 Io.stdout = Http.response.text_writer() 48 Io.stdout = Http.response.text_writer()
54 local code = Http.request.parameters.code 49 local code = Http.request.parameters.code
55 if code == nil then 50 if code == nil then