line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HiD::Generator::Sass; |
2
|
|
|
|
|
|
|
$HiD::Generator::Sass::VERSION = '0.004'; |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
In F<_config.yml>: |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
plugins: |
10
|
|
|
|
|
|
|
- Sass |
11
|
|
|
|
|
|
|
sass: |
12
|
|
|
|
|
|
|
sources: |
13
|
|
|
|
|
|
|
- _sass/*.scss |
14
|
|
|
|
|
|
|
output: css/ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
HiD::Generator::Sass is a plugin for the HiD static blog system |
19
|
|
|
|
|
|
|
that uses L<CSS::Sass> to compile your sass files |
20
|
|
|
|
|
|
|
into css. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 CONFIGURATION PARAMETERS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head2 sources |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
List of sass sources to compile. File globs can be used. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 output |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Site sub-directory where the compiled css files will be put. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
1
|
|
2381235
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
35
|
|
|
|
|
|
|
with 'HiD::Generator'; |
36
|
1
|
|
|
1
|
|
5803
|
use File::Find::Rule; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
12
|
|
37
|
1
|
|
|
1
|
|
42
|
use Path::Tiny; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
60
|
|
38
|
1
|
|
|
1
|
|
296
|
use CSS::Sass; |
|
1
|
|
|
|
|
9069
|
|
|
1
|
|
|
|
|
60
|
|
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
1
|
|
19
|
use 5.014; |
|
1
|
|
|
|
|
3
|
|
41
|
|
|
|
|
|
|
|
42
|
1
|
|
|
1
|
|
413
|
use HiD::VirtualPage; |
|
1
|
|
|
|
|
27009
|
|
|
1
|
|
|
|
|
223
|
|
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub generate { |
45
|
1
|
|
|
1
|
0
|
200
|
my($self, $site) = @_; |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
8
|
my $src = $site->config->{sass}{sources}; |
48
|
|
|
|
|
|
|
|
49
|
1
|
0
|
|
|
|
68
|
my @sass_sources = ref $src ? @$src : $src ? ( $src ) : (); |
|
|
50
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
1
|
|
|
|
|
2
|
my $sass_style; |
52
|
1
|
50
|
|
|
|
4
|
$sass_style = eval $site->config->{sass}{sass_style} if $site->config->{sass}{sass_style}; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
1
|
|
50
|
|
|
56
|
$sass_style //= SASS_STYLE_NESTED; |
56
|
|
|
|
|
|
|
|
57
|
1
|
|
|
|
|
7
|
my $sass = CSS::Sass->new( output_style => $sass_style ); |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
17
|
foreach my $file ( map { glob $_ } @sass_sources) { |
|
1
|
|
|
|
|
30
|
|
60
|
1
|
|
|
|
|
9
|
$site->INFO("* Compiling sass file - " . $file); |
61
|
1
|
|
|
|
|
57
|
my $css = $sass->compile_file($file); |
62
|
1
|
|
|
|
|
1503
|
my $filename = path($file)->basename('.scss'); |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
my $css_file = HiD::VirtualPage->new({ |
65
|
|
|
|
|
|
|
content => $css, |
66
|
|
|
|
|
|
|
output_filename => path( $site->destination, |
67
|
|
|
|
|
|
|
$site->config->{sass}{output}, |
68
|
1
|
|
|
|
|
135
|
$filename . '.css')->stringify |
69
|
|
|
|
|
|
|
}); |
70
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
248
|
$site->INFO("* Publishing " . $css_file->output_filename); |
72
|
|
|
|
|
|
|
|
73
|
1
|
|
|
|
|
67
|
$site->add_object($css_file); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
1
|
|
|
|
|
53
|
$site->INFO("* Compiled sass files successfully!"); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|