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'} = 's';
42 $CF{'PhotoDir'} = 'photo';
43 $CF{'CacheDir'} = 'cache',
44 $CF{'PhotoMaxWidth'} = 1024,
45 $CF{'PhotoMaxHeight'} = 1024,
46 # FIXME: ThumbSizes should be set by themes
47 $CF{'ThumbSizes'} = [ [114,94], [256,256] ],
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 Gallery::Theme::Init($CF{"GalURL"} . "/$v");
75 my ($file, $images) = @_;
76 open LIST, '>', "$file.new" or die "Cannot create $file.new: $!\n";
77 print LIST "# Image\tID\tRotate\tXform\tTitle\n";
78 for my $i (@$images) {
84 ($i->{title} eq '' ? '-' : $i->{title}),
88 rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n";
94 open LIST, '<', $file or return;
100 ($i->{file}, $i->{id}, $i->{orientation}, $i->{xfrm}, $i->{title}) = split /\t/;
101 if ($i->{title} eq '-') { $i->{title} = ""; }
109 my ($file, $meta) = @_;
110 open META, '>', "$file.new" or die "Cannot create $file.new: $!\n";
111 Storable::nstore_fd($meta, \*META);
113 rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n";
118 open META, '<', $file or die "Cannot read $file: $!\n";
119 my $meta = Storable::fd_retrieve(\*META) or die "Cannot parse $file\n";