Mercurial Hosting > freedit
diff src/lib/Shared.luan @ 42:0c1b820fff34
use push
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 08 Nov 2022 14:02:28 -0700 |
parents | c8d47981c74f |
children | 96f0c3d65698 |
line wrap: on
line diff
--- a/src/lib/Shared.luan Sun Nov 06 17:39:21 2022 -0700 +++ b/src/lib/Shared.luan Tue Nov 08 14:02:28 2022 -0700 @@ -3,6 +3,8 @@ local ipairs = Luan.ipairs or error() local set_metatable = Luan.set_metatable or error() local type = Luan.type or error() +local Html = require "luan:Html.luan" +local html_encode = Html.encode or error() local Http = require "luan:http/Http.luan" local Io = require "luan:Io.luan" local uri = Io.uri or error() @@ -96,4 +98,35 @@ end end +local function delete_post() + %><a href="javascript:" onclick="deletePost(parentNode)">delete</a><% +end +Shared.delete_post = delete_post + +function Shared.show_post(post,now) + local Bbcode = require "site:/lib/Bbcode.luan" + local bbcode_to_html = Bbcode.to_html or error() +%> + <div post="<%=post.id%>"> + <hr> + <div author> + <img src="/images/profile.png"> + <a href="/whatever"><%= post.author_name %></a> + <span ago date="<%=post.date%>"><% post.ago(now) %> ago</span> + </div> + <div output> + <% bbcode_to_html(post.content) %> + <p logged_in> + <a href="#">reply</a> + <span only_user="<%=html_encode(post.author_name)%>"> + - <a href="javascript:ajax('/edit.js?post=<%=post.id%>')">edit</a> + <span delete_opton> - <span delete><%delete_post()%></span> </span> + <span> + </p> + </div> + <div edit></div> + </div> +<% +end + return Shared