comparison src/lib/Shared.luan @ 79:b5a316575e64

reply
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 10 Mar 2025 21:41:53 -0600
parents a63faf49e1d7
children a47036fd0158
comparison
equal deleted inserted replaced
78:2a602ef53eef 79:b5a316575e64
15 local Chat = require "site:/lib/Chat.luan" 15 local Chat = require "site:/lib/Chat.luan"
16 local chat_search = Chat.search or error() 16 local chat_search = Chat.search or error()
17 local Utils = require "site:/lib/Utils.luan" 17 local Utils = require "site:/lib/Utils.luan"
18 local base_url = Utils.base_url or error() 18 local base_url = Utils.base_url or error()
19 local Db = require "site:/lib/Db.luan" 19 local Db = require "site:/lib/Db.luan"
20 local Post = require "site:/lib/Post.luan"
21 local get_post_by_id = Post.get_by_id or error()
20 local Logging = require "luan:logging/Logging.luan" 22 local Logging = require "luan:logging/Logging.luan"
21 local logger = Logging.logger "Shared" 23 local logger = Logging.logger "Shared"
22 24
23 25
24 local Shared = {} 26 local Shared = {}
119 function Shared.post_html(post) 121 function Shared.post_html(post)
120 local author_id = post.author_id 122 local author_id = post.author_id
121 local user = current_user() or error() 123 local user = current_user() or error()
122 local author = get_user_by_id(author_id) 124 local author = get_user_by_id(author_id)
123 local id = post.id 125 local id = post.id
126 local reply = post.reply
127 reply = reply and get_post_by_id(reply)
124 %> 128 %>
125 <div post="<%=id%>" author="<%=author.id%>" fix> 129 <div post="<%=id%>" author="<%=author.id%>" id="p<%=id%>" fix>
126 <div who> 130 <div who>
127 <span author><%=author.name_html()%></span> 131 <span author><%=author.name_html()%></span>
128 <span right> 132 <span right>
129 <span when><%=post.date%></span> 133 <span when><%=post.date%></span>
130 <span pulldown></span> 134 <span pulldown></span>
131 </span> 135 </span>
132 </div> 136 </div>
137 <% if reply ~= nil then %>
138 <div quote>
139 <blockquote><%= html_encode(reply.content) %></blockquote>
140 <div><a when href="#p<%=reply.id%>"><%=reply.date%></a></div>
141 </div>
142 <% end %>
133 <div text><%= html_encode(post.content) %></div> 143 <div text><%= html_encode(post.content) %></div>
134 </div> 144 </div>
135 <% 145 <%
136 end 146 end
137 147