line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Riji::Model::Entry; |
2
|
1
|
|
|
1
|
|
9
|
use feature ':5.10'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
107
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
51
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
548
|
use HTTP::Date; |
|
1
|
|
|
|
|
1820
|
|
|
1
|
|
|
|
|
74
|
|
7
|
1
|
|
|
1
|
|
7
|
use Time::Piece; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
11
|
|
8
|
1
|
|
|
1
|
|
79
|
use URI::tag; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1178
|
use Mouse; |
|
1
|
|
|
|
|
27322
|
|
|
1
|
|
|
|
|
5
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
extends 'Riji::Model::Article'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has repo_path => ( |
15
|
|
|
|
|
|
|
is => 'ro', |
16
|
|
|
|
|
|
|
lazy => 1, |
17
|
|
|
|
|
|
|
default => sub { |
18
|
|
|
|
|
|
|
my $self = shift; |
19
|
|
|
|
|
|
|
my $repo_dir = $self->repo->run(qw/rev-parse --show-toplevel/); |
20
|
|
|
|
|
|
|
$self->file_path->relative($repo_dir) |
21
|
|
|
|
|
|
|
}, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has file_history => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
lazy => 1, |
27
|
|
|
|
|
|
|
default => sub { |
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
$self->repo->file_history($self->repo_path.'', {branch => $self->blog->branch}); |
30
|
|
|
|
|
|
|
}, |
31
|
|
|
|
|
|
|
handles => [qw/created_by last_modified_by/], |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
has tag_uri => ( |
35
|
|
|
|
|
|
|
is => 'ro', |
36
|
|
|
|
|
|
|
lazy => 1, |
37
|
|
|
|
|
|
|
default => sub { |
38
|
|
|
|
|
|
|
my $self = shift; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $tag_uri = URI->new('tag:'); |
41
|
|
|
|
|
|
|
$tag_uri->authority($self->fqdn); |
42
|
|
|
|
|
|
|
$tag_uri->date($self->created_at->strftime('%Y-%m-%d')); |
43
|
|
|
|
|
|
|
$tag_uri->specific($self->blog->tag_uri_specific_prefix . join('-', grep {$_ ne ''} split(m{/}, $self->site_path))); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$tag_uri; |
46
|
|
|
|
|
|
|
}, |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has next => ( |
50
|
|
|
|
|
|
|
is => 'rw', |
51
|
|
|
|
|
|
|
lazy => 1, |
52
|
|
|
|
|
|
|
default => sub { |
53
|
|
|
|
|
|
|
my $self = shift; |
54
|
|
|
|
|
|
|
my ($prev, $next) = $self->_search_prev_and_next; |
55
|
|
|
|
|
|
|
$self->prev($prev); |
56
|
|
|
|
|
|
|
$next; |
57
|
|
|
|
|
|
|
}, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has prev => ( |
61
|
|
|
|
|
|
|
is => 'rw', |
62
|
|
|
|
|
|
|
lazy => 1, |
63
|
|
|
|
|
|
|
default => sub { |
64
|
|
|
|
|
|
|
my $self = shift; |
65
|
|
|
|
|
|
|
my ($prev, $next) = $self->_search_prev_and_next; |
66
|
|
|
|
|
|
|
$self->next($next); |
67
|
|
|
|
|
|
|
$prev; |
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
has last_modified_at => ( |
72
|
|
|
|
|
|
|
is => 'ro', |
73
|
|
|
|
|
|
|
lazy => 1, |
74
|
|
|
|
|
|
|
default => sub { |
75
|
|
|
|
|
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $updated_at = $self->updated_at; |
78
|
|
|
|
|
|
|
my $published_at = $self->published_at; |
79
|
|
|
|
|
|
|
$published_at > $updated_at ? $published_at : $updated_at; |
80
|
|
|
|
|
|
|
}, |
81
|
|
|
|
|
|
|
); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has created_at => ( |
84
|
|
|
|
|
|
|
is => 'ro', |
85
|
|
|
|
|
|
|
lazy => 1, |
86
|
|
|
|
|
|
|
default => sub { |
87
|
|
|
|
|
|
|
localtime($_[0]->file_history->created_at); |
88
|
|
|
|
|
|
|
}, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has updated_at => ( |
92
|
|
|
|
|
|
|
is => 'ro', |
93
|
|
|
|
|
|
|
lazy => 1, |
94
|
|
|
|
|
|
|
default => sub { |
95
|
|
|
|
|
|
|
localtime($_[0]->file_history->updated_at); |
96
|
|
|
|
|
|
|
}, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has published_at => ( |
100
|
|
|
|
|
|
|
is => 'ro', |
101
|
|
|
|
|
|
|
lazy => 1, |
102
|
|
|
|
|
|
|
default => sub { |
103
|
|
|
|
|
|
|
my $self = shift; |
104
|
|
|
|
|
|
|
if (my $pubdate = $self->header('pubdate')) { |
105
|
|
|
|
|
|
|
return localtime(str2time($pubdate)); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
$self->created_at; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
); |
110
|
|
|
|
|
|
|
|
111
|
1
|
|
|
1
|
|
1096
|
no Mouse; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
sub BUILD { |
114
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
115
|
0
|
0
|
|
|
|
|
return unless $self->file_history; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# surely assign them |
118
|
0
|
|
|
|
|
|
$self->last_modified_at; |
119
|
0
|
|
|
|
|
|
$self->created_at; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub _search_prev_and_next { |
123
|
0
|
|
|
0
|
|
|
my $self = shift; |
124
|
0
|
|
|
|
|
|
my ($prev, $next); |
125
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
|
my $found; |
127
|
0
|
|
|
|
|
|
my @entries = @{ $self->blog->entries }; |
|
0
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
while (my $entry = shift @entries) { |
129
|
0
|
0
|
|
|
|
|
if ($entry->file eq $self->file) { |
130
|
0
|
|
|
|
|
|
$prev = shift @entries; |
131
|
0
|
|
|
|
|
|
$found++; last; |
|
0
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
} |
133
|
0
|
|
|
|
|
|
$next = $entry; |
134
|
|
|
|
|
|
|
} |
135
|
0
|
0
|
|
|
|
|
return () unless $found; |
136
|
0
|
|
|
|
|
|
($prev, $next); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
1; |