view src/chat.js.luan @ 7:41d35b72c774

chat page
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 29 Oct 2024 22:11:40 -0600
parents
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Parsers = require "luan:Parsers.luan"
local json_string = Parsers.json_string or error()
local Io = require "luan:Io.luan"
local Http = require "luan:http/Http.luan"
local User = require "site:/lib/User.luan"
local current_user = User.current or error()
local Chat = require "site:/lib/Chat.luan"
local get_chat_by_id = Chat.get_by_id or error()


local function html()
	local user = current_user() or error()
	local chat = Http.request.parameters.chat or error()
	chat = get_chat_by_id(chat) or error()
%>
	<p><%= chat.other_users_email(user) %></p>
<%
end

return function()
	Io.stdout = Http.response.text_writer()
%>
	document.querySelector('div[posts]').innerHTML = <%=json_string(`html()`)%>;
<%
end