Mercurial Hosting > lang
view src/chats.html.luan @ 21:f551d19da80d
minor
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Wed, 30 Jul 2025 16:55:44 -0600 |
parents | 820136c5ee33 |
children | 0c17c233c45a |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.error local ipairs = Luan.ipairs or error() local Io = require "luan:Io.luan" local Http = require "luan:http/Http.luan" local Shared = require "site:/lib/Shared.luan" local head = Shared.head or error() local header = Shared.header or error() local User = require "site:/lib/User.luan" local current_user = User.current or error() local Chat = require "site:/lib/Chat.luan" local chat_search = Chat.search or error() return function() local user = current_user() if user == nil then Http.response.send_redirect("/login.html") return end local chats = chat_search( "chat_user_id:"..user.id, "chat_updated desc" ) Io.stdout = Http.response.text_writer() %> <!doctype html> <html lang="en"> <head> <% head() %> <style> td { padding: 8px 8px; } </style> </head> <body> <% header() %> <div content> <h1>Your Chats</h1> <p><a href="new_chat.red">new chat</a></p> <table> <% for _, chat in ipairs(chats) do %> <tr> <td><%= chat.language_name() %></td> <td><a href="chat.html?chat=<%=chat.id%>"><%= chat.name_html() %></a></td> </tr> <% end %> </table> </div> </body> </html> <% end