annotate src/thread.html.luan @ 12:ad1604c72156

fix bbcode
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 03 Jul 2022 22:01:23 -0600
parents 3ed1e3f3a53a
children 0edde02b908c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local ipairs = Luan.ipairs or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Io = require "luan:Io.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Http = require "luan:http/Http.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local Shared = require "site:/lib/Shared.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local head = Shared.head or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local header = Shared.header or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local footer = Shared.footer or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local Forum = require "site:/lib/Forum.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11 local forum_title = Forum.title or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 local Db = require "site:/lib/Db.luan"
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 local Post = require "site:/lib/Post.luan"
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
14 local Bbcode = require "site:/lib/Bbcode.luan"
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
15 local bbcode_to_html = Bbcode.to_html or error()
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16
11
3ed1e3f3a53a use bbcode_to_html
Franklin Schmidt <fschmidt@gmail.com>
parents: 9
diff changeset
17
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 return function()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 local root_id = Http.request.parameters.root or error()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"})
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 local posts = Post.from_docs(docs)
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 local subject_html = posts[1].subject_html
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 Io.stdout = Http.response.text_writer()
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <!doctype html>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 <html>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <head>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 <% head() %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <title><%=forum_title%>: <%=subject_html%></title>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 <style>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 [post] {
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 white-space: pre-wrap;
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 }
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 </style>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 </head>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 <body>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 <% header() %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 <div content>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 <h1><%=subject_html%></h1>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 <% for _, post in ipairs(posts) do %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 <hr>
12
ad1604c72156 fix bbcode
Franklin Schmidt <fschmidt@gmail.com>
parents: 11
diff changeset
42 <% bbcode_to_html(post.content) %>
9
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 <p>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 <a href="/reply.html?parent=<%=post.id%>">reply</a>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 - <a href="/edit.html?post=<%=post.id%>">edit</a>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 </p>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
47 <% end %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48 </div>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
49 <% footer() %>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 </body>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 </html>
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52 <%
9674275019bb reply and edit
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 end