Mercurial Hosting > freedit
comparison src/thread.html.luan @ 9:9674275019bb
reply and edit
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 30 Jun 2022 00:02:28 -0600 |
parents | |
children | 3ed1e3f3a53a |
comparison
equal
deleted
inserted
replaced
8:be36282b556a | 9:9674275019bb |
---|---|
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" | |
14 | |
15 | |
16 return function() | |
17 local root_id = Http.request.parameters.root or error() | |
18 local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"}) | |
19 local posts = Post.from_docs(docs) | |
20 local subject_html = posts[1].subject_html | |
21 Io.stdout = Http.response.text_writer() | |
22 %> | |
23 <!doctype html> | |
24 <html> | |
25 <head> | |
26 <% head() %> | |
27 <title><%=forum_title%>: <%=subject_html%></title> | |
28 <style> | |
29 [post] { | |
30 white-space: pre-wrap; | |
31 } | |
32 </style> | |
33 </head> | |
34 <body> | |
35 <% header() %> | |
36 <div content> | |
37 <h1><%=subject_html%></h1> | |
38 <% for _, post in ipairs(posts) do %> | |
39 <hr> | |
40 <p post><%=post.content%></p> | |
41 <p> | |
42 <a href="/reply.html?parent=<%=post.id%>">reply</a> | |
43 - <a href="/edit.html?post=<%=post.id%>">edit</a> | |
44 </p> | |
45 <% end %> | |
46 </div> | |
47 <% footer() %> | |
48 </body> | |
49 </html> | |
50 <% | |
51 end |