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 <% if user == nil then %>
|
|
27 <a href="/login.html">login</a>
|
|
28 <% else %>
|
|
29 <a href="/account.html"><%=user.name_html%></a>
|
|
30 <% end %>
|
0
|
31 </div>
|
|
32 <%
|
|
33 end
|
|
34
|
|
35 function Shared.footer()
|
|
36 %>
|
|
37 <div footer>
|
|
38 <a href="/config.html">Configuration</a>
|
|
39 </div>
|
|
40 <%
|
|
41 end
|
|
42
|
4
|
43 function Shared.admin_header()
|
|
44 %>
|
|
45 <div header>
|
|
46 <a href="/private/admin.html">Admin</a>
|
|
47 </div>
|
|
48 <%
|
|
49 end
|
|
50
|
3
|
51 function Shared.base_url()
|
|
52 return Http.request.scheme.."://"..Http.request.headers["host"]
|
|
53 end
|
|
54
|
0
|
55 return Shared
|