/[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

Contents of /trunk/lib/SourceSnoop.pm

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.26