comparison src/index.html.luan @ 15:49e9138b5460

add list.html
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Jul 2025 20:59:47 -0600
parents b1adec083e44
children 19901d6fb56f
comparison
equal deleted inserted replaced
14:47b00cce8b53 15:49e9138b5460
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 ipairs = Luan.ipairs or error()
4 local Io = require "luan:Io.luan" 3 local Io = require "luan:Io.luan"
5 local Http = require "luan:http/Http.luan" 4 local Http = require "luan:http/Http.luan"
6 local Shared = require "site:/lib/Shared.luan" 5 local Shared = require "site:/lib/Shared.luan"
7 local head = Shared.head or error() 6 local head = Shared.head or error()
8 local header = Shared.header or error() 7 local header = Shared.header or error()
9 local User = require "site:/lib/User.luan" 8 local User = require "site:/lib/User.luan"
10 local current_user = User.current or error() 9 local current_user = User.current or error()
11 local Chat = require "site:/lib/Chat.luan"
12 local chat_search = Chat.search or error()
13 10
14 11
15 return function() 12 return function()
16 local user = current_user() 13 local user = current_user()
17 if user == nil then
18 Http.response.send_redirect("/login.html")
19 return
20 end
21 local chats = chat_search( "chat_user_id:"..user.id, "chat_updated desc" )
22 Io.stdout = Http.response.text_writer() 14 Io.stdout = Http.response.text_writer()
23 %> 15 %>
24 <!doctype html> 16 <!doctype html>
25 <html lang="en"> 17 <html lang="en">
26 <head> 18 <head>
28 </head> 20 </head>
29 <body> 21 <body>
30 <% header() %> 22 <% header() %>
31 <div content> 23 <div content>
32 <h1>Lang</h1> 24 <h1>Lang</h1>
33 <% for _, chat in ipairs(chats) do %> 25 <% if user == nil then %>
34 <p><a href="chat.html?chat=<%=chat.id%>"><%= chat.name_html() %></a></p> 26 <p><a href="login.html">Register / Login</a> to use this.</p>
27 <% else %>
28 <p><a href="list.html">See your chats</a></p>
35 <% end %> 29 <% end %>
36 <p><a href="chat.html">new chat</a></p> 30 <p>More later...</p>
37 </div> 31 </div>
38 </body> 32 </body>
39 </html> 33 </html>
40 <% 34 <%
41 end 35 end