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

Contents of /trunk/lib/Frey/VCI.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 189 - (show annotations)
Sun Sep 14 00:45:11 2008 UTC (15 years, 7 months ago) by dpavlin
Original Path: trunk/lib/SourceSnoop.pm
File size: 1703 byte(s)
encode entities, dump diff
1 package SourceSnoop;
2
3 use Moose;
4
5 use lib '/rest/cvs/vci/lib'; # FIXME
6 use VCI;
7
8 use HTML::Entities qw/encode_entities/;
9
10 extends 'Frey';
11 with 'Frey::Web';
12
13 use Data::Dump qw/dump/;
14
15 our $debug = 1;
16
17 sub pre_dump {
18 my $o = shift;
19 # because Data::Dumper::HTML sucks
20 my $t;
21 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 {
31 my ( $self, $request ) = @_;
32
33 my %param = $request->params;
34 warn "## params = ",dump( %param );
35
36 my $html;
37 my $path = 'file:///home/dpavlin/private/svn/Frey';
38
39 my $repo = VCI->connect(
40 repo => $path,
41 type => 'Svn',
42 debug => 1,
43 );
44
45 $html .= qq|<h1>Projects</h1><ul>|;
46 $html .= qq|<li><a href="?name=$_">$_</a></li>| foreach map { $_->name } @{ $repo->projects };
47 $html .= qq|</ul>|;
48
49 $request->print( $self->page( title => $path, body => $html ) );
50 $request->next;
51
52 %param = $request->params;
53 warn "## params = ",dump( %param );
54
55 my $project = $repo->get_project( name => $param{name} );
56 my $rev = $project->head_revision;
57
58 my $commit = $project->get_commit( revision => $rev );
59
60 sub div {
61 my ( $class, $text ) = @_;
62 return "<div class=\"$class\">$text</div>";
63 }
64
65 my $diff = $commit->as_diff;
66
67 my $body =
68 '<h1>Commit</h1>' .
69 div( 'revision', $commit->revision ) .
70 div( 'commiter', $commit->committer ) .
71 div( 'date', $commit->time->iso8601 ) .
72 div( 'message', $commit->message ) .
73 '<pre>' . encode_entities( $diff->raw ) . '</pre>' .
74 pre_dump( $diff );
75
76 $request->print( $self->page(
77 title => $path . '/' . $project->name,
78 body => $body,
79 ) );
80 $request->next;
81 }
82
83 warn "## VCI loaded";
84
85 1;

  ViewVC Help
Powered by ViewVC 1.1.26