8
|
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
|
|
14
|
|
15 return function()
|
|
16 local user = User.current_required()
|
|
17 if user==nil then return end
|
|
18 if Http.request.method == "POST" then
|
|
19 local subject = Http.request.parameters.subject or error()
|
|
20 local content = Http.request.parameters.content or error()
|
|
21 local post = Post.new_thread(user,subject,content)
|
|
22 Http.response.send_redirect("/thread.html?root="..post.id)
|
|
23 return
|
|
24 end
|
|
25 Io.stdout = Http.response.text_writer()
|
|
26 %>
|
|
27 <!doctype html>
|
|
28 <html>
|
|
29 <head>
|
|
30 <% head() %>
|
|
31 <title><%=forum_title%></title>
|
|
32 </head>
|
|
33 <body>
|
|
34 <% header() %>
|
|
35 <div content>
|
|
36 <h1>New Thread</h1>
|
|
37 <form method=post>
|
|
38 <p>
|
|
39 <label>Subject</label>
|
|
40 <input name=subject required>
|
|
41 </p>
|
|
42 <p><textarea name=content></textarea></p>
|
|
43 <p><input type=submit></p>
|
|
44 </form>
|
|
45 </div>
|
|
46 <% footer() %>
|
|
47 </body>
|
|
48 </html>
|
|
49 <%
|
|
50 end
|