annotate src/lib/Shared.luan @ 1:b116b6ef07bf

add config
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 23 Oct 2024 21:18:04 -0600
parents fddd11ae516c
children ee1f91e67509
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local ipairs = Luan.ipairs or error()
1
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
4 local parse = Luan.parse or error()
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
5 local Io = require "luan:Io.luan"
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
6 local uri = Io.uri or error()
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local Shared = {}
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 function Shared.head()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 <meta name="viewport" content="width=device-width, initial-scale=1">
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 <style>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 @import "/site.css";
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 </style>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 local function header(crumbs)
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 <div header>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 <a href="/">Reactionary Chat</a>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <% for _, crumb in ipairs(crumbs or {}) do %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 / <%=crumb%>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 <% end %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 </div>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 Shared.header = header
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 function Shared.private_header()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 header{
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 [[<a href="/private/">private</a>]]
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 [[<a href="/private/tools/">tools</a>]]
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 }
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38
1
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
39 local config_file = uri("site:/private/local/config.luano")
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
40 Shared.config_file = config_file
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
41
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
42 do
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
43 if config_file.exists() then
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
44 Shared.config = parse( config_file.read_text() )
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
45 else
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
46 Shared.config = {
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
47 mail_server = {
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
48 host = "smtpcorp.com"
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
49 port = 465
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
50 username = "xxx"
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
51 password = "xxx"
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
52 }
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
53 }
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
54 end
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
55 end
b116b6ef07bf add config
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
56
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57 return Shared