Update of /cvsroot/openinteract/OpenInteract2/pkg/comments/OpenInteract2/Action
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13608/OpenInteract2/Action
Modified Files:
Comments.pm
Log Message:
OIN-128: ensure lines don't get too long...
Index: Comments.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract2/pkg/comments/OpenInteract2/Action/Comments.pm,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Comments.pm 28 Feb 2005 01:43:53 -0000 1.12
--- Comments.pm 28 Feb 2005 01:56:12 -0000 1.13
***************
*** 17,20 ****
--- 17,22 ----
my ( $log );
+ my $DEFAULT_ECODE_LINE_LENGTH = 70;
+
# Display some summary info (plus a link) for an object
***************
*** 387,391 ****
$count = 1;
foreach my $section ( @code_sections ) {
! $comment->{content} =~ s|$placeholder$count|<pre class="commentCode">$section</pre>|gsm;
$count++;
}
--- 389,394 ----
$count = 1;
foreach my $section ( @code_sections ) {
! my $fixed_section = $self->_trim_preformatted_line_length( $section );
! $comment->{content} =~ s|$placeholder$count|<pre class="commentCode">$fixed_section</pre>|gsm;
$count++;
}
***************
*** 474,477 ****
--- 477,496 ----
}
+ sub _trim_preformatted_line_length {
+ my ( $self, $text ) = @_;
+ my @new = ();
+ my $max = $self->param( 'max_ecode_line' ) || $DEFAULT_ECODE_LINE_LENGTH;
+ foreach my $line ( split /\r?\n/, $text ) {
+ if ( length $line > $max ) {
+ push @new, substr( $line, 0, $max ) . '+',
+ substr( $line, $max );
+ }
+ else {
+ push @new, $line;
+ }
+ }
+ return join( "\n", @new );
+ }
+
# When a new thread is added you can add people who get notified with
# every new message in that thread. Return value is the number of
|