Re: patch: quoting $dest in scale_image(), $UseMogrify branch

Carlos Puchol <[email protected]> Wed, 15 Jan 2003 02:18:00 -0800
Newsgroups gmane.comp.web.cthumb.devel
Message-ID <[email protected]>
Michael Banck <[email protected]> wrote:
> Hi,
> 
> I've just uploaded a new debian version with a patch for 
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=160647
> 
> I've attached the patch.

thanks!
now that i have relocated, i should have more time to
work on cthumb. sorry for the long delay.
terry, apparently i had not checked this in for a while
and it was dormant in my computer. sorry about that!

what features are people most interested in?
for me, the main index pages are just ugly and
they need an overhaul..

-c

Index: ChangeLog
===================================================================
RCS file: /cvsroot/cthumb/cthumb/ChangeLog,v
retrieving revision 1.27
diff -u -r1.27 ChangeLog
--- ChangeLog	9 Aug 2002 15:44:28 -0000	1.27
+++ ChangeLog	15 Jan 2003 10:20:37 -0000
@@ -1,3 +1,21 @@
+Wed Jan 15 02:13:05 PST 2003 Carlos Puchol <[email protected]>
+
+	* cthumb.in: Michael Bank submitted some fixes (found on
+	  debian, but which apply to all). thanks!
+
+Fri Aug  9 11:14:54 CDT 2002 Terry Gliedt <[email protected]>
+
+	* cthumb.in:
+	  - shorten long titles and descriptions to 50 chars.
+	  - join lines that end in '\'
+	  - parse_option loop optimizations
+	  - add HtmlExtension variable
+	  - add -H option for listing all variables available and
+	    where they apply
+	  - cut down long commentaries
+	  - fix InlineFiles bug, should work now.
+	  - fix diff issue for solaris
+
 Fri Aug  9 10:38:41 CDT 2002 Artur Kedzierski <[email protected]>
 
 	* themes/{ithumb,spotlight}.theme/theme.conf: link color fix
@@ -5,7 +23,7 @@
 Fri Aug  9 02:31:17 CDT 2002 Artur Kedzierski <[email protected]>
 
 	* themes/oak.theme/theme.conf: change default color from white
-	  to visiet link.
+	  to visited link.
 
 Fri Aug  2 17:47:18 CDT 2002 Artur Kedzierski <[email protected]>
 
Index: Makefile.in
===================================================================
RCS file: /cvsroot/cthumb/cthumb/Makefile.in,v
retrieving revision 1.8
diff -u -r1.8 Makefile.in
--- Makefile.in	12 Dec 2001 04:48:50 -0000	1.8
+++ Makefile.in	15 Jan 2003 10:20:37 -0000
@@ -47,7 +47,7 @@
 	mv $(DD).tar.gz releases/
 	rm -rf $(DD)
 
-rpm release: cthumb.spec configure
+rpm release: cthumb.spec configure ex-dist
 	./configure --prefix=/usr
 	mkdir -p releases
 	make dist; cp -f releases/cthumb-$(VERSION).tar.gz /usr/src/redhat/SOURCES/
Index: VERSION
===================================================================
RCS file: /cvsroot/cthumb/cthumb/VERSION,v
retrieving revision 1.13
diff -u -r1.13 VERSION
--- VERSION	15 Dec 2001 22:37:51 -0000	1.13
+++ VERSION	15 Jan 2003 10:20:37 -0000
@@ -1 +1 @@
-4.1
+4.2
Index: cthumb.in
===================================================================
RCS file: /cvsroot/cthumb/cthumb/cthumb.in,v
retrieving revision 1.19
diff -u -r1.19 cthumb.in
--- cthumb.in	2 Aug 2002 22:50:40 -0000	1.19
+++ cthumb.in	15 Jan 2003 10:20:38 -0000
@@ -87,7 +87,8 @@
 	["InsertExif"                 , "boolean", "" , "0"               , " ", "c", " ", "generate automatic Exif info"],
 	["UseMogrify"                 , "boolean", "" , "0"               , " ", "c", " ", "use mogrify for scaling and rotating - required for image rotation"],
 	["RecursiveCP"                , "string" , "" , "@CPR@"           , " ", "x", "x", "'cp -a' for gnu cp, set to 'cp -r' for bsd, else 'rsync -avq'"],
-	["ImageDir"                   , "string" , "" , "@themedir@"      , " ", "c", "x", "directory where themes are found"]
+	["ImageDir"                   , "string" , "" , "@themedir@"      , " ", "c", "x", "directory where themes are found"],
+	["HtmlExtension"              , "string" , "" , "html"            , " ", " ", "x", "files to create - typically html, shtml or php"],
 	);
 
 ############################
@@ -143,6 +144,7 @@
 my $UseMogrify = 0;
 my $RecursiveCP = '';
 my $ImageDir = '';
+my $HtmlExtension = '';
 
 my %opt = ();			# Option flags saved here
 my $InsertExifUrl = '';		# For broken InsertExif code
@@ -182,7 +184,27 @@
 {
     init_options ();
 
-    &getopt('lfxyis', \%opt);
+    &getopt('Hlfxyis', \%opt);
+
+    if (exists($opt{H})) {	    # Show synopsis of cthumb keywords
+        print "These are valid cthumb keywords:\n";
+        foreach my $o (@options) {
+            print "  $o->[0]: $o->[7]\n";
+            print "    Data type: '$o->[1]'  Default value: '$o->[3]'\n";
+            my $allowed = '';
+            my $notallowed = '';
+            if ($o->[4] eq ' ') { $allowed .= '.cthumbrc, '; }
+            else { $notallowed .= '.cthumbrc, '; }
+            if ($o->[5] eq ' ') { $allowed .= '.album files, '; }
+            else { $notallowed .= '.album files, '; }
+            if ($o->[6] eq ' ') { $allowed .= 'theme files,'; }
+            else { $notallowed .= 'theme files,'; }
+            if ($allowed ne '') { chop($allowed); print "    Allowed in $allowed\n"; }
+            if ($notallowed ne '') { chop($notallowed); print "    NOT allowed in $notallowed\n"; }
+            if ($o->[2] ne '') { print "    May be overridden using option '-$o->[2]'\n"; }
+        }
+	    exit 0;
+    }
 
     if (! @ARGV ) {
 	print "usage: cthumb [opts] <fname.album> ...\n\n";
@@ -368,12 +390,12 @@
 		 $options[$i][1] eq "boolean") &&
 		/^$pattern:\s*(\d+)/i) { # integer/boolean w/ or w/o comment
 		eval "\$$options[$i][0] = int($1)";
-			next;
+			last LOOP;
 	    }
 	    if ($options[$i][1] eq "string" &&
 		/^$pattern:\s*(.*)\s*?$/i) { # string w/o comment
 		eval "\$$options[$i][0] = \"$1\"";
-			next;
+			last LOOP;
 	    }
 	    if ($options[$i][1] eq "array" &&
 		/^$pattern:\s*(.*)\s*?$/i) { # array w/o comment
@@ -383,7 +405,7 @@
 		    $NLanguages = $#Languages + 1;
 		    # print "DEBUG: NLanguages: $NLanguages\n";
 		}
-			next;
+			last LOOP;
 	    }
 	    # print "DEBUG: $pattern = $1 ($cmdopt)\n";
 	    last LOOP;
@@ -473,7 +495,7 @@
     /^(.*?)(\.desc|\.txt|\.album)?$/;
     $descindex = $1;
     if ($MainIndexName eq "") {
-	$MainIndexName = $descindex . "-index.shtml";
+	$MainIndexName = $descindex . "-index.$HtmlExtension";
     }
     my $indextmp = "/tmp/.$descindex.tmp.$$";
     if (!open (ALBUM, "<$descfname")) {
@@ -557,7 +579,7 @@
     if ($NoMainIndex) {
 	unlink($indextmp);
     } else {
-        if (system ("diff -q $indextmp $MainIndexName &> /dev/null")) {
+        if (system ("diff $indextmp $MainIndexName >/dev/null 2>/dev/null")) {
 	    print "Index for $descfname in: $MainIndexName\n";
 	    my $cmd = "mv $indextmp $MainIndexName";
 	    if (system($cmd)) { print "cthumb warning: command '$cmd' failed: $!\n"; }
@@ -618,9 +640,9 @@
     $str .= "</title>\n</head>\n";
     $str .= "<body text=\"#000088\" bgcolor=\"$TitleBgColor\" link=\"#000033\" ";
     $str .= "vlink=\"#666600\" alink=\"#ff0000\">\n";
-    if (-e $InlineFiles . $header) {
+    if (-e "$InlineFiles/$header") {
         if ($InlineFiles ne "") {
-	    $str .= inline_file ($header);
+	    $str .= inline_file ("$InlineFiles/$header");
         } else {
 	    $str .= "<!--#include virtual=\"" . $header . "\" paco: $InlineFiles --><br>\n";
         }
@@ -662,12 +684,12 @@
     for my $i (1..$NLanguages) {
 	$append = "";
 	if ($fname !~ /\.s?html$/i) { # if not an html file, guess rationally
-	    if ($NLanguages > 1 && -e ($fname . "-$i.shtml")) {
-		$append =  "-$i.shtml";
-	    } elsif (-e ($fname . ".shtml")) {
-		$append = ".shtml";
+	    if ($NLanguages > 1 && -e ($fname . "-$i.$HtmlExtension")) {
+		$append =  "-$i.$HtmlExtension";
+	    } elsif (-e ($fname . ".$HtmlExtension")) {
+		$append = ".$HtmlExtension";
 	    } else {
-		$append = ".html"; # ok, last attempt. hope the html is there!
+		$append = ".$HtmlExtension"; # ok, last attempt. hope the html is there!
 	    }
 	}
 	$str .= "<td align=\"center\" valign=\"middle\">";
@@ -784,7 +806,7 @@
         my $fname = "$basename$appendage";
 
         # if it comes with a full file name already, do not append the extension
-        $fname .= ".shtml" if ($basename !~ /\.s?html$/i);
+        $fname .= ".$HtmlExtension" if ($basename !~ /\.s?html$/i);
 
 	my $text = "";
 	# if only one row, maybe we have less pictures than $PicturesPortRow, so we need to adjust
@@ -946,7 +968,7 @@
             # be displayed by "100-0103-1-1-1.shtml".
             push @generatedSlideURLArray, "$outputPath/$filename-" .
 		$PageNumber . "-" . $scaleIndexNumber .
-                $slideURLPostfix . ".shtml";
+                $slideURLPostfix . ".$HtmlExtension";
 
 	    $scaleIndexNumber++;
         }
@@ -1676,15 +1698,15 @@
 
     print "\tgenerating $dest ... ";
     if ($UseMogrify) {
-	system "cp $src $dest";
+	system "cp \"$src\" \"$dest\"";
 	my $cmd = "mogrify -rotate \"$destRotate\" -geometry \"${destWidth}x${destHeight}>\" -quality $quality";
 	if ($InsertExif){
-	    my $new_cmd = "jhead -cmd '$cmd &i' $dest";
+	    my $new_cmd = "jhead -cmd '$cmd &i' \"$dest\"";
 	    if (system($new_cmd)) { print "cthumb warning: command '$new_cmd' failed: $!\n"; }
 	    else {print "done.\n";}
 
 	} else {
-	    my $new_cmd = "$cmd $dest";
+	    my $new_cmd = "$cmd \"$dest\"";
 	    if (system($new_cmd)) { print "cthumb warning: command '$new_cmd' failed: $!\n"; }
 	    else {print "done.\n";}
 	}
Index: index.html
===================================================================
RCS file: /cvsroot/cthumb/cthumb/index.html,v
retrieving revision 1.5
diff -u -r1.5 index.html
--- index.html	8 Mar 2002 23:42:06 -0000	1.5
+++ index.html	15 Jan 2003 10:20:38 -0000
@@ -41,30 +41,30 @@
 	get the cvs head for the very latest. Join the development list for contributions or ideas!
 	<p>
 	See examples:
-	<a href="ex23-ithumb/page1-1.shtml">ithumb</a>
-	<a href="ex22-oak/page1-1.shtml">oak</a>
-	<a href="ex21-spotlight/page1-1.shtml">spotlight</a>
-	<a href="ex20-flaps/page1-1.shtml">flaps</a>
-	<a href="ex19-crosshair/page1-1.shtml">crosshair</a>
-	<a href="ex18-float-medium/page1-1.shtml">float-medium</a>
-	<a href="ex17-classic-clips/page1-1.shtml">classic-clips</a>
-	<a href="ex16-classic/page1-1.shtml">classic</a>
-	<a href="ex15-tv/page1-1.shtml">tv</a>
-	<a href="ex14-tv-large/page1-1.shtml">tv-large</a>
-	<a href="ex13-slides-clean/page1-1.shtml">slides-clean</a>
-	<a href="ex12-postcard/page1-1.shtml">postcard</a>,
-	<a href="ex11-float-thick/page1-1.shtml">float-thick</a>,
-	<a href="ex10-float-more/page1-1.shtml">float-more</a>,
-	<a href="ex09-float/page1-1.shtml">float</a>,
-	<a href="ex08-blue-steel/page1-1.shtml">blue-steel</a>,
-	<a href="ex07-shiny-tube/page1-1.shtml">shiny-tube</a>,
-	<a href="ex06-film/page1-1.shtml">film</a>,
-	<a href="ex05-neat-round/page1-1.shtml">neat-round</a>,
-	<a href="ex04-neat-square/page1-1.shtml">neat-square</a>,
-	<a href="ex03-simpleframe/page1-1.shtml">simpleframe</a>,
-	<a href="ex02-slides-huge/page1-1.shtml">slides-huge</a>,
-	<a href="ex01-slides-small/page1-1.shtml">slides-small</a>,
-	<a href="ex00-slides-big/page1-1.shtml">slides-big</a>,
+	<a href="ex23-ithumb/page1-1.html">ithumb</a>
+	<a href="ex22-oak/page1-1.html">oak</a>
+	<a href="ex21-spotlight/page1-1.html">spotlight</a>
+	<a href="ex20-flaps/page1-1.html">flaps</a>
+	<a href="ex19-crosshair/page1-1.html">crosshair</a>
+	<a href="ex18-float-medium/page1-1.html">float-medium</a>
+	<a href="ex17-classic-clips/page1-1.html">classic-clips</a>
+	<a href="ex16-classic/page1-1.html">classic</a>
+	<a href="ex15-tv/page1-1.html">tv</a>
+	<a href="ex14-tv-large/page1-1.html">tv-large</a>
+	<a href="ex13-slides-clean/page1-1.html">slides-clean</a>
+	<a href="ex12-postcard/page1-1.html">postcard</a>,
+	<a href="ex11-float-thick/page1-1.html">float-thick</a>,
+	<a href="ex10-float-more/page1-1.html">float-more</a>,
+	<a href="ex09-float/page1-1.html">float</a>,
+	<a href="ex08-blue-steel/page1-1.html">blue-steel</a>,
+	<a href="ex07-shiny-tube/page1-1.html">shiny-tube</a>,
+	<a href="ex06-film/page1-1.html">film</a>,
+	<a href="ex05-neat-round/page1-1.html">neat-round</a>,
+	<a href="ex04-neat-square/page1-1.html">neat-square</a>,
+	<a href="ex03-simpleframe/page1-1.html">simpleframe</a>,
+	<a href="ex02-slides-huge/page1-1.html">slides-huge</a>,
+	<a href="ex01-slides-small/page1-1.html">slides-small</a>,
+	<a href="ex00-slides-big/page1-1.html">slides-big</a>,
 	<p>
 	</td>
       </tr>
@@ -76,6 +76,48 @@
 	<font face="Comic Sans MS,Verdana" size="+2" color="#ffffff">
 	<b>News</b></font></td>
       </tr>
+      <tr><!-- begin new item -->
+      </tr>
+      <tr>
+	<td align="left" bgcolor="#ffffcc" width="40%">
+	<strong>Version 4.2 available</strong></td>
+	<td><small><tt>Tue Aug 13 12:12:33 CDT 2002</tt></small></td>
+      </tr>
+      <tr>
+	<td align="left" bgcolor="#ffffff" colspan="2">
+	Download Version <strong>4.2</strong>:
+	<ul>
+	  <li>as a convenient <a href="http://prdownloads.sourceforge.net/cthumb/cthumb-4.2-1.noarch.rpm">RPM</a>
+	      file (230Kb), plus some <strong>required perl modules</strong>,
+	      which I am <a href="perl-modules.tgz">making available</a>
+	      locally for your download convenience (70Kb, download only if
+	      you don't have them installed already).
+	  <li>or as a <a href="http://prdownloads.sourceforge.net/cthumb/cthumb-4.2-1.src.rpm">source RPM</a>
+	      (350Kb),
+	  <li>or as a <a href="http://prdownloads.sourceforge.net/cthumb/cthumb-4.2.tar.gz">tarball</a> (350Kb).
+	  <li>the <a href="http://prdownloads.sourceforge.net/cthumb/cthumb-examples-4.2.tar.gz">examples tarball</a> (1.1Mb - from version 4.0) are optional
+		and shipped separately.
+	</ul>
+	<p>
+	Here is what is new. Many thanks to Terry Gliedt and Artur Kedzierski!:
+	<ul>
+	  <li>shorten long titles and descriptions to 50 chars.
+	  <li>join lines that end in '\'.
+	  <li>parse_option loop optimizations.
+	  <li>add HtmlExtension variable.
+	  <li>add -H option for listing all variables available and where they apply.
+	  <li>cut down long commentaries.
+	  <li>fix InlineFiles bug, should work now.
+	  <li>fix diff issue for solaris.
+	  <li>themes/{ithumb,spotlight}.theme/theme.conf: link color fix
+	  <li>themes/oak.theme/theme.conf: change default color from white to visited link.
+	  <li>fix for the AutoSlideTime. changed it to default to 2 seconds.
+	  <li>correct wrong capitalization of doctype tag.
+	</ul>
+	<p>
+	Enjoy it and send <a href="mailto:[email protected]">bug reports,
+	comments, patches, etc.</a>.
+	</td></tr><!-- end new item -->
       <tr><!-- begin new item -->
       </tr>
       <tr>


-------------------------------------------------------
This SF.NET email is sponsored by: Take your first step towards giving 
your online business a competitive advantage. Test-drive a Thawte SSL 
certificate - our easy online guide will show you how. Click here to get 
started: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0027en