Hello community,
here is the log from the commit of package perl-Mojolicious-Plugin-AssetPack
for openSUSE:Factory checked in at 2018-07-22 23:05:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Mojolicious-Plugin-AssetPack (Old)
and /work/SRC/openSUSE:Factory/.perl-Mojolicious-Plugin-AssetPack.new
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Mojolicious-Plugin-AssetPack"
Sun Jul 22 23:05:34 2018 rev:39 rq:624411 version:2.04
Changes:
--------
---
/work/SRC/openSUSE:Factory/perl-Mojolicious-Plugin-AssetPack/perl-Mojolicious-Plugin-AssetPack.changes
2018-05-03 12:33:42.417449291 +0200
+++
/work/SRC/openSUSE:Factory/.perl-Mojolicious-Plugin-AssetPack.new/perl-Mojolicious-Plugin-AssetPack.changes
2018-07-22 23:05:37.000899877 +0200
@@ -1,0 +2,11 @@
+Fri Jul 20 05:40:39 UTC 2018 - [email protected]
+
+- updated to 2.04
+ see /usr/share/doc/packages/perl-Mojolicious-Plugin-AssetPack/Changes
+
+ 2.04 2018-07-19T17:39:06+0800
+ - Add support for generating manifest with Favicon pipe
+ - Marked AssetPack::tag_for() as deprecated
+ - Removed support for Mojolicious::Plugin::AssetPack::Backcompat
+
+-------------------------------------------------------------------
Old:
----
Mojolicious-Plugin-AssetPack-2.03.tar.gz
New:
----
Mojolicious-Plugin-AssetPack-2.04.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Mojolicious-Plugin-AssetPack.spec ++++++
--- /var/tmp/diff_new_pack.fXMYZp/_old 2018-07-22 23:05:37.524899683 +0200
+++ /var/tmp/diff_new_pack.fXMYZp/_new 2018-07-22 23:05:37.524899683 +0200
@@ -17,14 +17,14 @@
Name: perl-Mojolicious-Plugin-AssetPack
-Version: 2.03
+Version: 2.04
Release: 0
%define cpan_name Mojolicious-Plugin-AssetPack
Summary: Compress and convert css, less, sass, javascript and
coffeescript files
License: Artistic-2.0
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/Mojolicious-Plugin-AssetPack/
-Source0:
https://cpan.metacpan.org/authors/id/M/MR/MRAMBERG/%{cpan_name}-%{version}.tar.gz
+Source0:
https://cpan.metacpan.org/authors/id/J/JH/JHTHORSEN/%{cpan_name}-%{version}.tar.gz
Source1: cpanspec.yml
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
++++++ Mojolicious-Plugin-AssetPack-2.03.tar.gz ->
Mojolicious-Plugin-AssetPack-2.04.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/.vscode/tasks.json
new/Mojolicious-Plugin-AssetPack-2.04/.vscode/tasks.json
--- old/Mojolicious-Plugin-AssetPack-2.03/.vscode/tasks.json 1970-01-01
01:00:00.000000000 +0100
+++ new/Mojolicious-Plugin-AssetPack-2.04/.vscode/tasks.json 2018-04-29
14:07:30.000000000 +0200
@@ -0,0 +1,16 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "prove",
+ "type": "shell",
+ "command": "prove -vlj4",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
+ }
+ ]
+}
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/Changes
new/Mojolicious-Plugin-AssetPack-2.04/Changes
--- old/Mojolicious-Plugin-AssetPack-2.03/Changes 2018-04-26
10:22:06.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/Changes 2018-07-19
11:39:06.000000000 +0200
@@ -1,5 +1,10 @@
Revision history for perl distribution Mojolicious-Plugin-AssetPack
+2.04 2018-07-19T17:39:06+0800
+ - Add support for generating manifest with Favicon pipe
+ - Marked AssetPack::tag_for() as deprecated
+ - Removed support for Mojolicious::Plugin::AssetPack::Backcompat
+
2.03 2018-04-26T10:22:06+0200
- Ensure asset is processed when calling processed
- Update favicon generator URL to use https
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/MANIFEST
new/Mojolicious-Plugin-AssetPack-2.04/MANIFEST
--- old/Mojolicious-Plugin-AssetPack-2.03/MANIFEST 2018-04-26
10:22:07.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/MANIFEST 2018-07-19
11:39:09.000000000 +0200
@@ -1,6 +1,7 @@
.perltidyrc
.ship.conf
.travis.yml
+.vscode/tasks.json
Changes
cpanfile
examples/rollup.pl
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/META.json
new/Mojolicious-Plugin-AssetPack-2.04/META.json
--- old/Mojolicious-Plugin-AssetPack-2.03/META.json 2018-04-26
10:22:07.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/META.json 2018-07-19
11:39:09.000000000 +0200
@@ -1,16 +1,16 @@
{
"abstract" : "Compress and convert css, less, sass, javascript and
coffeescript files",
"author" : [
- "Marcus Ramberg <[email protected]>"
+ "Jan Henning Thorsen <[email protected]>"
],
"dynamic_config" : 0,
- "generated_by" : "ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter
version 2.150005",
+ "generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter
version 2.150010",
"license" : [
"artistic_2"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
- "version" : "2"
+ "version" : 2
},
"name" : "Mojolicious-Plugin-AssetPack",
"no_index" : {
@@ -53,6 +53,6 @@
"web" : "https://github.com/jhthorsen/mojolicious-plugin-assetpack"
}
},
- "version" : "2.03",
- "x_serialization_backend" : "JSON::PP version 2.27300"
+ "version" : "2.04",
+ "x_serialization_backend" : "JSON::PP version 2.97001"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/META.yml
new/Mojolicious-Plugin-AssetPack-2.04/META.yml
--- old/Mojolicious-Plugin-AssetPack-2.03/META.yml 2018-04-26
10:22:07.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/META.yml 2018-07-19
11:39:09.000000000 +0200
@@ -1,13 +1,13 @@
---
abstract: 'Compress and convert css, less, sass, javascript and coffeescript
files'
author:
- - 'Marcus Ramberg <[email protected]>'
+ - 'Jan Henning Thorsen <[email protected]>'
build_requires:
Test::More: '0.88'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 0
-generated_by: 'ExtUtils::MakeMaker version 7.24, CPAN::Meta::Converter version
2.150005'
+generated_by: 'ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version
2.150010'
license: artistic_2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -25,5 +25,5 @@
bugtracker: https://github.com/jhthorsen/mojolicious-plugin-assetpack/issues
homepage: https://github.com/jhthorsen/mojolicious-plugin-assetpack
repository: https://github.com/jhthorsen/mojolicious-plugin-assetpack.git
-version: '2.03'
+version: '2.04'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/Makefile.PL
new/Mojolicious-Plugin-AssetPack-2.04/Makefile.PL
--- old/Mojolicious-Plugin-AssetPack-2.03/Makefile.PL 2018-04-26
10:22:06.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/Makefile.PL 2018-07-19
11:39:06.000000000 +0200
@@ -2,7 +2,7 @@
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
NAME => 'Mojolicious::Plugin::AssetPack',
- AUTHOR => 'Marcus Ramberg <[email protected]>',
+ AUTHOR => 'Jan Henning Thorsen <[email protected]>',
LICENSE => 'artistic_2',
ABSTRACT_FROM => 'lib/Mojolicious/Plugin/AssetPack.pm',
VERSION_FROM => 'lib/Mojolicious/Plugin/AssetPack.pm',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack/Asset.pm
new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack/Asset.pm
---
old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack/Asset.pm
2018-04-26 07:37:12.000000000 +0200
+++
new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack/Asset.pm
2018-07-19 11:08:22.000000000 +0200
@@ -6,6 +6,13 @@
use Mojo::File;
use Mojolicious::Plugin::AssetPack::Util qw(diag has_ro DEBUG);
+my %TAG_TEMPLATE;
+$TAG_TEMPLATE{css} = [qw(link rel stylesheet href)];
+$TAG_TEMPLATE{ico} = [qw(link rel icon href)];
+$TAG_TEMPLATE{js} = [qw(script src)];
+$TAG_TEMPLATE{$_} = [qw(img src)] for qw(gif jpg jpeg png svg);
+$TAG_TEMPLATE{$_} = [qw(source src)] for qw(mp3 mp4 ogg ogv webm);
+
has checksum => sub {
Mojolicious::Plugin::AssetPack::Util::checksum(shift->content) };
has format => sub {
my $self = shift;
@@ -18,6 +25,7 @@
};
has minified => sub { shift->url =~ /\bmin\b/ ? 1 : 0 };
+has renderer => sub { \&_default_renderer };
has _asset => sub {
my $self = shift;
@@ -82,6 +90,15 @@
sub url_for { $_[1]->url_for(assetpack => $_[0]->TO_JSON); }
+sub _default_renderer {
+ my ($asset, $c, $args, @attrs) = @_;
+ my $url = $asset->url_for($c);
+ my @template = @{$TAG_TEMPLATE{$asset->format} || $TAG_TEMPLATE{css}};
+ splice @template, 1, 0, type => $c->app->types->type($asset->format)
+ if $template[0] eq 'source';
+ return $c->tag(@template, Mojo::URL->new("$args->{base_url}$url"), @attrs);
+}
+
sub FROM_JSON {
my ($self, $attrs) = @_;
$self->$_($attrs->{$_}) for grep { defined $attrs->{$_} } qw(checksum format
minified);
@@ -139,6 +156,35 @@
Returns the basename of L</url>, without extension.
+=head2 renderer
+
+ $code = $self->renderer;
+ $self = $self->renderer(sub { my ($c, \%args, @attrs) = @_; return qq(<link
rel="...">) });
+
+Used to register a custom renderer for this asset. The arguments passed in
+are:
+
+=over 2
+
+=item * C<$c>
+
+The L<Mojolicious::Controller> object used for this request.
+
+=item * C<%args>
+
+A hash-ref with "base_url" and
+L<topic|Mojolicious::Plugin::AssetPack::Pipe/topic>. See
+L<Mojolicious::Plugin::AssetPack::Guides::Cookbook/ASSETS FROM CUSTOM DOMAIN>
+of example "base_url".
+
+=item * C<@attrs>
+
+The HTML attributes passed in from the template.
+
+=item
+
+=back
+
=head2 url
$str = $self->url;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack/Pipe/Favicon.pm
new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack/Pipe/Favicon.pm
---
old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack/Pipe/Favicon.pm
2018-04-26 10:17:18.000000000 +0200
+++
new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack/Pipe/Favicon.pm
2018-07-19 11:34:22.000000000 +0200
@@ -2,73 +2,108 @@
use Mojo::Base 'Mojolicious::Plugin::AssetPack::Pipe';
use Mojo::DOM;
+use Mojo::JSON qw(false true);
+use Mojo::Template;
use Mojo::Util;
+use Mojolicious::Plugin::AssetPack::Util 'checksum';
# this should be considered private
-use constant API_URL => $ENV{MOJO_ASSETPACK_FAVICON_API_URL} ||
'https://realfavicongenerator.net/api/favicon';
+use constant API_URL => $ENV{MOJO_ASSETPACK_FAVICON_API_URL}
+ || 'https://realfavicongenerator.net/api/favicon';
has api_key => sub { die 'api_key() must be set' };
-has design => sub { +{desktop_browser => {}} };
+has design => sub { shift->_build_design };
has settings => sub { +{error_on_image_too_small => Mojo::JSON->true} };
-has _icons => sub { +{} };
-
sub process {
my ($self, $assets) = @_;
- return unless $self->topic eq 'favicon.ico';
+ return unless $self->topic =~ m!^favicon(\.\w+)?\.ico$!;
my $store = $self->assetpack->store;
my $asset = $assets->first;
my $attrs = $asset->TO_JSON;
- my ($db, $files, $markup, @icons);
+ my ($urls, $markup, %sub_assets);
- $attrs->{key} = join '-', sort keys %{$self->design}
+ $attrs->{key} = checksum(Mojo::JSON::encode_json($self->design))
or die '[AssetPack] Invalid pipe("Favicon")->design({})';
- if ($db = $store->load($attrs)) {
- ($files, $markup) = split /__MARKUP__/, $db->content;
- $files = [grep {/\w/} split /\n/, $files];
+ if (my $db = $store->load($attrs)) {
+ ($urls, $markup) = split /__MARKUP__/, $db->content;
+ $urls = [grep {/\w/} split /\n/, $urls];
}
else {
- ($files, $markup) = $self->_fetch($assets);
- $db = join "\n", @$files, __MARKUP__ => $markup;
+ ($urls, $markup) = $self->_fetch($asset);
+ $db = join "\n", @$urls, __MARKUP__ => $markup;
$store->save(\$db, $attrs);
}
- for my $url (@$files) {
- push @icons, $store->asset($url)
- or die "AssetPack was unable to fetch icon asset $url";
+ for my $url (@$urls) {
+ my $asset = $store->asset($url)
+ or die "AssetPack was unable to fetch icons/assets asset $url";
+ $sub_assets{join '.', $asset->name, $asset->format} = $asset;
+ $self->assetpack->{by_checksum}{$asset->checksum} = $asset;
}
- $self->assetpack->{by_checksum}{$_->checksum} = $_ for @icons;
- $self->assetpack->{by_topic}{$self->topic} = Mojo::Collection->new(@icons);
-
- for my $child (Mojo::DOM->new($markup)->children->each) {
- my $key = $child->{content} ? 'content' : 'href';
- my $icon = shift @icons;
- $self->_icons->{$icon->url} = [$key => $child, $icon];
- }
-
- if (@icons) {
- my $child
- = Mojo::DOM->new('<link rel="shortcut icon"
href="favicon.ico">')->children->first;
- my $icon = shift @icons;
- $self->_icons->{$icon->url} = [href => $child, $icon];
- }
+ $asset->renderer(
+ sub {
+ my ($asset, $c, $args, @attrs) = @_;
+ $markup
+ =~ s!href="(/?)([^"]+)"!sprintf 'href="%s"', $sub_assets{$2} ?
$sub_assets{$2}->url_for($c) : "$1$2"!ger;
+ }
+ );
}
-sub render {
- my ($self, $c) = @_;
- my $icons = $self->_icons;
- $icons = [map { $icons->{$_} } sort keys %$icons];
- $_->[1]{$_->[0]} = $_->[2]->url_for($c) for @$icons;
- return Mojo::ByteStream->new(join "\n", map { $_->[1] } @$icons);
+sub _build_design {
+ my $self = shift;
+ my $name = ref $self->app;
+ my $bg_color = '#F5F5F5';
+ my $theme_color = '#536DFE';
+
+ return {
+ desktop_browser => {},
+ android_chrome => {
+ manifest => {display => 'standalone', name => $name, orientation =>
'portrait'},
+ picture_aspect => 'shadow',
+ theme_color => $theme_color,
+ },
+ firefox_app => {
+ background_color => $bg_color,
+ circle_inner_margin => '5',
+ keep_picture_in_circle => 'true',
+ picture_aspect => 'circle',
+ manifest => {
+ app_description => '',
+ app_name => $name,
+ developer_name => '',
+ developer_url => '',
+ }
+ },
+ ios => {
+ background_color => $bg_color,
+ margin => '4',
+ picture_aspect => 'background_and_margin',
+ },
+ safari_pinned_tab => {
+ picture_aspect => 'black_and_white',
+ threshold => 60,
+ theme_color => $theme_color,
+ },
+ windows => {
+ background_color => $theme_color,
+ picture_aspect => "white_silhouette",
+ assets => {
+ windows_80_ie_10_tile => true,
+ windows_10_ie_11_edge_tiles =>
+ {big => true, medium => true, rectangle => false, small => false},
+ }
+ },
+ };
}
sub _fetch {
- my ($self, $assets) = @_;
+ my ($self, $asset) = @_;
$self->assetpack->ua->inactivity_timeout(60);
- my $res = $self->assetpack->ua->post(API_URL, json =>
$self->_request($assets))->res;
+ my $res = $self->assetpack->ua->post(API_URL, json =>
$self->_request($asset))->res;
unless ($res->code eq '200') {
my $json = $res->json || {};
@@ -85,7 +120,7 @@
}
sub _request {
- my ($self, $assets) = @_;
+ my ($self, $asset) = @_;
return {
favicon_generation => {
@@ -94,7 +129,7 @@
settings => $self->settings,
files_location => {type => 'path', path => '/'},
master_picture =>
- {content => Mojo::Util::b64_encode($assets->first->content), type =>
'inline'}
+ {content => Mojo::Util::b64_encode($asset->content), type => 'inline'}
}
};
}
@@ -115,9 +150,13 @@
app->asset->pipe("Favicon")->api_key("fd27cc5654345678765434567876545678765556");
app->asset->process("favicon.ico" => "images/favicon.png");
-Note that the topic must be "favicon.ico".
+ # Can also register variations of the favicon:
+ app->asset->process("favicon.variant1.ico" => "images/favicon1.png");
+ app->asset->process("favicon.variant2.ico" => "images/favicon2.png");
-The input image file should be 260x260 for optimal results.
+Note that the topic must be either "favicon.ico" or
"favicon.some_identifier.ico".
+
+The input image file should be a 260x260 PNG file for optimal results.
=head2 Template
@@ -175,16 +214,6 @@
See L<Mojolicious::Plugin::AssetPack::Pipe/process>.
-=head2 render
-
- $bytestream = $self->render($c);
-
-Used to render the favicons as HTML.
-
-=head1 TODO
-
-Add support for different icons for each platform.
-
=head1 SEE ALSO
L<http://realfavicongenerator.net>.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm
new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm
---
old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm
2018-04-26 07:37:12.000000000 +0200
+++
new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack/Pipe/Sass.pm
2018-05-30 03:43:46.000000000 +0200
@@ -65,7 +65,8 @@
}
else {
my @args = (qw(sass -s), map { ('-I', $_) } @{$opts{include_paths}});
- push @args, '--scss' if $asset->format eq 'scss';
+ push @args, '--scss' if $asset->format eq 'scss';
+ push @args, qw(-t compressed) if $attrs->{minified};
$self->run(\@args, \$content, \my $css, undef);
$asset->content($store->save(\$css, $attrs))->FROM_JSON($attrs);
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack.pm
new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack.pm
--- old/Mojolicious-Plugin-AssetPack-2.03/lib/Mojolicious/Plugin/AssetPack.pm
2018-04-26 10:22:06.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/lib/Mojolicious/Plugin/AssetPack.pm
2018-07-19 11:39:06.000000000 +0200
@@ -1,19 +1,12 @@
package Mojolicious::Plugin::AssetPack;
use Mojo::Base 'Mojolicious::Plugin';
-use Mojo::Util 'trim';
+use Mojo::Util qw(deprecated trim);
use Mojolicious::Plugin::AssetPack::Asset::Null;
use Mojolicious::Plugin::AssetPack::Store;
use Mojolicious::Plugin::AssetPack::Util qw(diag has_ro load_module DEBUG);
-our $VERSION = '2.03';
-
-my %TAG_TEMPLATE;
-$TAG_TEMPLATE{css} = [qw(link rel stylesheet href)];
-$TAG_TEMPLATE{ico} = [qw(link rel icon href)];
-$TAG_TEMPLATE{js} = [qw(script src)];
-$TAG_TEMPLATE{$_} = [qw(img src)] for qw(gif jpg jpeg png svg);
-$TAG_TEMPLATE{$_} = [qw(source src)] for qw(mp3 mp4 ogg ogv webm);
+our $VERSION = '2.04';
has minify => sub { shift->_app->mode eq 'development' ? 0 : 1 };
@@ -31,23 +24,6 @@
);
};
-has tag_for => sub {
- my $self = shift;
- my $favicon = $self->pipe('Favicon') ? 1 : 0;
-
- Scalar::Util::weaken($self);
- return sub {
- my ($asset, $c, $args, @attrs) = @_;
- return $self->pipe('Favicon')->render($c)
- if $args->{topic} eq 'favicon.ico' and $favicon;
- my $url = $asset->url_for($c);
- my @template = @{$TAG_TEMPLATE{$_->format} || $TAG_TEMPLATE{css}};
- splice @template, 1, 0, type => $c->app->types->type($asset->format)
- if $template[0] eq 'source';
- return $c->tag(@template, Mojo::URL->new("$args->{base_url}$url"), @attrs);
- };
-};
-
has_ro ua => sub { Mojo::UserAgent->new->max_redirects(3) };
sub pipe {
@@ -103,19 +79,17 @@
$self->ua->proxy->detect;
}
- if ($config->{pipes}) {
- $self->_pipes($config->{pipes});
- $app->helper($helper => sub { @_ == 1 ? $self : $self->_render_tags(@_) });
- }
- else {
- $app->log->warn(
- 'https://metacpan.org/release/Mojolicious-Plugin-AssetPack-Backcompat is
required');
- Test::More::diag("Loading DEPRECATED
Mojolicious::Plugin::AssetPack::Backcompat.")
- if $ENV{HARNESS_ACTIVE} and UNIVERSAL::can(qw(Test::More diag));
- require Mojolicious::Plugin::AssetPack::Backcompat;
- @Mojolicious::Plugin::AssetPack::ISA =
('Mojolicious::Plugin::AssetPack::Backcompat');
- return $self->SUPER::register($app, $config);
- }
+ $self->_pipes($config->{pipes} || []);
+ $app->helper($helper => sub { @_ == 1 ? $self : $self->_render_tags(@_) });
+}
+
+sub tag_for {
+ my $self = shift;
+ deprecated
+ 'tag_for() is DEPRECATED in favor of
Mojolicious::Plugin::AssetPack::Asset::renderer()';
+ return $self->{tag_for} unless @_;
+ $self->{tag_for} = shift;
+ return $self;
}
sub _app { shift->ua->server->app }
@@ -170,6 +144,10 @@
}
}
+ if (my $renderer = $self->{tag_for}) {
+ $_->{renderer} or $_->{renderer} = $renderer for @$assets;
+ }
+
my @checksum = map { $_->checksum } @$assets;
$self->_app->log->debug(qq(Processed asset "$topic". [@checksum])) if DEBUG;
$self->{by_checksum}{$_->checksum} = $_ for @$assets;
@@ -215,8 +193,11 @@
my %args = (base_url => $route->pattern->defaults->{base_url} || '', topic
=> $topic);
$args{base_url} =~ s!/+$!!;
- return $assets->grep(sub {
!$_->isa('Mojolicious::Plugin::AssetPack::Asset::Null') })
- ->map($self->tag_for, $c, \%args, @attrs)->join("\n");
+ return Mojo::ByteStream->new(
+ join "\n",
+ map { $_->renderer->($_, $c, \%args, @attrs) }
+ grep { !$_->isa('Mojolicious::Plugin::AssetPack::Asset::Null') } @$assets
+ );
}
sub _serve {
@@ -257,7 +238,7 @@
=head1 VERSION
-2.03
+2.04
=head1 SYNOPSIS
@@ -392,27 +373,7 @@
=head2 tag_for
- $self = $self->tag_for(sub { my ($asset, $c, \%args, @attrs) = @_; });
- $code = $self->tag_for;
-
-Holds a sub reference that returns a L<Mojo::Bytestream> object containing the
-markup required to render an asset.
-
-C<$asset> is a L<Mojolicious::Plugin::AssetPack::Asset> object, C<$c> is an
-L<Mojolicious::Controller> object and C<@attrs> can contain a list of
-HTML attributes. C<%args> currently contains:
-
-=over 4
-
-=item * base_url
-
-See L<Mojolicious::Plugin::AssetPack::Guides::Cookbook/ASSETS FROM CUSTOM
DOMAIN>.
-
-=item * topic
-
-Name of the current topic.
-
-=back
+Deprecated. Use L<Mojolicious::Plugin::AssetPack::Asset/renderer> instead.
=head2 ua
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/t/Helper.pm
new/Mojolicious-Plugin-AssetPack-2.04/t/Helper.pm
--- old/Mojolicious-Plugin-AssetPack-2.03/t/Helper.pm 2018-04-26
07:37:12.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/t/Helper.pm 2018-07-19
09:54:31.000000000 +0200
@@ -28,7 +28,7 @@
sub cleanup {
$CREATED_FILES{path($ENV{TEST_HOME}, 'assets',
$ENV{MOJO_ASSETPACK_DB_FILE})} = 1
- if $ENV{MOJO_ASSETPACK_DB_FILE};
+ if $ENV{MOJO_ASSETPACK_DB_FILE} and !$ENV{TEST_KEEP_FILES};
unlink $_ for keys %CREATED_FILES;
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/t/favicon.t
new/Mojolicious-Plugin-AssetPack-2.04/t/favicon.t
--- old/Mojolicious-Plugin-AssetPack-2.03/t/favicon.t 2018-04-26
07:37:12.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/t/favicon.t 2018-07-19
11:34:36.000000000 +0200
@@ -7,12 +7,35 @@
my $t = t::Helper->t(pipes => [qw(Favicon)]);
$t->app->asset->pipe('Favicon')->api_key($ENV{TEST_REALFAVICONGENERATOR_API_KEY});
$t->app->asset->process('favicon.ico' =>
'/image/master_favicon_thumbnail.png');
-$t->get_ok('/')->status_is(200)->element_exists('[sizes="16x16"]')
- ->element_exists('[sizes="32x32"]');
-like $t->tx->res->dom->at('[rel="shortcut icon"]')->{href}, qr{/favicon\.ico$},
- 'plain favicon';
-$t->get_ok($t->tx->res->dom->at('[sizes="16x16"]')->{href})->status_is(200);
+$t->get_ok('/')->status_is(200)
+
->element_exists('[href$="114x114.png"][rel="apple-touch-icon"][sizes="114x114"]')
+
->element_exists('[href$="120x120.png"][rel="apple-touch-icon"][sizes="120x120"]')
+
->element_exists('[href$="57x57.png"][rel="apple-touch-icon"][sizes="57x57"]')
+
->element_exists('[href$="60x60.png"][rel="apple-touch-icon"][sizes="60x60"]')
+
->element_exists('[href$="72x72.png"][rel="apple-touch-icon"][sizes="72x72"]')
+
->element_exists('[href$="76x76.png"][rel="apple-touch-icon"][sizes="76x76"]')
+
->element_exists('[href$="16x16.png"][rel="icon"][sizes="16x16"][type="image/png"]')
+
->element_exists('[href$="32x32.png"][rel="icon"][sizes="32x32"][type="image/png"]')
+
->element_exists('[href$="safari-pinned-tab.svg"][color="#536DFE"][rel="mask-icon"]')
+ ->element_exists('[href$="site.webmanifest"][rel="manifest"]')
+ ->element_exists('[name="msapplication-TileColor"][content="#536DFE"]')
+ ->element_exists('[name="theme-color"][content="#536DFE"]');
+
+# Make sure that all the [href] above looks like
/asset/19b5e7c873/apple-touch-icon-57x57.png
+$t->tx->res->dom->find("[href]")->each(
+ sub {
+ like $_->{href}, qr{^/asset/\w+/\w+.*$}, "href $_->{href}";
+ }
+);
+
+{
+ no warnings 'redefine';
+ local *Mojolicious::Plugin::AssetPack::Pipe::Favicon::_request = sub { die
$_[1] };
+ eval { $t->app->asset->process('favicon.cool_beans.ico' =>
'/image/sample.png') };
+ like "$@", qr{Mojolicious::Plugin::AssetPack::Asset},
+ 'will also process variants of the favicon';
+}
done_testing;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/t/riotjs.t
new/Mojolicious-Plugin-AssetPack-2.04/t/riotjs.t
--- old/Mojolicious-Plugin-AssetPack-2.03/t/riotjs.t 2018-04-26
07:37:12.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/t/riotjs.t 2018-07-19
11:14:40.000000000 +0200
@@ -1,5 +1,8 @@
use lib '.';
use t::Helper;
+
+plan skip_all => 'cpanm JavaScript::Minifier::XS'
+ unless eval 'require JavaScript::Minifier::XS;1';
plan skip_all => 'TEST_RIOTJS=1' unless $ENV{TEST_RIOTJS} or -e
'.test-everything';
my $t = t::Helper->t(pipes => [qw(Riotjs JavaScript)]);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Mojolicious-Plugin-AssetPack-2.03/t/sass-bin.t
new/Mojolicious-Plugin-AssetPack-2.04/t/sass-bin.t
--- old/Mojolicious-Plugin-AssetPack-2.03/t/sass-bin.t 2018-04-26
07:37:12.000000000 +0200
+++ new/Mojolicious-Plugin-AssetPack-2.04/t/sass-bin.t 2018-05-30
03:43:46.000000000 +0200
@@ -4,10 +4,9 @@
my $t = t::Helper->t(pipes => [qw(Sass Css)]);
my $sass = $t->app->asset->pipe('Sass');
-
isa_ok($sass, 'Mojolicious::Plugin::AssetPack::Pipe::Sass');
-
$sass->{has_module} = ''; # make sure CSS::Sass is not used
+
$t->app->asset->process('app.css' => ('sass.sass', 'sass/sass-1.scss'));
$t->get_ok('/')->status_is(200)
->element_exists(qq(link[href="/asset/8d347a7a6f/sass.css"]))
@@ -20,6 +19,14 @@
$t->get_ok($html->at('link:nth-of-child(2)')->{href})->status_is(200)
->content_like(qr{footer.*\#aaa.*body.*\#222}s);
+$ENV{MOJO_MODE} = 'Test_minify_from_here';
+$t = t::Helper->t(pipes => [qw(Sass Css Combine)]);
+$t->app->asset->pipe('Sass')->{has_module} = ''; # make sure CSS::Sass is
not used
+$t->app->asset->process('app.css' => ('sass.sass', 'sass/sass-1.scss'));
+$t->get_ok('/')->status_is(200);
+$t->get_ok($t->tx->res->dom->at('link')->{href})->status_is(200)->content_unlike(qr/[
]/)
+ ; # No spaces in minified
version
+
done_testing;
__DATA__