annotate blog/src/new.luan @ 604:b73f005f3735 0.13

table constructor now uses end_of_line as a delimiter
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 24 Nov 2015 16:29:27 -0700
parents 6bb0c83116e9
children ca169567ce07
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
596
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan"
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Io = require "luan:Io"
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Http = require "luan:http/Http"
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Post = require "site:/lib/Post"
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 return function()
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local subject = Http.request.parameter.subject
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local content = Http.request.parameter.content
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 if Http.request.parameter.save ~= nil then
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local post = Post.new{ subject=subject, content=content }
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 post.save()
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 Http.response.send_redirect("/")
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 return
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 end
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 Io.stdout = Http.response.text_writer()
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 %>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 <html>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 <head>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <style>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 @import "/site.css";
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 </style>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 </head>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 <body>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <h1>Make New Post</h1>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <form method=post>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <p>Subject: <input name=subject size=50 type=text></p>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 <p><textarea name=content rows=20 cols=90></textarea></p>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 <p>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 <input type=submit name=save value=Submit>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 </p>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 </form>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 </body>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 </html>
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 <%
6bb0c83116e9 add blog sample app
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 end