Mercurial Hosting > lang
comparison src/list.html.luan @ 15:49e9138b5460
add list.html
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 29 Jul 2025 20:59:47 -0600 |
parents | src/index.html.luan@b1adec083e44 |
children |
comparison
equal
deleted
inserted
replaced
14:47b00cce8b53 | 15:49e9138b5460 |
---|---|
1 local Luan = require "luan:Luan.luan" | |
2 local error = Luan.error | |
3 local ipairs = Luan.ipairs or error() | |
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() | |
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() | |
13 | |
14 | |
15 return function() | |
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" ) | |
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> | |
32 <h1>Your Chats</h1> | |
33 <p><a href="chat.html">new chat</a></p> | |
34 <% for _, chat in ipairs(chats) do %> | |
35 <p><a href="chat.html?chat=<%=chat.id%>"><%= chat.name_html() %></a></p> | |
36 <% end %> | |
37 </div> | |
38 </body> | |
39 </html> | |
40 <% | |
41 end |