Mercurial Hosting > lang
comparison src/index.html.luan @ 4:b1adec083e44
chat work
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Tue, 08 Jul 2025 22:15:41 -0600 |
| parents | 78708fa556a0 |
| children | 49e9138b5460 |
comparison
equal
deleted
inserted
replaced
| 3:eee6d4f59811 | 4:b1adec083e44 |
|---|---|
| 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() | |
| 3 local Io = require "luan:Io.luan" | 4 local Io = require "luan:Io.luan" |
| 4 local Http = require "luan:http/Http.luan" | 5 local Http = require "luan:http/Http.luan" |
| 5 local Shared = require "site:/lib/Shared.luan" | 6 local Shared = require "site:/lib/Shared.luan" |
| 6 local head = Shared.head or error() | 7 local head = Shared.head or error() |
| 7 local header = Shared.header 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() | |
| 8 | 13 |
| 9 | 14 |
| 10 return function() | 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" ) | |
| 11 Io.stdout = Http.response.text_writer() | 22 Io.stdout = Http.response.text_writer() |
| 12 %> | 23 %> |
| 13 <!doctype html> | 24 <!doctype html> |
| 14 <html lang="en"> | 25 <html lang="en"> |
| 15 <head> | 26 <head> |
| 17 </head> | 28 </head> |
| 18 <body> | 29 <body> |
| 19 <% header() %> | 30 <% header() %> |
| 20 <div content> | 31 <div content> |
| 21 <h1>Lang</h1> | 32 <h1>Lang</h1> |
| 22 <p><a href="chat.html">chat</a></p> | 33 <% for _, chat in ipairs(chats) do %> |
| 34 <p><a href="chat.html?chat=<%=chat.id%>"><%= chat.name_html() %></a></p> | |
| 35 <% end %> | |
| 36 <p><a href="chat.html">new chat</a></p> | |
| 23 </div> | 37 </div> |
| 24 </body> | 38 </body> |
| 25 </html> | 39 </html> |
| 26 <% | 40 <% |
| 27 end | 41 end |
