/[Frey]/trunk/lib/SourceSnoop.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/SourceSnoop.pm

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

revision 186 by dpavlin, Sat Sep 13 14:19:04 2008 UTC revision 213 by dpavlin, Fri Oct 31 19:51:51 2008 UTC
# Line 5  use Moose; Line 5  use Moose;
5  use lib '/rest/cvs/vci/lib'; # FIXME  use lib '/rest/cvs/vci/lib'; # FIXME
6  use VCI;  use VCI;
7    
8    use HTML::Entities qw/encode_entities/;
9    
10  extends 'Frey';  extends 'Frey';
11  with 'Frey::Web';  with 'Frey::Web';
12    
# Line 15  our $debug = 1; Line 17  our $debug = 1;
17  sub pre_dump {  sub pre_dump {
18          my $o = shift;          my $o = shift;
19          # because Data::Dumper::HTML sucks          # because Data::Dumper::HTML sucks
20          my $t = $o->dump; $t =~ s/ {8}/  /gm;          my $t;
21          return "<pre>$t</pre>";          if ( blessed($o) && $o->can('dump') ) {
22                    $t = $o->dump;
23                    $t =~ s/ {8}/  /gm;
24            } else {
25                    $t = dump( $o );
26            }
27            return '<hr><pre>' . encode_entities($t) . '</pre><hr>';
28  }  }
29    
30  sub html {  use MooseX::Method;
31    
32    method request => positional(
33            { isa => 'Continuity::RequestHolder', required => 1 },
34    ) => sub {
35    #sub request {
36          my ( $self, $request ) = @_;          my ( $self, $request ) = @_;
37    
38          my %param = $request->params;          my %param = $request->params;
# Line 41  sub html { Line 54  sub html {
54          $request->print( $self->page( title => $path, body => $html ) );          $request->print( $self->page( title => $path, body => $html ) );
55          $request->next;          $request->next;
56    
57          my %param = $request->params;          %param = $request->params;
58          warn "## params = ",dump( %param );          warn "## params = ",dump( %param );
59    
60          my $project = $repo->get_project( name => $param{name} );          my $project = $repo->get_project( name => $param{name} );
61            my $rev = $project->head_revision;
62    
63            my $commit = $project->get_commit( revision => $rev );
64    
65            sub div {
66                    my ( $class, $text ) = @_;
67                    return "<div class=\"$class\">$text</div>";
68            }
69    
70            my $diff = $commit->as_diff;
71    
72            my $body =
73                    '<h1>Commit</h1>' .
74                    div( 'revision', $commit->revision ) .
75                    div( 'commiter', $commit->committer ) .
76                    div( 'date',     $commit->time->iso8601 ) .
77                    div( 'message',  $commit->message ) .
78                    '<pre>' . encode_entities( $diff->raw ) . '</pre>' .
79                    pre_dump( $diff );
80    
81          $request->print( $self->page(          $request->print( $self->page(
82                  title => $path . '/' . $project->name ,                  title => $path . '/' . $project->name,
83                  body => pre_dump( $project )                  body => $body,
84          ) );          ) );
85          $request->next;          $request->next;
86  }  };
87    
88  warn "## VCI loaded";  warn "## VCI loaded";
89    

Legend:
Removed from v.186  
changed lines
  Added in v.213

  ViewVC Help
Powered by ViewVC 1.1.26