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;
|
59
|
29 margin-bottom: 16px;
|
7
|
30 }
|
|
31 <% end %>
|
|
32 </style>
|
|
33 </head>
|
9
|
34 <body>
|
7
|
35 <% header() %>
|
|
36 <div content>
|
|
37 <h1>Chat <%=chat_id%></h1>
|
51
|
38 <h2 name><%= chat.name_html() %></h2>
|
|
39 <p>
|
59
|
40 <a href="/chat.html?chat=<%=chat_id%>">Chat</a>
|
|
41 - <a href="/chat.json?chat=<%=chat_id%>">JSON</a>
|
51
|
42 </p>
|
59
|
43 <p>Voice: <%=chat.voice%></p>
|
7
|
44 <div messages>
|
|
45 <% chat.output_messages_html() %>
|
|
46 </div>
|
|
47 </div>
|
|
48 <% if process_markdown then %>
|
|
49 <script>
|
46
|
50 handleMarkdown(<%=json_string(chat.voice)%>,<%=json_string(chat.tts_instructions)%>);
|
7
|
51 </script>
|
|
52 <% end %>
|
|
53 </body>
|
|
54 </html>
|
|
55 <%
|
|
56 end
|