diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/reply.html.luan	Thu Jun 30 00:02:28 2022 -0600
@@ -0,0 +1,48 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local Io = require "luan:Io.luan"
+local Http = require "luan:http/Http.luan"
+local Shared = require "site:/lib/Shared.luan"
+local head = Shared.head or error()
+local header = Shared.header or error()
+local footer = Shared.footer or error()
+local Forum = require "site:/lib/Forum.luan"
+local forum_title = Forum.title or error()
+local Post = require "site:/lib/Post.luan"
+local User = require "site:/lib/User.luan"
+
+
+return function()
+	local user = User.current_required()
+	if user==nil then return end
+	local parent_id = Http.request.parameters.parent or error()
+	local parent = Post.get_by_id(parent_id) or error()
+	if Http.request.method == "POST" then
+		local content = Http.request.parameters.content or error()
+		local post = parent.reply(user,content)
+		Http.response.send_redirect("/thread.html?root="..post.root_id)
+		return
+	end
+	Io.stdout = Http.response.text_writer()
+%>
+<!doctype html>
+<html>
+	<head>
+<%		head() %>
+		<title><%=forum_title%>: reply</title>
+	</head>
+	<body>
+<%		header() %>
+		<div content>
+			<h1>reply to: <%=parent.root.subject_html%></h1>
+			<p>This page will almost certainly be replaced by ajax, but whatever.  Hack for now.</p>
+			<form method=post>
+				<p><textarea name=content></textarea></p>
+				<p><input type=submit></p>
+			</form>
+		</div>
+<%		footer() %>
+	</body>
+</html>
+<%
+end