0
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
4
|
3 local ipairs = Luan.ipairs or error()
|
23
|
4 local pairs = Luan.pairs or error()
|
0
|
5 local Io = require "luan:Io.luan"
|
|
6 local Http = require "luan:http/Http.luan"
|
|
7 local Shared = require "site:/lib/Shared.luan"
|
|
8 local head = Shared.head or error()
|
|
9 local header = Shared.header or error()
|
4
|
10 local User = require "site:/lib/User.luan"
|
24
|
11 local current_user = User.current_required or error()
|
4
|
12 local Chat = require "site:/lib/Chat.luan"
|
|
13 local chat_search = Chat.search or error()
|
23
|
14 local languages = require "site:/lib/languages.luan"
|
|
15 local Logging = require "luan:logging/Logging.luan"
|
|
16 local logger = Logging.logger "chats.html"
|
0
|
17
|
|
18
|
|
19 return function()
|
4
|
20 local user = current_user()
|
24
|
21 if user == nil then return end
|
4
|
22 local chats = chat_search( "chat_user_id:"..user.id, "chat_updated desc" )
|
23
|
23 local select_language = #chats > 0 and chats[1].language or nil
|
0
|
24 Io.stdout = Http.response.text_writer()
|
|
25 %>
|
|
26 <!doctype html>
|
|
27 <html lang="en">
|
|
28 <head>
|
|
29 <% head() %>
|
21
|
30 <style>
|
23
|
31 form {
|
|
32 margin-bottom: 20px;
|
|
33 }
|
21
|
34 td {
|
|
35 padding: 8px 8px;
|
|
36 }
|
|
37 </style>
|
0
|
38 </head>
|
|
39 <body>
|
|
40 <% header() %>
|
|
41 <div content>
|
15
|
42 <h1>Your Chats</h1>
|
24
|
43 <form action="lang_courses.html">
|
23
|
44 <select name=language>
|
|
45 <% for _, lang in pairs(languages) do
|
|
46 local code = lang.code
|
|
47 local selected = code==select_language and "selected" or ""
|
|
48 %>
|
|
49 <option value="<%=code%>" <%=selected%> ><%=lang.name%></option>
|
|
50 <% end %>
|
|
51 </select>
|
|
52 <input type=submit value="new chat">
|
|
53 </form>
|
21
|
54 <table>
|
4
|
55 <% for _, chat in ipairs(chats) do %>
|
21
|
56 <tr>
|
|
57 <td><%= chat.language_name() %></td>
|
|
58 <td><a href="chat.html?chat=<%=chat.id%>"><%= chat.name_html() %></a></td>
|
|
59 </tr>
|
4
|
60 <% end %>
|
21
|
61 </table>
|
0
|
62 </div>
|
|
63 </body>
|
|
64 </html>
|
|
65 <%
|
|
66 end
|