changeset 6:a6be8817c05b

move mail_info to config
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 02 Jun 2022 19:18:12 -0600
parents a09d8bcdc0f9
children 46f6b69e8b10
files doc/update.txt src/get_password.html.luan src/private/tools/configure_mail.html.luan src/private/tools/index.html.luan
diffstat 4 files changed, 80 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
diff -r a09d8bcdc0f9 -r a6be8817c05b doc/update.txt
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/doc/update.txt	Thu Jun 02 19:18:12 2022 -0600
@@ -0,0 +1,3 @@
+ussh administrator@hg.luan.software
+cd hghosting
+./update.sh
diff -r a09d8bcdc0f9 -r a6be8817c05b src/get_password.html.luan
--- a/src/get_password.html.luan	Wed May 18 00:21:44 2022 -0600
+++ b/src/get_password.html.luan	Thu Jun 02 19:18:12 2022 -0600
@@ -13,12 +13,8 @@
 local save_raw_config = Shared.save_raw_config or error()
 
 
-local send_mail = Mail.sender{
-	host = "smtpcorp.com"
-	username = "smtp@luan.software"
-	password = "luanhost"
-	port = 2525
-}.send
+local mail_info = config.mail_info or error "missing config.mail_info"
+local send_mail = Mail.sender(mail_info).send
 
 local function handle(email)
 	local change = Http.request.parameters.change ~= nil
diff -r a09d8bcdc0f9 -r a6be8817c05b src/private/tools/configure_mail.html.luan
--- /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
diff -r a09d8bcdc0f9 -r a6be8817c05b src/private/tools/index.html.luan
--- a/src/private/tools/index.html.luan	Wed May 18 00:21:44 2022 -0600
+++ b/src/private/tools/index.html.luan	Thu Jun 02 19:18:12 2022 -0600
@@ -23,6 +23,7 @@
 			<p><a href="private_users.html">edit private users</a></p>
 			<p><a href="backup.html">edit backup</a></p>
 			<p><a href="all_users.html">all users</a></p>
+			<p><a href="configure_mail.html">configure mail</a></p>
 			<p><a href="links.txt">links.txt</a></p>
 		</div>
 	</body>