view src/private/tools/configure_mail.html.luan @ 19:a90e510ccc4f

fix restart/move logs
author Vadim Filimonov <fffilimonov@yandex.ru>
date Mon, 05 Aug 2024 11:29:06 +0300
parents a6be8817c05b
children
line wrap: on
line source

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