diff src/private/admin/mail_config.html.luan @ 4:a17e400ddaa1

add email
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 21 Jun 2022 11:58:27 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/private/admin/mail_config.html.luan	Tue Jun 21 11:58:27 2022 -0600
@@ -0,0 +1,68 @@
+local Luan = require "luan:Luan.luan"
+local error = Luan.error
+local stringify = Luan.stringify or error()
+local String = require "luan:String.luan"
+local trim = String.trim or error()
+local Html = require "luan:Html.luan"
+local html_encode = Html.encode or error()
+local Parsers = require "luan:Parsers.luan"
+local json_string = Parsers.json_string or error()
+local Io = require "luan:Io.luan"
+local Http = require "luan:http/Http.luan"
+local Mail = require "site:/lib/Mail.luan"
+local Shared = require "site:/lib/Shared.luan"
+local head = Shared.head or error()
+local header = Shared.admin_header or error()
+local Logging = require "luan:logging/Logging.luan"
+local logger = Logging.logger "admin/mail_config.html"
+
+--[[
+local default = stringify{
+	host = "smtpcorp.com"
+	username = "xxx"
+	password = "xxx"
+	port = 2525
+}
+]]
+
+return function()
+	Io.stdout = Http.response.text_writer()
+	local updated = false
+	if Http.request.method == "POST" then
+		local config = Http.request.parameters.config or error()
+		if trim(config) == "" then
+			config = nil
+		end
+		Mail.set(config)
+		updated = true
+	end
+%>
+<!doctype html>
+<html>
+	<head>
+<%		head() %>
+		<title>FreedIt - Configure Mail</title>
+		<style>
+			textarea {
+				width: 20em;
+				height: 10em;
+			}
+		</style>
+	</head>
+	<body>
+<%		header() %>
+		<div content>
+			<h1>Configure Mail</h1>
+<%	if updated then %>
+			<p>Updated</p>
+<%	else %>
+			<form method=post>
+				<p><textarea name=config autofocus><%= html_encode(Mail.get() or "") %></textarea></p>
+				<p><input type=submit><p>
+			</form>
+<%	end %>
+		</div>
+	</body>
+</html>
+<%
+end