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'} = '.',
40 $CF{'ScanDefaultTransform'} = 'n';
42 $CF{'PhotoDir'} = 'photo';
43 $CF{'CacheDir'} = "cache",
44 $CF{'PhotoMaxWidth'} = 1024,
45 $CF{'PhotoMaxHeight'} = 1024,
49 my $cfg = "./gallery.cf";
50 unless (defined do $cfg) {
52 die "Error parsing $cfg: $@";
54 die "Cannot load $cfg: $!\n";
56 die "Cannot load $cfg, check that it returns true\n";
62 while (my $o = shift @_) {
66 require $CF{"GalDir"} . "/$v/theme.pm";
67 Gallery::Theme::Init($CF{"GalURL"} . "/$v");
73 my ($file, $images) = @_;
74 open LIST, '>', "$file.new" or die "Cannot create $file.new: $!\n";
75 print LIST "# Image\tID\tRotate\tXform\tTitle\n";
76 for my $i (@$images) {
82 ($i->{title} eq '' ? '-' : $i->{title}),
86 rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n";
92 open LIST, '<', $file or return;
98 ($i->{file}, $i->{id}, $i->{orientation}, $i->{xfrm}, $i->{title}) = split /\t/;
99 if ($i->{title} eq '-') { $i->{title} = ""; }
107 my ($file, $meta) = @_;
108 open META, '>', "$file.new" or die "Cannot create $file.new: $!\n";
109 Storable::nstore_fd($meta, \*META);
111 rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n";
116 open META, '<', $file or die "Cannot read $file: $!\n";
117 my $meta = Storable::fd_retrieve(\*META) or die "Cannot parse $file\n";