diff examples/blog/src/new.luan @ 779:c38f6619feb9

move blog into examples
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 28 Aug 2016 14:50:47 -0600
parents blog/src/new.luan@1460d297e960
children 21d157b153fe
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/examples/blog/src/new.luan	Sun Aug 28 14:50:47 2016 -0600
@@ -0,0 +1,40 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local Io = require "luan:Io.luan"
+local Http = require "luan:http/Http.luan"
+local Post = require "site:/lib/Post.luan"
+
+
+return function()
+	local subject = Http.request.parameter.subject
+	local content = Http.request.parameter.content
+	if Http.request.parameter.save ~= nil then
+		local post = Post.new{ subject=subject, content=content }
+		post.save()
+		Http.response.send_redirect("/")
+		return
+	end
+
+	Io.stdout = Http.response.text_writer()
+%>
+<html>
+	<head>
+		<style>
+			@import "/site.css";
+		</style>
+	</head>
+	<body>
+		<h1>Make New Post</h1>
+
+		<form method=post>
+			<p>Subject: <input name=subject size=50 type=text></p>
+			<p><textarea name=content rows=20 cols=90></textarea><br>bbcode works</p>
+			<p>
+				<input type=submit name=save value=Submit>
+			</p>
+		</form>
+
+	</body>
+</html>
+<%
+end