changeset 11:3ed1e3f3a53a

use bbcode_to_html
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 30 Jun 2022 20:05:11 -0600
parents de0cbf515ef5
children ad1604c72156
files src/thread.html.luan
diffstat 1 files changed, 23 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/thread.html.luan	Thu Jun 30 11:11:00 2022 -0600
+++ b/src/thread.html.luan	Thu Jun 30 20:05:11 2022 -0600
@@ -1,7 +1,12 @@
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
 local ipairs = Luan.ipairs or error()
+local Html = require "luan:Html.luan"
+local html_encode = Html.encode or error()
+local Parsers = require "luan:Parsers.luan"
+local bbcode_to_html = Parsers.bbcode_to_html or error()
 local Io = require "luan:Io.luan"
+local output_of = Io.output_of or error()
 local Http = require "luan:http/Http.luan"
 local Shared = require "site:/lib/Shared.luan"
 local head = Shared.head or error()
@@ -11,8 +16,25 @@
 local forum_title = Forum.title or error()
 local Db = require "site:/lib/Db.luan"
 local Post = require "site:/lib/Post.luan"
+local User = require "site:/lib/User.luan"
 
 
+local function quoter(content,user_name)
+	return output_of( function() 
+		%><blockquote><%
+		if user_name ~= nil then
+			local user = User.get_by_name(user_name)
+			if user == nil then
+				%><%= html_encode(user_name) %> wrote:<%
+			else
+				%><a href="/user_somthing"><%= html_encode(user_name) %></a> wrote:<%
+			end
+		end
+		%><%= content %><%
+		%></blockquote><%
+	end_function )
+end
+
 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"})
@@ -37,7 +59,7 @@
 			<h1><%=subject_html%></h1>
 <%	for _, post in ipairs(posts) do %>
 			<hr>
-			<p post><%=post.content%></p>
+			<div post><%=bbcode_to_html(post.content,quoter)%></div>
 			<p>
 				<a href="/reply.html?parent=<%=post.id%>">reply</a>
 				- <a href="/edit.html?post=<%=post.id%>">edit</a>