Mail Index


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

[ApacheGallery] Re: Various improvements to Apache::Gallery



Hi,

Further improvements

- Re-add the ability to have working thumbnails for navigation at the
  bottom of the page (controlled via templates).
- Add with/height tags to the main picture shown
- With mod_perl2 one need to use Apache::ServerRec instead of
  Apache::Server

For a example of the new look, see

  http://jesper.skriver.dk/pics/UK/walks/cumbria/img_4476.jpg

Attached the changed files

If you do not want the thumbnail links, or want to change that to text
links, you need to edit the showpicture.tpl, and change this section:

      <tr>
      <td align="left" rowspan=2>
        { $BACK_THUMB }
      </td>
      <td align="center">
        { $PICTUREINFO }
      </td>
      <td align="right" rowspan=2>
        { $NEXT_THUMB }
      </td>
      </tr>
      <tr>

to either

      <tr>
      <td align="left" rowspan=2>
        { $BACK }
      </td>
      <td align="center">
        { $PICTUREINFO }
      </td>
      <td align="right" rowspan=2>
        { $NEXT }
      </td>
      </tr>
      <tr>

For text links, or

      <tr>
      <td align="left" rowspan=2>
        &nbsp;
      </td>
      <td align="center">
        { $PICTUREINFO }
      </td>
      <td align="right" rowspan=2>
        &nbsp;
      </td>
      </tr>
      <tr>

For no links.

/Jesper

On Sun, Nov 21, 2004 at 05:42:29PM +0100, Jesper Skriver wrote:
> Hi,
> 
> I've made what I believe is a few minor improvements to the look
> of the pages rendered by Apache::Gallery
> 
> - Less space wasted at the top of the page, above the picture,
>   reducing the risk of having to scroll down, to see the bottom
>   bit if the picture.
> - Put the comment for the picture in a box seperate from the info
>   to make it more visible.
> - Render the directory comments in the same way we render picture
>   info/comments, that is in a box with a dark background with the
>   default style sheet.
> 
> Attached my changes, please consider them for inclusion in the next
> release.
> 
> /Jesper
> 
> -- 
> Jesper Skriver, jesper(at)skriver(dot)dk  -  CCIE #5456
> 
> One Unix to rule them all, One Resolver to find them,
> One IP to bring them all and in the zone to bind them.

> --- /usr/local/lib/perl5/site_perl/5.8.5/Apache/Gallery.pm.bak	Sun Nov 21 16:33:15 2004
> +++ //usr/local/lib/perl5/site_perl/5.8.5/Apache/Gallery.pm	Sun Nov 21 16:52:17 2004
> @@ -515,6 +515,8 @@
>  				slideshowoff   => "$tpl_dir/slideshowoff.tpl",
>  				pictureinfo    => "$tpl_dir/pictureinfo.tpl",
>  				nopictureinfo  => "$tpl_dir/nopictureinfo.tpl",
> +				picturecomment    => "$tpl_dir/picturecomment.tpl",
> +				nopicturecomment  => "$tpl_dir/nopicturecomment.tpl",
>  			       );
>  
>  		my $resolution = (($image_width > $orig_width) && ($height > $orig_height)) ? 
> @@ -662,8 +664,7 @@
>  			$tpl_vars{INFO} = "";
>  		}
>  
> -		if ($exif_mode eq 'namevalue' && $foundinfo or $foundcomment) {
> -
> +		if ($exif_mode eq 'namevalue' && $foundinfo) {
>  			$tpl_vars{PICTUREINFO} = fill_in_file($tpl_vars{pictureinfo},
>  				HASH => \%tpl_vars
>  			);
> @@ -671,10 +672,22 @@
>  			unless (defined($exifvalues)) {
>  				$tpl_vars{EXIFVALUES} = "";
>  			}
> -
>  		}
>  		else {
>  			$tpl_vars{PICTUREINFO} = fill_in_file($tpl_vars{nopictureinfo},
> +					HASH => \%tpl_vars,
> +			);
> +		}
> +
> +		if ($foundcomment) {
> +			$tpl_vars{PICTURECOMMENT} =
> +				fill_in_file($tpl_vars{picturecomment},
> +				HASH => \%tpl_vars
> +			);
> +		}
> +		else {
> +			$tpl_vars{PICTURECOMMENT} =
> +					fill_in_file($tpl_vars{nopicturecomment},
>  					HASH => \%tpl_vars,
>  			);
>  		}

> <td width="60%">
>           <center>
>             <table align="center">
>               <tr>
>                 <td>
> 									&nbsp;
>                 </td>
>               </tr>
>             </table>
>           </center>
> </td>

>               <tr>
>                  <td colspan="3">
>                    <div id="comment">
>                       { $COMMENT }
>                    </div>
>                  </td>
>               </tr>

> Only in .: #showpicture.tpl#
> Only in .: a
> diff -u /usr/local/apache/gallery/templates/dircomment.tpl ./dircomment.tpl
> --- /usr/local/apache/gallery/templates/dircomment.tpl	Fri Nov 19 17:24:28 2004
> +++ ./dircomment.tpl	Sun Nov 21 16:53:43 2004
> @@ -2,7 +2,7 @@
>    <td>
>  <table class="info">
>    <tr>
> -    <td>
> +    <td id="comment">
>      { $COMMENT }
>      </td>
>    </tr>
> Only in .: nopicturecomment.tpl
> Only in .: picturecomment.tpl
> diff -u /usr/local/apache/gallery/templates/pictureinfo.tpl ./pictureinfo.tpl
> --- /usr/local/apache/gallery/templates/pictureinfo.tpl	Fri Nov 19 17:24:28 2004
> +++ ./pictureinfo.tpl	Sun Nov 21 16:49:00 2004
> @@ -2,7 +2,6 @@
>                   <td colspan="3">
>                     <div id="comment">
>                        { $INFO }
> -                      { $COMMENT }
>                     </div>
>                   </td>
>                </tr>
> diff -u /usr/local/apache/gallery/templates/showpicture.tpl ./showpicture.tpl
> --- /usr/local/apache/gallery/templates/showpicture.tpl	Fri Nov 19 17:24:28 2004
> +++ ./showpicture.tpl	Sun Nov 21 17:01:30 2004
> @@ -1,30 +1,37 @@
>  <div id="page">
> -  <div id="title">
> -    { $MENU }
> -  </div>
> -
> -  <div id="menu">
> -{ $BACK } - <a href="./">up</a> - { $NEXT }</div>
> +  <table width=100% border=0 cellspacing=0 cellpadding=0>
> +    <tr>
> +      <td align="LEFT" id="title">
> +        { $MENU }
> +      </td>
> +      <td align="RIGHT" id="menu">
> +        { $BACK } - <a href="./">up</a> - { $NEXT }
> +      </td>
> +    </tr>
> +    <tr>
> +      <td align="CENTER" id="picture" colspan=2>
> +        IMG { $NUMBER } of { $TOTAL }
> +      </td>
> +    </tr>
> +  </table>
>    <div>
> -    <table>
> +    <table border=0 cellspacing=0 cellpadding=0>
>        <tr>
> -
> -        <td colspan="3" id="picture">
> -          IMG { $NUMBER } of { $TOTAL } { $EXIFVALUES } <br><br>
> -          <img src="{ $SRC }" alt="* Image { $NUMBER }"><br><br>
> -[ Size: { $SIZES } | Slideshow: { $SLIDESHOW } ]</td>
> -
> -              </tr>
> -              { $PICTUREINFO }
> +       <td colspan="3" id="picture">
> +          { $EXIFVALUES }
> +          <img src="{ $SRC }" alt="* Image { $NUMBER }"><br>
> +          [ Size: { $SIZES } | Slideshow: { $SLIDESHOW } ]
> +       </td>
> +      </tr>
> +      { $PICTUREINFO }
> +      { $PICTURECOMMENT }
> +      <tr>
> +	<td colspan="3">
> +	  <div id="gallery">
> +	  <a href="http://apachegallery.dk/";>Apache::Gallery</a> &copy; 2001-2004 Michael Legart, <a href="http://www.hestdesign.com/";>Hest Design</a>
> +	  </div>
> +	</td>
>        </tr>
> -	  <tr>
> -	  	<td colspan="3">
> -		  <div id="gallery">
> -		  <a href="http://apachegallery.dk/";>Apache::Gallery</a> &copy; 2001-2004 Michael Legart, <a href="http://www.hestdesign.com/";>Hest Design</a>
> -
> -		  </div>
> -		</td>
> -	  </tr>
>      </table>
>    </div>
>  </div>


/Jesper

-- 
Jesper Skriver, jesper(at)skriver(dot)dk  -  CCIE #5456

One Unix to rule them all, One Resolver to find them,
One IP to bring them all and in the zone to bind them.
<a href="{ $URL }?width={ $WIDTH }">
<img alt="{ $FILENAME }" src="{ $PICTURE }" width="{ $T_WIDTH }" height="{ $T_HEIGHT }">
</a>
&nbsp;
<div id="comment">
{ $COMMENT }
</div>
Only in .: #showpicture.tpl#
diff -u /usr/local/src/Apache-Gallery-0.9.1/templates/new/dircomment.tpl ./dircomment.tpl
--- /usr/local/src/Apache-Gallery-0.9.1/templates/new/dircomment.tpl	Fri Jan  2 13:45:06 2004
+++ ./dircomment.tpl	Sun Nov 21 19:17:18 2004
@@ -2,7 +2,7 @@
   <td>
 <table class="info">
   <tr>
-    <td>
+    <td id="comment">
     { $COMMENT }
     </td>
   </tr>
Only in .: navpicture_thumb.tpl
Only in .: nopicturecomment.tpl
diff -u /usr/local/src/Apache-Gallery-0.9.1/templates/new/nopictureinfo.tpl ./nopictureinfo.tpl
--- /usr/local/src/Apache-Gallery-0.9.1/templates/new/nopictureinfo.tpl	Sun Sep  7 19:34:36 2003
+++ ./nopictureinfo.tpl	Sun Nov 21 19:17:20 2004
@@ -1,11 +1 @@
-<td width="60%">
-          <center>
-            <table align="center">
-              <tr>
-                <td>
-									&nbsp;
-                </td>
-              </tr>
-            </table>
-          </center>
-</td>
+&nbsp;
Only in .: picturecomment.tpl
diff -u /usr/local/src/Apache-Gallery-0.9.1/templates/new/pictureinfo.tpl ./pictureinfo.tpl
--- /usr/local/src/Apache-Gallery-0.9.1/templates/new/pictureinfo.tpl	Fri Jan  2 13:45:06 2004
+++ ./pictureinfo.tpl	Sun Nov 21 19:17:20 2004
@@ -1,8 +1,3 @@
-              <tr>
-                 <td colspan="3">
-                   <div id="comment">
-                      { $INFO }
-                      { $COMMENT }
-                   </div>
-                 </td>
-              </tr>
+<div id="comment">
+{ $INFO }
+</div>
diff -u /usr/local/src/Apache-Gallery-0.9.1/templates/new/showpicture.tpl ./showpicture.tpl
--- /usr/local/src/Apache-Gallery-0.9.1/templates/new/showpicture.tpl	Mon Apr 26 15:06:51 2004
+++ ./showpicture.tpl	Sun Nov 21 19:17:21 2004
@@ -1,30 +1,51 @@
 <div id="page">
-  <div id="title">
-    { $MENU }
-  </div>
-
-  <div id="menu">
-{ $BACK } - <a href="./">up</a> - { $NEXT }</div>
+  <table width=100% border=0 cellspacing=0 cellpadding=0>
+    <tr>
+      <td align="LEFT" id="title">
+        { $MENU }
+      </td>
+      <td align="RIGHT" id="menu">
+        { $BACK } - <a href="./">up</a> - { $NEXT }
+      </td>
+    </tr>
+    <tr>
+      <td align="CENTER" id="picture" colspan=2>
+        IMG { $NUMBER } of { $TOTAL }
+      </td>
+    </tr>
+  </table>
   <div>
-    <table>
+    <table border=0 cellspacing=5 cellpadding=0>
       <tr>
-
-        <td colspan="3" id="picture">
-          IMG { $NUMBER } of { $TOTAL } { $EXIFVALUES } <br><br>
-          <img src="{ $SRC }" alt="* Image { $NUMBER }"><br><br>
-[ Size: { $SIZES } | Slideshow: { $SLIDESHOW } ]</td>
-
-              </tr>
-              { $PICTUREINFO }
+       <td colspan="3" id="picture">
+          { $EXIFVALUES }
+          <img src="{ $SRC }" alt="* Image { $NUMBER }" width="{ $WIDTH }" height="{ $HEIGHT }"><br>
+          [ Size: { $SIZES } | Slideshow: { $SLIDESHOW } ]
+       </td>
+      </tr>
+      <tr>
+      <td align="left" rowspan=2>
+        { $BACK_THUMB }
+      </td>
+      <td align="center">
+        { $PICTUREINFO }
+      </td>
+      <td align="right" rowspan=2>
+        { $NEXT_THUMB }
+      </td>
+      </tr>
+      <tr>
+      <td align="center">
+        { $PICTURECOMMENT }
+      </td>
+      </tr>
+      <tr>
+        <td colspan=3>
+	  <div id="gallery">
+	  <a href="http://apachegallery.dk/";>Apache::Gallery</a> &copy; 2001-2004 Michael Legart, <a href="http://www.hestdesign.com/";>Hest Design</a>
+	  </div>
+	</td>
       </tr>
-	  <tr>
-	  	<td colspan="3">
-		  <div id="gallery">
-		  <a href="http://apachegallery.dk/";>Apache::Gallery</a> &copy; 2001-2004 Michael Legart, <a href="http://www.hestdesign.com/";>Hest Design</a>
-
-		  </div>
-		</td>
-	  </tr>
     </table>
   </div>
 </div>
Only in .: showpicture.tpl.bak
Only in .: templates.diff
--- /usr/local/src/Apache-Gallery-0.9.1/blib/lib/Apache/Gallery.pm	Sat Sep 11 23:53:05 2004
+++ /usr/local/lib/perl5/site_perl/5.8.5/Apache/Gallery.pm	Sun Nov 21 19:18:00 2004
@@ -20,7 +20,7 @@
 	
 	if ($::MP2) {
 		require Apache2;
-		require Apache::Server;
+		require Apache::ServerRec;
 		require Apache::RequestRec;
 		require Apache::Log;
 		require APR::Table;
@@ -370,7 +370,6 @@
 					my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $width, $height);	
 					my $imageinfo = get_imageinfo($r, $thumbfilename, $type, $width, $height);
 					my $cached = get_scaled_picture_name($thumbfilename, $thumbnailwidth, $thumbnailheight);
-
 					my $rotate = readfile_getnum($r, $imageinfo, $thumbfilename.".rotate");
 					my %file_vars = (FILEURL => uri_escape($fileurl, $escape_rule),
 							 FILE    => $file,
@@ -504,6 +503,7 @@
 		my %tpl_vars = (layout         => "$tpl_dir/layout.tpl",
 				picture        => "$tpl_dir/showpicture.tpl",
 				navpicture     => "$tpl_dir/navpicture.tpl",
+				navpicture_thumb => "$tpl_dir/navpicture_thumb.tpl",
 				info           => "$tpl_dir/info.tpl",
 				scale          => "$tpl_dir/scale.tpl",
 				scaleactive    => "$tpl_dir/scaleactive.tpl",
@@ -515,8 +515,22 @@
 				slideshowoff   => "$tpl_dir/slideshowoff.tpl",
 				pictureinfo    => "$tpl_dir/pictureinfo.tpl",
 				nopictureinfo  => "$tpl_dir/nopictureinfo.tpl",
+				picturecomment    => "$tpl_dir/picturecomment.tpl",
+				nopicturecomment  => "$tpl_dir/nopicturecomment.tpl",
 			       );
 
+		# Check if we are rotating the picture.
+		my $rotate = readfile_getnum($r, $imageinfo, $filename.".rotate");
+		if (grep($rotate==$_, (1, 3))) {
+			my $tmp = $image_width;
+			$image_width = $height;
+			$height = $tmp;
+
+			$tmp = $orig_width;
+			$orig_width = $orig_height;
+			$orig_height = $tmp;
+		}
+
 		my $resolution = (($image_width > $orig_width) && ($height > $orig_height)) ? 
 			"$orig_width x $orig_height" : "$image_width x $height";
 
@@ -526,6 +540,9 @@
 		$tpl_vars{MENU} = generate_menu($r);
 		$tpl_vars{SRC} = uri_escape(".cache/$cached", $escape_rule);
 		$tpl_vars{URI} = $r->uri();
+
+		$tpl_vars{WIDTH} = $image_width;
+		$tpl_vars{HEIGHT} = $height;
 	
 		my $exif_mode = $r->dir_config('GalleryEXIFMode');
 		unless ($exif_mode) {
@@ -562,15 +579,26 @@
 					my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $orig_width, $orig_height);	
 					my $imageinfo = get_imageinfo($r, $path.$prevpicture, $type, $orig_width, $orig_height);
 					my $cached = get_scaled_picture_name($path.$prevpicture, $thumbnailwidth, $thumbnailheight);
+					my $rotate = readfile_getnum($r, $imageinfo, $path.$prevpicture.".rotate");
 					my %nav_vars;
 					$nav_vars{URL}       = uri_escape($prevpicture, $escape_rule);
 					$nav_vars{FILENAME}  = $prevpicture;
 					$nav_vars{WIDTH}     = $width;
+					if (grep($rotate==$_, (1, 3))) {
+						$nav_vars{T_WIDTH}   = $thumbnailheight;
+						$nav_vars{T_HEIGHT}  = $thumbnailwidth;
+					} else {
+						$nav_vars{T_WIDTH}   = $thumbnailwidth;
+						$nav_vars{T_HEIGHT}  = $thumbnailheight;
+					}
 					$nav_vars{PICTURE}   = uri_escape(".cache/$cached", $escape_rule);
 					$nav_vars{DIRECTION} = "&laquo; prev";
 					$tpl_vars{BACK} = fill_in_file($tpl_vars{navpicture},
 								       HASH => \%nav_vars,
 								      );
+					$tpl_vars{BACK_THUMB} = fill_in_file($tpl_vars{navpicture_thumb},
+								       HASH => \%nav_vars,
+								      );
 				}
 				else {
 					$tpl_vars{BACK} = "&nbsp";
@@ -586,16 +614,27 @@
 					my ($thumbnailwidth, $thumbnailheight) = get_thumbnailsize($r, $orig_width, $orig_height);	
 					my $imageinfo = get_imageinfo($r, $path.$nextpicture, $type, $thumbnailwidth, $thumbnailheight);
 					my $cached = get_scaled_picture_name($path.$nextpicture, $thumbnailwidth, $thumbnailheight);
+					my $rotate = readfile_getnum($r, $imageinfo, $path.$nextpicture.".rotate");
 					my %nav_vars;
 					$nav_vars{URL}       = uri_escape($nextpicture, $escape_rule);
 					$nav_vars{FILENAME}  = $nextpicture;
 					$nav_vars{WIDTH}     = $width;
+					if (grep($rotate==$_, (1, 3))) {
+						$nav_vars{T_WIDTH}   = $thumbnailheight;
+						$nav_vars{T_HEIGHT}  = $thumbnailwidth;
+					} else {
+						$nav_vars{T_WIDTH}   = $thumbnailwidth;
+						$nav_vars{T_HEIGHT}  = $thumbnailheight;
+					}
 					$nav_vars{PICTURE}   = uri_escape(".cache/$cached", $escape_rule);
 					$nav_vars{DIRECTION} = "next &raquo;";
 
 					$tpl_vars{NEXT} = fill_in_file($tpl_vars{navpicture},
 							HASH => \%nav_vars
 					);
+					$tpl_vars{NEXT_THUMB} = fill_in_file($tpl_vars{navpicture_thumb},
+							HASH => \%nav_vars
+					);
 				}
 				else {
 					$tpl_vars{NEXT} = "&nbsp;";
@@ -662,8 +701,7 @@
 			$tpl_vars{INFO} = "";
 		}
 
-		if ($exif_mode eq 'namevalue' && $foundinfo or $foundcomment) {
-
+		if ($exif_mode eq 'namevalue' && $foundinfo) {
 			$tpl_vars{PICTUREINFO} = fill_in_file($tpl_vars{pictureinfo},
 				HASH => \%tpl_vars
 			);
@@ -671,10 +709,22 @@
 			unless (defined($exifvalues)) {
 				$tpl_vars{EXIFVALUES} = "";
 			}
-
 		}
 		else {
 			$tpl_vars{PICTUREINFO} = fill_in_file($tpl_vars{nopictureinfo},
+					HASH => \%tpl_vars,
+			);
+		}
+
+		if ($foundcomment) {
+			$tpl_vars{PICTURECOMMENT} =
+				fill_in_file($tpl_vars{picturecomment},
+				HASH => \%tpl_vars
+			);
+		}
+		else {
+			$tpl_vars{PICTURECOMMENT} =
+					fill_in_file($tpl_vars{nopicturecomment},
 					HASH => \%tpl_vars,
 			);
 		}