0
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
9
|
3 local ipairs = Luan.ipairs or error()
|
0
|
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 footer = Shared.footer or error()
|
|
10 local Forum = require "site:/lib/Forum.luan"
|
3
|
11 local forum_title = Forum.title or error()
|
9
|
12 local Db = require "site:/lib/Db.luan"
|
|
13 local Post = require "site:/lib/Post.luan"
|
0
|
14
|
|
15
|
|
16 return function()
|
9
|
17 local docs, total_hits = Db.search("post_is_root:true",1,1000,{sort="id desc"})
|
|
18 local posts = Post.from_docs(docs)
|
0
|
19 Io.stdout = Http.response.text_writer()
|
|
20 %>
|
|
21 <!doctype html>
|
|
22 <html>
|
|
23 <head>
|
|
24 <% head() %>
|
3
|
25 <title><%=forum_title%></title>
|
0
|
26 </head>
|
|
27 <body>
|
|
28 <% header() %>
|
|
29 <div content>
|
8
|
30 <p><a href="/new_thread.html">New Thread</a></p>
|
9
|
31 <% for _, post in ipairs(posts) do %>
|
|
32 <p><a href="/thread.html?root=<%=post.id%>"><%=post.subject_html%></a></p>
|
|
33 <% end %>
|
0
|
34 </div>
|
|
35 <% footer() %>
|
|
36 </body>
|
|
37 </html>
|
|
38 <%
|
|
39 end
|