User: sits    
  Date: 08/06/17 04:09:35

  Modified:    lib/Codestriker/Http DeltaRenderer.pm HighlightLineFilter.pm
               .        codestriker.conf
               html     codestriker.css
  Log:
  Rough integration with external highlighter working.  Need to still play 
around with proper integration and fallback if it is not present.
  
  
  
  Index: DeltaRenderer.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Http/DeltaRenderer.pm,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DeltaRenderer.pm  16 Jun 2008 11:32:05 -0000      1.7
  +++ DeltaRenderer.pm  17 Jun 2008 11:09:34 -0000      1.8
  @@ -15,6 +15,7 @@
   use Codestriker::Http::TabToNbspLineFilter;
   use Codestriker::Http::LineBreakLineFilter;
   use Codestriker::Http::LxrLineFilter;
  +use Codestriker::Http::HighlightLineFilter;
   
   # Constructor.
   sub new {
  @@ -57,8 +58,10 @@
                $Codestriker::lxr_map->{$repository->toString()} : undef;
       
       @{$self->{line_filters}} = ();
  -    push @{$self->{line_filters}}, 
Codestriker::Http::HtmlEntityLineFilter->new();
  -    push @{$self->{line_filters}}, 
Codestriker::Http::TabToNbspLineFilter->new($tabwidth);
  +    push @{$self->{line_filters}}, 
Codestriker::Http::HighlightLineFilter->new($Codestriker::highlight);
  +    
  +    #push @{$self->{line_filters}}, 
Codestriker::Http::HtmlEntityLineFilter->new();
  +    #push @{$self->{line_filters}}, 
Codestriker::Http::TabToNbspLineFilter->new($tabwidth);
       #push @{$self->{line_filters}}, 
Codestriker::Http::LineBreakLineFilter->new($brmode);
       #if (defined $lxr_config) {
        #    push @{$self->{line_filters}}, 
Codestriker::Http::LxrLineFilter->new($lxr_config);
  
  
  
  
  
  Index: HighlightLineFilter.pm
  ===================================================================
  RCS file: 
/cvsroot/codestriker/codestriker/lib/Codestriker/Http/HighlightLineFilter.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- HighlightLineFilter.pm    16 Jun 2008 11:32:05 -0000      1.1
  +++ HighlightLineFilter.pm    17 Jun 2008 11:09:34 -0000      1.2
  @@ -5,13 +5,15 @@
   # This program is free software; you can redistribute it and modify it under
   # the terms of the GPL.
   
  -# Line filter for converting tabs to the appropriate number of  
  -# entities.
  +# Line filter for highlighting code into xhtml using highlight, available 
from
  +#  http://www.andre-simon.de/.
   
   package Codestriker::Http::HighlightLineFilter;
   
   use strict;
   
  +use File::Temp qw/ tempfile /;
  +
   use Codestriker::Http::LineFilter;
   
   @Codestriker::Http::HighlightLineFilter::ISA =
  @@ -29,19 +31,43 @@
   
   # Convert tabs to the appropriate number of   entities.
   sub _filter {
  -    my ($self, $text) = @_;
  +    my ($self, $text, $extension) = @_;
   
  +     # Create a temporary file which will contain the delta text to 
highlight.
  +     my ($input_text_fh, $input_filename) = tempfile(SUFFIX => $extension);
  +     print $input_text_fh $text;
  +     close $input_text_fh;
        
  -
  -    return $text;
  +     # Execute the highlight command, and store the stdout into $read_data.
  +     my $read_data;  
  +    my $read_stdout_fh = new FileHandle;
  +    open($read_stdout_fh, '>', \$read_data);
  +    my @args = ();
  +    push @args, '-i';
  +    push @args, $input_filename;
  +    push @args, '--xhtml';
  +    push @args, '-f';
  +    Codestriker::execute_command($read_stdout_fh, undef, $self->{highlight}, 
@args);
  +    
  +    # Delete the temp file.
  +    unlink $input_filename;
  +    
  +    return $read_data;
   }
   
   # Convert tabs to the appropriate number of   entities.
   sub filter {
       my ($self, $delta) = @_;
       
  -    $delta->{diff_old_lines} = $self->_filter($delta->{diff_old_lines});
  -    $delta->{diff_new_lines} = $self->_filter($delta->{diff_new_lines});
  +    # Determine the filename extension so the highlighter knows what language
  +    # to apply highlighting to.  Handle CVS files which might end in ,v.
  +    my $extension = ".txt";
  +    if ($delta->{filename} =~ /^.*(\..*),v$/o || $delta->{filename} =~ 
/^.*(\..*)$/o) {
  +     $extension = $1;
  +    }
  +    
  +    $delta->{diff_old_lines} = $self->_filter($delta->{diff_old_lines}, 
$extension);
  +    $delta->{diff_new_lines} = $self->_filter($delta->{diff_new_lines}, 
$extension);
   }
   
   1;
  
  
  
  
  
  Index: codestriker.conf
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/codestriker.conf,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- codestriker.conf  22 Feb 2008 00:31:55 -0000      1.92
  +++ codestriker.conf  17 Jun 2008 11:09:35 -0000      1.93
  @@ -76,6 +76,10 @@
   # use VSS (Visual Source Safe).
   $vss = 'C:/Program Files/Microsoft Visual Studio/VSS/win32/ss.exe';
   
  +# Location of the highlight binary, which is used for highlighting source 
code.
  +# Available from  http://www.andre-simon.de/.
  +$highlight = 'C:/Program Files/WinHighlight/highlight.exe'; 
  +
   # Temporary directory Codestriker can use.  For *NIX platforms, this will
   # /tmp by default, for Windows 2000 c:\winnt\temp and for XP, 
c:\windows\temp.
   # For Win32 deployments, these temp directories may not be accessible to
  
  
  
  
  
  Index: codestriker.css
  ===================================================================
  RCS file: /cvsroot/codestriker/codestriker/html/codestriker.css,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- codestriker.css   13 Jun 2008 07:16:21 -0000      1.17
  +++ codestriker.css   17 Jun 2008 11:09:35 -0000      1.18
  @@ -160,3 +160,20 @@
   
   span.feedback {color: red;}
   span.obsolete-header {color: red; font-weight: bold;}
  +
  +/* Styles for highlight program. */
  +pre.hl       { color:#000000; background-color:#ffffff; font-size:10pt; 
font-family:'Courier New';}
  +.hl.num { color:#2928ff; }
  +.hl.esc { color:#ff00ff; }
  +.hl.str { color:#ff0000; }
  +.hl.dstr { color:#818100; }
  +.hl.slc { color:#838183; font-style:italic; }
  +.hl.com { color:#838183; font-style:italic; }
  +.hl.dir { color:#008200; }
  +.hl.sym { color:#000000; }
  +.hl.line { color:#555555; }
  +.hl.mark     { background-color:#ffffbb;}
  +.hl.kwa { color:#000000; font-weight:bold; }
  +.hl.kwb { color:#830000; }
  +.hl.kwc { color:#000000; font-weight:bold; }
  +.hl.kwd { color:#010181; }
  \ No newline at end of file
  
  
  

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Codestriker-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/codestriker-commits

Reply via email to