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">
40 $hextras$theme_hextras<title>$title</title>
44 $UCW::CGI::ErrorHandler::error_hook = \&error;
49 print $self->get('WebBotExtras'), "</body></html>\n";
55 if ($show_img < 1 || $show_img > $self->{num_photos}) {
56 UCW::CGI::http_error(404, 'No such photo');
60 my $meta = $self->{meta};
61 my $id = $meta->{sequence}->[$show_img-1];
62 my $m = $meta->{photo}->{$id} or die;
65 $self->show_links(($show_img > 1 ? ("?i=".($show_img-1)) : ""),
67 ($show_img < $self->{num_photos} ? ("?i=".($show_img+1)) : ""));
69 my $t = UCW::CGI::html_escape($m->{title});
72 print "<h1>$t</h1>\n" if $t ne "";
73 my $img = $self->get('PhotoUrlPrefix') . $id . '.jpg';
74 print "<p class=large><img src='$img' width=$w height=$h alt='$t'>\n";
79 sub show_pre_thumbs($) {
83 sub show_post_thumbs($) {
91 $self->show_links($self->get('BackURL'), $self->get('ParentURL'), $self->get('FwdURL'));
92 print "<h1>", $self->get('Title'), "</h1>\n";
93 my $subtitle = $self->get('SubTitle');
94 print "<h2>$subtitle</h2>\n" if $subtitle ne "";
95 $self->show_pre_thumbs;
97 my $meta = $self->{meta};
98 for my $idx (1..$self->{num_photos}) {
99 my $id = $meta->{sequence}->[$idx-1];
101 if ($self->get('WebImageSubpages')) {
102 $click_url = "?i=$idx";
104 $click_url = $self->get('PhotoUrlPrefix') . "$id.jpg";
106 $self->show_thumb($meta, $id, $click_url);
109 $self->show_post_thumbs;
115 binmode STDOUT, ':utf8';
116 UCW::CGI::parse_args(\%args);
117 $self->{meta} = $self->{gal}->read_meta(File::Spec->catfile($self->get('CacheDir'), 'cache.meta'));
118 $self->{num_photos} = scalar @{$self->{meta}->{sequence}};
120 if ($show_img ne "") {
128 my ($class, $gal) = @_;
129 my $self = { gal => $gal };
135 WebThemeCSS => undef,
136 WebImageSubpages => 1,