line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::Breadcrumbs; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
96085
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
3
|
|
|
|
|
17
|
|
|
3
|
|
|
|
|
12
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.001002'; # VERSION |
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1081
|
use utf8; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
11
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $Crumbs_Map = { |
10
|
|
|
|
|
|
|
'/' => 'Home', |
11
|
|
|
|
|
|
|
}; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub register { |
14
|
2
|
|
|
2
|
1
|
64
|
my ($self, $app) = @_; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$app->helper( |
17
|
|
|
|
|
|
|
breadcrumbs => sub { |
18
|
5
|
|
|
5
|
|
35476
|
my $c = shift; |
19
|
5
|
100
|
|
|
|
19
|
@_ and $Crumbs_Map = shift; |
20
|
|
|
|
|
|
|
|
21
|
5
|
100
|
|
|
|
17
|
length $c->url_for->to_string |
22
|
|
|
|
|
|
|
or return; # if this is the case, we're just setting the |
23
|
|
|
|
|
|
|
# $Crumbs_Map and not needing crumbs; |
24
|
|
|
|
|
|
|
|
25
|
4
|
|
|
|
|
1705
|
my $path = ''; |
26
|
4
|
|
|
|
|
5
|
my @crumbs; |
27
|
4
|
|
|
|
|
12
|
for my $crumb ( |
28
|
|
|
|
|
|
|
'', grep length, split m{/}, $c->url_for->to_string |
29
|
|
|
|
|
|
|
) { |
30
|
8
|
100
|
|
|
|
1041
|
$path .= ($path eq '/' ? '' : '/') . $crumb; |
31
|
|
|
|
|
|
|
push @crumbs, { |
32
|
|
|
|
|
|
|
path => $path, |
33
|
|
|
|
|
|
|
text => $Crumbs_Map->{ $path } |
34
|
8
|
|
66
|
|
|
42
|
// do{ |
35
|
2
|
|
|
|
|
3
|
( my $x = $crumb ) =~ tr/-_/ /; |
36
|
2
|
|
|
|
|
6
|
ucfirst $x; |
37
|
|
|
|
|
|
|
}, |
38
|
|
|
|
|
|
|
}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
4
|
|
|
|
|
16
|
my $current_page = pop @crumbs; |
42
|
4
|
|
|
|
|
19
|
my $bread = ' |
43
|
|
|
|
|
|
|
join(q{▸}, |
44
|
|
|
|
|
|
|
(map qq{$_->{text}}, @crumbs), |
45
|
|
|
|
|
|
|
'', |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
4
|
|
|
|
|
13
|
$bread .= '' |
49
|
|
|
|
|
|
|
. ($current_page->{text}) . ''; |
50
|
|
|
|
|
|
|
|
51
|
4
|
|
|
|
|
12
|
return $bread; |
52
|
|
|
|
|
|
|
}, |
53
|
2
|
|
|
|
|
18
|
); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
' |
57
|
|
|
|
|
|
|
Q. Why was the statement scared while the comment was not? |
58
|
|
|
|
|
|
|
A. Statements are executed. |
59
|
|
|
|
|
|
|
'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |