line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::View::GD::Barcode::QRcode; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
116
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use base qw(Catalyst::View); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
978
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
1232
|
use MRO::Compat; |
|
1
|
|
|
|
|
4381
|
|
|
1
|
|
|
|
|
33
|
|
11
|
1
|
|
|
1
|
|
2422
|
use GD::Barcode::QRcode; |
|
1
|
|
|
|
|
26219
|
|
|
1
|
|
|
|
|
548
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw( ecc version module_size img_type )); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub new { |
16
|
0
|
|
|
0
|
|
|
my ($class, $c, $args) = @_; |
17
|
0
|
|
|
|
|
|
my $self = $class->next::method($c, $args); |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
$self->ecc($args->{ecc}); |
20
|
0
|
|
|
|
|
|
$self->version($args->{version}); |
21
|
0
|
|
|
|
|
|
$self->module_size($args->{module_size}); |
22
|
0
|
|
|
|
|
|
$self->img_type($args->{img_type}); |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
return $self |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub process { |
28
|
0
|
|
|
0
|
|
|
my ($self, $c) = @_; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
0
|
|
|
|
my $conf = $c->stash->{qrcode_conf} || $self->config; |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
0
|
|
|
|
my $ecc = $conf->{ecc} || $self->ecc || 'M'; |
33
|
0
|
|
0
|
|
|
|
my $version = $conf->{version} || $self->version || 4; |
34
|
0
|
|
0
|
|
|
|
my $module_size = $conf->{module_size} || $self->module_size || 1; |
35
|
0
|
|
0
|
|
|
|
my $img_type = $conf->{img_type} || $self->img_type || 'png'; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $text = $c->stash->{qrcode}; |
38
|
0
|
|
|
|
|
|
my $qrcode = GD::Barcode::QRcode->new( |
39
|
|
|
|
|
|
|
$text, { |
40
|
|
|
|
|
|
|
Ecc => $ecc, |
41
|
|
|
|
|
|
|
Version => $version, |
42
|
|
|
|
|
|
|
ModuleSize => $module_size |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
); |
45
|
0
|
|
|
|
|
|
my $gd = $qrcode->plot(); |
46
|
0
|
|
|
|
|
|
$c->res->content_type("image/$img_type"); |
47
|
0
|
|
|
|
|
|
$c->res->body($gd->$img_type()); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
51
|
|
|
|
|
|
|
__END__ |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 NAME |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Catalyst::View::GD::Barcode::QRcode - GD::Barcode::QRcode View Class |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Create a View class using the helper |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
script/myapp_create.pl view QRcode GD::Barcode::QRcode |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Configure variables in your application class |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
package MyApp; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
MyApp->config( |
69
|
|
|
|
|
|
|
'View::QRcode' => { |
70
|
|
|
|
|
|
|
ecc => 'M', |
71
|
|
|
|
|
|
|
version => 4, |
72
|
|
|
|
|
|
|
module_size => 1, |
73
|
|
|
|
|
|
|
img_type => 'png' |
74
|
|
|
|
|
|
|
}, |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Or using YAML config file |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
View::QRcode: |
80
|
|
|
|
|
|
|
ecc: 'M' |
81
|
|
|
|
|
|
|
version: 4 |
82
|
|
|
|
|
|
|
module_size: 1 |
83
|
|
|
|
|
|
|
img_type: 'png' |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Add qrcode action to forward to the View on MyApp::Controller::Root |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub qrcode : Local { |
88
|
|
|
|
|
|
|
my ( $self, $c ) = @_; |
89
|
|
|
|
|
|
|
$c->stash->{qrcode} = 'http://www.cpan.org'; |
90
|
|
|
|
|
|
|
$c->forward( $c->view( 'QRcode' ) ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Or change configuration dynamically |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub qrcode : Local { |
96
|
|
|
|
|
|
|
my ( $self, $c ) = @_; |
97
|
|
|
|
|
|
|
$c->stash( |
98
|
|
|
|
|
|
|
qrcode => 'http://www.cpan.org', |
99
|
|
|
|
|
|
|
qrcode_conf => { |
100
|
|
|
|
|
|
|
ecc => 'Q', |
101
|
|
|
|
|
|
|
version => 5, |
102
|
|
|
|
|
|
|
module_size => 3, |
103
|
|
|
|
|
|
|
img_type => 'gif', |
104
|
|
|
|
|
|
|
}, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$c->forward( $c->view( 'QRcode' ) ); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Catalyst::View::GD::Barcode::QRcode is the Catalyst view class for GD::Barcode::QRcode, create QRcode barcode image with GD. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 CONFIG VARIABLES |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=over 4 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item ecc |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
ECC mode. Select 'M', 'L', 'H' or 'Q' (Default = 'M'). |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item version |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Version ie. size of barcode image (Default = 4). |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item module_size |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Size of modules (barcode unit) (Default = 1). |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item img_type |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Type of barcode image (Default = 'png'). |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=head1 AUTHOR |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Hideo Kimura C<< <<hide@hide-k.net>> >> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 LICENSE |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
This program is free software; you can redistribute |
145
|
|
|
|
|
|
|
it and/or modify it under the same terms as Perl itself. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The full text of the license can be found in the |
148
|
|
|
|
|
|
|
LICENSE file included with this module. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|