Implement markdown preivew for remarks; no markdown for last remark/last thread view

This commit is contained in:
swagg boi 2025-04-04 22:03:57 -04:00
parent 3c5f86c3de
commit df31080154
2 changed files with 13 additions and 5 deletions

View File

@ -73,7 +73,7 @@ sub create($self) {
})->fragment('remarks')); })->fragment('remarks'));
} }
$draft = $remark_body; $draft = {body => $remark_body, markdown => $markdown};
} }
} }

View File

@ -14,9 +14,13 @@
content="Remark on thread #<%= $thread->{'id'} %>."> content="Remark on thread #<%= $thread->{'id'} %>.">
<% end %> <% end %>
<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">
@ -51,6 +55,10 @@
<%= check_box bump => 1, id => 'bump', checked => undef %> <%= check_box bump => 1, id => 'bump', checked => undef %>
<%= label_for bump => 'Bump' %> <%= label_for bump => 'Bump' %>
</div> </div>
<div class="form-checkbox">
<%= check_box markdown => 1, id => 'markdown' %>
<%= label_for markdown => 'Markdown' %>
</div>
<div class="form-checkbox"> <div class="form-checkbox">
<%= check_box preview => 1, id => 'preview' %> <%= check_box preview => 1, id => 'preview' %>
<%= label_for preview => 'Preview' %> <%= label_for preview => 'Preview' %>
@ -72,7 +80,7 @@
</h4> </h4>
<h5 class="post__author"><%= $last_remark->{'author'} %></h5> <h5 class="post__author"><%= $last_remark->{'author'} %></h5>
<div class="post__body"> <div class="post__body">
<%== markdown $last_remark->{'body'} =%> <%= $last_remark->{'body'} =%>
</div> </div>
<nav class="post__nav"> <nav class="post__nav">
<%= link_to Thread => single_thread => <%= link_to Thread => single_thread =>
@ -98,7 +106,7 @@
<h4 class="post__date"><%= $thread->{'date'} %></h4> <h4 class="post__date"><%= $thread->{'date'} %></h4>
<h5 class="post__author"><%= $thread->{'author'} %></h5> <h5 class="post__author"><%= $thread->{'author'} %></h5>
<div class="post__body"> <div class="post__body">
<%== markdown $thread->{'body'} =%> <%= $thread->{'body'} =%>
</div> </div>
<nav class="post__nav"> <nav class="post__nav">
<%= link_to post_remark => {thread_id => $thread->{'id'}}, <%= link_to post_remark => {thread_id => $thread->{'id'}},