line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::StaticImageGallery; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
2
|
|
|
2
|
|
46560
|
$App::StaticImageGallery::VERSION = '0.002'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1276
|
use App::StaticImageGallery::Dir; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
70
|
|
7
|
2
|
|
|
2
|
|
17
|
use Path::Class (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
42
|
|
8
|
2
|
|
|
2
|
|
2517
|
use Getopt::Lucid qw( :all ); |
|
2
|
|
|
|
|
64708
|
|
|
2
|
|
|
|
|
476
|
|
9
|
2
|
|
|
2
|
|
3514
|
use Pod::Usage; |
|
2
|
|
|
|
|
130403
|
|
|
2
|
|
|
|
|
290
|
|
10
|
2
|
|
|
2
|
|
25
|
use File::Path (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
1605
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new_with_options { |
13
|
2
|
|
|
2
|
1
|
694
|
my $class = shift; |
14
|
|
|
|
|
|
|
|
15
|
2
|
|
|
|
|
15
|
my @specs = ( |
16
|
|
|
|
|
|
|
Counter("verbose|v"), |
17
|
|
|
|
|
|
|
Counter("quiet|q"), |
18
|
|
|
|
|
|
|
Switch("recursive")->default( 1 ), |
19
|
|
|
|
|
|
|
Param("style|s")->default("Simple"), |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $cb = sub { |
23
|
0
|
|
|
0
|
|
0
|
my ($self) = @_; |
24
|
0
|
|
|
|
|
0
|
print "TODO Command ",$self->cmd_name,"\n"; |
25
|
2
|
|
|
|
|
103
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $self = { |
28
|
|
|
|
|
|
|
_opt => Getopt::Lucid->getopt(\@specs), |
29
|
|
|
|
|
|
|
_cmd_name => shift @ARGV, |
30
|
|
|
|
|
|
|
_work_dir => shift @ARGV || '.', |
31
|
|
|
|
|
|
|
_cmd_dipatcher => { |
32
|
0
|
|
|
0
|
|
0
|
build => sub { shift->cmd_build(@_) }, |
33
|
|
|
|
|
|
|
help => sub { |
34
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
35
|
0
|
|
|
|
|
0
|
pod2usage( |
36
|
|
|
|
|
|
|
-input => __FILE__, |
37
|
|
|
|
|
|
|
-verbose => 99, |
38
|
|
|
|
|
|
|
-exitval => 0, |
39
|
|
|
|
|
|
|
-sections => ['NAME','VERSION','SYNOPSIS','COMMANDS','OPTIONS'] |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
imager_formats => sub { |
44
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
45
|
0
|
|
|
|
|
0
|
require Imager; |
46
|
0
|
|
|
|
|
0
|
$self->msg("Supported image formats: " . join(', ',keys %Imager::formats) . '.'); |
47
|
|
|
|
|
|
|
}, |
48
|
0
|
|
|
0
|
|
0
|
clean => sub { shift->cmd_clean(@_); }, |
49
|
|
|
|
|
|
|
rebuild => sub { |
50
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
51
|
0
|
|
|
|
|
0
|
$self->cmd_clean(@_); |
52
|
0
|
|
|
|
|
0
|
$self->cmd_build(@_); |
53
|
|
|
|
|
|
|
}, |
54
|
2
|
|
50
|
|
|
16
|
init => $cb, |
55
|
|
|
|
|
|
|
list_styles => $cb, |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
}; |
58
|
2
|
|
|
|
|
1739
|
bless $self, $class; |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
13
|
$self->msg_verbose(2,"Work dir: %s", $self->{_work_dir}); |
61
|
2
|
|
|
|
|
6
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
8
|
|
|
8
|
1
|
1676
|
sub opt { shift->{_opt} }; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub config { |
67
|
|
|
|
|
|
|
return { |
68
|
0
|
|
|
0
|
1
|
0
|
data_dir_name => '.StaticImageGallery', |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
2
|
|
|
2
|
1
|
780
|
sub cmd_name { shift->{_cmd_name}; }; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _disptach_cmd { |
75
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
76
|
0
|
0
|
|
|
|
0
|
if (defined $self->{_cmd_dipatcher}->{ $self->cmd_name } ){ |
77
|
0
|
|
|
|
|
0
|
$self->{_cmd_dipatcher}->{ $self->cmd_name }($self); |
78
|
|
|
|
|
|
|
}else{ |
79
|
0
|
|
|
|
|
0
|
die sprintf("Command '%s' not found.",$self->cmd_name); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub cmd_build { |
84
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
my $dir = App::StaticImageGallery::Dir->new( |
87
|
|
|
|
|
|
|
ctx => $self, |
88
|
|
|
|
|
|
|
work_dir => Path::Class::dir( $self->{_work_dir} ), |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
0
|
$dir->write_index(); |
92
|
0
|
|
|
|
|
0
|
return; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub cmd_clean { |
96
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
0
|
my $dir = App::StaticImageGallery::Dir->new( |
99
|
|
|
|
|
|
|
ctx => $self, |
100
|
|
|
|
|
|
|
work_dir => Path::Class::dir( $self->{_work_dir} ), |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
0
|
return $dir->clean_work_dir(); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub run { |
107
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
108
|
0
|
|
|
|
|
0
|
$self->_disptach_cmd(); |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub msg_verbose { |
112
|
2
|
|
|
2
|
1
|
3
|
my $self = shift; |
113
|
2
|
|
|
|
|
4
|
my $level = shift; |
114
|
2
|
|
|
|
|
3
|
my $format = shift; |
115
|
2
|
50
|
|
|
|
8
|
return if $self->opt->get_verbose() == 0; |
116
|
|
|
|
|
|
|
|
117
|
2
|
50
|
|
|
|
85
|
if ( $self->opt->get_verbose() >= $level ){ |
118
|
2
|
|
|
|
|
148
|
printf '[sig:VERBOSE:%2s] ' . $format . "\n" ,$level,@_; |
119
|
|
|
|
|
|
|
} |
120
|
2
|
|
|
|
|
8
|
return; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub msg { |
124
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
125
|
0
|
|
|
|
|
|
my $format = shift; |
126
|
0
|
0
|
|
|
|
|
return if $self->opt->get_quiet() > 0; |
127
|
0
|
|
|
|
|
|
printf '[sig] ' . $format . "\n" ,@_; |
128
|
0
|
|
|
|
|
|
return; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub msg_warning { |
132
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
133
|
0
|
|
|
|
|
|
my $format = shift; |
134
|
0
|
|
|
|
|
|
printf STDERR $format . "\n" ,@_; |
135
|
0
|
|
|
|
|
|
return; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub msg_error { |
139
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
140
|
0
|
|
|
|
|
|
my $format = shift; |
141
|
0
|
|
|
|
|
|
printf STDERR $format . "\n" ,@_; |
142
|
0
|
|
|
|
|
|
return; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
1; # End of App::StaticImageGallery |
146
|
|
|
|
|
|
|
__END__ |
147
|
|
|
|
|
|
|
=head1 NAME |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
App::StaticImageGallery - Static Image Gallery |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 VERSION |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
version 0.002 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 SYNOPSIS |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
./bin/sig [command] [options] |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COMMANDS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 build [dir] |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Create image gallery |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Dir: Working directory, direcotry with the images. |
166
|
|
|
|
|
|
|
Write html pages and thumbnails into this directory. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head2 imager_formats |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
List all available image formats |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head2 init |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Initila App-StaticImageGallery |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 list_styles |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
List all available styles and there source |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 clean |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Remove all image gallery files |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 rebuild |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Run command clean and build. |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 OPTIONS |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head2 B<--style|-s> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=over 4 |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=item Default: Simple |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Set the style/theme. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head2 B<--help|-h> |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Print a brief help message and exits. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
=head2 B<-v> |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
Verbose mode, more v more output... |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head2 B<--quiet|-q> |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Quite mode |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head2 B<--no-recursive> |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Disabled recursiv mode |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 METHODS |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=over 4 |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item new_with_options |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item config |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Returns the config hashref, at the moment the configuration is hardcode in StaticImageGallery.pm |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item msg |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
If not in quite mode, print message to STDOUT. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item msg_error |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
Print message at any time to STDERR. |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item msg_verbose |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item msg_warning |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
Print message at any time to STDERR. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=item opt |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Returns the L<Getopt::Lucid> object. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item run |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=item cmd_build |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Command build |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item cmd_clean |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Command clean |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item cmd_name |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Name of the current command |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=back |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head1 TODO |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=over 4 |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=item * Documentation |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item * Sourcecode cleanup |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=item * Write Dispatcher |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
App::StaticImageGallery::Style::Source::Dispatcher |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=item * App::StaticImageGallery::Image line: 31, errorhandling |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=item * Test unsupported format |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=item * Added config file support ( App::StaticImageGallery->config ) |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
=item * Write App::StaticImageGallery::Style::Source::FromDir |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
=item * Add config file ~/.sig/config.ini |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=back |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
Copyright 2010 Robert Bohne. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
290
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
291
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
=head1 AUTHOR |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
Robert Bohne, C<< <rbo at cpan.org> >> |