0
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
4
|
3 local ipairs = Luan.ipairs or error()
|
0
|
4 local Io = require "luan:Io.luan"
|
|
5 local Http = require "luan:http/Http.luan"
|
|
6 local Shared = require "site:/lib/Shared.luan"
|
|
7 local head = Shared.head or error()
|
|
8 local header = Shared.header or error()
|
4
|
9 local User = require "site:/lib/User.luan"
|
|
10 local current_user = User.current or error()
|
|
11 local Chat = require "site:/lib/Chat.luan"
|
|
12 local chat_search = Chat.search or error()
|
0
|
13
|
|
14
|
|
15 return function()
|
4
|
16 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" )
|
0
|
22 Io.stdout = Http.response.text_writer()
|
|
23 %>
|
|
24 <!doctype html>
|
|
25 <html lang="en">
|
|
26 <head>
|
|
27 <% head() %>
|
|
28 </head>
|
|
29 <body>
|
|
30 <% header() %>
|
|
31 <div content>
|
15
|
32 <h1>Your Chats</h1>
|
|
33 <p><a href="chat.html">new chat</a></p>
|
4
|
34 <% for _, chat in ipairs(chats) do %>
|
|
35 <p><a href="chat.html?chat=<%=chat.id%>"><%= chat.name_html() %></a></p>
|
|
36 <% end %>
|
0
|
37 </div>
|
|
38 </body>
|
|
39 </html>
|
|
40 <%
|
|
41 end
|