annotate src/lib/Shared.luan @ 3:fc3ee39d7764

login
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 19 Jun 2022 20:47:31 -0600
parents 6a1e2749571d
children a17e400ddaa1
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
3
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
3 local Http = require "luan:http/Http.luan"
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Forum = require "site:/lib/Forum.luan"
3
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
5 local User = require "site:/lib/User.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
6 local Logging = require "luan:logging/Logging.luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
7 local logger = Logging.logger "Shared"
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local Shared = {}
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 function Shared.head()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 <meta name="viewport" content="width=device-width, initial-scale=1">
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 <style>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 @import "/site.css";
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 </style>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 function Shared.header()
3
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
22 local user = User.current()
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 <div header>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <a href="/"><%=Forum.title%></a>
3
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
26 -
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
27 <% if user == nil then %>
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
28 <a href="/login.html">login</a>
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
29 <% else %>
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
30 <a href="/account.html"><%=user.name_html%></a>
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
31 <% end %>
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 </div>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 function Shared.footer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 %>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 <div footer>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 <a href="/config.html">Configuration</a>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 </div>
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 <%
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 end
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43
3
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
44 function Shared.base_url()
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
45 return Http.request.scheme.."://"..Http.request.headers["host"]
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
46 end
Franklin Schmidt <fschmidt@gmail.com>
parents: 0
diff changeset
47
0
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 return Shared