Mercurial Hosting > lang
comparison src/lang_courses.html.luan @ 24:87fe70201aa8
courses work
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 31 Jul 2025 22:30:26 -0600 |
parents | |
children | 176a182c02cf |
comparison
equal
deleted
inserted
replaced
23:0c17c233c45a | 24:87fe70201aa8 |
---|---|
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> | |
48 </tr> | |
49 <% end %> | |
50 </table> | |
51 </div> | |
52 </body> | |
53 </html> | |
54 <% | |
55 end |