]> mj.ucw.cz Git - gallery.git/blob - gal/UCW/Gallery/Web/NrtBlue.pm
Little improvements to GeoHack
[gallery.git] / gal / UCW / Gallery / Web / NrtBlue.pm
1 # NRT Theme for MJ's Photo Gallery
2 # (c) 2003--2012 Martin Mares <mj@ucw.cz>; GPL'ed
3 # Theme images taken from the cthumb package (c) Carlos Puchol
4
5 package UCW::Gallery::Web::NrtBlue;
6
7 use strict;
8 use warnings;
9
10 use UCW::Gallery;
11 use UCW::Gallery::Web;
12
13 our @ISA = qw(UCW::Gallery::Web);
14
15 my $theme_name = "nrt-blue";
16 my $navw = 48;
17 my $navh = 48;
18 my $interior_margin = 4;
19 my $left_w = 14;
20 my $right_w = 18;
21 my $top_h = 14;
22 my $bot_h = 18;
23
24 sub theme_dir($) {
25         my ($self) = @_;
26         return $self->get('ThemeUrlPrefix') . $theme_name;
27 }
28
29 sub theme_head_extras($) {
30         my ($self) = @_;
31         my $stylesheet = $self->theme_dir . "/style.css";
32         return "<link rel=stylesheet href='$stylesheet' type='text/css' media=all>\n";
33 }
34
35 sub show_links($$$$) {
36         my ($self, $prev, $up, $next) = @_;
37         my $theme = $self->theme_dir;
38         print "<p class=parent>";
39         print "<span class=back style='width: ${navw}px; height: ${navh}px'>";
40         print "<a href='$prev'><img src='$theme/prev.png' width=${navw} height=${navh} alt='Back'></a>" if $prev ne "";
41         print "</span>\n";
42         printf "<span class=fwd style='width: ${navw}px; height: ${navh}px'>";
43         printf "<a href='$next'><img src='$theme/next.png' width=${navw} height=${navh} alt='Forward'></a>" if $next ne "";
44         print "</span>\n";
45         printf "<a href='$up'><img src='$theme/back.png' width=${navw} height=${navh} alt='Up'></a>" if $up ne "";
46 }
47
48 sub show_thumb($) {
49         my ($self, $meta, $photo_id, $click_url) = @_;
50         my $theme = $self->theme_dir;
51         my $m = $meta->{photo}->{$photo_id};
52         my $annot = UCW::CGI::html_escape($m->{title});
53         my $tf = $self->get('ThumbFormats')->[0];
54         my ($thumb_w, $thumb_h) = $self->{gal}->thumb_fmt_to_size($tf);
55         my $tm = $meta->{thumb}->{$tf}->{$photo_id} or die "No thumbnails for format $tf found!\n";
56         my $tw = $tm->{w};
57         my $th = $tm->{h};
58         my $thumb = $self->get('ThumbUrlPrefix') . "$tf/$photo_id.jpg";
59         my $side_w = $thumb_w + 2*$interior_margin;
60         my $side_h = $thumb_h + 2*$interior_margin;
61         my $box_w = $left_w + $side_w + $right_w;
62         my $box_h = $top_h + $side_h + $bot_h;
63         print "<div class=thf><div class=thumb>\n";
64         print "<img src='$theme/top.png' width=$box_w height=$top_h alt='' class=tt>\n";
65         print "<img src='$theme/left.png' width=$left_w height=$side_h alt='' class=tl>\n";
66         my $ol = $left_w + $interior_margin + int(($thumb_w - $tw)/2);
67         my $ot = $top_h + $interior_margin + int(($thumb_h - $th)/2);
68         my $tit = ($annot ne "") ? " title=\"$annot\"" : "";
69         print "<a href='$click_url'><img src='$thumb' width=$tw height=$th alt='Photo'$tit class=ti style='left: ${ol}px; top: ${ot}px'></a>\n";
70         print "<img src='$theme/right.png' width=$right_w height=$side_h alt='' class=tr>\n";
71         print "<img src='$theme/bot.png' width=$box_w height=$bot_h alt='' class=tb>\n";
72         print "</div></div>\n\n";
73 }
74
75 sub run($$) {
76         my ($class, $gal) = @_;
77         my $self = $class->SUPER::attach($gal);
78         $self->dispatch();
79         return $self;
80 }
81
82 1;