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()
|
46
|
20 local content = Http.request.parameters.bbcode or error()
|
8
|
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() %>
|
9
|
31 <title><%=forum_title%>: new thread</title>
|
42
|
32 <style>
|
46
|
33 @import "/bbcode/bbcode.css";
|
42
|
34 </style>
|
46
|
35 <script src="/bbcode/bbcode.js"></script>
|
8
|
36 <body>
|
|
37 <% header() %>
|
|
38 <div content>
|
|
39 <h1>New Thread</h1>
|
|
40 <form method=post>
|
|
41 <p>
|
|
42 <label>Subject</label>
|
|
43 <input name=subject required>
|
|
44 </p>
|
46
|
45 <p editor></p>
|
8
|
46 <p><input type=submit></p>
|
|
47 </form>
|
|
48 </div>
|
|
49 <% footer() %>
|
|
50 </body>
|
46
|
51 <script>
|
|
52 bbcodeCreate('p[editor]');
|
|
53 </script>
|
8
|
54 </html>
|
|
55 <%
|
|
56 end
|