%doc> $Id: dhandler,v 1.2 Oct 25 21:12:07 CDT 2004 rhizo Exp $ %doc> <%init> # $r->send_http_header("text/html"); # setup-dependent %init> <%args> $page => 1 $name => 'faceplant' $title => 'Photo Gallery' $attribute => 1 $sub_gal_wrap => 1 $sub_gal_table_css => 'faceplant-sub-gal-table' $photo_list_wrap => 5 $photo_list_rows => 7 $photo_list_pager_sep => '·' # · $thumb_xsize => 50 $thumb_ysize => 40 $photo_xsize => 300 $photo_ysize => 400 $photo_xsize_small => 300 $photo_ysize_small => 400 $photo_xsize_medium => 600 $photo_ysize_medium => 800 $photo_xsize_large => 1200 $photo_ysize_large => 1600 $thumb_table_css => 'faceplant-thumb-table' %args> <%ARGS> $photo_scale => q/medium/ %ARGS> <%shared> my $bread_crumb_sep = q/ :: /; my $bread_crumb_href_sep = q/ :: /; use List::Group qw[group]; use HTML::Table; use File::Spec::Functions qw[:ALL]; my $d_arg = $m->dhandler_arg; my ($URI_BASE) = ( $r->uri =~ m!^(.+)/(?:$d_arg|index\.html)! ); my $GALLERY_ROOT = $r->document_root . "$URI_BASE/pictures"; (my $path_from_uri = $d_arg) =~ s!(?:(?:/index)?\.html|/)$!!; my $file = catdir $GALLERY_ROOT, $path_from_uri; $m->clear_buffer and $m->abort(404) unless -e $file; my $dir = -d $file ? $file : (splitpath $file)[1]; opendir DIR, $dir or die "$dir: $!"; my $dir_list = [ map "$dir/$_", grep { ! /^\./ } readdir DIR ]; closedir DIR; my @bread_crumb = ('Gallery', splitdir $path_from_uri); my @bread_crumb_href; push @bread_crumb_href, sprintf q|%s|, $URI_BASE, join('/',@bread_crumb[1..$_]), $bread_crumb[$_] for 0 .. $#bread_crumb - 1; # photo re-size onclick push @bread_crumb_href, $bread_crumb[-1]; my $bread_crumb = join $bread_crumb_sep, @bread_crumb; my $bread_crumb_href = join $bread_crumb_href_sep, @bread_crumb_href; %shared>
| <& SELF:.sub_gal_list, dir_list => $dir_list, wrap => $sub_gal_wrap, sub_gal_table_css => $sub_gal_table_css, &> | <& SELF:.photo_list, dir_list => $dir_list, page => $page, wrap => $photo_list_wrap, rows => $photo_list_rows, pager_sep => $photo_list_pager_sep, thumb_xsize => $thumb_xsize, thumb_ysize => $thumb_ysize, thumb_table_css => $thumb_table_css, &> <& SELF:.photo_size_chooser, page => $page, scale => $photo_scale, &> | <& SELF:.photo_view, file => $file, xsize => $photo_xsize, ysize => $photo_ysize, alt => undef, # TODO add annotations comp scale => $photo_scale, # xsize_small => $photo_xsize_small, # ysize_small => $photo_ysize_small, # photo re-size xsize_medium => $photo_xsize_medium, # tweak arguments ysize_medium => $photo_ysize_medium, # xsize_large => $photo_xsize_large, # ysize_large => $photo_ysize_large, # &> |