line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
my $DIST = 'Photography-Website'; |
2
|
|
|
|
|
|
|
package Photography::Website::Configure; |
3
|
|
|
|
|
|
|
$Photography::Website::Configure::VERSION = '0.27'; |
4
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
17
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
655
|
use DateTime; |
|
1
|
|
|
|
|
96521
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
7
|
use File::Basename qw(basename dirname); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
80
|
|
9
|
1
|
|
|
1
|
|
435
|
use File::ShareDir qw(dist_file); |
|
1
|
|
|
|
|
4196
|
|
|
1
|
|
|
|
|
51
|
|
10
|
1
|
|
|
1
|
|
380
|
use File::Spec::Functions qw(catfile); |
|
1
|
|
|
|
|
584
|
|
|
1
|
|
|
|
|
55
|
|
11
|
1
|
|
|
1
|
|
576
|
use Config::General qw(ParseConfig); |
|
1
|
|
|
|
|
16958
|
|
|
1
|
|
|
|
|
58
|
|
12
|
1
|
|
|
1
|
|
403
|
use String::Random qw(random_regex); |
|
1
|
|
|
|
|
2114
|
|
|
1
|
|
|
|
|
762
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
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 for the documentation |
24
|
|
|
|
|
|
|
about the command-line interface and see L 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
|
|
|
|
|
|
|
sub image { |
38
|
0
|
|
|
0
|
0
|
|
my $source = shift; |
39
|
0
|
|
|
|
|
|
my $parent = shift; |
40
|
0
|
0
|
|
|
|
|
return if not is_image($source); |
41
|
0
|
|
|
|
|
|
my $img = { |
42
|
|
|
|
|
|
|
type => 'image', |
43
|
|
|
|
|
|
|
parent => $parent, |
44
|
|
|
|
|
|
|
}; |
45
|
0
|
|
|
|
|
|
my $filename = basename($source); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item B |
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 |
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 |
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 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
The relative URL of the image thumbnail, i.e., C. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$img->{src} = "thumbnails/$filename"; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item B |
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 |
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 |
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
|
|
|
|
|
|
|
sub album { |
130
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
if (not $album) { |
139
|
0
|
0
|
|
|
|
|
return if $parent->{oblivious}; |
140
|
0
|
|
|
|
|
|
$album = {}; |
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# Implementation of the "private" feature |
144
|
0
|
0
|
0
|
|
|
|
if (defined $album->{slug} and $album->{slug} eq 'private') { |
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
|
0
|
|
|
|
|
if (not $parent) { |
155
|
0
|
|
|
|
|
|
$album->{allfiles} = {}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
else { |
158
|
0
|
|
|
|
|
|
$album->{allfiles} = $parent->{allfiles}; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=item I |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item B |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
The source directory. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
|
$album->{source} = $source; |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item B |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Path to the album's C |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
0
|
|
|
|
|
|
$album->{config} = catfile($source, $CONFIG_FILE); |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item B |
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 |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
The destination directory of the root album. This is always inherited |
192
|
|
|
|
|
|
|
from the parent album. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=cut |
195
|
|
|
|
|
|
|
|
196
|
0
|
0
|
|
|
|
|
if ($parent) { |
197
|
0
|
|
|
|
|
|
$album->{root} = $parent->{root}; |
198
|
|
|
|
|
|
|
} |
199
|
|
|
|
|
|
|
else { |
200
|
0
|
|
0
|
|
|
|
$album->{root} = $album->{destination} || die |
201
|
|
|
|
|
|
|
"ERROR: Destination not specified"; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=item I |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=item B |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
A slug is the part of the URL that identifies an album, |
209
|
|
|
|
|
|
|
e.g. C. 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 file, replacing the |
217
|
|
|
|
|
|
|
original "private" value. In addition, the variable B |
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
|
|
0
|
|
|
|
$album->{slug} ||= basename($source); |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item B |
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
|
0
|
0
|
0
|
|
|
|
$album->{url} ||= $parent->{url} |
234
|
|
|
|
|
|
|
? "$parent->{url}$album->{slug}/" |
235
|
|
|
|
|
|
|
: "/"; |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=item B |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
The album link for use inside the tag in the template. |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=cut |
242
|
|
|
|
|
|
|
|
243
|
0
|
|
0
|
|
|
|
$album->{href} ||= $album->{slug} . '/'; |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item B |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
The album preview image for use inside the tag in the |
248
|
|
|
|
|
|
|
template. Width and height will also be made available to the |
249
|
|
|
|
|
|
|
template. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=cut |
252
|
|
|
|
|
|
|
|
253
|
0
|
|
0
|
|
|
|
$album->{src} ||= $album->{href} . "thumbnails/all.jpg"; |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=item B |
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 option instead (see above). |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=cut |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
0
|
|
|
|
$album->{destination} ||= |
265
|
|
|
|
|
|
|
catfile($album->{root}, substr($album->{url}, 1)); |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item B |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Path to the album preview image, for use a thumbnail in the parent |
270
|
|
|
|
|
|
|
album. Defaults to the file C in subdirectory C |
271
|
|
|
|
|
|
|
inside the destination directory. |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |
274
|
|
|
|
|
|
|
|
275
|
0
|
|
0
|
|
|
|
$album->{thumbnail} ||= |
276
|
|
|
|
|
|
|
catfile($album->{destination}, "thumbnails/all.jpg"); |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=item B |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
Path to to the album's C. |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=cut |
283
|
|
|
|
|
|
|
|
284
|
0
|
|
0
|
|
|
|
$album->{index} ||= |
285
|
|
|
|
|
|
|
catfile($album->{destination}, "index.html"); |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
=item B |
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. Not inherited, always defaults to |
292
|
|
|
|
|
|
|
false (except for the root album) |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
=cut |
295
|
|
|
|
|
|
|
|
296
|
0
|
|
0
|
|
|
|
$album->{unlisted} ||= (not defined $album->{parent}); |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
=item B |
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
|
|
0
|
|
|
|
$album->{date} ||= DateTime->from_epoch( |
309
|
|
|
|
|
|
|
epoch => (stat $source)[9]); |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=item B |
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
|
0
|
|
|
|
|
if (not exists $album->{protected}) { |
321
|
0
|
|
|
|
|
|
$album->{protected} = []; |
322
|
|
|
|
|
|
|
} |
323
|
0
|
|
|
|
|
|
push @{$album->{protected}}, ('index.html', 'thumbnails'); |
|
0
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
=item I |
326
|
|
|
|
|
|
|
|
327
|
|
|
|
|
|
|
=item B |
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
|
0
|
|
|
|
|
if (not exists $album->{title}) { |
337
|
0
|
|
0
|
|
|
|
$album->{title} = $parent->{title} |
338
|
|
|
|
|
|
|
|| "My Photography Website"; |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
=item B |
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
|
0
|
|
|
|
|
if (not exists $album->{copyright}) { |
349
|
0
|
|
0
|
|
|
|
$album->{copyright} = $parent->{copyright} || ''; |
350
|
|
|
|
|
|
|
} |
351
|
|
|
|
|
|
|
|
352
|
|
|
|
|
|
|
=item B |
353
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
Path to an HTML file containing directives in L |
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 and |
359
|
|
|
|
|
|
|
have them available in the template. The default is the file |
360
|
|
|
|
|
|
|
C that's included with Photog!. Use it as a starting |
361
|
|
|
|
|
|
|
point to create your own template! |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
=cut |
364
|
|
|
|
|
|
|
|
365
|
0
|
|
0
|
|
|
|
$album->{template} ||= $parent->{template} |
|
|
|
0
|
|
|
|
|
366
|
|
|
|
|
|
|
|| dist_file($DIST, 'template.html'); |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=item B |
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
|
|
0
|
|
|
|
$album->{preview} ||= $parent->{preview} || 9; |
|
|
|
0
|
|
|
|
|
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
=item B |
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 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
|
0
|
|
|
|
|
if (not exists $album->{watermark}) { |
389
|
0
|
|
0
|
|
|
|
$album->{watermark} = $parent->{watermark} || ''; |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
=item B |
393
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
Photos are sorted according to EXIF date. Possible sort orders are: |
395
|
|
|
|
|
|
|
C, C, or C. The default value is |
396
|
|
|
|
|
|
|
C. |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
=cut |
399
|
|
|
|
|
|
|
|
400
|
0
|
|
0
|
|
|
|
$album->{sort} ||= $parent->{sort} || 'descending'; |
|
|
|
0
|
|
|
|
|
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
=item B |
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
|
0
|
|
|
|
|
if (not exists $album->{fullscreen}) { |
411
|
0
|
0
|
|
|
|
|
if ($album->{parent}) { |
412
|
0
|
|
|
|
|
|
$album->{fullscreen} = $parent->{fullscreen}; |
413
|
|
|
|
|
|
|
} |
414
|
|
|
|
|
|
|
else { |
415
|
0
|
|
|
|
|
|
$album->{fullscreen} = 1; |
416
|
|
|
|
|
|
|
} |
417
|
|
|
|
|
|
|
} |
418
|
|
|
|
|
|
|
|
419
|
|
|
|
|
|
|
=item B |
420
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
A boolean value that specifies whether C |
422
|
|
|
|
|
|
|
files are required. If true, Photog! will only consider a |
423
|
|
|
|
|
|
|
subdirectory an album when it contains a C file, even if |
424
|
|
|
|
|
|
|
the file is empty. Defaults to false. |
425
|
|
|
|
|
|
|
|
426
|
|
|
|
|
|
|
=cut |
427
|
|
|
|
|
|
|
|
428
|
0
|
0
|
|
|
|
|
if (not exists $album->{oblivious}) { |
429
|
0
|
|
0
|
|
|
|
$album->{oblivious} = $parent->{oblivious} || 0; |
430
|
|
|
|
|
|
|
} |
431
|
|
|
|
|
|
|
|
432
|
|
|
|
|
|
|
=item B |
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, which |
437
|
|
|
|
|
|
|
will scale an image to measure 2160 pixels vertically. |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=cut |
440
|
|
|
|
|
|
|
|
441
|
0
|
|
0
|
|
|
|
$album->{scale_command} ||= $parent->{scale_command} |
|
|
|
0
|
|
|
|
|
442
|
|
|
|
|
|
|
|| 'photog-scale'; |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
=item B |
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 which |
449
|
|
|
|
|
|
|
places the watermark file in the lower-right corner. |
450
|
|
|
|
|
|
|
|
451
|
|
|
|
|
|
|
=cut |
452
|
|
|
|
|
|
|
|
453
|
0
|
|
0
|
|
|
|
$album->{watermark_command} ||= $parent->{watermark_command} |
|
|
|
0
|
|
|
|
|
454
|
|
|
|
|
|
|
|| 'photog-watermark'; |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
=item B |
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, 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
|
0
|
|
0
|
|
|
|
$album->{thumbnail_command} ||= $parent->{thumbnail_command} |
|
|
|
0
|
|
|
|
|
467
|
|
|
|
|
|
|
|| 'photog-thumbnail'; |
468
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
=item B |
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
|
0
|
|
0
|
|
|
|
$album->{preview_command} ||= $parent->{preview_command} |
|
|
|
0
|
|
|
|
|
480
|
|
|
|
|
|
|
|| 'photog-preview'; |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
=back |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
=cut |
485
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
# Finally, inherit all remaining parent values |
487
|
0
|
|
|
|
|
|
for (keys %$parent) { |
488
|
0
|
0
|
|
|
|
|
next if $_ eq 'items'; |
489
|
0
|
0
|
|
|
|
|
next if exists $album->{$_}; |
490
|
0
|
|
|
|
|
|
$album->{$_} = $parent->{$_}; |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
|
493
|
0
|
|
|
|
|
|
return $album; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
sub get_config { |
497
|
0
|
|
|
0
|
0
|
|
my $directory = shift; |
498
|
0
|
|
|
|
|
|
my $file = catfile($directory, $CONFIG_FILE); |
499
|
0
|
0
|
|
|
|
|
if (-f $file) { |
500
|
0
|
|
|
|
|
|
return { ParseConfig(-ConfigFile=>$file, -AutoTrue=>1) }; |
501
|
|
|
|
|
|
|
} |
502
|
|
|
|
|
|
|
else { |
503
|
0
|
|
|
|
|
|
return 0; |
504
|
|
|
|
|
|
|
} |
505
|
|
|
|
|
|
|
} |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
sub save_config { |
508
|
0
|
|
|
0
|
0
|
|
my $config = shift; |
509
|
0
|
|
|
|
|
|
my $directory = shift; |
510
|
0
|
|
|
|
|
|
my $file = catfile($directory ,$CONFIG_FILE); |
511
|
0
|
0
|
|
|
|
|
open(my $fh, '>', $file) |
512
|
|
|
|
|
|
|
or die "ERROR: Can't open '$file' for writing\n"; |
513
|
0
|
|
|
|
|
|
for my $key (keys %{$config}) { |
|
0
|
|
|
|
|
|
|
514
|
0
|
|
|
|
|
|
say $fh "$key = $config->{$key}"; |
515
|
|
|
|
|
|
|
} |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
sub is_image { |
519
|
0
|
|
|
0
|
0
|
|
my $name = lc(shift); |
520
|
0
|
0
|
|
|
|
|
return 1 if $name =~ /\.jpg$/; |
521
|
0
|
0
|
|
|
|
|
return 1 if $name =~ /\.jpeg$/; |
522
|
0
|
|
|
|
|
|
return 0; |
523
|
|
|
|
|
|
|
} |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
sub strip_suffix { |
526
|
0
|
|
|
0
|
0
|
|
my $file = shift; |
527
|
0
|
|
|
|
|
|
$file =~ s/\.[^\.]+$//; |
528
|
0
|
|
|
|
|
|
return $file; |
529
|
|
|
|
|
|
|
} |
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=head1 SEE ALSO |
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
L, L |
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=head1 AUTHOR |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
Photog! was written by Jaap Joris Vens , and is used to |
538
|
|
|
|
|
|
|
create his personal photography website at L |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=cut |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
1; |