0
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
4
|
3 local ipairs = Luan.ipairs or error()
|
23
|
4 local pairs = Luan.pairs or error()
|
0
|
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()
|
46
|
10 local languages = Shared.languages or error()
|
4
|
11 local User = require "site:/lib/User.luan"
|
24
|
12 local current_user = User.current_required or error()
|
|
13 local Course = require "site:/lib/Course.luan"
|
|
14 local course_search = Course.search or error()
|
23
|
15 local Logging = require "luan:logging/Logging.luan"
|
|
16 local logger = Logging.logger "chats.html"
|
0
|
17
|
|
18
|
|
19 return function()
|
4
|
20 local user = current_user()
|
24
|
21 if user == nil then return end
|
|
22 local courses = course_search( "course_user_id:"..user.id, "course_updated desc" )
|
|
23 local select_language = #courses > 0 and courses[1].language or nil
|
0
|
24 Io.stdout = Http.response.text_writer()
|
|
25 %>
|
|
26 <!doctype html>
|
|
27 <html lang="en">
|
|
28 <head>
|
|
29 <% head() %>
|
21
|
30 <style>
|
23
|
31 form {
|
|
32 margin-bottom: 20px;
|
|
33 }
|
21
|
34 td {
|
|
35 padding: 8px 8px;
|
|
36 }
|
|
37 </style>
|
0
|
38 </head>
|
|
39 <body>
|
|
40 <% header() %>
|
|
41 <div content>
|
24
|
42 <h1>Your Courses</h1>
|
|
43 <form action="edit_course.html">
|
23
|
44 <select name=language>
|
46
|
45 <% for code, name in pairs(languages) do
|
23
|
46 local selected = code==select_language and "selected" or ""
|
|
47 %>
|
46
|
48 <option value="<%=code%>" <%=selected%> ><%=name%></option>
|
23
|
49 <% end %>
|
|
50 </select>
|
24
|
51 <input type=submit value="new course">
|
23
|
52 </form>
|
21
|
53 <table>
|
24
|
54 <% for _, course in ipairs(courses) do %>
|
21
|
55 <tr>
|
24
|
56 <td><%= course.language_name() %></td>
|
|
57 <td><%= course.name_html() %></td>
|
|
58 <td><a href="new_chat.red?course=<%=course.id%>">new chat</a></td>
|
|
59 <td><a href="edit_course.html?course=<%=course.id%>">edit</a></td>
|
21
|
60 </tr>
|
4
|
61 <% end %>
|
21
|
62 </table>
|
0
|
63 </div>
|
|
64 </body>
|
|
65 </html>
|
|
66 <%
|
|
67 end
|