comparison src/lib/Shared.luan @ 2:ee1f91e67509

add Db
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 24 Oct 2024 15:37:35 -0600
parents b116b6ef07bf
children 2c63b10781e1
comparison
equal deleted inserted replaced
1:b116b6ef07bf 2:ee1f91e67509
2 local error = Luan.error 2 local error = Luan.error
3 local ipairs = Luan.ipairs or error() 3 local ipairs = Luan.ipairs or error()
4 local parse = Luan.parse or error() 4 local parse = Luan.parse or error()
5 local Io = require "luan:Io.luan" 5 local Io = require "luan:Io.luan"
6 local uri = Io.uri or error() 6 local uri = Io.uri or error()
7 local User = require "site:/lib/User.luan"
8 local current_user = User.current or error()
7 9
8 10
9 local Shared = {} 11 local Shared = {}
10 12
11 function Shared.head() 13 function Shared.head()
16 </style> 18 </style>
17 <% 19 <%
18 end 20 end
19 21
20 local function header(crumbs) 22 local function header(crumbs)
23 local user = current_user()
21 %> 24 %>
22 <div header> 25 <div header>
23 <a href="/">Reactionary Chat</a> 26 <span>
27 <a href="/">Web Chat</a>
24 <% for _, crumb in ipairs(crumbs or {}) do %> 28 <% for _, crumb in ipairs(crumbs or {}) do %>
25 / <%=crumb%> 29 / <%=crumb%>
26 <% end %> 30 <% end %>
31 </span>
32 <span>
33 <% if user == nil then %>
34 <a href="/login.html">Login / Register</a>
35 <% else %>
36 <a href="/account.html"><%= user.email %></a>
37 <% end %>
38 </span>
27 </div> 39 </div>
28 <% 40 <%
29 end 41 end
30 Shared.header = header 42 Shared.header = header
31 43