9
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local Html = require "luan:Html.luan"
|
|
4 local html_encode = Html.encode or error()
|
|
5 local Io = require "luan:Io.luan"
|
|
6 local Http = require "luan:http/Http.luan"
|
|
7 local Shared = require "site:/lib/Shared.luan"
|
|
8 local head = Shared.head or error()
|
|
9 local header = Shared.header or error()
|
|
10 local footer = Shared.footer or error()
|
|
11 local Forum = require "site:/lib/Forum.luan"
|
|
12 local forum_title = Forum.title or error()
|
|
13 local Post = require "site:/lib/Post.luan"
|
|
14 local User = require "site:/lib/User.luan"
|
13
|
15 local Bbcode = require "site:/lib/Bbcode.luan"
|
|
16 local bbcode_preprocess = Bbcode.preprocess or error()
|
9
|
17
|
|
18
|
|
19 return function()
|
|
20 local user = User.current_required()
|
|
21 if user==nil then return end
|
|
22 local post_id = Http.request.parameters.post or error()
|
|
23 local post = Post.get_by_id(post_id) or error()
|
|
24 if Http.request.method == "POST" then
|
13
|
25 local content = Http.request.parameters.content or error()
|
|
26 content = bbcode_preprocess(content)
|
|
27 post.content = content
|
9
|
28 post.save()
|
|
29 Http.response.send_redirect("/thread.html?root="..post.root_id)
|
|
30 return
|
|
31 end
|
|
32 Io.stdout = Http.response.text_writer()
|
|
33 %>
|
|
34 <!doctype html>
|
|
35 <html>
|
|
36 <head>
|
|
37 <% head() %>
|
|
38 <title><%=forum_title%>: edit</title>
|
|
39 </head>
|
|
40 <body>
|
|
41 <% header() %>
|
|
42 <div content>
|
|
43 <h1>edit: <%=post.root.subject_html%></h1>
|
|
44 <p>This page will almost certainly be replaced by ajax, but whatever. Hack for now.</p>
|
|
45 <form method=post>
|
|
46 <p><textarea name=content><%=html_encode(post.content)%></textarea></p>
|
|
47 <p><input type=submit></p>
|
|
48 </form>
|
|
49 </div>
|
|
50 <% footer() %>
|
|
51 </body>
|
|
52 </html>
|
|
53 <%
|
|
54 end
|