1 # Simple Photo Gallery: Web Interface
2 # (c) 2003--2005 Martin Mares <mj@ucw.cz>
5 import Gallery qw(%CF);
13 'i' => { 'var' => \$show_img, 'check' => '\d+' },
14 'a' => { 'var' => \$send_archive }
18 UCW::CGI::parse_args(\%args);
19 if ($send_archive && $CF{'AllowArchives'}) {
20 require Gallery::Archive;
21 return new Gallery::Archive($send_archive);
28 print "<p style='color:red'>Bad luck, the script is broken. Sorry.\n<p>$_[0]\n";
29 print "</body></html>\n";
32 our (@images, %widths, %heights, %widths_orig, %heights_orig, %imgno);
39 my $notes = $CF{'MetaDataDir'} . "/notes";
40 open NOTES, $notes or die "Unable to read notes ($notes): $!";
43 my ($n, $w, $h, $wo, $ho) = split /\s+/;
47 $widths_orig{$n} = $wo;
48 $heights_orig{$n} = $ho;
49 $imgno{$n} = $#images;
55 my ($prev, $up, $next) = @_;
56 print "<p class=parent>";
57 print "<span class=back style='width: $CF{'BackW'}px; height: $CF{'BackH'}px'>";
58 print "<a href='$prev'><img src='$CF{'BackImg'}' width=$CF{'BackW'} height=$CF{'BackH'} alt='Back'></a>" if $prev ne "";
60 print "<span class=fwd style='width: $CF{'FwdW'}px; height: $CF{'FwdH'}px'>";
61 print "<a href='$next'><img src='$CF{'FwdImg'}' width=$CF{'FwdW'} height=$CF{'FwdH'} alt='Forward'></a>" if $next ne "";
63 print "<a href='$up'><img src='$CF{'ParentImg'}' width=$CF{'ParentW'} height=$CF{'ParentH'} alt='Up'></a>\n" if $up ne "";
67 my $title = UCW::CGI::html_escape($CF{"Title"});
69 Content-Type: text/html
71 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
74 <link rel=stylesheet href="$CF{"StyleSheet"}" type="text/css" media=all>
79 $UCW::CGI::error_hook = \&error;
81 if ($show_img ne "" && $show_img > 0 && $show_img <= $#images) {
82 show_links(($show_img > 1 ? ("?i=".($show_img-1)) : ""),
84 ($show_img < $#images ? ("?i=".($show_img+1)) : ""));
86 show_links($CF{'BackURL'}, $CF{'ParentURL'}, $CF{'FwdURL'});
87 print "<h1>$CF{'Title'}</h1>\n";
88 print "<h2>$CF{'SubTitle'}</h2>\n" if defined $CF{'SubTitle'};
93 print "$CF{'BotExtras'}\n</body></html>\n";
98 print $h if $show_img eq "";
102 my ($this, $orig, $annot) = @_;
103 my ($base, $ext) = ($orig =~ /^(.*)\.([^.]+)$/) or die "Unable to dissect name $orig";
104 $annot = UCW::CGI::html_escape($annot);
105 my $id = $imgno{$base} || 0;
107 if ($show_img ne "") {
108 if ($id == $show_img) {
109 print "<h1>$annot</h1>\n" if $annot ne "";
110 my $img = $CF{'PhotoUrlPrefix'} . $orig;
111 print "<p class=large><img src='$img' width=$widths_orig{$base} height=$heights_orig{$base} alt='$orig'>\n";
116 my $thumb = $CF{'ThumbUrlPrefix'} . "$base-thumb.jpg";
117 my $w = $widths{$base} || 10;
118 my $h = $heights{$base} || 10;
119 my $side_w = $CF{"ThumbW"} + 2*$CF{"InteriorMargin"};
120 my $side_h = $CF{"ThumbH"} + 2*$CF{"InteriorMargin"};
121 my $box_w = $CF{"LeftW"} + $side_w + $CF{"RightW"};
122 my $box_h = $CF{"TopH"} + $side_h + $CF{"BotH"};
123 print "<div class=thf><div class=thumb>\n";
124 print "<img src='$CF{'TopImg'}' width=$box_w height=$CF{'TopH'} alt='' class=tt>\n";
125 print "<img src='$CF{'LeftImg'}' width=$CF{'LeftW'} height=$side_h alt='' class=tl>\n";
126 my $ol = $CF{'LeftW'} + $CF{'InteriorMargin'} + int(($CF{'ThumbW'} - $w)/2);
127 my $ot = $CF{'TopH'} + $CF{'InteriorMargin'} + int(($CF{'ThumbH'} - $h)/2);
128 my $tit = ($annot ne "") ? " title=\"$annot\"" : "";
129 my $url = ($CF{"ImageSubpages"} ? "?i=$id" : $orig);
130 print "<a href='$url'><img src='$thumb' width=$w height=$h alt='$orig'$tit class=ti style='left: ${ol}px; top: ${ot}px'></a>\n";
131 print "<img src='$CF{'RightImg'}' width=$CF{'RightW'} height=$side_h alt='' class=tr>\n";
132 print "<img src='$CF{'BotImg'}' width=$box_w height=$CF{'BotH'} alt='' class=tb>\n";
134 # if ($annot ne "") {
135 # print "<p class=annot>$annot\n";