Mojolicious-Plugin-Badge
view release on metacpan or search on metacpan
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Image::Magick" : "0",
"Mojolicious" : "9.0"
}
},
"test" : {
"requires" : {
"Test::More" : "0"
}
}
},
"release_status" : "stable",
license: artistic_2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Mojolicious-Plugin-Badge
no_index:
directory:
- t
- inc
requires:
Image::Magick: '0'
Mojolicious: '9.0'
resources:
bugtracker: https://github.com/giterlizzi/perl-Mojolicious-Plugin-Badge/issues
repository: git://github.com/giterlizzi/perl-Mojolicious-Plugin-Badge
version: '1.12'
x_purl: pkg:cpan/GDT/Mojolicious-Plugin-Badge
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
Makefile.PL view on Meta::CPAN
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => 'Mojolicious::Plugin::Badge',
VERSION_FROM => 'lib/Mojolicious/Plugin/Badge.pm',
ABSTRACT_FROM => 'lib/Mojolicious/Plugin/Badge.pm',
LICENSE => 'artistic_2',
AUTHOR => q{Giuseppe Di Terlizzi <gdt@cpan.org>},
CONFIGURE_REQUIRES => {'ExtUtils::MakeMaker' => '0',},
TEST_REQUIRES => {'Test::More' => '0',},
PREREQ_PM => {'Mojolicious' => '9.0', 'Image::Magick' => 0},
META_MERGE => {
'meta-spec' => {version => 2},
'resources' => {
bugtracker => {web => 'https://github.com/giterlizzi/perl-Mojolicious-Plugin-Badge/issues'},
repository => {
type => 'git',
url => 'git://github.com/giterlizzi/perl-Mojolicious-Plugin-Badge',
web => 'https://github.com/giterlizzi/perl-Mojolicious-Plugin-Badge'
},
},
lib/Mojolicious/Plugin/Badge.pm view on Meta::CPAN
package Mojolicious::Plugin::Badge;
use Mojo::Base 'Mojolicious::Plugin';
use Carp ();
use Image::Magick;
use Mojo::ByteStream;
use Mojo::File qw(path);
use Mojo::URL;
use Mojo::UserAgent;
use Mojo::Util qw(b64_encode);
use Mojolicious::Types;
our $VERSION = '1.12';
use constant DEBUG => $ENV{BADGE_PLUGIN_DEBUG} || 0;
lib/Mojolicious/Plugin/Badge.pm view on Meta::CPAN
my %badge_options = _build_options(%options);
DEBUG and $c->log->debug('[Badge] User Config', $c->app->dumper(\%options));
DEBUG and $c->log->debug('[Badge] Badge Config', $c->app->dumper(\%badge_options));
my $svg = $c->render_to_string('badge', format => 'svg', %badge_options);
if ($badge_options{badge_format} eq 'png') {
my $image = Image::Magick->new(magick => 'svg');
$image->BlobToImage($svg);
return $image->ImageToBlob(magick => 'png');
}
# Minify SVG
$svg =~ s/^(\s+)//mg;
$svg =~ s/\n//mg;
lib/Mojolicious/Plugin/Badge.pm view on Meta::CPAN
}
return sprintf('data:%s;base64,%s', $content_type, b64_encode($content));
}
sub _get_text_width {
my ($text, %properties) = @_;
my $image = Image::Magick->new;
$properties{pointsize} ||= 110;
$properties{text} ||= $text;
$properties{gravity} ||= 'northwest';
$properties{font} ||= 'DejaVu-Sans';
$image->Set(size => '1x1');
$image->ReadImage('xc:none');
my ($x_ppem, $y_ppem, $ascender, $descender, $width, $height, $max_advance)
( run in 1.798 second using v1.01-cache-2.11-cpan-beeb90c9504 )