comparison src/lib/Shared.luan @ 12:9f45d32670ae

server push
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 31 Oct 2024 21:40:57 -0600 (5 months ago)
parents f9e6a4cc4f7d
children 8b8905f63d80
comparison
equal deleted inserted replaced
11:563a5358f2ee 12:9f45d32670ae
5 local Io = require "luan:Io.luan" 5 local Io = require "luan:Io.luan"
6 local uri = Io.uri or error() 6 local uri = Io.uri or error()
7 local Time = require "luan:Time.luan" 7 local Time = require "luan:Time.luan"
8 local Thread = require "luan:Thread.luan" 8 local Thread = require "luan:Thread.luan"
9 local thread_run = Thread.run or error() 9 local thread_run = Thread.run or error()
10 local Html = require "luan:Html.luan"
11 local html_encode = Html.encode or error()
10 local Mail = require "luan:mail/Mail.luan" 12 local Mail = require "luan:mail/Mail.luan"
11 local User = require "site:/lib/User.luan" 13 local User = require "site:/lib/User.luan"
12 local current_user = User.current or error() 14 local current_user = User.current or error()
15 local get_user_by_id = User.get_by_id or error()
13 16
14 17
15 local Shared = {} 18 local Shared = {}
16 19
17 local started = Time.now() 20 local started = Time.now()
81 thread_run( function() 84 thread_run( function()
82 send_mail(mail) 85 send_mail(mail)
83 end ) 86 end )
84 end 87 end
85 88
89 function Shared.post_html(post)
90 local author = get_user_by_id(post.author_id)
91 local id = post.id
92 %>
93 <div post="<%=id%>">
94 <div who>
95 <span author><%=author.email%></span>
96 <span when fix><%=post.date%></span>
97 </div>
98 <div text><%= html_encode(post.content) %></div>
99 </div>
100 <%
101 end
102
86 return Shared 103 return Shared