File tree 6 files changed +408
-4
lines changed
6 files changed +408
-4
lines changed Original file line number Diff line number Diff line change 1
1
Revision history for Perl module CPAN::Mini::Webserver:
2
2
3
+ 0.44
4
+ - autogenerate the CSS template file
5
+
3
6
0.43 Thu Sep 18 17:14:50 BST 2008
4
7
- add an abstract to the Makefile.PL
5
8
- add a human-readable license
Original file line number Diff line number Diff line change 3
3
lib/CPAN/Mini/Webserver.pm
4
4
lib/CPAN/Mini/Webserver/Index.pm
5
5
lib/CPAN/Mini/Webserver/Templates.pm
6
+ lib/CPAN/Mini/Webserver/Templates/CSS.pm
6
7
Makefile.PL
7
8
MANIFEST This list of files
8
9
README
Original file line number Diff line number Diff line change
1
+ # !perl
2
+ use strict;
3
+ use warnings;
4
+ use Cwd qw( cwd) ;
5
+ use CSS::Squish;
6
+ use File::Find::Rule;
7
+ use File::Slurp;
8
+ use Perl::Tidy;
9
+ use Template;
10
+ use YAML qw( LoadFile DumpFile) ;
11
+
12
+ foreach my $filename ( File::Find::Rule-> new-> file-> in(' root/static/css' ) ) {
13
+ next if $filename =~ / my-screen\. css/ ;
14
+ unlink ($filename ) || die $! ;
15
+ }
16
+
17
+ my $settings = ' blueprint_0.7.1/lib/settings.yml' ;
18
+ my $conf = LoadFile($settings );
19
+ $conf -> {cpanminiwebserver }-> {path } = cwd . ' /root/static/css/' ;
20
+ DumpFile( $settings , $conf );
21
+ use YAML;
22
+
23
+ system " cd blueprint_0.7.1/lib && ruby compress.rb -p cpanminiwebserver" ;
24
+
25
+ die " CSS files not generated" unless -f ' root/static/css/screen.css' ;
26
+
27
+ my $template = q{ package CPAN::Mini::Webserver::Templates::CSS;
28
+ use strict;
29
+ use warnings;
30
+ use Template::Declare::Tags;
31
+ use base 'Template::Declare';
32
+
33
+ [% FOREACH file IN files %]
34
+ [% name = file.0 %]
35
+ [% css = file.1 %]
36
+ template 'css_[% name %]' => sub {
37
+ my $self = shift;
38
+ my $css = <<'END';
39
+ [% css %]
40
+ END
41
+ outs_raw $css;
42
+ };
43
+ [% END %]
44
+
45
+ 1;
46
+ } ;
47
+
48
+ my $tt = Template-> new;
49
+ $tt -> process(
50
+ \$template ,
51
+ { files => [
52
+ [ ' ie' => scalar read_file(' root/static/css/ie.css' ) ],
53
+ [ ' print' => scalar read_file(' root/static/css/print.css' ) ],
54
+ [ ' screen' => scalar read_file(' root/static/css/screen.css' ) ],
55
+ ],
56
+ },
57
+ \my $perl ,
58
+ ) || die $template -> error();
59
+ Perl::Tidy::perltidy( source => \$perl , destination => \my $tidied );
60
+ write_file( ' lib/CPAN/Mini/Webserver/Templates/CSS.pm' , $tidied );
Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ use PPI;
19
19
use PPI::HTML;
20
20
use Template::Declare;
21
21
22
- Template::Declare-> init( roots => [' CPAN::Mini::Webserver::Templates' ] );
22
+ Template::Declare-> init(
23
+ roots => [
24
+ ' CPAN::Mini::Webserver::Templates' ,
25
+ ' CPAN::Mini::Webserver::Templates::CSS'
26
+ ]
27
+ );
23
28
24
29
if ( eval { require HTTP::Server::Simple::Bonjour } ) {
25
30
extends ' HTTP::Server::Simple::Bonjour' , ' HTTP::Server::Simple::CGI' ;
You can’t perform that action at this time.
0 commit comments