diff --git a/VERSION b/VERSION index 73462a5a13445f66009e00988279d30e55aa8363..e70b4523ae7ffe8aa3cac8ecd1b093fba5a98737 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5.1 +2.6.0 diff --git a/lib/PZ/Controller/Shortcut.pm b/lib/PZ/Controller/Shortcut.pm index 199dd2a2706219e4f5265c2abd07d9941a89c4c1..310427f99eb90ce2e2bfeb4f24cb2d14e8e5d41e 100644 --- a/lib/PZ/Controller/Shortcut.pm +++ b/lib/PZ/Controller/Shortcut.pm @@ -3,6 +3,7 @@ use Mojo::Base 'Mojolicious::Controller', -signatures; use Data::Validate::URI qw(is_uri); use Image::PNG::QRCode 'qrpng'; +use GD; use Mojo::UserAgent; use constant SHORTCUT => qr/^[a-z\d\-]{1,32}$/; @@ -19,19 +20,6 @@ sub redirect ($c) { return; } -# TRACKER: -# foreach my $tracker ( $c->trackers() ) { -# if ( $c->param($tracker) ) { -# $c->stash( -# url => $shortcut->url, -# tracker_name => $tracker, -# tracker_value => $c->param($tracker), -# ); -# $c->render( 'tracker' ); -# return; -# } -# } - $shortcut->update({ counter => $shortcut->counter + 1 }); @@ -125,10 +113,22 @@ sub list ($c) { sub qr ($c) { - my $url = 'https://' . $c->config->{domain} . '/' . $c->stash->{shortcut}; - my $png = qrpng (text => $url, level => 4, scale => 5); + my $url = 'https://' . $c->config->{domain} . '/' . $c->stash->{shortcut}; + $c->trace($url); + + my $png = qrpng (text => $url, level => 4, scale => 6); + + my $qr = GD::Image->new($png); + my $logo = GD::Image->new($c->app->home . '/public/logo.png'); + + $qr->trueColor(1); + $logo->trueColor(1); + $logo->transparent($logo->colorClosest($logo->rgb($logo->getPixel(0,0)))); + + $qr->copyMerge($logo,73,73,0,0,100,100,80); + $c->res->headers->content_type('image/png'); - $c->render( data => $png ); + $c->render( data => $qr->png ); } 1; diff --git a/public/logo.png b/public/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..1cfb676d57f1e9a2f7a7c79876f6262c9435c70a Binary files /dev/null and b/public/logo.png differ diff --git a/templates/shortcuts.html.ep b/templates/shortcuts.html.ep index 10d2b69dd067f2a6091e2133f72f8070ff416112..ff73b268e77c7ae144f84766f8c1b1a4b9c69f7d 100644 --- a/templates/shortcuts.html.ep +++ b/templates/shortcuts.html.ep @@ -267,6 +267,7 @@ }, showInfo: function(shortcut) { + this.selectedShortcut = shortcut; this.selectedShortcut.full_url = 'https://<%= config->{domain} %>/'+ shortcut.shortcut ; this.shortcutInfoVisible = true; navigator.clipboard.writeText(this.selectedShortcut.full_url);