line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Contenticious::Content::Node::File; |
2
|
5
|
|
|
5
|
|
1045
|
use Mojo::Base 'Contenticious::Content::Node'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
26
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
648
|
use Carp; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
263
|
|
5
|
5
|
|
|
5
|
|
31
|
use Mojo::Util 'decode'; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
253
|
|
6
|
5
|
|
|
5
|
|
2719
|
use Text::Markdown 'markdown'; |
|
5
|
|
|
|
|
80095
|
|
|
5
|
|
|
|
|
1828
|
|
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
|
69
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# open file for decoded reading |
16
|
43
|
|
|
|
|
111
|
my $fn = $self->filename; |
17
|
4
|
50
|
|
4
|
|
28
|
open my $fh, '<:encoding(UTF-8)', $fn or croak "couldn't open $fn: $!"; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
25
|
|
|
43
|
|
|
|
|
1815
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# slurp |
20
|
43
|
|
|
|
|
6759
|
return do { local $/; <$fh> }; |
|
43
|
|
|
|
|
206
|
|
|
43
|
|
|
|
|
1113
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub build_content_and_meta { |
24
|
43
|
|
|
43
|
0
|
79
|
my $self = shift; |
25
|
43
|
|
|
|
|
103
|
my $content = $self->raw; |
26
|
43
|
|
|
|
|
1327
|
my %meta = (); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# extract (and delete) meta data from file content |
29
|
43
|
|
|
|
|
694
|
$meta{lc $1} = $2 |
30
|
|
|
|
|
|
|
while $content =~ s/\A(\w+):\s*(.*)[\n\r]+//; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# done |
33
|
43
|
|
|
|
|
175
|
$self->content($content)->meta(\%meta); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub build_html { |
37
|
13
|
|
|
13
|
0
|
28
|
my $self = shift; |
38
|
13
|
|
|
|
|
37
|
return markdown($self->content); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |