7
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
34
|
3 local Parsers = require "luan:Parsers.luan"
|
|
4 local json_string = Parsers.json_string or error()
|
7
|
5 local Io = require "luan:Io.luan"
|
|
6 local Http = require "luan:http/Http.luan"
|
|
7 local Shared = require "site:/lib/Shared.luan"
|
|
8 local head = Shared.head or error()
|
|
9 local header = Shared.header or error()
|
|
10 local started = Shared.started or error()
|
|
11 local Chat = require "site:/lib/Chat.luan"
|
|
12 local get_chat_by_id = Chat.get_by_id or error()
|
|
13
|
|
14
|
|
15 return function()
|
|
16 local chat_id = Http.request.parameters.chat or error()
|
|
17 local process_markdown = Http.request.parameters.markdown ~= nil
|
|
18 local chat = get_chat_by_id(chat_id) or error()
|
|
19 Io.stdout = Http.response.text_writer()
|
|
20 %>
|
|
21 <!doctype html>
|
|
22 <html lang="en">
|
|
23 <head>
|
|
24 <% head() %>
|
|
25 <style>
|
|
26 <% if not process_markdown then %>
|
9
|
27 [markdown] {
|
7
|
28 white-space-collapse: preserve;
|
|
29 }
|
|
30 <% end %>
|
|
31 </style>
|
|
32 </head>
|
9
|
33 <body>
|
7
|
34 <% header() %>
|
|
35 <div content>
|
|
36 <h1>Chat <%=chat_id%></h1>
|
|
37 <h3 name><%= chat.name_html() %></h3>
|
|
38 <div messages>
|
|
39 <% chat.output_messages_html() %>
|
|
40 </div>
|
|
41 </div>
|
|
42 <% if process_markdown then %>
|
|
43 <script>
|
46
|
44 handleMarkdown(<%=json_string(chat.voice)%>,<%=json_string(chat.tts_instructions)%>);
|
7
|
45 </script>
|
|
46 <% end %>
|
|
47 </body>
|
|
48 </html>
|
|
49 <%
|
|
50 end
|