Mercurial Hosting > lang
view src/chat.html.luan @ 27:176a182c02cf
add view_course
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 01 Aug 2025 20:08:13 -0600 |
parents | 3a80ddafe5a4 |
children | 99b71a377f2c |
line wrap: on
line source
local Luan = require "luan:Luan.luan" local error = Luan.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 started = Shared.started or error() local User = require "site:/lib/User.luan" local current_user = User.current_required or error() local Chat = require "site:/lib/Chat.luan" local get_chat_by_id = Chat.get_by_id or error() return function() local user = current_user() if user == nil then return end local chat_id = Http.request.parameters.chat or error() local chat = get_chat_by_id(chat_id) or error() local added_message = chat.init_ai() Io.stdout = Http.response.text_writer() %> <!doctype html> <html lang="en"> <head> <% head() %> <style> @import "/chat.css?s=<%=started%>"; </style> <script> let chatId = <%= chat.id %>; </script> <script src="/chat.js?s=<%=started%>"></script> </head> <body> <% header() %> <div content ai_container> <div top> <h3 name><%= chat.name_html() %></h3> <span pulldown> <img onclick="clickMenu(this)" src="/images/menu.svg"> <div> <span onclick="renameChat()">Rename Chat</span> <span onclick="deleteChat()">Delete Chat</span> <span onclick="systemPrompt()">System Prompt</span> </div> </span> </div> <div messages> <% chat.output_messages_html() %> </div> <div ask> <textarea autofocus oninput="fixTextarea(event.target)" onkeydown="textareaKey(event)"></textarea> <div buttons> <button record onclick="toggleRecording()">Record</button> <button onclick="askAi()" title="Send"><img src="/images/send.svg"></button> </div> </div> </div> <img waiting-ai-icon src="/images/spinner_green.gif"> <dialog rename> <h2>Rename Chat</h2> <form action="javascript:saveRenameChat()"> <p> <label>Chat name</label><br> <input name=name required><br> <span error></span> </p> <div buttons> <button type=button onclick="closeModal(this)">Cancel</button> <button type=submit>Rename</button> </div> </form> </dialog> <dialog delete> <h2>Delete Chat</h2> <p>Are you sure that you want to delete this chat?</p> <div buttons> <button onclick="closeModal(this)">Cancel</button> <button onclick="doDeleteChat(this)">Delete</button> </div> </dialog> <dialog system_prompt> <h2>System Prompt</h2> <pre> <% chat.output_system_prompt() %> </pre> <p><a href="view_course.html?course=<%=chat.course_id%>">View course</a></p> <div buttons> <button onclick="closeModal(this)">Close</button> </div> </dialog> <input name=initialized style="display:none"> <script> handleMarkdown(); setTimeout(function(){ let initialized = document.querySelector('[name=initialized]'); if( !initialized.value ) { initialized.value = 'yes'; //alert('init'); scrollToEnd(); <% if added_message then %> playLastMessage(); <% end %> } },10); </script> </body> </html> <% end