You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package LDV::Helpers;
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
use utf8;
|
|
|
|
|
|
|
|
use Mojo::Base 'Mojolicious::Plugin';
|
|
|
|
|
|
|
|
use POSIX qw(strftime);
|
|
|
|
use Text::Markdown;
|
|
|
|
|
|
|
|
sub register {
|
|
|
|
my ($self, $app) = @_;
|
|
|
|
|
|
|
|
$app->helper(markdown => sub {
|
|
|
|
my ($c, $text) = @_;
|
|
|
|
my $render = Text::Markdown->new;
|
|
|
|
return $render->markdown($text);
|
|
|
|
});
|
|
|
|
|
|
|
|
$app->helper(plaintext => sub {
|
|
|
|
my ($c, $text) = @_;
|
|
|
|
$text =~ s{\r?\n}{<br/>}go;
|
|
|
|
return $text;
|
|
|
|
});
|
|
|
|
|
|
|
|
$app->helper(from_unixtime => sub {
|
|
|
|
my ($c, $unixtime) = @_;
|
|
|
|
return strftime("%Y-%m-%d %H:%M", localtime($unixtime));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|