Mail Index


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ApacheGallery] [PATCH] per-image comments configurable in thumbnail index pages



Hello A::G users.

My name is Ian Kluft.  I live in San Jose, Calfornia (a.k.a Silicon Valley.)

I got way behind on posting pictures from trips I went on in 2004,
and needed to improve my "productivity" in putting these together.
I like what I see in Apache::Gallery.

I found A::G does a lot of what I wanted to expand my old ad-hoc image
gallery script to do.  Except that it didn't do something mine already
does.  Just as a matter of my style, I like to have per-image comments
on the thumbnail image pages.  So I've made a patch.

I knew this had to be made configurable because it would otherwise be a
performance hit if it's something you don't use.  So it's disabled by
default.  Otherwise I wouldn't stand a chance of getting this accepted
into A::G.  To turn it on (such as just per directory in a .htaccess
file as I do) use
   PerlSetVar   GalleryIndexImageComments '1'

Here's an example.  (If you visit in the next few hours, you'll find
I'm still adding image comments as I prepare to announce to my friends
at AeroPAC that these pictures are finally posted.)
   http://www.kluft.com/~ikluft/blackrock/aeronaut2004/

Here's my patch relative to snapshot r288...
---------------------------------------------------------------------------
diff -c -r Apache-Gallery-0.9.1-r288/lib/Apache/Gallery.pm Apache-Gallery-0.9.1-r288-ikluft/lib/Apache/Gallery.pm
*** Apache-Gallery-0.9.1-r288/lib/Apache/Gallery.pm	2004-12-09 12:22:19.000000000 -0800
--- Apache-Gallery-0.9.1-r288-ikluft/lib/Apache/Gallery.pm	2005-02-07 22:54:30.549421481 -0800
***************
*** 387,392 ****
--- 387,398 ----
  							 HEIGHT => (grep($rotate==$_, (1, 3)) ? $thumbnailwidth : $thumbnailheight),
  							 WIDTH => (grep($rotate==$_, (1, 3)) ? $thumbnailheight : $thumbnailwidth),
  							 SELECT  => $select_mode?'<input type="checkbox" name="selection" value="'.$file.'">&nbsp;&nbsp;':'',);
+ 					if ( $r->dir_config('GalleryIndexImageComments')) {
+ 						my @tmp = split (/\//, $filename);
+ 						my $picfilename = $file;
+ 						my $path = (join "/", @tmp)."/";
+ 						read_image_comment( $path, $picfilename, \%tpl_vars );
+ 					}
  					$tpl_vars{FILES} .= $templates{picture}->fill_in(HASH => {%tpl_vars,
  												 %file_vars,
  												},
***************
*** 606,618 ****
  		}
  
  		my $foundcomment = 0;
! 		if (-f $path . '/' . $picfilename . '.comment') {
! 			my $comment_ref = get_comment($path . '/' . $picfilename . '.comment');
  			$foundcomment = 1;
- 			$tpl_vars{COMMENT} = $comment_ref->{COMMENT} . '<br>' if $comment_ref->{COMMENT};
- 			$tpl_vars{TITLE} = $comment_ref->{TITLE} if $comment_ref->{TITLE};
- 		} else {
- 			$tpl_vars{COMMENT} = '';
  		}
  
  		my @infos = split /, /, $r->dir_config('GalleryInfo') ? $r->dir_config('GalleryInfo') : 'Picture Taken => DateTimeOriginal, Flash => Flash';
--- 612,620 ----
  		}
  
  		my $foundcomment = 0;
! 		read_image_comment( $path, $picfilename, \%tpl_vars );
! 		if ( $tpl_vars{TITLE} or $tpl_vars{COMMENT}) {
  			$foundcomment = 1;
  		}
  
  		my @infos = split /, /, $r->dir_config('GalleryInfo') ? $r->dir_config('GalleryInfo') : 'Picture Taken => DateTimeOriginal, Flash => Flash';
***************
*** 1459,1464 ****
--- 1461,1479 ----
       return %texttemplate_objects;
  }
  
+ # read per-image .comment file if present
+ sub read_image_comment
+ {
+ 	my ( $path, $picfilename, $tpl_vars_ref ) = @_;
+ 	if (-f $path . '/' . $picfilename . '.comment') {
+ 		my $comment_ref = get_comment($path . '/' . $picfilename . '.comment');
+ 		$tpl_vars_ref->{COMMENT} = $comment_ref->{COMMENT} . '<br>' if $comment_ref->{COMMENT};
+ 		$tpl_vars_ref->{TITLE} = $comment_ref->{TITLE} if $comment_ref->{TITLE};
+ 	} else {
+ 		$tpl_vars_ref->{COMMENT} = '';
+ 	}
+ }
+ 
  1;
  
  =head1 NAME
***************
*** 1731,1736 ****
--- 1746,1759 ----
  Set this option to 1 to convert underscores to spaces in the listing
  of directory names.
  
+ =item B<GalleryIndexImageComments>
+ 
+ Set this option if you want per-image $COMMENT variables to work in the
+ picture.tpl template, which is used on thumbnail index pages.
+ This is disabled by default because it takes more time to read the
+ comment files for each image,
+ and should only be done if you actually want it.
+ 
  =back
  
  =head1 FEATURES
_______________________________________________
users mailing list
[email protected]
http://ufo.hestdesign.com/cgi-bin/mailman/listinfo/agusers