X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=gal2%2FUCW%2FGallery.pm;h=847de01987b3b1f226424ed13e483743111ff5cf;hb=b89f977dc5a5d785766118992aa90a7eff7b5d3b;hp=ad0f35dac944980b259c4cbc1666a9e491e3fbc0;hpb=929e3ca5d5af812fe382abe5bd88ab306a3b496a;p=gallery.git diff --git a/gal2/UCW/Gallery.pm b/gal2/UCW/Gallery.pm index ad0f35d..847de01 100644 --- a/gal2/UCW/Gallery.pm +++ b/gal2/UCW/Gallery.pm @@ -6,6 +6,8 @@ package UCW::Gallery; use strict; use warnings; +use Storable; + BEGIN { # Standard Perl module stuff use Exporter(); @@ -21,24 +23,28 @@ our %CF; our $th; BEGIN { - $CF{"Title"} = "An Unnamed Gallery", - $CF{"HeadExtras"} = "", - $CF{"TopExtras"} = "", - $CF{"BotExtras"} = "", - $CF{"ParentURL"} = "../", - $CF{"BackURL"} = "", - $CF{"FwdURL"} = "", - $CF{"ImageSubpages"} = 1, - $CF{"AllowArchives"} = 1, - $CF{"PhotoUrlPrefix"} = "", - $CF{"ThumbUrlPrefix"} = "", - $CF{"MetaDataDir"} = ".", - $CF{"PhotoDir"} = ".", + $CF{'Title'} = 'An Unnamed Gallery', + $CF{'HeadExtras'} = "", + $CF{'TopExtras'} = "", + $CF{'BotExtras'} = "", + $CF{'ParentURL'} = '../', + $CF{'BackURL'} = "", + $CF{'FwdURL'} = "", + $CF{'ImageSubpages'} = 1, + $CF{'AllowArchives'} = 1, + $CF{'PhotoUrlPrefix'} = "", + $CF{'ThumbUrlPrefix'} = "", + $CF{'MetaDataDir'} = '.', + $CF{'PhotoDir'} = '.', - $CF{'ScanDefaultTransform'} = 'n'; + $CF{'ScanDefaultTransform'} = 's'; $CF{'OrigDir'} = '.'; $CF{'PhotoDir'} = 'photo'; - $CF{"CacheDir"} = "cache", + $CF{'CacheDir'} = 'cache', + $CF{'PhotoMaxWidth'} = 1024, + $CF{'PhotoMaxHeight'} = 1024, + # FIXME: ThumbSizes should be set by themes + $CF{'ThumbSizes'} = [ [114,94], [256,256] ], } sub LoadConfig() { @@ -99,4 +105,20 @@ sub ReadList($) { return \@images; } +sub WriteMeta($$) { + my ($file, $meta) = @_; + open META, '>', "$file.new" or die "Cannot create $file.new: $!\n"; + Storable::nstore_fd($meta, \*META); + close META; + rename "$file.new", $file or die "Cannot rename $file.new to $file: $!\n"; +} + +sub ReadMeta($) { + my ($file) = @_; + open META, '<', $file or die "Cannot read $file: $!\n"; + my $meta = Storable::fd_retrieve(\*META) or die "Cannot parse $file\n"; + close META; + return $meta; +} + 1;