24
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local Html = require "luan:Html.luan"
|
|
4 local html_encode = Html.encode or error()
|
|
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 Course = require "site:/lib/Course.luan"
|
|
11 local get_course_by_id = Course.get_by_id or error()
|
50
|
12 local User = require "site:/lib/User.luan"
|
|
13 local current_user = User.current or error()
|
24
|
14
|
|
15
|
|
16 return function()
|
|
17 local course_id = Http.request.parameters.course
|
27
|
18 local course = get_course_by_id(course_id) or error()
|
50
|
19 local user = current_user()
|
|
20 local is_owner = user ~= nil and user.id == course.user_id
|
24
|
21 Io.stdout = Http.response.text_writer()
|
|
22 %>
|
|
23 <!doctype html>
|
|
24 <html lang="en">
|
|
25 <head>
|
|
26 <% head() %>
|
|
27 <style>
|
25
|
28 h4 {
|
|
29 margin-top: 22px;
|
|
30 margin-bottom: 4px;
|
|
31 }
|
24
|
32 </style>
|
|
33 </head>
|
|
34 <body>
|
|
35 <% header() %>
|
27
|
36 <div content>
|
25
|
37 <input type=hidden name=language value="<%=course.language%>">
|
24
|
38 <% if course_id ~= nil then %>
|
25
|
39 <input type=hidden name=course value="<%=course_id%>">
|
24
|
40 <% end %>
|
27
|
41 <h1>View Course</h1>
|
25
|
42
|
27
|
43 <h2><%= course.name_html() %></h2>
|
|
44
|
|
45 <h3><%= course.language_name() %></h3>
|
25
|
46
|
50
|
47 <p>
|
|
48 <a href="new_chat.red?course=<%=course.id%>">New chat</a>
|
|
49 <% if is_owner then %>
|
|
50 - <a href="edit_course.html?course=<%=course.id%>">Edit</a>
|
|
51 <% end %>
|
|
52 </p>
|
47
|
53
|
25
|
54 <h4>AI system prompt</h4>
|
27
|
55 <pre><%=html_encode(course.ai_system_prompt)%></pre>
|
25
|
56
|
|
57 <h4>AI first message (optional)</h4>
|
47
|
58 <pre><%=html_encode(course.ai_first_message)%></pre>
|
|
59
|
|
60 <h4>Text to speech instructions</h4>
|
|
61 <pre><%=html_encode(course.tts_instructions)%></pre>
|
25
|
62
|
27
|
63 </div>
|
24
|
64 </body>
|
|
65 </html>
|
|
66 <%
|
|
67 end
|