[Bast-commits] r9091 - ironman/Perlanet-IronMan/lib/Perlanet

idn at dev.catalyst.perl.org idn at dev.catalyst.perl.org
Tue Apr 6 21:53:47 GMT 2010


Author: idn
Date: 2010-04-06 22:53:47 +0100 (Tue, 06 Apr 2010)
New Revision: 9091

Modified:
   ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm
Log:
Improved summary text creation.  Do the length trim after creation of the summary string to avoid excessive summaries in either the summary or body

Modified: ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm
===================================================================
--- ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm	2010-04-06 21:51:19 UTC (rev 9090)
+++ ironman/Perlanet-IronMan/lib/Perlanet/IronMan.pm	2010-04-06 21:53:47 UTC (rev 9091)
@@ -124,10 +124,15 @@
 
     foreach my $post (@{$posts}) {
 
-        # Set the summary text if not explicity specified (250 characters)
+        # Set the summary text to the summary or body if not supplied
         # This should probably be in config rather than hard coded.
-        my $summary = $post->_entry->summary->body || substr($post->_entry->content->body, 0, 250) . "...";
+        my $summary = $post->_entry->summary->body || $post->_entry->content->body;
 
+        # Limit the summary text length.  This might be better as a word regexp.
+        if(length($summary) > 250) {
+            $summary = substr($summary, 0, 250) . " [...]"
+        }
+
         #print(Dumper($post));
         #exit;
 




More information about the Bast-commits mailing list