24
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
|
4 local Io = require "luan:Io.luan"
|
|
5 local Http = require "luan:http/Http.luan"
|
|
6 local Shared = require "site:/lib/Shared.luan"
|
|
7 local head = Shared.head or error()
|
|
8 local header = Shared.header or error()
|
|
9 local Course = require "site:/lib/Course.luan"
|
|
10 local course_search = Course.search or error()
|
|
11 local languages = require "site:/lib/languages.luan"
|
|
12 local Logging = require "luan:logging/Logging.luan"
|
|
13 local logger = Logging.logger "chats.html"
|
|
14
|
|
15
|
|
16 return function()
|
|
17 local language = Http.request.parameters.language or error()
|
|
18 local courses = course_search( "course_language:"..language )
|
|
19 local select_language = #courses > 0 and courses[1].language or nil
|
|
20 Io.stdout = Http.response.text_writer()
|
|
21 %>
|
|
22 <!doctype html>
|
|
23 <html lang="en">
|
|
24 <head>
|
|
25 <% head() %>
|
|
26 <style>
|
|
27 form {
|
|
28 margin-bottom: 20px;
|
|
29 }
|
|
30 td {
|
|
31 padding: 8px 8px;
|
|
32 }
|
|
33 </style>
|
|
34 </head>
|
|
35 <body>
|
|
36 <% header() %>
|
|
37 <div content>
|
|
38 <h1><%=languages[language].name%> Courses</h1>
|
|
39 <form action="edit_course.html">
|
|
40 <input type=hidden name=language value="<%=language%>">
|
|
41 <input type=submit value="new course">
|
|
42 </form>
|
|
43 <table>
|
|
44 <% for _, course in ipairs(courses) do %>
|
|
45 <tr>
|
|
46 <td><%= course.name_html() %></td>
|
|
47 <td><a href="new_chat.red?course=<%=course.id%>">new chat</a></td>
|
27
|
48 <td><a href="view_course.html?course=<%=course.id%>">view</a></td>
|
24
|
49 </tr>
|
|
50 <% end %>
|
|
51 </table>
|
|
52 </div>
|
|
53 </body>
|
|
54 </html>
|
|
55 <%
|
|
56 end
|