Added Markdown support
This commit is contained in:
parent
94988c2d34
commit
e86cda1cc5
|
@ -40,7 +40,6 @@ Run the tests locally (against development environment):
|
|||
|
||||
### (Lord knows there's TODOs I could be working on...)
|
||||
|
||||
1. Support at least some Markdown, specifically the code blocks
|
||||
1. Implement tripcodes (moving this down in priority due to complexity...)
|
||||
1. Return a text response instead of HTML if a `.txt` extension [is
|
||||
requested](https://docs.mojolicious.org/Mojolicious/Plugin/DefaultHelpers#respond_to)
|
||||
|
|
|
@ -20,3 +20,67 @@
|
|||
.thread .body, .remark .body {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
/*
|
||||
* For the custom Markdown <h1> - <h6>
|
||||
*/
|
||||
|
||||
span.head1 {
|
||||
display: block;
|
||||
font-size: 2em;
|
||||
margin-top: 0.67em;
|
||||
margin-bottom: 0.67em;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.head2 {
|
||||
display: block;
|
||||
font-size: 1.5em;
|
||||
margin-top: 0.83em;
|
||||
margin-bottom: 0.83em;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.head3 {
|
||||
display: block;
|
||||
font-size: 1.17em;
|
||||
margin-top: 1em;
|
||||
margin-bottom: 1em;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.head4 {
|
||||
display: block;
|
||||
font-size: 1em;
|
||||
margin-top: 1.33em;
|
||||
margin-bottom: 1.33em;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.head5 {
|
||||
display: block;
|
||||
font-size: .83em;
|
||||
margin-top: 1.67em;
|
||||
margin-bottom: 1.67em;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
span.head6 {
|
||||
display: block;
|
||||
font-size: .67em;
|
||||
margin-top: 2.33em;
|
||||
margin-bottom: 2.33em;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use Crypt::Passphrase;
|
|||
use PostText::Model::Thread;
|
||||
use PostText::Model::Remark;
|
||||
use PostText::Model::Moderator;
|
||||
use PostText::Markdown;
|
||||
|
||||
sub startup($self) {
|
||||
$self->plugin('Config');
|
||||
|
@ -62,6 +63,10 @@ sub startup($self) {
|
|||
$c->session->{'is_admin'} || undef
|
||||
});
|
||||
|
||||
$self->helper(markdown => sub ($c, $input_text) {
|
||||
PostText::Markdown::Markdown($input_text)
|
||||
});
|
||||
|
||||
# Finish configuring some things
|
||||
$self->secrets($self->config->{'secrets'}) || die $@;
|
||||
|
||||
|
|
1290
lib/PostText/Markdown.pm
Normal file
1290
lib/PostText/Markdown.pm
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -6,7 +6,7 @@
|
|||
<nav class="id">#<%= $remark->{'id'} %></nav>
|
||||
<h4 class="date"><%= $remark->{'date'} %></h4>
|
||||
<h5 class="author"><%= $remark->{'author'} %></h5>
|
||||
<p class="body"><%== $remark->{'body'} %></p>
|
||||
<div class="body"><%== markdown $remark->{'body'} %></div>
|
||||
</article>
|
||||
</div>
|
||||
<nav>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
<h3 class="title"><%= $thread->{'title'} %></h3>
|
||||
<h4 class="date"><%= $thread->{'date'} %></h4>
|
||||
<h5 class="author"><%= $thread->{'author'} %></h5>
|
||||
<p class="body"><%== $thread->{'body'} %></p>
|
||||
<div class="body"><%== markdown $thread->{'body'} %></div>
|
||||
</article>
|
||||
</div>
|
||||
<% if (my $last_remark_id = $last_remark->{'id'}) { =%>
|
||||
|
@ -50,7 +50,7 @@
|
|||
</nav>
|
||||
<h4 class="date"><%= $last_remark->{'date'} %></h4>
|
||||
<h5 class="author"><%= $last_remark->{'author'} %></h5>
|
||||
<p class="body"><%== $last_remark->{'body'} %></p>
|
||||
<div class="body"><%== markdown $last_remark->{'body'} %></div>
|
||||
</article>
|
||||
</div>
|
||||
<% } =%>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<h3 class="title"><%= $thread->{'title'} %></h3>
|
||||
<h4 class="date"><%= $thread->{'date'} %></h4>
|
||||
<h5 class="author"><%= $thread->{'author'} %></h5>
|
||||
<p class="body"><%== $thread->{'body'} %></p>
|
||||
<div class="body"><%== markdown $thread->{'body'} %></div>
|
||||
</article>
|
||||
</div>
|
||||
<nav>
|
||||
|
@ -32,7 +32,7 @@
|
|||
</nav>
|
||||
<h4 class="date"><%= $remark->{'date'} %></h4>
|
||||
<h5 class="author"><%= $remark->{'author'} %></h5>
|
||||
<p class="body"><%== $remark->{'body'} %></p>
|
||||
<div class="body"><%== markdown $remark->{'body'} %></div>
|
||||
<nav class="flag">
|
||||
<%= link_to Flag => flag_remark => {remark_id => $remark->{'id'}} %>
|
||||
</nav>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</h3>
|
||||
<h4 class="date"><%= $thread->{'date'} %></h4>
|
||||
<h5 class="author"><%= $thread->{'author'} %></h5>
|
||||
<p class="body"><%== truncate_text $thread->{'body'} %></p>
|
||||
<div class="body"><%== markdown truncate_text $thread->{'body'} %></div>
|
||||
<nav>
|
||||
<%= link_to Remark => post_remark => {thread_id => $thread->{'id'}} %>
|
||||
<%= link_to url_for(single_thread => {thread_id => $thread->{'id'}})
|
||||
|
|
Loading…
Reference in New Issue
Block a user