From: Marius Gavrilescu Date: Thu, 2 Apr 2015 08:11:59 +0000 (+0300) Subject: Merge branch 'master' into newmc X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=b0201bcc83ed8e81b0842e06c282386fd0d0ed85;hp=0f623f3d41b33606db73af07c12161320ed4aa93;p=plack-app-gruntmaster.git Merge branch 'master' into newmc Conflicts: Makefile.PL make_static.PL --- diff --git a/Makefile.PL b/Makefile.PL index 2b025b1..6f86eb4 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,7 +10,7 @@ WriteMakefile( LICENSE => 'AGPL_3', SIGN => 1, clean => { - FILES => 'static/css/ static/js.js css/logos.css static/logos.png static/js.map static/js/' + FILES => 'static/css/ static/js.js static/js.js.gz css/logos.css static/logos.png static/js.map static/js/' }, BUILD_REQUIRES => { qw/CSS::Minifier::XS 0 @@ -32,11 +32,10 @@ WriteMakefile( strict 0 warnings 0 - Email::Simple 0 - Email::Sender::Simple 0 File::Slurp 0 Gruntmaster::Data 0 - HTML::Seamstress 0 + HTML::Element::Library 0 + HTML::TreeBuilder 0 JSON::MaybeXS 0 Log::Log4perl 0 PerlX::Maybe 0 diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index 8aa42d2..c02e7dd 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -14,9 +14,6 @@ use Web::Simple; use Gruntmaster::Data; use Plack::App::Gruntmaster::HTML; -use Email::Sender::Simple qw/sendmail/; -use Email::Simple; - use warnings NONFATAL => 'all'; no warnings 'illegalproto'; diff --git a/lib/Plack/App/Gruntmaster/HTML.pm b/lib/Plack/App/Gruntmaster/HTML.pm index 7b343b2..396f7d9 100644 --- a/lib/Plack/App/Gruntmaster/HTML.pm +++ b/lib/Plack/App/Gruntmaster/HTML.pm @@ -4,7 +4,8 @@ use parent qw/Exporter/; our @EXPORT = qw/render render_article/; use File::Slurp qw/read_file/; -use HTML::Seamstress; +use HTML::Element::Library; +use HTML::TreeBuilder; use POSIX qw//; use Data::Dumper qw/Dumper/; @@ -45,7 +46,7 @@ sub HTML::Element::namedlink { my %page_cache; for () { my ($tmpl, $lang) = m,tmpl/(\w+)\.(\w+),; - my $builder = HTML::Seamstress->new; + my $builder = HTML::TreeBuilder->new; $builder->ignore_unknown(0); $page_cache{$tmpl, $lang} = $builder->parse_file($_); } @@ -74,7 +75,7 @@ sub _render { $process->($tree, %args) if $process; $_->detach for $tree->look_down(static => $args{static} ? 'no' : 'yes'); $_->attr('static', undef) for $tree->look_down(sub {$_[0]->attr('static')}); - $_->attr('smap', undef) for $tree->look_down(sub {$_[0]->attr('defmap')}); + $_->attr('smap', undef) for $tree->look_down(sub {$_[0]->attr('smap')}); $tree->as_HTML; } diff --git a/make_static.PL b/make_static.PL index 489652a..4d737fa 100644 --- a/make_static.PL +++ b/make_static.PL @@ -6,6 +6,7 @@ use CSS::Minifier::XS qw//; use CSS::SpriteMaker; use JavaScript::Minifier::XS qw//; +use IO::Compress::Gzip qw/gzip/; use File::Slurp qw/read_file write_file/; mkdir 'static'; @@ -36,6 +37,11 @@ sub make_sprite { rename 'static/logos-nq8.png', 'static/logos.png'; } +sub gzip_file { + my ($file) = @_; + gzip $file => "$file.gz", -Level => 9, Minimal => 1; +} + sub make_css { my $common_css; $common_css .= read_file $_ for ; @@ -44,6 +50,7 @@ sub make_css { my $css = read_file $_; $css .= $common_css; write_file "static/css/$theme.css", CSS::Minifier::XS::minify $css; + gzip_file "static/css/$theme.css"; } } @@ -58,6 +65,7 @@ sub make_js { $js .= read_file $_ for ; write_file 'static/js.js', JavaScript::Minifier::XS::minify $js; } + gzip_file 'static/js.js'; } my $css_mtime = -M 'static/css/slate.css' // 0;