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', |
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 |
|
|
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 |
|
|
106 |
my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); |
107 |
|
|
108 |
foreach my $e (@{$xml->{'logentry'}}) { |
foreach my $e (@{$xml->{'logentry'}}) { |
109 |
warn "# e = ",$self->dump( $e ); |
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 |
} |
} |
137 |
$foo =~ s/</</g; |
$foo =~ s/</</g; |
138 |
$foo =~ s/>/>/g; |
$foo =~ s/>/>/g; |
139 |
$foo =~ s/"/"/g; |
$foo =~ s/"/"/g; |
140 |
$foo =~ s/([\n\r][\n\r]+)/<\/p>$1<p>/gis; |
# $foo =~ s/([\n\r][\n\r]+)/$1<br\/>/gis; |
141 |
$foo =~ s/([\n\r]+)([\-\*]\s+)/$1<br\/>$2/gis; |
$foo =~ s/([\n\r]+)([\-\*]\s+)/$1<br\/>$2/gis; |
142 |
$foo =~ s/([\n\r]+)(r\d+:\s+)/$1<br\/>$2/gis; |
$foo =~ s/([\n\r]+)(r\d+:\s+)/$1<br\/>$2/gis; |
143 |
$foo =~ s/([\n\r]+)(\s+r\d+@)/$1<br\/>$2/gis; # svk |
$foo =~ s/([\n\r]+)(\s+r\d+@)/$1<br\/>$2/gis; # svk |
144 |
return $foo; |
return $foo; |
145 |
} |
} |
146 |
|
|
147 |
our $html = ''; |
my $repository = $self->repository; |
148 |
sub html { |
my $path = $self->path; |
149 |
$html .= join("\n", @_); |
|
150 |
} |
our $html = qq| |
151 |
|
<h1><a href="?repository=$repository">$repository</a></h1> |
152 |
|
<h2>$path</h2> |
153 |
|
|; |
154 |
|
|
155 |
|
$self->add_css(qq| |
156 |
|
.commit { |
157 |
|
clear: both; |
158 |
|
padding-top: 1em; |
159 |
|
padding-bottom: 1em; |
160 |
|
border-top: 1px dashed #ccc; |
161 |
|
} |
162 |
|
.files { |
163 |
|
color: #888; |
164 |
|
font-family: monospace; |
165 |
|
font-size: 80%; |
166 |
|
float: right; |
167 |
|
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; } |
174 |
|
.message { |
175 |
|
padding-top: 0.5em; |
176 |
|
padding-left: 2em; /* like blockquote */ |
177 |
|
white-space: pre-wrap; |
178 |
|
} |
179 |
|
|
180 |
|
ins { color: #8c8 } |
181 |
|
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; |
193 |
$date =~ s/T/ /; |
$date =~ s/T/ /; |
194 |
$date =~ s/\.\d+Z$//; |
$date =~ s/\.\d+Z$//; |
195 |
|
|
196 |
html '<p><tt>'.$date.'</tt> <em>',$e->{'author'},'</em> <tt style="color:#808080">r',$e->{'revision'},'</tt></p>'; |
my $msg = $e->{'msg'}; |
197 |
|
$msg = '' if ref($msg); # FIXME why do I need this, dammit? |
198 |
|
if ( $msg ) { |
199 |
|
$msg = encode( $msg ); |
200 |
|
$msg = qq|<div class="message">$msg</div>|; |
201 |
|
} |
202 |
|
|
203 |
my @files; |
my @files; |
204 |
|
|
209 |
push @files, "<ins>$path</ins>"; |
push @files, "<ins>$path</ins>"; |
210 |
} elsif ($action eq "D") { |
} elsif ($action eq "D") { |
211 |
push @files, "<del>$path</del>"; |
push @files, "<del>$path</del>"; |
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 |
html '<blockquote><p><tt style="color:#808080">',join(", ",@files),':</tt> ',encode($e->{'msg'}),'</p></blockquote>'; |
my $diff = $self->html_diff( $e->{diff} ) if $e->{diff}; |
221 |
|
|
222 |
|
$html .= qq| |
223 |
|
<div class="commit"> |
224 |
|
<span class="date">$date</span> |
225 |
|
<em>$e->{author}</em> |
226 |
|
<span class="revision">$e->{revision}</span> |
227 |
|
<div class="files">\n |
228 |
|
| |
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> |
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 |
|
|