Mercurial Hosting > chat
diff src/lib/Shared.luan @ 12:9f45d32670ae
server push
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 31 Oct 2024 21:40:57 -0600 |
parents | f9e6a4cc4f7d |
children | 8b8905f63d80 |
line wrap: on
line diff
--- a/src/lib/Shared.luan Thu Oct 31 19:17:53 2024 -0600 +++ b/src/lib/Shared.luan Thu Oct 31 21:40:57 2024 -0600 @@ -7,9 +7,12 @@ local Time = require "luan:Time.luan" local Thread = require "luan:Thread.luan" local thread_run = Thread.run or error() +local Html = require "luan:Html.luan" +local html_encode = Html.encode or error() local Mail = require "luan:mail/Mail.luan" local User = require "site:/lib/User.luan" local current_user = User.current or error() +local get_user_by_id = User.get_by_id or error() local Shared = {} @@ -83,4 +86,18 @@ end ) end +function Shared.post_html(post) + local author = get_user_by_id(post.author_id) + local id = post.id +%> + <div post="<%=id%>"> + <div who> + <span author><%=author.email%></span> + <span when fix><%=post.date%></span> + </div> + <div text><%= html_encode(post.content) %></div> + </div> +<% +end + return Shared