line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Contenticious::Content::Node::File; |
2
|
5
|
|
|
5
|
|
763
|
use Mojo::Base 'Contenticious::Content::Node'; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
20
|
|
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
523
|
use Carp; |
|
5
|
|
|
|
|
5
|
|
|
5
|
|
|
|
|
205
|
|
5
|
5
|
|
|
5
|
|
1025
|
use Mojo::Util 'decode'; |
|
5
|
|
|
|
|
63673
|
|
|
5
|
|
|
|
|
248
|
|
6
|
5
|
|
|
5
|
|
2651
|
use Text::Markdown 'markdown'; |
|
5
|
|
|
|
|
64833
|
|
|
5
|
|
|
|
|
1484
|
|
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
|
55
|
my $self = shift; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# open file for decoded reading |
16
|
43
|
|
|
|
|
105
|
my $fn = $self->filename; |
17
|
4
|
50
|
|
4
|
|
21
|
open my $fh, '<:encoding(UTF-8)', $fn or croak "couldn't open $fn: $!"; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
24
|
|
|
43
|
|
|
|
|
1609
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# slurp |
20
|
43
|
|
|
|
|
5332
|
return do { local $/; <$fh> }; |
|
43
|
|
|
|
|
121
|
|
|
43
|
|
|
|
|
672
|
|
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub build_content_and_meta { |
24
|
43
|
|
|
43
|
0
|
41
|
my $self = shift; |
25
|
43
|
|
|
|
|
94
|
my $content = $self->raw; |
26
|
43
|
|
|
|
|
912
|
my %meta = (); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# extract (and delete) meta data from file content |
29
|
43
|
|
|
|
|
616
|
$meta{lc $1} = $2 |
30
|
|
|
|
|
|
|
while $content =~ s/\A(\w+):\s*(.*)[\n\r]+//; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# done |
33
|
43
|
|
|
|
|
119
|
$self->content($content)->meta(\%meta); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub build_html { |
37
|
13
|
|
|
13
|
0
|
18
|
my $self = shift; |
38
|
13
|
|
|
|
|
30
|
return markdown($self->content); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |