2 # (c) 2003--2012 Martin Mares <mj@ucw.cz>
12 # Standard Perl module stuff
14 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
17 @EXPORT = qw(&SetOptions);
26 $CF{'Title'} = 'An Unnamed Gallery',
27 $CF{'HeadExtras'} = "",
28 $CF{'TopExtras'} = "",
29 $CF{'BotExtras'} = "",
30 $CF{'ParentURL'} = '../',
33 $CF{'ImageSubpages'} = 1,
34 $CF{'AllowArchives'} = 1,
35 $CF{'PhotoUrlPrefix'} = "",
36 $CF{'ThumbUrlPrefix'} = "",
37 $CF{'MetaDataDir'} = '.',
38 $CF{'PhotoDir'} = '.',
39 # FIXME: Who sets GalDir?
41 $CF{'ScanDefaultTransform'} = 's';
43 $CF{'PhotoDir'} = 'photo';
44 $CF{'CacheDir'} = 'cache',
45 $CF{'PhotoMaxWidth'} = 1024,
46 $CF{'PhotoMaxHeight'} = 1024,
47 $CF{'ThumbFormats'} = {},
51 my $cfg = "./gallery.cf";
52 unless (defined do $cfg) {
54 die "Error parsing $cfg: $@";
56 die "Cannot load $cfg: $!\n";
58 die "Cannot load $cfg, check that it returns true\n";
64 while (my $o = shift @_) {
68 require $CF{"GalDir"} . "/$v/theme.pm";
69 UCW::Gallery::Theme::Init($CF{"GalURL"} . "/$v");
74 sub RequireThumbnails($$) {
76 my $fmt = "${w}x${h}";
77 $CF{'ThumbFormats'}->{$fmt} = 1;
81 my ($file, $images) = @_;
82 open LIST, '>', "$file.new" or die "Cannot create $file.new: $!\n";
83 print LIST "# Image\tID\tRotate\tXform\tTitle\n";
84 for my $i (@$images) {
90 ($i->{title} eq '' ? '-' : $i->{title}),
94 rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n";
100 open LIST, '<', $file or return;
106 ($i->{file}, $i->{id}, $i->{orientation}, $i->{xfrm}, $i->{title}) = split /\t/;
107 if ($i->{title} eq '-') { $i->{title} = ""; }
115 my ($file, $meta) = @_;
116 open META, '>', "$file.new" or die "Cannot create $file.new: $!\n";
117 Storable::nstore_fd($meta, \*META);
119 rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n";
124 open META, '<', $file or die "Cannot read $file: $!\n";
125 my $meta = Storable::fd_retrieve(\*META) or die "Cannot parse $file\n";