Mercurial Hosting > luan
annotate examples/blog/src/edit.luan @ 1082:ece3567d4df5
fix http content type
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 15 Nov 2016 19:19:19 -0700 |
parents | c38f6619feb9 |
children | 21d157b153fe |
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> | |
777
1460d297e960
add bbcode to blog example
Franklin Schmidt <fschmidt@gmail.com>
parents:
693
diff
changeset
|
34 <p><textarea name=content rows=20 cols=90><%= post.content %></textarea><br>bbcode works</p> |
596 | 35 <p> |
36 <input type=submit name=save value=Submit> | |
37 </p> | |
38 </form> | |
39 | |
40 </body> | |
41 </html> | |
42 <% | |
43 end |