line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Plugin::FontAwesome4; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Mojolicious::Plugin::FontAwesome4 - Mojolicious + http://fortawesome.github.io/Font-Awesome/ |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 VERSION |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
4.2005 |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
L is used a L plugin to simpler include |
14
|
|
|
|
|
|
|
L CSS and font files into your project. |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
This is done with the help of L. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head2 Mojolicious::Lite |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Mojolicious::Lite; |
23
|
|
|
|
|
|
|
plugin 'FontAwesome4'; |
24
|
|
|
|
|
|
|
get '/' => 'index'; |
25
|
|
|
|
|
|
|
app->start; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 Template |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
%= asset "font-awesome4.css" |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
%= fa "user", "class" => "fa-4x" |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
2
|
|
|
2
|
|
360356
|
use Mojo::Base 'Mojolicious::Plugin'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
12
|
|
42
|
2
|
|
|
2
|
|
1109
|
use File::Spec::Functions 'catdir'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
88
|
|
43
|
2
|
|
|
2
|
|
12
|
use Cwd (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
1014
|
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
our $VERSION = '4.2005'; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 HELPERS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 fa |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Insert a L icons. |
52
|
|
|
|
|
|
|
Example: |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# this... |
55
|
|
|
|
|
|
|
<%= fa "bars", class => "fa-4x", id => "abc" %> |
56
|
|
|
|
|
|
|
# turns into... |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 METHODS |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 asset_path |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$path = Mojolicious::Plugin::FontAwesome4->asset_path($type); |
64
|
|
|
|
|
|
|
$path = $self->asset_path($type); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns the base path to the assets bundled with this module. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Set C<$type> to "sass" if you want a return value that is suitable for |
69
|
|
|
|
|
|
|
the C environment variable. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub asset_path { |
74
|
1
|
|
|
1
|
1
|
11
|
my ($class, $type) = @_; |
75
|
1
|
|
|
|
|
131
|
my $path = Cwd::abs_path(__FILE__); |
76
|
|
|
|
|
|
|
|
77
|
1
|
|
|
|
|
6
|
$path =~ s!\.pm$!!; |
78
|
|
|
|
|
|
|
|
79
|
1
|
50
|
33
|
|
|
8
|
return join ':', grep {$_} catdir($path, 'scss'), $ENV{SASS_PATH} if $type and $type eq 'sass'; |
|
0
|
|
|
|
|
0
|
|
80
|
1
|
|
|
|
|
3
|
return $path; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 register |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$app->plugin("FontAwesome4"); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
See L. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub register { |
92
|
1
|
|
|
1
|
1
|
38
|
my ($self, $app, $config) = @_; |
93
|
1
|
|
50
|
|
|
10
|
my $helper = $config->{helper} || 'fa'; |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
50
|
|
|
9
|
$config->{css} ||= [qw( font-awesome.scss )]; |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
8
|
$app->helper($helper => \&_fa); |
98
|
1
|
50
|
|
|
|
38
|
$app->plugin('AssetPack') unless eval { $app->asset }; |
|
1
|
|
|
|
|
15
|
|
99
|
|
|
|
|
|
|
|
100
|
1
|
|
|
|
|
31144
|
push @{$app->static->paths}, $self->asset_path; |
|
1
|
|
|
|
|
4
|
|
101
|
|
|
|
|
|
|
|
102
|
1
|
50
|
|
|
|
2
|
if (@{$config->{css}}) { |
|
1
|
|
|
|
|
7
|
|
103
|
1
|
|
|
|
|
1
|
$app->asset('font-awesome4.css' => map {"/scss/$_"} @{$config->{css}}); |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
3
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub _fa { |
108
|
1
|
|
|
1
|
|
23137
|
my ($c, $icon) = (shift, shift); |
109
|
1
|
|
|
|
|
4
|
my @class = ("fa", "fa-$icon"); |
110
|
1
|
|
|
|
|
3
|
my @args; |
111
|
|
|
|
|
|
|
|
112
|
1
|
|
|
|
|
7
|
while (my $arg = shift) { |
113
|
1
|
50
|
50
|
|
|
9
|
push @class, shift and next if $arg eq 'class'; |
114
|
0
|
|
|
|
|
0
|
push @args, $arg; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
1
|
|
|
1
|
|
14
|
$c->tag('i', class => join(' ', @class), @args, sub {''}); |
|
1
|
|
|
|
|
39
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 CREDITS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
L is created by |
123
|
|
|
|
|
|
|
L. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 LICENSE |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
FontAwesome is licensed under L. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
L is licensed under Artistic License |
130
|
|
|
|
|
|
|
version 2.0 and so is this code. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Jan Henning Thorsen - C |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |