1 # Simple Photo Gallery: Web Interface
2 # (c) 2003--2012 Martin Mares <mj@ucw.cz>
4 package UCW::Gallery::Web;
16 'i' => { 'var' => \$show_img, 'check' => '\d+' },
20 print "<p style='color:red'>Bad luck, the script is broken. Sorry.\n<p>$_[0]\n";
21 print "</body></html>\n";
25 my ($self, $key) = @_;
26 return $self->{gal}->get($key);
31 my $title = UCW::CGI::html_escape($self->get('Title'));
32 my $hextras = $self->get('WebHeadExtras');
33 my $textras = $self->get('WebTopExtras');
34 my $theme_hextras = $self->theme_head_extras;
36 Content-Type: text/html
38 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
46 $UCW::CGI::error_hook = \&error;
51 print $self->get('WebBotExtras'), "\n</body></html>\n";
57 if ($show_img < 1 || $show_img > $self->{num_photos}) {
58 print "Status: 404\n";
60 print "<h1>No such photo</h1>\n";
65 my $meta = $self->{meta};
66 my $id = $meta->{sequence}->[$show_img-1];
67 my $m = $meta->{photo}->{$id} or die;
70 $self->show_links(($show_img > 1 ? ("?i=".($show_img-1)) : ""),
72 ($show_img < $self->{num_photos} ? ("?i=".($show_img+1)) : ""));
74 my $t = UCW::CGI::html_escape($m->{title});
77 print "<h1>$t</h1>\n" if $t ne "";
78 my $img = $self->get('PhotoUrlPrefix') . $id . '.jpg';
79 print "<p class=large><img src='$img' width=$w height=$h alt='$t'>\n";
88 $self->show_links($self->get('BackURL'), $self->get('ParentURL'), $self->get('FwdURL'));
89 print "<h1>", $self->get('Title'), "</h1>\n";
90 my $subtitle = $self->get('SubTitle');
91 print "<h2>$subtitle</h2>\n" if $subtitle ne "";
93 my $meta = $self->{meta};
94 for my $idx (1..$self->{num_photos}) {
95 my $id = $meta->{sequence}->[$idx-1];
97 if ($self->get('WebImageSubpages')) {
98 $click_url = "?i=$idx";
100 $click_url = $self->get('PhotoUrlPrefix') . "$id.jpg";
102 $self->show_thumb($meta, $id, $click_url);
110 UCW::CGI::parse_args(\%args);
111 $self->{meta} = UCW::Gallery::ReadMeta(File::Spec->catfile($self->get('CacheDir'), 'cache.meta'));
112 $self->{num_photos} = scalar @{$self->{meta}->{sequence}};
114 if ($show_img ne "") {
122 my ($class, $gal) = @_;
123 my $self = { gal => $gal };
129 WebThemeCSS => undef,
130 WebImageSubpages => 1,