X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=gal2%2FUCW%2FGallery%2FWeb.pm;h=dbf913a63de4858f97fbdb8ef1359cb08cbf4d47;hb=426863234124dfad2c43a3d6967680c7217bc090;hp=34a76916dc8c16558015b41980550cb9c07243be;hpb=42aa8d92ead61bc53773af56d8fd2c52a6047588;p=gallery.git diff --git a/gal2/UCW/Gallery/Web.pm b/gal2/UCW/Gallery/Web.pm index 34a7691..dbf913a 100644 --- a/gal2/UCW/Gallery/Web.pm +++ b/gal2/UCW/Gallery/Web.pm @@ -11,9 +11,11 @@ use UCW::CGI; use File::Spec; my $show_img; +my $want_archive; my %args = ( 'i' => { 'var' => \$show_img, 'check' => '\d+' }, + 'a' => { 'var' => \$want_archive }, ); sub error($) { @@ -26,11 +28,21 @@ sub get($$) { return $self->{gal}->get($key); } +sub extras($$) { + my ($self, $key) = @_; + my $val = $self->get($key); + if (ref $val eq 'CODE') { + return &$val($self->{gal}); + } else { + return $val; + } +} + sub html_top($) { my ($self) = @_; my $title = UCW::CGI::html_escape($self->get('Title')); - my $hextras = $self->get('WebHeadExtras'); - my $textras = $self->get('WebTopExtras'); + my $hextras = $self->extras('WebHeadExtras'); + my $textras = $self->extras('WebTopExtras'); my $theme_hextras = $self->theme_head_extras; print <get('WebBotExtras'), "\n"; + print $self->extras('WebBotExtras'), "\n"; } sub show_img($) { my ($self) = @_; if ($show_img < 1 || $show_img > $self->{num_photos}) { - UCW::CGI::http_error(404, 'No such photo'); + UCW::CGI::http_error('404 No such photo'); return; } @@ -63,7 +75,7 @@ sub show_img($) { $self->html_top; $self->show_links(($show_img > 1 ? ("?i=".($show_img-1)) : ""), - "?", + ".", ($show_img < $self->{num_photos} ? ("?i=".($show_img+1)) : "")); my $t = UCW::CGI::html_escape($m->{title}); @@ -76,6 +88,14 @@ sub show_img($) { $self->html_bot; } +sub show_pre_thumbs($) { + my ($self) = @_; +} + +sub show_post_thumbs($) { + my ($self) = @_; +} + sub show_list($) { my ($self) = @_; $self->html_top; @@ -84,6 +104,7 @@ sub show_list($) { print "

", $self->get('Title'), "

\n"; my $subtitle = $self->get('SubTitle'); print "

$subtitle

\n" if $subtitle ne ""; + $self->show_pre_thumbs; my $meta = $self->{meta}; for my $idx (1..$self->{num_photos}) { @@ -97,16 +118,21 @@ sub show_list($) { $self->show_thumb($meta, $id, $click_url); } + $self->show_post_thumbs; $self->html_bot(); } sub dispatch($) { my ($self) = @_; + binmode STDOUT, ':utf8'; UCW::CGI::parse_args(\%args); $self->{meta} = $self->{gal}->read_meta(File::Spec->catfile($self->get('CacheDir'), 'cache.meta')); $self->{num_photos} = scalar @{$self->{meta}->{sequence}}; - if ($show_img ne "") { + if ($want_archive) { + require UCW::Gallery::Archive; + UCW::Gallery::Archive::send_archive($self->{gal}, $self->{meta}); + } elsif ($show_img ne "") { $self->show_img; } else { $self->show_list; @@ -118,11 +144,20 @@ sub attach($$) { my $self = { gal => $gal }; $gal->def( WebFE => $self, + + # Extras are either strings or functions called with the current gallery object as parameter WebHeadExtras => "", WebTopExtras => "", WebBotExtras => "", + + # Used by the theming logic WebThemeCSS => undef, + + # 1 if thumbnail link to sub-pages with images, 0 if they link directly to image files WebImageSubpages => 1, + + # If enabled, calling the CGI with a=zip produces a ZIP archive with all photos. + WebAllowArchives => 1, ); bless $self, $class; return $self;