Mercurial Hosting > luan
annotate blog/src/edit.luan @ 704:90c89138c234
optimize lucene
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 13 May 2016 17:13:13 -0600 |
parents | ca169567ce07 |
children | 1460d297e960 |
rev | line source |
---|---|
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
1 local Luan = require "luan:Luan.luan" |
596 | 2 local error = Luan.error |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
3 local String = require "luan:String.luan" |
596 | 4 local to_number = String.to_number or error() |
693
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
5 local Io = require "luan:Io.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
6 local Http = require "luan:http/Http.luan" |
ca169567ce07
module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
596
diff
changeset
|
7 local Post = require "site:/lib/Post.luan" |
596 | 8 |
9 | |
10 return function() | |
11 local post_id = to_number(Http.request.parameter.post) or error() | |
12 local post = Post.get_by_id(post_id) or error() | |
13 if Http.request.parameter.save ~= nil then | |
14 post.subject = Http.request.parameter.subject | |
15 post.content = Http.request.parameter.content | |
16 post.save() | |
17 Http.response.send_redirect("/#p"..post.id) | |
18 return | |
19 end | |
20 | |
21 Io.stdout = Http.response.text_writer() | |
22 %> | |
23 <html> | |
24 <head> | |
25 <style> | |
26 @import "/site.css"; | |
27 </style> | |
28 </head> | |
29 <body> | |
30 <h1>Make New Post</h1> | |
31 | |
32 <form method=post> | |
33 <p>Subject: <input name=subject size=50 type=text value="<%= post.subject %>"></p> | |
34 <p><textarea name=content rows=20 cols=90><%= post.content %></textarea></p> | |
35 <p> | |
36 <input type=submit name=save value=Submit> | |
37 </p> | |
38 </form> | |
39 | |
40 </body> | |
41 </html> | |
42 <% | |
43 end |