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() %>
|
21
|
28 <style>
|
|
29 td {
|
|
30 padding: 8px 8px;
|
|
31 }
|
|
32 </style>
|
0
|
33 </head>
|
|
34 <body>
|
|
35 <% header() %>
|
|
36 <div content>
|
15
|
37 <h1>Your Chats</h1>
|
18
|
38 <p><a href="new_chat.red">new chat</a></p>
|
21
|
39 <table>
|
4
|
40 <% for _, chat in ipairs(chats) do %>
|
21
|
41 <tr>
|
|
42 <td><%= chat.language_name() %></td>
|
|
43 <td><a href="chat.html?chat=<%=chat.id%>"><%= chat.name_html() %></a></td>
|
|
44 </tr>
|
4
|
45 <% end %>
|
21
|
46 </table>
|
0
|
47 </div>
|
|
48 </body>
|
|
49 </html>
|
|
50 <%
|
|
51 end
|