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"
|
52
|
13 local Bbcode = require "site:/bbcode/Bbcode.luan"
|
|
14 local preprocess = Bbcode.preprocess or error()
|
8
|
15
|
|
16
|
|
17 return function()
|
|
18 local user = User.current_required()
|
|
19 if user==nil then return end
|
|
20 if Http.request.method == "POST" then
|
|
21 local subject = Http.request.parameters.subject or error()
|
46
|
22 local content = Http.request.parameters.bbcode or error()
|
52
|
23 local convert_urls = Http.request.parameters.convert_urls or error()
|
|
24 if convert_urls == "true" then
|
|
25 content = preprocess(content)
|
|
26 end
|
8
|
27 local post = Post.new_thread(user,subject,content)
|
|
28 Http.response.send_redirect("/thread.html?root="..post.id)
|
|
29 return
|
|
30 end
|
|
31 Io.stdout = Http.response.text_writer()
|
|
32 %>
|
|
33 <!doctype html>
|
|
34 <html>
|
|
35 <head>
|
|
36 <% head() %>
|
9
|
37 <title><%=forum_title%>: new thread</title>
|
42
|
38 <style>
|
46
|
39 @import "/bbcode/bbcode.css";
|
42
|
40 </style>
|
8
|
41 <body>
|
|
42 <% header() %>
|
|
43 <div content>
|
|
44 <h1>New Thread</h1>
|
|
45 <form method=post>
|
|
46 <p>
|
|
47 <label>Subject</label>
|
|
48 <input name=subject required>
|
|
49 </p>
|
46
|
50 <p editor></p>
|
8
|
51 <p><input type=submit></p>
|
|
52 </form>
|
|
53 </div>
|
|
54 <% footer() %>
|
|
55 </body>
|
46
|
56 <script>
|
|
57 bbcodeCreate('p[editor]');
|
|
58 </script>
|
8
|
59 </html>
|
|
60 <%
|
|
61 end
|