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()
|
53
|
10 local started = Shared.started or error()
|
24
|
11 local Course = require "site:/lib/Course.luan"
|
|
12 local get_course_by_id = Course.get_by_id or error()
|
50
|
13 local User = require "site:/lib/User.luan"
|
|
14 local current_user = User.current or error()
|
24
|
15
|
|
16
|
|
17 return function()
|
|
18 local course_id = Http.request.parameters.course
|
27
|
19 local course = get_course_by_id(course_id) or error()
|
50
|
20 local user = current_user()
|
|
21 local is_owner = user ~= nil and user.id == course.user_id
|
24
|
22 Io.stdout = Http.response.text_writer()
|
|
23 %>
|
|
24 <!doctype html>
|
|
25 <html lang="en">
|
|
26 <head>
|
|
27 <% head() %>
|
|
28 <style>
|
25
|
29 h4 {
|
|
30 margin-top: 22px;
|
|
31 margin-bottom: 4px;
|
|
32 }
|
24
|
33 </style>
|
53
|
34 <script src="/course.js?s=<%=started%>"></script>
|
24
|
35 </head>
|
|
36 <body>
|
|
37 <% header() %>
|
27
|
38 <div content>
|
25
|
39 <input type=hidden name=language value="<%=course.language%>">
|
24
|
40 <% if course_id ~= nil then %>
|
25
|
41 <input type=hidden name=course value="<%=course_id%>">
|
24
|
42 <% end %>
|
27
|
43 <h1>View Course</h1>
|
25
|
44
|
27
|
45 <h2><%= course.name_html() %></h2>
|
|
46
|
|
47 <h3><%= course.language_name() %></h3>
|
25
|
48
|
50
|
49 <p>
|
|
50 <a href="new_chat.red?course=<%=course.id%>">New chat</a>
|
|
51 <% if is_owner then %>
|
|
52 - <a href="edit_course.html?course=<%=course.id%>">Edit</a>
|
53
|
53 - <a href="javascript:deleteCourse()">Delete</a>
|
50
|
54 <% end %>
|
|
55 </p>
|
47
|
56
|
67
|
57 <h4>Description</h4>
|
|
58 <pre><%=html_encode(course.description)%></pre>
|
|
59
|
|
60 <br>
|
|
61
|
52
|
62 <p><input type=checkbox name=has_ruby <%= course.has_ruby and "checked" or "" %> disabled> Has pronunciation like {japanese|romaji}</p>
|
|
63
|
60
|
64 <h4>AI system prompt - chat instructions</h4>
|
27
|
65 <pre><%=html_encode(course.ai_system_prompt)%></pre>
|
25
|
66
|
|
67 <h4>AI first message (optional)</h4>
|
47
|
68 <pre><%=html_encode(course.ai_first_message)%></pre>
|
|
69
|
|
70 <h4>Text to speech instructions</h4>
|
|
71 <pre><%=html_encode(course.tts_instructions)%></pre>
|
25
|
72
|
69
|
73 <h4>Speech to text prompt</h4>
|
|
74 <pre><%=html_encode(course.stt_prompt)%></pre>
|
|
75
|
27
|
76 </div>
|
53
|
77 <dialog delete>
|
|
78 <h2>Delete Course</h2>
|
|
79 <p>Are you sure that you want to delete this course?</p>
|
|
80 <div buttons>
|
|
81 <button onclick="closeModal(this)">Cancel</button>
|
|
82 <button onclick="doDeleteCourse(this,<%=course_id%>)">Delete</button>
|
|
83 </div>
|
|
84 </dialog>
|
24
|
85 </body>
|
|
86 </html>
|
|
87 <%
|
|
88 end
|