Website/Configure.pm

filter: Statementstmt 22.9% 28 / 122 Branchbran 0.0% 0 / 40 Conditioncond 0.0% 0 / 74 MC/DCmcdc 0.0% 0 / 38 Subroutinesub 57.1% 8 / 14 Podpod 0.0% 0 / 6 totaltotal 12.2% 36 / 294 CC 52 SCAR 73.3
CC
52
Cov
12%
album
2162.0
save_config
12.0
is_image
12.0
CRAP 1531.7
↑ Summary Website.pm »
1 1 my $DIST = 'Photography-Website';
2 package Photography::Website::Configure;
3 1 $Photography::Website::Configure::VERSION = '0.27';
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use DateTime;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Basename qw(basename dirname);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use File::ShareDir qw(dist_file);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use File::Spec::Functions qw(catfile);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Config::General qw(ParseConfig);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use String::Random qw(random_regex);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 my $CONFIG_FILE = "photog.ini";
15  
16 =head1 NAME
17  
18 Photography::Website::Configure - List of Configuration Options
19  
20 =head1 DESCRIPTION
21  
22 This module contains the configuration logic of Photog! the
23 photography website generator. See L<photog> for the documentation
24 about the command-line interface and see L<Photography::Website> for
25 documentation about the Perl interface.
26  
27 What follows is a comprehensive list of all configuration options
28 currently in use, with a short description of their usage and their
29 default value.
30  
31 =head2 Image variables
32  
33 =over 12
34  
35 =cut
36  
37 0 ▶sub image {
Subroutine image: not called CC=2 SCAR=17.9
Pod undocumented
38 0 my $source = shift;
39 0 my $parent = shift;
40 0 ▶ return if not is_image($source);
Branch: 1 branch
BranchTrueFalseTotal
unless is_image($source) 0 0 0
41 0 my $img = {
42 type => 'image',
43 parent => $parent,
44 };
45 0 my $filename = basename($source);
46  
47 =item B<name>
48  
49 The image filename without the extension. Is used by the default
50 template as the caption when the image is viewed fullscreen.
51  
52 =cut
53  
54 0 $img->{name} = strip_suffix($filename);
55  
56 =item B<url>
57  
58 The absolute URL of the fullscreen image. This is used to calculate
59 the image destination. Templates should use the relative URL (see next).
60  
61 =cut
62  
63 0 $img->{url} = $parent->{url} . $filename;
64  
65 =item B<href>
66  
67 The relative URL of the full-size image, i.e., the image filename.
68  
69 =cut
70  
71 0 $img->{href} = $filename;
72  
73 =item B<src>
74  
75 The relative URL of the image thumbnail, i.e., C<thumbnails/$filename>.
76  
77 =cut
78  
79 0 $img->{src} = "thumbnails/$filename";
80  
81 =item B<source>
82  
83 The full path to the original image in the source directory.
84  
85 =cut
86  
87 0 $img->{source} = $source;
88  
89 =item B<destination>
90  
91 The full path to the fullscreen image in the destination directory.
92  
93 =cut
94  
95 0 $img->{destination} = catfile($parent->{root}, substr($img->{url}, 1));
96  
97 =item B<thumbnail>
98  
99 The path to the image thumbnail.
100  
101 =cut
102  
103 0 $img->{thumbnail} = catfile($parent->{destination}, $img->{src});
104  
105  
106 # These are documented further below
107 0 $img->{watermark} = $parent->{watermark};
108 0 $img->{scale_command} = $parent->{scale_command};
109 0 $img->{watermark_command} = $parent->{watermark_command};
110 0 $img->{thumbnail_command} = $parent->{thumbnail_command};
111 0 return $img;
112 }
113  
114 =back
115  
116 =head2 Album variables
117  
118 There are three types of album configuration variables: static variables,
119 dynamic variables, and inherited variables. Static variables cannot be
120 changed from a configuration file. Dynamic variables can be set in a
121 configuration or they are calculated dynamically. Inherited variables
122 are either set from a configuration file, inherited from the parent,
123 or a default value.
124  
125 =over 12
126  
127 =cut
128  
129 0 ▶sub album {
Subroutine album: not called CC=46 SCAR=76.8
Pod undocumented
130 0 my $source = shift;
131 0 my $parent = shift; # optional
132 0 my $album = get_config($source);
133  
134 # Special case for root albums
135 # $parent = $album if not $parent;
136  
137 # Implementation of the "oblivious" feature
138 0 ▶ if (not $album) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($album) 0 0 0
139 0 ▶ return if $parent->{oblivious};
Branch: 1 branch
BranchTrueFalseTotal
if $parent->{"oblivious"} 0 0 0
140 0 $album = {};
141 }
142  
143 # Implementation of the "private" feature
144 0 ▶ if (defined $album->{slug} and $album->{slug} eq 'private') {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $album->{"slug"} and $album->{"slug"} eq "private") 0 0 0
Condition0%0/3
defined $album->{"slug"} and $album->{"slug"} eq "private"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $album->{"slug"} and $album->{"slug"} eq "private"
defined $album->{"slug"} $album->{"slug"} eq "private"
Truth table0%0/3
A and B
A= defined $album->{"slug"}B= $album->{"slug"} eq "private"
ABresult
0X0
100
111
145 0 $album->{slug} = random_regex('[1-9][a-hjkp-z2-9]{15}');
146 0 $album->{unlisted} = "true";
147 0 save_config($album, $source);
148 }
149  
150 0 $album->{type} = 'album';
151 0 $album->{parent} = $parent;
152  
153 # Instantiate the global allfiles hash
154 0 ▶ if (not $parent) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $parent) { } 0 0 0
155 0 $album->{allfiles} = {};
156 }
157 else {
158 0 $album->{allfiles} = $parent->{allfiles};
159 }
160  
161  
162 =item I<Static variables>
163  
164 =item B<source>
165  
166 The source directory.
167  
168 =cut
169  
170 0 $album->{source} = $source;
171  
172 =item B<config>
173  
174 Path to the album's C<photog.ini>
175  
176 =cut
177  
178 0 $album->{config} = catfile($source, $CONFIG_FILE);
179  
180 =item B<name>
181  
182 Directory basename of the album, currently only used for debugging
183 purposes.
184  
185 =cut
186  
187 0 $album->{name} = basename($source);
188  
189 =item B<root>
190  
191 The destination directory of the root album. This is always inherited
192 from the parent album.
193  
194 =cut
195  
196 0 ▶ if ($parent) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent) { } 0 0 0
197 0 $album->{root} = $parent->{root};
198 }
199 else {
200 0 ▶ $album->{root} = $album->{destination} || die
Condition0%0/2
$album->{'destination'} || die('ERROR: Destination not specified')
l!l
00
MC/DC0%0/1
$album->{'destination'} || die('ERROR: Destination not specified')
$album->{'destination'}
Truth table0%0/2
A
A= $album->{'destination'}
Aresult
11
00
201 "ERROR: Destination not specified";
202 }
203  
204 =item I<Dynamic variables>
205  
206 =item B<slug>
207  
208 A slug is the part of the URL that identifies an album,
209 e.g. C<www.example.com/slug/>. The default value is the directory's
210 name, so be careful not to use characters in directory names that are
211 not allowed in URLs, like spaces. Or, simply override this value to
212 choose an appropriate URL for each album.
213  
214 The special value of "private" will cause a random slug to be
215 generated consisting of 16 alphanumeric characters, which will
216 immediately be saved to the C<photog.ini> file, replacing the
217 original "private" value. In addition, the variable B<unlisted>
218 will be set to true. Use this for creating private albums that
219 are only accessible to people who know the secret URL.
220  
221 =cut
222  
223 0 ▶ $album->{slug} ||= basename($source);
Condition0%0/3
$album->{"slug"} ||= basename($source)
l!l&&r!l&&!r
000
MC/DC0%0/2
$album->{"slug"} ||= basename($source)
$album->{"slug"} basename($source)
Truth table0%0/3
A ||= B
A= $album->{"slug"}B= basename($source)
ABresult
1X1
011
000
224  
225 =item B<url>
226  
227 Calculated by concatenating the parent url and the album slug.
228 Overriding this option allows the source directories to be differently
229 organized than the destination directories.
230  
231 =cut
232  
233 $album->{url} ||= $parent->{url}
234 0 ▶ ? "$parent->{url}$album->{slug}/"
Branch: 1 branch
BranchTrueFalseTotal
$parent->{'url'} ? : 0 0 0
Condition0%0/3
$album->{"url"} ||= $parent->{"url"} ? qq[$parent->{"url"}$album->{"slug"}/] : "/"
l!l&&r!l&&!r
000
MC/DC0%0/2
$album->{"url"} ||= $parent->{"url"} ? qq[$parent->{"url"}$album->{"slug"}/] : "/"
$album->{"url"} $parent->{"url"} ? qq[$parent->{"url"}$album->{"slug"}/] : "/"
Truth table0%0/3
A ||= B
A= $album->{"url"}B= $parent->{"url"} ? qq[$parent->{"url"}$album->{"slug"}/] : "/"
ABresult
1X1
011
000
235 : "/";
236  
237 =item B<href>
238  
239 The album link for use inside the <a> tag in the template.
240  
241 =cut
242  
243 0 ▶ $album->{href} ||= $album->{slug} . '/';
Condition0%0/2
$album->{"href"} ||= $album->{"slug"} . '/'
l!l
00
MC/DC0%0/1
$album->{"href"} ||= $album->{"slug"} . '/'
$album->{"href"}
Truth table0%0/2
A
A= $album->{"href"}
Aresult
11
00
244  
245 =item B<src>
246  
247 The album preview image for use inside the <img> tag in the
248 template. Width and height will also be made available to the
249 template.
250  
251 =cut
252  
253 0 ▶ $album->{src} ||= $album->{href} . "thumbnails/all.jpg";
Condition0%0/2
$album->{"src"} ||= $album->{"href"} . 'thumbnails/all.jpg'
l!l
00
MC/DC0%0/1
$album->{"src"} ||= $album->{"href"} . 'thumbnails/all.jpg'
$album->{"src"}
Truth table0%0/2
A
A= $album->{"src"}
Aresult
11
00
254  
255 =item B<destination>
256  
257 The album's destination directory. Calculated by concatenating the
258 root destination directory and the album's URL. Although possible,
259 overriding this option for subdirectories is not recommended. Use the
260 B<url> option instead (see above).
261  
262 =cut
263  
264 $album->{destination} ||=
265 0 ▶ catfile($album->{root}, substr($album->{url}, 1));
Condition0%0/3
$album->{"destination"} ||= catfile($album->{"root"}, substr($album->{"url"}, 1))
l!l&&r!l&&!r
000
MC/DC0%0/2
$album->{"destination"} ||= catfile($album->{"root"}, substr($album->{"url"}, 1))
$album->{"destination"} catfile($album->{"root"}, substr($album->{"url"}, 1))
Truth table0%0/3
A ||= B
A= $album->{"destination"}B= catfile($album->{"root"}, substr($album->{"url"}, 1))
ABresult
1X1
011
000
266  
267 =item B<thumbnail>
268  
269 Path to the album preview image, for use a thumbnail in the parent
270 album. Defaults to the file C<all.jpg> in subdirectory C<thumbnails>
271 inside the destination directory.
272  
273 =cut
274  
275 $album->{thumbnail} ||=
276 0 ▶ catfile($album->{destination}, "thumbnails/all.jpg");
Condition0%0/3
$album->{"thumbnail"} ||= catfile($album->{"destination"}, "thumbnails/all.jpg")
l!l&&r!l&&!r
000
MC/DC0%0/2
$album->{"thumbnail"} ||= catfile($album->{"destination"}, "thumbnails/all.jpg")
$album->{"thumbnail"} catfile($album->{"destination"}, "thumbnails/all.jpg")
Truth table0%0/3
A ||= B
A= $album->{"thumbnail"}B= catfile($album->{"destination"}, "thumbnails/all.jpg")
ABresult
1X1
011
000
277  
278 =item B<index>
279  
280 Path to to the album's C<index.html>.
281  
282 =cut
283  
284 $album->{index} ||=
285 0 ▶ catfile($album->{destination}, "index.html");
Condition0%0/3
$album->{"index"} ||= catfile($album->{"destination"}, "index.html")
l!l&&r!l&&!r
000
MC/DC0%0/2
$album->{"index"} ||= catfile($album->{"destination"}, "index.html")
$album->{"index"} catfile($album->{"destination"}, "index.html")
Truth table0%0/3
A ||= B
A= $album->{"index"}B= catfile($album->{"destination"}, "index.html")
ABresult
1X1
011
000
286  
287 =item B<unlisted>
288  
289 Boolean value that specifies whether this album will be diplayed on
290 the parent album. The album page remains accessible to people who know
291 the URL. Defaults to C<false>. Not inherited, always defaults to
292 false (except for the root album)
293  
294 =cut
295  
296 0 ▶ $album->{unlisted} ||= (not defined $album->{parent});
Condition0%0/3
$album->{"unlisted"} ||= !defined($album->{"parent"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$album->{"unlisted"} ||= !defined($album->{"parent"})
$album->{"unlisted"} !defined($album->{"parent"})
Truth table0%0/3
A ||= not(B)
A= $album->{"unlisted"}B= !defined($album->{"parent"})
ABresult
1X1
011
000
297  
298 =item B<date>
299  
300 The ISO 8601 date and optionally time of this album. This is used when
301 sorting items chronologically. The default is the directory's
302 modification date. The default template never actually shows dates,
303 but it can also be used to determine the placement of album previews
304 on a page.
305  
306 =cut
307  
308 0 ▶ $album->{date} ||= DateTime->from_epoch(
Condition0%0/3
$album->{"date"} ||= "DateTime"->from_epoch("epoch", (stat $source)[9])
l!l&&r!l&&!r
000
MC/DC0%0/2
$album->{"date"} ||= "DateTime"->from_epoch("epoch", (stat $source)[9])
$album->{"date"} "DateTime"->from_epoch("epoch", (stat $source)[9])
Truth table0%0/3
A ||= B
A= $album->{"date"}B= "DateTime"->from_epoch("epoch", (stat $source)[9])
ABresult
1X1
011
000
309 epoch => (stat $source)[9]);
310  
311 =item B<protected>
312  
313 A list of filenames that will not be automatically deleted at the
314 album's destination directory. Defaults to ('index.html',
315 'thumbnails'). The root album will also get the directory 'static'
316 appended to this list.
317  
318 =cut
319  
320 0 ▶ if (not exists $album->{protected}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $album->{"protected"}) 0 0 0
321 0 $album->{protected} = [];
322 }
323 0 push @{$album->{protected}}, ('index.html', 'thumbnails');
324  
325 =item I<Inherited variables>
326  
327 =item B<title>
328  
329 In the default template, the title appears at the top of the page. The
330 default value is "My Photography Website". Please set this to
331 something more catchy. You can also override it for specific albums to
332 show an album name.
333  
334 =cut
335  
336 0 ▶ if (not exists $album->{title}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $album->{"title"}) 0 0 0
337 $album->{title} = $parent->{title}
338 0 ▶ || "My Photography Website";
Condition0%0/2
$parent->{'title'} || 'My Photography Website'
l!l
00
MC/DC0%0/1
$parent->{'title'} || 'My Photography Website'
$parent->{'title'}
Truth table0%0/2
A
A= $parent->{'title'}
Aresult
11
00
339 }
340  
341 =item B<copyright>
342  
343 In the default template, the copyright notice appears at the
344 bottom of the page. The default value is empty.
345  
346 =cut
347  
348 0 ▶ if (not exists $album->{copyright}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $album->{"copyright"}) 0 0 0
349 0 ▶ $album->{copyright} = $parent->{copyright} || '';
Condition0%0/2
$parent->{'copyright'} || ''
l!l
00
MC/DC0%0/1
$parent->{'copyright'} || ''
$parent->{'copyright'}
Truth table0%0/2
A
A= $parent->{'copyright'}
Aresult
11
00
350 }
351  
352 =item B<template>
353  
354 Path to an HTML file containing directives in L<Template::Toolkit>
355 syntax. The current album will be made available as the variable
356 "album", from where all additional configuration variables can be
357 accessed using dot syntax, i.e., album.title, album.copyright etc. You
358 can even make up your own configuration variables in C<photog.ini> and
359 have them available in the template. The default is the file
360 C<template.html> that's included with Photog!. Use it as a starting
361 point to create your own template!
362  
363 =cut
364  
365 $album->{template} ||= $parent->{template}
366 0 ▶ || dist_file($DIST, 'template.html');
Condition0%0/6
$album->{"template"} ||= $parent->{"template"} || dist_file($DIST, "template.html")
l!l&&r!l&&!r
000
$parent->{'template'} || dist_file($DIST, 'template.html')
l!l&&r!l&&!r
000
MC/DC0%0/3
$album->{"template"} ||= $parent->{"template"} || dist_file($DIST, "template.html")
$album->{"template"} $parent->{'template'} dist_file($DIST, 'template.html')
Truth table0%0/4
A ||= B || C
A= $album->{"template"}B= $parent->{'template'}C= dist_file($DIST, 'template.html')
ABCresult
1XX1
01X1
0011
0000
367  
368 =item B<preview>
369  
370 An album preview is a thumbnail image of the album that contains a
371 number of smaller images. This option sets the number of preview
372 images for an album. Allowed values are 3, 6, and 9. The default is 9.
373  
374 =cut
375  
376 0 ▶ $album->{preview} ||= $parent->{preview} || 9;
Condition0%0/5
$album->{"preview"} ||= $parent->{"preview"} || 9
l!l&&r!l&&!r
000
$parent->{'preview'} || 9
l!l
00
MC/DC0%0/2
$album->{"preview"} ||= $parent->{"preview"} || 9
$album->{"preview"} $parent->{'preview'}
Truth table0%0/3
A ||= B
A= $album->{"preview"}B= $parent->{'preview'}
ABresult
1X1
011
000
377  
378 =item B<watermark>
379  
380 The path to a transparent PNG file that will be used to watermark all
381 fullscreen images in an album. The command C<photog-watermark> is
382 called to do the actual watermarking, and it currently places the
383 watermark in the lower right corner. The default is to not watermark
384 website images.
385  
386 =cut
387  
388 0 ▶ if (not exists $album->{watermark}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $album->{"watermark"}) 0 0 0
389 0 ▶ $album->{watermark} = $parent->{watermark} || '';
Condition0%0/2
$parent->{'watermark'} || ''
l!l
00
MC/DC0%0/1
$parent->{'watermark'} || ''
$parent->{'watermark'}
Truth table0%0/2
A
A= $parent->{'watermark'}
Aresult
11
00
390 }
391  
392 =item B<sort>
393  
394 Photos are sorted according to EXIF date. Possible sort orders are:
395 C<ascending>, C<descending>, or C<random>. The default value is
396 C<descending>.
397  
398 =cut
399  
400 0 ▶ $album->{sort} ||= $parent->{sort} || 'descending';
Condition0%0/5
$album->{"sort"} ||= $parent->{"sort"} || "descending"
l!l&&r!l&&!r
000
$parent->{'sort'} || 'descending'
l!l
00
MC/DC0%0/2
$album->{"sort"} ||= $parent->{"sort"} || "descending"
$album->{"sort"} $parent->{'sort'}
Truth table0%0/3
A ||= B
A= $album->{"sort"}B= $parent->{'sort'}
ABresult
1X1
011
000
401  
402 =item B<fullscreen>
403  
404 A boolean to indicate whether large images should be made
405 available. Use this to prevent access to full-size images by clients
406 who haven't paid yet. Defaults to true.
407  
408 =cut
409  
410 0 ▶ if (not exists $album->{fullscreen}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $album->{"fullscreen"}) 0 0 0
411 0 ▶ if ($album->{parent}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($album->{'parent'}) { } 0 0 0
412 0 $album->{fullscreen} = $parent->{fullscreen};
413 }
414 else {
415 0 $album->{fullscreen} = 1;
416 }
417 }
418  
419 =item B<oblivious>
420  
421 A boolean value that specifies whether C<photog.ini>
422 files are required. If true, Photog! will only consider a
423 subdirectory an album when it contains a C<photog.ini> file, even if
424 the file is empty. Defaults to false.
425  
426 =cut
427  
428 0 ▶ if (not exists $album->{oblivious}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $album->{"oblivious"}) 0 0 0
429 0 ▶ $album->{oblivious} = $parent->{oblivious} || 0;
Condition0%0/2
$parent->{'oblivious'} || 0
l!l
00
MC/DC0%0/1
$parent->{'oblivious'} || 0
$parent->{'oblivious'}
Truth table0%0/2
A
A= $parent->{'oblivious'}
Aresult
11
00
430 }
431  
432 =item B<scale_command>
433  
434 The path to a command to convert an original image to a fullscreen
435 web-image. The command will receive 2 arguments: The source image path
436 and the destination image path. The default is C<photog-scale>, which
437 will scale an image to measure 2160 pixels vertically.
438  
439 =cut
440  
441 $album->{scale_command} ||= $parent->{scale_command}
442 0 ▶ || 'photog-scale';
Condition0%0/5
$album->{"scale_command"} ||= $parent->{"scale_command"} || "photog-scale"
l!l&&r!l&&!r
000
$parent->{'scale_command'} || 'photog-scale'
l!l
00
MC/DC0%0/2
$album->{"scale_command"} ||= $parent->{"scale_command"} || "photog-scale"
$album->{"scale_command"} $parent->{'scale_command'}
Truth table0%0/3
A ||= B
A= $album->{"scale_command"}B= $parent->{'scale_command'}
ABresult
1X1
011
000
443  
444 =item B<watermark_command>
445  
446 The command that does the image watermarking. The command will receive
447 3 arguments: Paths to the source image, the watermark image, and the
448 destination image. The default command is C<photog-watermark> which
449 places the watermark file in the lower-right corner.
450  
451 =cut
452  
453 $album->{watermark_command} ||= $parent->{watermark_command}
454 0 ▶ || 'photog-watermark';
Condition0%0/5
$album->{"watermark_command"} ||= $parent->{"watermark_command"} || "photog-watermark"
l!l&&r!l&&!r
000
$parent->{'watermark_command'} || 'photog-watermark'
l!l
00
MC/DC0%0/2
$album->{"watermark_command"} ||= $parent->{"watermark_command"} || "photog-watermark"
$album->{"watermark_command"} $parent->{'watermark_command'}
Truth table0%0/3
A ||= B
A= $album->{"watermark_command"}B= $parent->{'watermark_command'}
ABresult
1X1
011
000
455  
456 =item B<thumbnail_command>
457  
458 The path to a command that generates image thumbnails. The command
459 receives 2 arguments: The source image path and the thumbnail
460 destination path. The default is C<photog-thumbnail>, which performs
461 quite a bit of sharpening to make sure that the thumbnail doesn't
462 become blurry after resizing.
463  
464 =cut
465  
466 $album->{thumbnail_command} ||= $parent->{thumbnail_command}
467 0 ▶ || 'photog-thumbnail';
Condition0%0/5
$album->{"thumbnail_command"} ||= $parent->{"thumbnail_command"} || "photog-thumbnail"
l!l&&r!l&&!r
000
$parent->{'thumbnail_command'} || 'photog-thumbnail'
l!l
00
MC/DC0%0/2
$album->{"thumbnail_command"} ||= $parent->{"thumbnail_command"} || "photog-thumbnail"
$album->{"thumbnail_command"} $parent->{'thumbnail_command'}
Truth table0%0/3
A ||= B
A= $album->{"thumbnail_command"}B= $parent->{'thumbnail_command'}
ABresult
1X1
011
000
468  
469 =item B<preview_command>
470  
471 The command that generates album previews by compositing multiple
472 thumbnails together. It will receive paths to the source images'
473 thumbnails as its arguments, and the path to a destination file as its
474 final argument. Currently, Photog! will only request previews of 3, 6,
475 or 9 images.
476  
477 =cut
478  
479 $album->{preview_command} ||= $parent->{preview_command}
480 0 ▶ || 'photog-preview';
Condition0%0/5
$album->{"preview_command"} ||= $parent->{"preview_command"} || "photog-preview"
l!l&&r!l&&!r
000
$parent->{'preview_command'} || 'photog-preview'
l!l
00
MC/DC0%0/2
$album->{"preview_command"} ||= $parent->{"preview_command"} || "photog-preview"
$album->{"preview_command"} $parent->{'preview_command'}
Truth table0%0/3
A ||= B
A= $album->{"preview_command"}B= $parent->{'preview_command'}
ABresult
1X1
011
000
481  
482 =back
483  
484 =cut
485  
486 # Finally, inherit all remaining parent values
487 0 for (keys %$parent) {
488 0 ▶ next if $_ eq 'items';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "items" 0 0 0
489 0 ▶ next if exists $album->{$_};
Branch: 1 branch
BranchTrueFalseTotal
if exists $album->{$_} 0 0 0
490 0 $album->{$_} = $parent->{$_};
491 }
492  
493 0 return $album;
494 }
495  
496 0 ▶sub get_config {
Subroutine get_config: not called CC=2 SCAR=17.9
Pod undocumented
497 0 my $directory = shift;
498 0 my $file = catfile($directory, $CONFIG_FILE);
499 0 ▶ if (-f $file) {
Branch: 1 branch
BranchTrueFalseTotal
if (-f $file) { } 0 0 0
500 0 return { ParseConfig(-ConfigFile=>$file, -AutoTrue=>1) };
501 }
502 else {
503 0 return 0;
504 }
505 }
506  
507 0 ▶sub save_config {
Subroutine save_config: not called CC=3 SCAR=24.8
Pod undocumented
508 0 my $config = shift;
509 0 my $directory = shift;
510 0 my $file = catfile($directory ,$CONFIG_FILE);
511 0 ▶ open(my $fh, '>', $file)
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $file or die "ERROR: Can't open '${file}' for writing\n" 0 0 0
512 or die "ERROR: Can't open '$file' for writing\n";
513 0 for my $key (keys %{$config}) {
514 0 say $fh "$key = $config->{$key}";
515 }
516 }
517  
518 0 ▶sub is_image {
Subroutine is_image: not called CC=3 SCAR=24.8
Pod undocumented
519 0 my $name = lc(shift);
520 0 ▶ return 1 if $name =~ /\.jpg$/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\.jpg$/ 0 0 0
521 0 ▶ return 1 if $name =~ /\.jpeg$/;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /\.jpeg$/ 0 0 0
522 0 return 0;
523 }
524  
525 0 ▶sub strip_suffix {
Subroutine strip_suffix: not called CC=1 SCAR=6.9
Pod undocumented
526 0 my $file = shift;
527 0 $file =~ s/\.[^\.]+$//;
528 0 return $file;
529 }
530  
531 =head1 SEE ALSO
532  
533 L<photog>, L<Photography::Website>
534  
535 =head1 AUTHOR
536  
537 Photog! was written by Jaap Joris Vens <jj@rtts.eu>, and is used to
538 create his personal photography website at L<http://www.superformosa.nl/>
539  
540 =cut
541  
542 1 1;
↑ Summary Website.pm »