comparison 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
comparison
equal deleted inserted replaced
2:fc2383eb48a9 3:fc3ee39d7764
1 local Luan = require "luan:Luan.luan" 1 local Luan = require "luan:Luan.luan"
2 local error = Luan.error 2 local error = Luan.error
3 local Http = require "luan:http/Http.luan"
3 local Forum = require "site:/lib/Forum.luan" 4 local Forum = require "site:/lib/Forum.luan"
5 local User = require "site:/lib/User.luan"
6 local Logging = require "luan:logging/Logging.luan"
7 local logger = Logging.logger "Shared"
4 8
5 9
6 local Shared = {} 10 local Shared = {}
7 11
8 function Shared.head() 12 function Shared.head()
13 </style> 17 </style>
14 <% 18 <%
15 end 19 end
16 20
17 function Shared.header() 21 function Shared.header()
22 local user = User.current()
18 %> 23 %>
19 <div header> 24 <div header>
20 <a href="/"><%=Forum.title%></a> 25 <a href="/"><%=Forum.title%></a>
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 %>
21 </div> 32 </div>
22 <% 33 <%
23 end 34 end
24 35
25 function Shared.footer() 36 function Shared.footer()
28 <a href="/config.html">Configuration</a> 39 <a href="/config.html">Configuration</a>
29 </div> 40 </div>
30 <% 41 <%
31 end 42 end
32 43
44 function Shared.base_url()
45 return Http.request.scheme.."://"..Http.request.headers["host"]
46 end
47
33 return Shared 48 return Shared