/[SVNBrowser]/trunk/lib/SVNBrowser/ColorDiff.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/SVNBrowser/ColorDiff.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 36 by dpavlin, Mon Dec 11 17:58:07 2006 UTC revision 37 by dpavlin, Mon Dec 11 19:05:25 2006 UTC
# Line 4  use strict; Line 4  use strict;
4  use HTML::Entities;  use HTML::Entities;
5  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
6    
   
7  =head1 Name  =head1 Name
8    
9  SVNBrowser::ColorDiff  SVNBrowser::ColorDiff
# Line 46  sub diff { Line 45  sub diff {
45    
46          my $out = "<tt>$cmd</tt><br/>";          my $out = "<tt>$cmd</tt><br/>";
47    
48          $out .= "<pre>" . encode_entities($diff, '<>&"') . "</pre>";          my $mode = '';
49            my $mode_map = {
50                    '+' => 'add',
51                    '-' => 'rm',
52                    ' ' => 'nop',
53            };
54    
55            foreach my $line (split(/\n/,$diff)) {
56    
57                    next if ($line =~ /^(\+\+\+|---)\s/ || $line =~ /^=+$/);
58    
59                    my $html = encode_entities($line, '<>&"');
60                    if ($line =~ m/^([+\-\s])/) {
61                            my $m = $1;
62                            if ($mode ne $m) {
63                                    $out .= qq{</pre>} if ($mode ne '');
64                                    $out .= qq{<pre class="diff-$mode_map->{$m}">};
65                            } else {
66                                    $out .= "\n";
67                            }
68    
69                            $mode = $m;
70                            $out .= qq{$html};
71    
72                    } else {
73                            $out .= qq{</pre>} if ($mode ne '');
74                            $out .= qq{<div class="diff-note">$html</div>};
75                            $mode = '';
76                    }
77    
78            };
79    
80            $out .= qq{</pre>} if ($mode ne '');
81    
82          return $out;          return $out;
83    

Legend:
Removed from v.36  
changed lines
  Added in v.37

  ViewVC Help
Powered by ViewVC 1.1.26