annotate src/private/admin/config.html.luan @ 21:33731231093a

fix bbcode editing
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 17 Jul 2022 08:24:52 -0600
parents a17e400ddaa1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Html = require "luan:Html.luan"
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local html_encode = Html.encode or error()
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Parsers = require "luan:Parsers.luan"
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local json_string = Parsers.json_string or error()
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local Io = require "luan:Io.luan"
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Http = require "luan:http/Http.luan"
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local reset_luan = Http.reset_luan or error()
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local test_as_init = Http.test_as_init or error()
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local Run = require "luan:http/tools/Run.luan"
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local Config = require "site:/lib/Config.luan"
4
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
13 local Shared = require "site:/lib/Shared.luan"
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
14 local head = Shared.head or error()
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
15 local header = Shared.admin_header or error()
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 local Logging = require "luan:logging/Logging.luan"
4
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
17 local logger = Logging.logger "admin/config.html"
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 return function()
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 Io.stdout = Http.response.text_writer()
4
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
22 local updated = false
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 if Http.request.method == "POST" then
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 local config = Http.request.parameters.config or error()
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 try
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 test_as_init(config,"config")
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 catch e
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 Run.print_error(e,config)
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 return
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 end
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 Config.set(config)
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 reset_luan()
4
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
33 updated = true
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 end
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 %>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 <!doctype html>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 <html>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 <head>
4
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
39 <% head() %>
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 <title>FreedIt - Configure Forum</title>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 <style>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 textarea {
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 width: 90%;
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 height: 20em;
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 }
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 </style>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 <script>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 function restoreDefault() {
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 document.querySelector('textarea').value = <%=json_string(Config.default_text,{compressed=true})%>;
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 }
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 </script>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 </head>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 <body>
4
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
54 <% header() %>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
55 <div content>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
56 <h1>Configure Forum</h1>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
57 <% if updated then %>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
58 <p>Updated</p>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
59 <% else %>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
60 <form method=post>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
61 <p>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
62 Configuration in <a href="http://www.luan.software/">Luan</a>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
63 - <a href="javascript:restoreDefault()">restore default</a>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
64 </p>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
65 <p><textarea name=config autofocus><%= html_encode(Config.text) %></textarea></p>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
66 <p><input type=submit><p>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
67 </form>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
68 <% end %>
a17e400ddaa1 add email
Franklin Schmidt <fschmidt@gmail.com>
parents: 2
diff changeset
69 </div>
2
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
70 </body>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
71 </html>
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
72 <%
fc2383eb48a9 set config
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
73 end