annotate src/new_thread.html.luan @ 48:4e1a01db19ec

add lists
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 17 Nov 2022 00:11:44 -0700
parents 289718f121e4
children 78b2d6995244
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Io = require "luan:Io.luan"
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Http = require "luan:http/Http.luan"
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Shared = require "site:/lib/Shared.luan"
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local head = Shared.head or error()
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local header = Shared.header or error()
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local footer = Shared.footer or error()
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Forum = require "site:/lib/Forum.luan"
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local forum_title = Forum.title or error()
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local Post = require "site:/lib/Post.luan"
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local User = require "site:/lib/User.luan"
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 return function()
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 local user = User.current_required()
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 if user==nil then return end
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 if Http.request.method == "POST" then
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 local subject = Http.request.parameters.subject or error()
46
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 42
diff changeset
20 local content = Http.request.parameters.bbcode or error()
8
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 local post = Post.new_thread(user,subject,content)
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 Http.response.send_redirect("/thread.html?root="..post.id)
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 return
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 end
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 Io.stdout = Http.response.text_writer()
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 %>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <!doctype html>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 <html>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <head>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <% head() %>
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents: 8
diff changeset
31 <title><%=forum_title%>: new thread</title>
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 9
diff changeset
32 <style>
46
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 42
diff changeset
33 @import "/bbcode/bbcode.css";
42
0c1b820fff34 use push
Franklin Schmidt <fschmidt@gmail.com>
parents: 9
diff changeset
34 </style>
46
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 42
diff changeset
35 <script src="/bbcode/bbcode.js"></script>
8
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 <body>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 <% header() %>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 <div content>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 <h1>New Thread</h1>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 <form method=post>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 <p>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 <label>Subject</label>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 <input name=subject required>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 </p>
46
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 42
diff changeset
45 <p editor></p>
8
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 <p><input type=submit></p>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 </form>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 </div>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 <% footer() %>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 </body>
46
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 42
diff changeset
51 <script>
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 42
diff changeset
52 bbcodeCreate('p[editor]');
289718f121e4 use bbcode editor
Franklin Schmidt <fschmidt@gmail.com>
parents: 42
diff changeset
53 </script>
8
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 </html>
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 <%
be36282b556a add new_thread
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 end