9
|
1 local Luan = require "luan:Luan.luan"
|
|
2 local error = Luan.error
|
|
3 local ipairs = Luan.ipairs or error()
|
11
|
4 local Html = require "luan:Html.luan"
|
|
5 local html_encode = Html.encode or error()
|
|
6 local Parsers = require "luan:Parsers.luan"
|
|
7 local bbcode_to_html = Parsers.bbcode_to_html or error()
|
9
|
8 local Io = require "luan:Io.luan"
|
11
|
9 local output_of = Io.output_of or error()
|
9
|
10 local Http = require "luan:http/Http.luan"
|
|
11 local Shared = require "site:/lib/Shared.luan"
|
|
12 local head = Shared.head or error()
|
|
13 local header = Shared.header or error()
|
|
14 local footer = Shared.footer or error()
|
|
15 local Forum = require "site:/lib/Forum.luan"
|
|
16 local forum_title = Forum.title or error()
|
|
17 local Db = require "site:/lib/Db.luan"
|
|
18 local Post = require "site:/lib/Post.luan"
|
11
|
19 local User = require "site:/lib/User.luan"
|
9
|
20
|
|
21
|
11
|
22 local function quoter(content,user_name)
|
|
23 return output_of( function()
|
|
24 %><blockquote><%
|
|
25 if user_name ~= nil then
|
|
26 local user = User.get_by_name(user_name)
|
|
27 if user == nil then
|
|
28 %><%= html_encode(user_name) %> wrote:<%
|
|
29 else
|
|
30 %><a href="/user_somthing"><%= html_encode(user_name) %></a> wrote:<%
|
|
31 end
|
|
32 end
|
|
33 %><%= content %><%
|
|
34 %></blockquote><%
|
|
35 end_function )
|
|
36 end
|
|
37
|
9
|
38 return function()
|
|
39 local root_id = Http.request.parameters.root or error()
|
|
40 local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"})
|
|
41 local posts = Post.from_docs(docs)
|
|
42 local subject_html = posts[1].subject_html
|
|
43 Io.stdout = Http.response.text_writer()
|
|
44 %>
|
|
45 <!doctype html>
|
|
46 <html>
|
|
47 <head>
|
|
48 <% head() %>
|
|
49 <title><%=forum_title%>: <%=subject_html%></title>
|
|
50 <style>
|
|
51 [post] {
|
|
52 white-space: pre-wrap;
|
|
53 }
|
|
54 </style>
|
|
55 </head>
|
|
56 <body>
|
|
57 <% header() %>
|
|
58 <div content>
|
|
59 <h1><%=subject_html%></h1>
|
|
60 <% for _, post in ipairs(posts) do %>
|
|
61 <hr>
|
11
|
62 <div post><%=bbcode_to_html(post.content,quoter)%></div>
|
9
|
63 <p>
|
|
64 <a href="/reply.html?parent=<%=post.id%>">reply</a>
|
|
65 - <a href="/edit.html?post=<%=post.id%>">edit</a>
|
|
66 </p>
|
|
67 <% end %>
|
|
68 </div>
|
|
69 <% footer() %>
|
|
70 </body>
|
|
71 </html>
|
|
72 <%
|
|
73 end
|