comparison 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
comparison
equal deleted inserted replaced
3:fc3ee39d7764 4:a17e400ddaa1
1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error
3 local stringify = Luan.stringify or error()
4 local String = require "luan:String.luan"
5 local trim = String.trim or error()
6 local Html = require "luan:Html.luan"
7 local html_encode = Html.encode or error()
8 local Parsers = require "luan:Parsers.luan"
9 local json_string = Parsers.json_string or error()
10 local Io = require "luan:Io.luan"
11 local Http = require "luan:http/Http.luan"
12 local Mail = require "site:/lib/Mail.luan"
13 local Shared = require "site:/lib/Shared.luan"
14 local head = Shared.head or error()
15 local header = Shared.admin_header or error()
16 local Logging = require "luan:logging/Logging.luan"
17 local logger = Logging.logger "admin/mail_config.html"
18
19 --[[
20 local default = stringify{
21 host = "smtpcorp.com"
22 username = "xxx"
23 password = "xxx"
24 port = 2525
25 }
26 ]]
27
28 return function()
29 Io.stdout = Http.response.text_writer()
30 local updated = false
31 if Http.request.method == "POST" then
32 local config = Http.request.parameters.config or error()
33 if trim(config) == "" then
34 config = nil
35 end
36 Mail.set(config)
37 updated = true
38 end
39 %>
40 <!doctype html>
41 <html>
42 <head>
43 <% head() %>
44 <title>FreedIt - Configure Mail</title>
45 <style>
46 textarea {
47 width: 20em;
48 height: 10em;
49 }
50 </style>
51 </head>
52 <body>
53 <% header() %>
54 <div content>
55 <h1>Configure Mail</h1>
56 <% if updated then %>
57 <p>Updated</p>
58 <% else %>
59 <form method=post>
60 <p><textarea name=config autofocus><%= html_encode(Mail.get() or "") %></textarea></p>
61 <p><input type=submit><p>
62 </form>
63 <% end %>
64 </div>
65 </body>
66 </html>
67 <%
68 end