diff src/chats.html.luan @ 23:0c17c233c45a

start courses
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 30 Jul 2025 23:29:33 -0600
parents f551d19da80d
children 87fe70201aa8
line wrap: on
line diff
--- a/src/chats.html.luan	Wed Jul 30 19:51:49 2025 -0600
+++ b/src/chats.html.luan	Wed Jul 30 23:29:33 2025 -0600
@@ -1,6 +1,7 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
 local ipairs = Luan.ipairs or error()
+local pairs = Luan.pairs or error()
 local Io = require "luan:Io.luan"
 local Http = require "luan:http/Http.luan"
 local Shared = require "site:/lib/Shared.luan"
@@ -10,6 +11,9 @@
 local current_user = User.current or error()
 local Chat = require "site:/lib/Chat.luan"
 local chat_search = Chat.search or error()
+local languages = require "site:/lib/languages.luan"
+local Logging = require "luan:logging/Logging.luan"
+local logger = Logging.logger "chats.html"
 
 
 return function()
@@ -19,6 +23,7 @@
 		return
 	end
 	local chats = chat_search( "chat_user_id:"..user.id, "chat_updated desc" )
+	local select_language = #chats > 0 and chats[1].language or nil
 	Io.stdout = Http.response.text_writer()
 %>
 <!doctype html>
@@ -26,6 +31,9 @@
 	<head>
 <%		head() %>
 		<style>
+			form {
+				margin-bottom: 20px;
+			}
 			td {
 				padding: 8px 8px;
 			}
@@ -35,7 +43,17 @@
 <%		header() %>
 		<div content>
 			<h1>Your Chats</h1>
-			<p><a href="new_chat.red">new chat</a></p>
+			<form action="new_chat.red">
+				<select name=language>
+<%	for _, lang in pairs(languages) do
+		local code = lang.code
+		local selected = code==select_language and "selected" or ""
+%>
+					<option value="<%=code%>" <%=selected%> ><%=lang.name%></option>
+<%	end %>
+				</select>
+				<input type=submit value="new chat">
+			</form>
 			<table>
 <%	for _, chat in ipairs(chats) do %>
 				<tr>