add quote to babycode, improve quote text

This commit is contained in:
Lera Elvoé 2025-05-24 16:45:34 +03:00
parent 2773ba5243
commit 22f97dcc82
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc
4 changed files with 55 additions and 31 deletions

View File

@ -154,6 +154,14 @@ pre code {
margin-right: 10px; margin-right: 10px;
} }
blockquote {
padding: 10px 20px;
margin: 10px;
border-radius: 4px;
border-left: 10px solid rgb(229.84, 231.92, 227.28);
background-color: rgb(135.1928346457, 145.0974015748, 123.0025984252);
}
.user-posts { .user-posts {
display: grid; display: grid;
grid-template-columns: 200px 1fr; grid-template-columns: 200px 1fr;

View File

@ -38,6 +38,8 @@ function babycode.to_html(s, escape_html)
text = text:gsub("%[i%](.-)%[/i%]", "<em>%1</em>") text = text:gsub("%[i%](.-)%[/i%]", "<em>%1</em>")
text = text:gsub("%[s%](.-)%[/s%]", "<del>%1</del>") text = text:gsub("%[s%](.-)%[/s%]", "<del>%1</del>")
text = text:gsub("%[quote%](.-)%[/quote%]", "<blockquote>%1</blockquote>")
-- replace loose links -- replace loose links
text = text:gsub("(https?://[%w-_%.%?%.:/%+=&~%@#%%]+[%w-/])", function(url) text = text:gsub("(https?://[%w-_%.%?%.:/%+=&~%@#%%]+[%w-/])", function(url)
if not text:find('<a[^>]*>'..url..'</a>') then if not text:find('<a[^>]*>'..url..'</a>') then

View File

@ -192,6 +192,14 @@ pre code {
margin-right: 10px; margin-right: 10px;
} }
blockquote {
padding: 10px 20px;
margin: 10px;
border-radius: 4px;
border-left: 10px solid $lighter;
background-color: $dark2;
}
.user-posts { .user-posts {
display: grid; display: grid;
grid-template-columns: 200px 1fr; grid-template-columns: 200px 1fr;

View File

@ -17,7 +17,10 @@
<div class="post-content-container"<%= is_latest and 'id=latest-post' or "" %>> <div class="post-content-container"<%= is_latest and 'id=latest-post' or "" %>>
<div class="post-info"> <div class="post-info">
<a href="<%= url_for("thread", {slug = thread.slug}, {page = page}) .. "#post-" .. post.id %>" title="Permalink"><i> <%
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 -%> <% if tonumber(post.edited_at) > tonumber(post.created_at) then -%>
Edited at <%= os.date("%c", post.edited_at) %> Edited at <%= os.date("%c", post.edited_at) %>
<% else -%> <% else -%>
@ -44,7 +47,10 @@
end end
if show_reply then if show_reply then
local d = post.created_at < post.edited_at and post.edited_at or post.created_at local d = post.created_at < post.edited_at and post.edited_at or post.created_at
local reply_text = ("On %s, %s said:\n%s\n\n---\n\n"):format(os.date("%c", d), post.username, post.original_markup) 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> <button value="<%= reply_text %>" class="reply-button">Reply</button>
<% end %> <% end %>
@ -55,7 +61,7 @@
<%- post.content %> <%- post.content %>
<% else %> <% else %>
<% render("views.common.babycode-editor", { <% render("views.common.babycode-editor", {
cancel_url = url_for("thread", {slug = thread.slug}, {page = page}) .. "#post-" .. post.id, cancel_url = post_url,
prefill = post.original_markup, prefill = post.original_markup,
ta_name = "new_content" ta_name = "new_content"
}) %> }) %>