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