Another patch

Koos Pol <[email protected]> Wed, 15 Jun 2005 21:27:18 +0200
Newsgroups gmane.comp.web.cthumb.devel
Message-ID <[email protected]>
--Boundary-00=_WEIsCfCcHp8d7Vl
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Good day yawl,

I was a bit confused trying to annotate pictures. I needed to create 
additional annotation files, keeping names in sync with the picture name.
That was a bit too much (for my taste at least).

The following patch allows you to include annotation in the description 
itself. Here's a short piece of the modifed README:

+To annotate a picture with an additional longer text, use the extended
+description with the annotation between braces:
+
+        - image003.jpg
+                Graduation class 2005 {l2r: John, Mark, Marie, Melvin}
+
+

This keeps the annotations nicely together with the rest of the stuff.

BTW, the patch also removes an superfluous 'StoryOn' test. (That was already 
checked for)

Cheers,
Koos


-- 
KP
[email protected]

--Boundary-00=_WEIsCfCcHp8d7Vl
Content-Type: text/x-diff;
  charset="us-ascii";
  name="README.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="README.patch"

Index: README
===================================================================
RCS file: /cvsroot/cthumb/cthumb/README,v
retrieving revision 1.6
diff -u -b -B -r1.6 README
--- README	12 Dec 2001 04:48:50 -0000	1.6
+++ README	15 Jun 2005 19:19:24 -0000
@@ -260,13 +260,21 @@
         - image002.jpg
                 ...
 
-To annotate a picture with an additional longer text, create a text file in
-the same directory as the picture file with the following schema:
+
+To annotate a picture with an additional longer text, use the extended
+description with the annotation between braces:
+
+        - image003.jpg
+                Graduation class 2005 {l2r: John, Mark, Marie, Melvin}
+
+
+Alternatively you can create a text file in the same directory as the
+picture file with the following schema:
 
 	picturename.language
 
-Using the example above, the name would be "image001.jpg.english", if
-the first language is English. Please note, that the language is
+Using the first example above, the name would be "image001.jpg.english",
+if the first language is English. Please note, that the language is
 always in lower case. To activate this feature, use the following
 setting: StoryOn=1
 

--Boundary-00=_WEIsCfCcHp8d7Vl
Content-Type: text/x-diff;
  charset="us-ascii";
  name="cthumb.in.patch.2"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="cthumb.in.patch.2"

--- cthumb	2005-06-15 21:01:25.310323593 +0200
+++ /usr/local/bin/cthumb	2005-06-15 20:43:15.246774027 +0200
@@ -815,15 +815,24 @@
             chop($l);
             $l .= <ALBUM>;
         }
-        if ($l =~ /\\$/) { chomp($l); chop($l); }
+                if ($l =~ /\\$/) { chomp($l); chop($l); }  # last line, EOF
         $_ = $l;                    # Continue with one long line
 	    if (/^(Page|\s*[-<>] )/) {
 		goto top;
 	    }
-	    /^\s*(.*?)\s*$/;
-	    $desc[$i][$npics-1] = $1 unless ($1 eq '');
+                s/^\s*//;
+                s/\s*$//;
+                if ($_) {
+                    if (/{.*?}/) {  # story text ?
+                        /^(.*?){(.*?)}/;  # extract it
+                        $desc[$i][$npics-1] = $1;
+                        $story[$i][$npics-1] = $2;
+                    } else {
+                        $desc[$i][$npics-1] = $_;
+                    }
+                }
 	    if ($StoryOn == 1) {
-	        $story[$i][$npics-1] = getStoryText ($picname[$npics-1], $i); 
+                    $story[$i][$npics-1] = $story[$i][$npics-1] || getStoryText ($picname[$npics-1], $i);
 	    }
 	    last if eof ALBUM;
 	}
@@ -1258,7 +1276,8 @@
     }

     # Generate the story.
-    if ($StoryOn == 1 && $pictureStory ne "") {
+    if ($pictureStory) {
+    # if ($StoryOn == 1 && $pictureStory ne "") {
         $str .= "<p><font face=\"$StoryFont\" size=\"$StoryFontSize\" ";
         $str .= "color=\"$StoryFontColor\">";
         $str .= $pictureStory;

--Boundary-00=_WEIsCfCcHp8d7Vl--


-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click