comparison src/reply.html.luan @ 9:9674275019bb

reply and edit
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 30 Jun 2022 00:02:28 -0600
parents
children 24668255cede
comparison
equal deleted inserted replaced
8:be36282b556a 9:9674275019bb
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 local parent_id = Http.request.parameters.parent or error()
19 local parent = Post.get_by_id(parent_id) or error()
20 if Http.request.method == "POST" then
21 local content = Http.request.parameters.content or error()
22 local post = parent.reply(user,content)
23 Http.response.send_redirect("/thread.html?root="..post.root_id)
24 return
25 end
26 Io.stdout = Http.response.text_writer()
27 %>
28 <!doctype html>
29 <html>
30 <head>
31 <% head() %>
32 <title><%=forum_title%>: reply</title>
33 </head>
34 <body>
35 <% header() %>
36 <div content>
37 <h1>reply to: <%=parent.root.subject_html%></h1>
38 <p>This page will almost certainly be replaced by ajax, but whatever. Hack for now.</p>
39 <form method=post>
40 <p><textarea name=content></textarea></p>
41 <p><input type=submit></p>
42 </form>
43 </div>
44 <% footer() %>
45 </body>
46 </html>
47 <%
48 end