Mercurial Hosting > freedit
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/thread.html.luan Thu Jun 30 00:02:28 2022 -0600 @@ -0,0 +1,51 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local ipairs = Luan.ipairs or error() +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Shared = require "site:/lib/Shared.luan" +local head = Shared.head or error() +local header = Shared.header or error() +local footer = Shared.footer or error() +local Forum = require "site:/lib/Forum.luan" +local forum_title = Forum.title or error() +local Db = require "site:/lib/Db.luan" +local Post = require "site:/lib/Post.luan" + + +return function() + local root_id = Http.request.parameters.root or error() + local docs, total_hits = Db.search("post_root_id:"..root_id,1,1000,{sort="id"}) + local posts = Post.from_docs(docs) + local subject_html = posts[1].subject_html + Io.stdout = Http.response.text_writer() +%> +<!doctype html> +<html> + <head> +<% head() %> + <title><%=forum_title%>: <%=subject_html%></title> + <style> + [post] { + white-space: pre-wrap; + } + </style> + </head> + <body> +<% header() %> + <div content> + <h1><%=subject_html%></h1> +<% for _, post in ipairs(posts) do %> + <hr> + <p post><%=post.content%></p> + <p> + <a href="/reply.html?parent=<%=post.id%>">reply</a> + - <a href="/edit.html?post=<%=post.id%>">edit</a> + </p> +<% end %> + </div> +<% footer() %> + </body> +</html> +<% +end