Mercurial Hosting > freedit
comparison 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 |
comparison
equal
deleted
inserted
replaced
41:acb730710328 | 42:0c1b820fff34 |
---|---|
1 local Luan = require "luan:Luan.luan" | 1 local Luan = require "luan:Luan.luan" |
2 local error = Luan.error | 2 local error = Luan.error |
3 local ipairs = Luan.ipairs or error() | 3 local ipairs = Luan.ipairs or error() |
4 local set_metatable = Luan.set_metatable or error() | 4 local set_metatable = Luan.set_metatable or error() |
5 local type = Luan.type or error() | 5 local type = Luan.type or error() |
6 local Html = require "luan:Html.luan" | |
7 local html_encode = Html.encode or error() | |
6 local Http = require "luan:http/Http.luan" | 8 local Http = require "luan:http/Http.luan" |
7 local Io = require "luan:Io.luan" | 9 local Io = require "luan:Io.luan" |
8 local uri = Io.uri or error() | 10 local uri = Io.uri or error() |
9 local Parsers = require "luan:Parsers.luan" | 11 local Parsers = require "luan:Parsers.luan" |
10 local json_parse = Parsers.json_parse or error() | 12 local json_parse = Parsers.json_parse or error() |
94 else | 96 else |
95 return {input} | 97 return {input} |
96 end | 98 end |
97 end | 99 end |
98 | 100 |
101 local function delete_post() | |
102 %><a href="javascript:" onclick="deletePost(parentNode)">delete</a><% | |
103 end | |
104 Shared.delete_post = delete_post | |
105 | |
106 function Shared.show_post(post,now) | |
107 local Bbcode = require "site:/lib/Bbcode.luan" | |
108 local bbcode_to_html = Bbcode.to_html or error() | |
109 %> | |
110 <div post="<%=post.id%>"> | |
111 <hr> | |
112 <div author> | |
113 <img src="/images/profile.png"> | |
114 <a href="/whatever"><%= post.author_name %></a> | |
115 <span ago date="<%=post.date%>"><% post.ago(now) %> ago</span> | |
116 </div> | |
117 <div output> | |
118 <% bbcode_to_html(post.content) %> | |
119 <p logged_in> | |
120 <a href="#">reply</a> | |
121 <span only_user="<%=html_encode(post.author_name)%>"> | |
122 - <a href="javascript:ajax('/edit.js?post=<%=post.id%>')">edit</a> | |
123 <span delete_opton> - <span delete><%delete_post()%></span> </span> | |
124 <span> | |
125 </p> | |
126 </div> | |
127 <div edit></div> | |
128 </div> | |
129 <% | |
130 end | |
131 | |
99 return Shared | 132 return Shared |