diff src/private/tools/configure_mail.html.luan @ 6:a6be8817c05b

move mail_info to config
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 02 Jun 2022 19:18:12 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/private/tools/configure_mail.html.luan	Thu Jun 02 19:18:12 2022 -0600
@@ -0,0 +1,74 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local stringify = Luan.stringify or error()
+local parse = Luan.parse or 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.private_header or error()
+local config = Shared.config or error()
+local get_raw_config = Shared.get_raw_config or error()
+local save_raw_config = Shared.save_raw_config or error()
+
+
+local function posted()
+	local mail_info = Http.request.parameters.mail_info or error()
+	mail_info = parse(mail_info)
+	local raw_config = get_raw_config()
+	raw_config.mail_info = mail_info
+	save_raw_config(raw_config)
+%>
+<!doctype html>
+<html>
+	<head>
+<%		head() %>
+		<title>Mercurial Configure Email</title>
+	</head>
+	<body>
+<%		header() %>
+		<div content>
+			<h1>Configure Email</h1>
+			<p>Updated</p>
+		</div>
+	</body>
+</html>
+<%
+end
+
+return function()
+	local mail_info = stringify(config.mail_info or {
+		host = "smtpcorp.com"
+		username = "xxx"
+		password = "xxx"
+		port = 2525
+	})
+	Io.stdout = Http.response.text_writer()
+	if Http.request.method == "POST" then
+		posted()
+		return
+	end
+%>
+<!doctype html>
+<html>
+	<head>
+<%		head() %>
+		<title>Mercurial Configure Email</title>
+	</head>
+	<body>
+<%		header() %>
+		<div content>
+			<h1>Configure Email</h1>
+			<form method=post>
+				<p>
+					<textarea name=mail_info rows=6 cols=40><%=mail_info%></textarea>
+				</p>
+				<p>
+					<input type=submit value="Update">
+				</p>
+			</form>
+		</div>
+	</body>
+</html>
+<%
+end