Mercurial Hosting > luan
annotate examples/blog/src/edit.html.luan @ 1497:f04bfbb08721
link_from
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 08 May 2020 16:54:30 -0600 |
parents | 4c2972f4d862 |
children |
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() | |
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
11 local post_id = to_number(Http.request.parameters.post) or error() |
596 | 12 local post = Post.get_by_id(post_id) or error() |
1152
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
13 if Http.request.parameters.save ~= nil then |
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
14 post.subject = Http.request.parameters.subject |
21d157b153fe
change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents:
779
diff
changeset
|
15 post.content = Http.request.parameters.content |
596 | 16 post.save() |
17 Http.response.send_redirect("/#p"..post.id) | |
18 return | |
19 end | |
20 | |
21 Io.stdout = Http.response.text_writer() | |
22 %> | |
1216 | 23 <!doctype html> |
596 | 24 <html> |
25 <head> | |
26 <style> | |
27 @import "/site.css"; | |
28 </style> | |
29 </head> | |
30 <body> | |
31 <h1>Make New Post</h1> | |
32 | |
33 <form method=post> | |
34 <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
|
35 <p><textarea name=content rows=20 cols=90><%= post.content %></textarea><br>bbcode works</p> |
596 | 36 <p> |
37 <input type=submit name=save value=Submit> | |
38 </p> | |
39 </form> | |
40 | |
41 </body> | |
42 </html> | |
43 <% | |
44 end |