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

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

revision 979 by dpavlin, Fri Jan 9 23:26:25 2009 UTC revision 1066 by dpavlin, Mon Apr 27 18:45:14 2009 UTC
# Line 8  use Moose; Line 8  use Moose;
8    
9  extends 'Frey';  extends 'Frey';
10  with 'Frey::Web';  with 'Frey::Web';
11  #with 'Frey::Storage';  with 'Frey::Storage';
12    with 'Frey::HTML::Diff';
13    
14  use XML::Simple;  use XML::Simple;
15  use DateTimeX::Easy;  use DateTimeX::Easy;
16    use Text::Diff::Parser;
17    
18  has repository => (  has repository => (
19          is => 'rw',          is => 'rw',
# Line 20  has repository => ( Line 22  has repository => (
22          default => 'file:///home/dpavlin/private/svn/Frey',          default => 'file:///home/dpavlin/private/svn/Frey',
23  );  );
24    
25    has path => (
26            is => 'rw',
27            isa => 'Str'
28    );
29    
30  has limit => (  has limit => (
31          is => 'rw',          is => 'rw',
32          isa => 'Int',          isa => 'Int',
33          default => 50,          default => 50,
34  );  );
35    
36    has include_diff => (
37            is => 'ro',
38            isa => 'Bool',
39            default => 1,
40    );
41    
42  sub iterator {  sub iterator {
43          my ($self,$coderef) = @_;          my ($self,$coderef) = @_;
44                    
# Line 48  sub iterator { Line 61  sub iterator {
61                  return;                  return;
62          }          }
63    
64          my $path = $self->repository;          my $path = $self->repository . $self->path;
65          warn "# path $path\n";          warn "# path $path\n";
66    
67          my $cmd;          my $cmd;
68            my $svn_path = $path;
69    
70          if ($path =~ m#file://# || -e "$path/.svn") {          if ($path =~ m#file://# || -e "$path/.svn") {
71                  $cmd = "svn log -v --xml $path";                  $cmd = "svn log -v --xml $path";
72          } else {          } else {
73                  my $svn_path = sh_regex('svk info', qr#Mirrored From:\s+([^,]+)#i);                  $svn_path = sh_regex('svk info', qr#Mirrored From:\s+([^,]+)#i);
74    
75                  if (! $svn_path) {                  if (! $svn_path) {
76    
# Line 92  sub iterator { Line 107  sub iterator {
107    
108          foreach my $e (@{$xml->{'logentry'}}) {          foreach my $e (@{$xml->{'logentry'}}) {
109                  warn "# e = ",$self->dump( $e ) if $self->debug;                  warn "# e = ",$self->dump( $e ) if $self->debug;
110    
111                    if ( $self->include_diff ) {
112                            my $rev = $e->{'revision'};
113                            my $file = $svn_path;
114                            $file =~ s{^\w+:/+}{};
115                            my $file = "var/svn/$path.diff";
116                            my $diff = $self->load( $file );
117                            if ( ! $diff ) {
118                                    $diff = `svn diff -c $rev $svn_path`;
119                                    $self->store( $file, $diff );
120                            }
121                            $e->{diff} .= $diff;
122                    }
123    
124                  $coderef->($e);                  $coderef->($e);
125          }          }
126  }  }
# Line 115  sub as_markup { Line 144  sub as_markup {
144                  return $foo;                  return $foo;
145          }          }
146    
147          our $html = qq|<h1>| . $self->repository . qq|</h1>|;          my $repository = $self->repository;
148            my $path = $self->path;
149    
150            our $html = qq|
151                    <h1><a href="?repository=$repository">$repository</a></h1>
152                    <h2>$path</h2>
153            |;
154    
155          $self->add_css(qq|          $self->add_css(qq|
156                  .commit {                  .commit {
# Line 131  sub as_markup { Line 166  sub as_markup {
166                          float: right;                          float: right;
167                          padding-bottom: 1.2em; /* fix 80% back to original 1em */                          padding-bottom: 1.2em; /* fix 80% back to original 1em */
168                  }                  }
169                    .files a {
170                            text-decoration: none;
171                            color: #888;
172                    }
173                  .date, .revision { color: #666; }                  .date, .revision { color: #666; }
174                  .message {                  .message {
175                          padding-top: 0.5em;                          padding-top: 0.5em;
# Line 142  sub as_markup { Line 181  sub as_markup {
181                  del { color: #c88 }                  del { color: #c88 }
182          |);          |);
183    
184            my $max_path_len = 0;
185            my $path_count;
186    
187          $self->iterator( sub {          $self->iterator( sub {
188                  my $e = shift;                  my $e = shift;
189    
# Line 170  sub as_markup { Line 212  sub as_markup {
212                          } else {                          } else {
213                                  push @files, $path;                                  push @files, $path;
214                          }                          }
215    
216                            $max_path_len = length $path if length $path > $max_path_len;
217                            $path_count->{$path}++;
218                  }                  }
219    
220                    my $diff = $self->html_diff( $e->{diff} ) if $e->{diff};
221    
222                  $html .= qq|                  $html .= qq|
223                          <div class="commit">                          <div class="commit">
224                          <span class="date">$date</span>                                  <span class="date">$date</span>
225                          <em>$e->{author}</em>                                  <em>$e->{author}</em>
226                          <span class="revision">$e->{revision}</span>                                  <span class="revision">$e->{revision}</span>
227                          <div class="files">\n| . join("<br>\n",@files) . qq|\n</div>                                  <div class="files">\n
228                          $msg                                  |
229                                    . join("<br>\n",
230                                            map {
231                                                    my $path = $_;
232                                                    $path =~ s{<[^>]+>}{}g;
233                                                    qq|<a href="?repository=$repository;path=$path" title="$path ##">$_</a>|
234                                            } @files
235                                    )
236                                    . qq|
237                                    </div>
238                                    $msg
239                                    $diff
240                          </div>                          </div>
241                  |;                  |;
242    
243          });          });
244    
245            $self->add_css(qq|
246                    .files {
247                            width: ${max_path_len}ex;
248                    }
249            |);
250    
251            $html =~ s[title="(\S+) ##"]['title="' . $path_count->{$1} . '"']gse;
252    
253          return $html;          return $html;
254  }  }
255    

Legend:
Removed from v.979  
changed lines
  Added in v.1066

  ViewVC Help
Powered by ViewVC 1.1.26