83 lines
3.0 KiB
Plaintext
83 lines
3.0 KiB
Plaintext
<%
|
|
local pc = "post"
|
|
if edit then
|
|
pc = pc .. " editing"
|
|
end
|
|
%>
|
|
<div class="<%= pc %>" id="post-<%= post.id %>">
|
|
<div class="usercard">
|
|
<a href="<%= url_for("user", {username = post.username}) %>" style="display: contents;">
|
|
<img src="<%= post.avatar_path %>" class="avatar">
|
|
</a>
|
|
<a href="<%= url_for("user", {username = post.username}) %>" class="username-link"><%= post.username %></a>
|
|
<% if post.status ~= "" then %>
|
|
<em class="user-status"><%= post.status %></em>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="post-content-container"<%= is_latest and 'id=latest-post' or "" %>>
|
|
<div class="post-info">
|
|
<%
|
|
local post_url = url_for("thread", {slug = thread.slug}, {page = page}) .. "#post-" .. post.id
|
|
%>
|
|
<a href="<%= post_url %>" title="Permalink"><i>
|
|
<% if tonumber(post.edited_at) > tonumber(post.created_at) then -%>
|
|
Edited at <%= os.date("%c", post.edited_at) %>
|
|
<% else -%>
|
|
Posted on <%= os.date("%c", post.created_at) %>
|
|
<% end -%>
|
|
</i></a>
|
|
<span>
|
|
<%
|
|
local show_edit = me.id == post.user_id and not me:is_guest() and not ntob(thread.is_locked) and not no_reply
|
|
if show_edit then
|
|
%>
|
|
<a class="linkbutton" href="<%= url_for("edit_post", {post_id = post.id}) %>">Edit</a>
|
|
<% end %>
|
|
<%
|
|
local show_reply = true
|
|
if ntob(thread.is_locked) and not me:is_mod() then
|
|
show_reply = false
|
|
elseif me:is_guest() then
|
|
show_reply = false
|
|
elseif edit then
|
|
show_reply = false
|
|
elseif no_reply then
|
|
show_reply = false
|
|
end
|
|
if show_reply then
|
|
local d = post.created_at < post.edited_at and post.edited_at or post.created_at
|
|
local quote_src_text = ("On [url=%s]%s[/url], [url=%s]%s[/url] said:"):format(
|
|
post_url, os.date("%c", d), url_for("user", {username = post.username}), post.username
|
|
)
|
|
local reply_text = ("%s\n[quote]%s[/quote]\n---\n\n"):format(quote_src_text, post.original_markup)
|
|
%>
|
|
<button value="<%= reply_text %>" class="reply-button">Reply</button>
|
|
<% end %>
|
|
<%
|
|
local show_delete = (post.user_id == me.id and not ntob(thread.is_locked)) or me:is_mod()
|
|
if show_delete then
|
|
%>
|
|
<button class="critical post-delete-button" value="<%= post.id %>">Delete</button>
|
|
<% end %>
|
|
</span>
|
|
</div>
|
|
<div class="post-content">
|
|
<% if not edit then %>
|
|
<div class="post-inner"><%- post.content %></div>
|
|
<% if render_sig and #post.signature_rendered > 0 then %>
|
|
<div class="signature-container">
|
|
<hr>
|
|
<%- post.signature_rendered %></div>
|
|
<% end %>
|
|
<% else %>
|
|
<% render("views.common.babycode-editor", {
|
|
cancel_url = post_url,
|
|
prefill = post.original_markup,
|
|
ta_name = "new_content"
|
|
}) %>
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|