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