9
|
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 footer = Shared.footer or error()
|
|
10 local Forum = require "site:/lib/Forum.luan"
|
|
11 local forum_title = Forum.title or error()
|
|
12 local Db = require "site:/lib/Db.luan"
|
|
13 local Post = require "site:/lib/Post.luan"
|
12
|
14 local Bbcode = require "site:/lib/Bbcode.luan"
|
|
15 local bbcode_to_html = Bbcode.to_html or error()
|
9
|
16
|
11
|
17
|
9
|
18 return function()
|
|
19 local root_id = Http.request.parameters.root or error()
|
|
20 local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"})
|
|
21 local posts = Post.from_docs(docs)
|
|
22 local subject_html = posts[1].subject_html
|
|
23 Io.stdout = Http.response.text_writer()
|
|
24 %>
|
|
25 <!doctype html>
|
|
26 <html>
|
|
27 <head>
|
|
28 <% head() %>
|
|
29 <title><%=forum_title%>: <%=subject_html%></title>
|
|
30 <style>
|
|
31 [post] {
|
|
32 white-space: pre-wrap;
|
|
33 }
|
|
34 </style>
|
|
35 </head>
|
|
36 <body>
|
|
37 <% header() %>
|
|
38 <div content>
|
|
39 <h1><%=subject_html%></h1>
|
|
40 <% for _, post in ipairs(posts) do %>
|
|
41 <hr>
|
12
|
42 <% bbcode_to_html(post.content) %>
|
9
|
43 <p>
|
|
44 <a href="/reply.html?parent=<%=post.id%>">reply</a>
|
|
45 - <a href="/edit.html?post=<%=post.id%>">edit</a>
|
|
46 </p>
|
|
47 <% end %>
|
|
48 </div>
|
|
49 <% footer() %>
|
|
50 </body>
|
|
51 </html>
|
|
52 <%
|
|
53 end
|