Mercurial Hosting > luan
comparison examples/blog/src/edit.luan @ 779:c38f6619feb9
move blog into examples
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 28 Aug 2016 14:50:47 -0600 |
parents | blog/src/edit.luan@1460d297e960 |
children | 21d157b153fe |
comparison
equal
deleted
inserted
replaced
778:305ffb00ebc1 | 779:c38f6619feb9 |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local String = require "luan:String.luan" | |
4 local to_number = String.to_number or error() | |
5 local Io = require "luan:Io.luan" | |
6 local Http = require "luan:http/Http.luan" | |
7 local Post = require "site:/lib/Post.luan" | |
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><br>bbcode works</p> | |
35 <p> | |
36 <input type=submit name=save value=Submit> | |
37 </p> | |
38 </form> | |
39 | |
40 </body> | |
41 </html> | |
42 <% | |
43 end |