Implement preview for markdown and plain text thread

This commit is contained in:
swagg boi 2025-04-04 21:49:28 -04:00
parent ce7ea8c755
commit 3c5f86c3de
3 changed files with 8 additions and 5 deletions

View File

@ -61,6 +61,7 @@ tests locally:
## TODOs ## TODOs
- Non-markdown posts will need to handle whitespace/newlines with CSS stuff
- Do I need `SUM` for `by_id()`? - Do I need `SUM` for `by_id()`?
## AGPL-3.0+ANTIFA compliance ## AGPL-3.0+ANTIFA compliance

View File

@ -36,8 +36,6 @@ sub create($self) {
$self->session(author => $thread_author); $self->session(author => $thread_author);
print $self->dumper($v);
unless ($preview) { unless ($preview) {
my $new_thread_id = $self->thread->create( my $new_thread_id = $self->thread->create(
$thread_author, $thread_author,
@ -51,7 +49,7 @@ sub create($self) {
); );
} }
$draft = $thread_body; $draft = {body => $thread_body, markdown => $markdown};
} }
} }

View File

@ -11,9 +11,13 @@
% end % end
<h2 class="page-title"><%= title %></h2> <h2 class="page-title"><%= title %></h2>
<form method="post" class="form-body"> <form method="post" class="form-body">
<% if ($draft) { =%> <% if (keys %{$draft}) { =%>
<div class="form-preview"> <div class="form-preview">
<%== markdown $draft =%> <% if ($draft->{'markdown'}) { =%>
<%== markdown $draft->{'body'} =%>
<% } else { =%>
<%= $draft->{'body'} =%>
<% } =%>
</div> </div>
<% } =%> <% } =%>
<div class="form-field"> <div class="form-field">