--- ../../cvs/twiki/bin/rdiff Mon Oct 14 12:00:42 2002 +++ rdiff Thu Sep 5 17:01:18 2002 @@ -15,15 +15,18 @@ # GNU General Public License for more details, published at # http://www.gnu.org/copyleft/gpl.html -# Set library paths in @INC, at compile time -BEGIN { unshift @INC, '.'; require 'setlib.cfg'; } - use CGI::Carp qw(fatalsToBrowser); use CGI; +use lib ( '.' ); +use lib ( '../lib' ); use TWiki; +$|=1; + $query= new CGI; +my %color = ('-','#FFD7D7','+','#D0FFD0',' ','#FFFFFF'); + &main(); # ========================= @@ -31,6 +34,17 @@ { my( $data, $topic ) = @_; if( $data ) { + # TODO: need to close html tags on both sides + # How: + # - my $temp, $to_front + # - find next html tag + # - if opening + # - add to temp string + # - add table tags to $to_front and $temp if necessary + # - if closing + # - if tag at end of $temp (or through tags like

), remove + # - if tag not at end: add opening to $to_front + # - at the end: make closing tags for everything in $temp $data = &TWiki::handleCommonTags( $data, $topic ); $data = &TWiki::getRenderedVersion( $data ); if( $data =~ m/<\/?(th|td|table)/i ) @@ -61,10 +75,59 @@ my( $text, $topic ) = @_; $text =~ s/\r//go; # cut CR - my $result = "\n
"; + my $result = "\n"; my $data = ""; + my $unified = 0; + my $inside = ""; + if ($text =~ /^--- /) { + $unified = 1; + #DEBUG + #$result .= ""; + # Remove unified header + $text =~ s/^---.*\n\+\+\+ .*\n//m; + # Remove META tags + # FIXME: perhaps generate readable version of the meta change? + # META:TOPIC can be ignored, but the rest means stuff + $text =~ s/\n.%META:[^\n]*//mg; + # Remove empty change sections + $text =~ s/\n@@[^\n]*\n( [^\n]*\n)+@@/@@/mg; + $text =~ s/^@@[^\n]*\n( [^\n]*\n)+@@/@@/m; + $text =~ s/\n@@[^\n]*\n( [^\n]*\n)+$//m; + $text =~ s/^@@[^\n]*\n( [^\n]*\n)+$//m; + #$result .= ""; + if ( $text !~ /\n/m ) { + $result .= "\n"; + } + } else { + $result .= "\n"; + $data = ""; + $result .= "\n"; + } + $inside = ""; + } else { + /^(.)(.*)/; + if ($inside ne $1) { + if ($inside ne "") { + $data = renderCellData( $data, $topic ); + $result .= "$data\n"; + } + $inside = $1; + $result .= "
\n$text
\n$text
Administrative change. No modification to topic text.
"; + $inside = 1; + } + foreach( split( /\n/, $text ) ) { - if( /^[0-9]/ ) { + if ($unified) { + if( /^@@/ ) { + if ( $inside ne "") { + $data = renderCellData( $data, $topic ); + $result .= $data . "
[...]
$1
$1
"; + $data = ""; + } + $data.="\n$2"; + } + } else { + if( /^[0-9]/ ) { $data = renderCellData( $data, $topic ); $result .= $data; $data = ""; @@ -83,11 +146,12 @@ $data = ""; $result .= "\n
>
>
\n"; } +} } $data = renderCellData( $data, $topic ); $result .= $data; - $data = ""; - $text = "$result<\/td><\/tr>\n<\/table>"; + $result .= "<\/td><\/tr>\n" if $inside ne ""; + $text = "$result<\/table>"; return $text; } @@ -98,17 +162,15 @@ my( $web, $rev, $topic, $short ) = @_; my( $date, $user ) = &TWiki::Store::getRevisionInfo( $web, $topic, "1.$rev", 1 ); - $user = TWiki::getRenderedVersion( TWiki::userToWikiName( $user ) ); + $user = &TWiki::userToWikiName( $user ); + my $revInfo = &TWiki::getRenderedVersion( "$date GMT - $user" ); if( $short ) { # cut time - $date =~ s/ \- [0-9]*\:[0-9]+$//go; + $revInfo =~ s/ \- [0-9]*\:[0-9]*(?:\sGMT)*//go; # eliminate white space to prevent wrap around in HR table: - $date =~ s/ /\ \;/go; - } else { - $date .= " GMT"; + $revInfo =~ s/ /\ \;/go; } - my $revInfo = "$date - $user"; $revInfo =~ s/[\n\r]*//go; return $revInfo; }