svnno****@sourc*****
svnno****@sourc*****
2009年 3月 11日 (水) 19:14:05 JST
Revision: 1067 http://svn.sourceforge.jp/view?root=slashdotjp&view=rev&rev=1067 Author: tach Date: 2009-03-11 19:14:05 +0900 (Wed, 11 Mar 2009) Log Message: ----------- add shorten() method to Slash/Utility/Data/Data.pm Modified Paths: -------------- slashjp/trunk/Slash/Utility/Data/Data.pm slashjp/trunk/debian/changelog -------------- next part -------------- Modified: slashjp/trunk/Slash/Utility/Data/Data.pm =================================================================== --- slashjp/trunk/Slash/Utility/Data/Data.pm 2009-03-11 09:02:28 UTC (rev 1066) +++ slashjp/trunk/Slash/Utility/Data/Data.pm 2009-03-11 10:14:05 UTC (rev 1067) @@ -132,6 +132,7 @@ xmlencode_plain validUrl vislenify + shorten ); @@ -4526,7 +4527,43 @@ return ($fudgedurl && $scheme && $allowed_schemes{$scheme}); } +#======================================================================== +=head2 shorten (STRING, LEN) +Shorten given string to given length and add " ... ". + +=over 4 + +=item Parameters + +=over 4 + +=item STRING + +Target string + +=item LEN + +Length to shorten + +=back + +=item Return value + +Shorten string + +=back + +=cut + +sub shorten { + my($str, $len) = @_; + return ($len && length($str) > ($len - 1)) + ? substr($str, 0, $len) . ' ... ' + : $str; +} + + 1; __END__ Modified: slashjp/trunk/debian/changelog =================================================================== --- slashjp/trunk/debian/changelog 2009-03-11 09:02:28 UTC (rev 1066) +++ slashjp/trunk/debian/changelog 2009-03-11 10:14:05 UTC (rev 1067) @@ -3,8 +3,9 @@ * Fix slow query on getStoryByTime() * Remove warning "Use of uninitialized value in int at /usr/lib/perl5/Slash/DB/MySQL.pm line 12950." + * add shorten() method to Slash/Utility/Data/Data.pm - -- Taku YASUI <tach****@osdn*****> Wed, 11 Mar 2009 09:01:31 +0000 + -- Taku YASUI <tach****@osdn*****> Wed, 11 Mar 2009 10:13:28 +0000 slash (2.5.0.233-6) unstable; urgency=low