line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Contenticious::Content::Node::File; |
2
|
5
|
|
|
5
|
|
784
|
use Mojo::Base 'Contenticious::Content::Node'; |
|
5
|
|
|
|
|
6
|
|
|
5
|
|
|
|
|
24
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
507
|
use Carp; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
210
|
|
5
|
5
|
|
|
5
|
|
1107
|
use Mojo::Util 'decode'; |
|
5
|
|
|
|
|
130689
|
|
|
5
|
|
|
|
|
383
|
|
6
|
5
|
|
|
5
|
|
2656
|
use Text::Markdown 'markdown'; |
|
5
|
|
|
|
|
65179
|
|
|
5
|
|
|
|
|
1473
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has raw => sub { shift->build_raw }; |
9
|
|
|
|
|
|
|
has content => sub { shift->build_content_and_meta->content }; |
10
|
|
|
|
|
|
|
has meta => sub { shift->build_content_and_meta->meta }; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub build_raw { |
13
|
43
|
|
|
43
|
0
|
53
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# open file for decoded reading |
16
|
43
|
|
|
|
|
82
|
my $fn = $self->filename; |
17
|
4
|
50
|
|
4
|
|
23
|
open my $fh, '<:encoding(UTF-8)', $fn or croak "couldn't open $fn: $!"; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
26
|
|
|
43
|
|
|
|
|
1542
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# slurp |
20
|
43
|
|
|
|
|
5312
|
return do { local $/; <$fh> }; |
|
43
|
|
|
|
|
118
|
|
|
43
|
|
|
|
|
666
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub build_content_and_meta { |
24
|
43
|
|
|
43
|
0
|
44
|
my $self = shift; |
25
|
43
|
|
|
|
|
88
|
my $content = $self->raw; |
26
|
43
|
|
|
|
|
916
|
my %meta = (); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# extract (and delete) meta data from file content |
29
|
43
|
|
|
|
|
599
|
$meta{lc $1} = $2 |
30
|
|
|
|
|
|
|
while $content =~ s/\A(\w+):\s*(.*)[\n\r]+//; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# done |
33
|
43
|
|
|
|
|
133
|
$self->content($content)->meta(\%meta); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub build_html { |
37
|
13
|
|
|
13
|
0
|
18
|
my $self = shift; |
38
|
13
|
|
|
|
|
26
|
return markdown($self->content); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |