changeset 11:057cd84ce271

2007-08-14 13:39:30 by steve Strip leading/trailing spaces from titles.
author steve
date Tue, 14 Aug 2007 13:39:30 +0000
parents 6d7827134a4f
children 9efe0b8729a8
files bin/chronicle
diffstat 1 files changed, 38 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/bin/chronicle	Mon Aug 13 23:22:03 2007 +0000
+++ b/bin/chronicle	Tue Aug 14 13:39:30 2007 +0000
@@ -54,7 +54,7 @@
  --
  http://www.steve.org.uk/
 
- $Id: chronicle,v 1.4 2007-08-13 23:17:15 steve Exp $
+ $Id: chronicle,v 1.5 2007-08-14 13:39:30 steve Exp $
 
 =cut
 
@@ -294,7 +294,7 @@
 
     if ( $VERSION )
     {
-        my $REVISION      = '$Revision: 1.4 $';
+        my $REVISION      = '$Revision: 1.5 $';
         if ( $REVISION =~ /1.([0-9.]+) / )
         {
             $REVISION = $1;
@@ -361,7 +361,7 @@
         open( INPUT, "<", $file ) or die "Failed to open blog file $file - $!";
         while( my $line = <INPUT> )
         {
-            if ( $line =~ /^tags: (.*)/i )
+            if ( $line =~ /^tags:(.*)/i )
             {
                 my $tag .= $1;
                 foreach my $t ( split( /,/, $tag ) )
@@ -378,17 +378,31 @@
                     push ( @tags, $t );
                 }
             }
-            elsif (( $line =~ /^title: (.*)/i ) && !length($title) )
+            elsif (( $line =~ /^title:(.*)/i ) && !length($title) )
             {
                 $title = $1;
+
+                # strip leading and trailing space.
+                $title =~ s/^\s+// if ( length $title );
+                $title =~ s/\s+$// if ( length $title );
             }
-            elsif (( $line =~ /^date: (.*)/i ) && !length($date) )
+            elsif (( $line =~ /^date:(.*)/i ) && !length($date) )
             {
                 $date = $1;
+
+                # strip leading and trailing space.
+                $date =~ s/^\s+// if ( $date );
+                $date =~ s/\s+$// if ( $date );
+
             }
-            elsif ( $line =~ /^status: (.*)/i )
+            elsif ( $line =~ /^status:(.*)/i )
             {
                 my $level = $1;
+
+                # strip leading and trailing space.
+                $level =~ s/^\s+// if ( $level );
+                $level =~ s/\s+$// if ( $level );
+
                 $private = 1 if ( $level =~ /private/i);
             }
         }
@@ -1035,10 +1049,12 @@
     my %entry;
 
 
-    my $title = "";
-    my $tags  = "";
-    my $body  = "";
-    my $date  = "";
+    my $title  = "";
+    my $tags   = "";
+    my $body   = "";
+    my $date   = "";
+    my $status = "";
+
 
     open( ENTRY, "<", $filename ) or die "Failed to read $filename $!";
     while( my $line = <ENTRY> )
@@ -1053,10 +1069,22 @@
         elsif (( $line =~ /^title: (.*)/i ) && !length($title) )
         {
             $title = $1;
+
+            # strip leading and trailing space.
+            $title =~ s/^\s+// if ( length $title );
+            $title =~ s/\s+$// if ( length $title );
         }
         elsif (( $line =~ /^date: (.*)/i ) && !length($date) )
         {
             $date = $1;
+
+            # strip leading and trailing space.
+            $date =~ s/^\s+// if ( length $date );
+            $date =~ s/\s+$// if ( length $date );
+        }
+        elsif (( $line =~ /^status:(.*)/ ) && !length ( $status ) )
+        {
+            $status = $1;
         }
         else
         {