10 |
isa => 'ArrayRef|Str', |
isa => 'ArrayRef|Str', |
11 |
); |
); |
12 |
|
|
13 |
|
has revert_path => ( |
14 |
|
documentation => 'path to commit', |
15 |
|
is => 'rw', |
16 |
|
isa => 'ArrayRef|Str', |
17 |
|
); |
18 |
|
|
19 |
has message => ( |
has message => ( |
20 |
documentation => 'commit message', |
documentation => 'commit message', |
21 |
is => 'rw', |
is => 'rw', |
90 |
$self->add_css( qq| |
$self->add_css( qq| |
91 |
pre span.add { background: #dfd } |
pre span.add { background: #dfd } |
92 |
pre span.del { background: #fdd } |
pre span.del { background: #fdd } |
93 |
|
pre form.revert { display: inline } |
94 |
| ); |
| ); |
95 |
$diff =~ s{^(\+.+?)$}{<span class="add">$1</span>}gm; |
$diff =~ s{^(\+.+?)$}{<span class="add">$1</span>}gm; |
96 |
$diff =~ s{^(\-.+?)$}{<span class="del">$1</span>}gm; |
$diff =~ s{^(\-.+?)$}{<span class="del">$1</span>}gm; |
97 |
$diff =~ s{^(===\s+)(\S+)$}{$1<a name="$2">$2</a>}gm; |
$diff =~ s{^(===\s+)(\S+)$}{$1<form class="revert"><input type="hidden" name="revert_path" value="$2"><input type="submit" value="Revert"></form> <a name="$2">$2</a>}gm; |
98 |
|
|
99 |
$diff = qq|<pre>$diff</pre>|; |
$diff = qq|<pre>$diff</pre>|; |
100 |
warn "diff_as_markup ",length($diff)," bytes"; |
warn "diff_as_markup ",length($diff)," bytes"; |
104 |
sub as_markup { |
sub as_markup { |
105 |
my ($self) = @_; |
my ($self) = @_; |
106 |
|
|
107 |
|
my $html = ''; |
108 |
|
|
109 |
|
if ( $self->revert_path ) { |
110 |
|
my $cmd = 'svk revert ' . join(' ', $self->revert_path ); |
111 |
|
my $revert = `$cmd`; |
112 |
|
warn "$cmd $revert"; |
113 |
|
$html .= qq|<code style="background: #ff8;">$revert</code>|; |
114 |
|
} |
115 |
|
|
116 |
|
$self->title('svk'); # XXX without this we get wrong icon and title |
117 |
|
|
118 |
if ( ! $self->can('html_escape') ) { |
if ( ! $self->can('html_escape') ) { |
119 |
Frey::Web->meta->apply( $self ); |
Frey::Web->meta->apply( $self ); |
120 |
$self->TODO( "Frey::Web role missing" ); |
$self->TODO( "Frey::Web role missing" ); |
121 |
} |
} |
122 |
|
|
123 |
my $html |
$html .= $self->status_as_markup || $self->error('no status_or_markup output'); |
124 |
= ( $self->status_as_markup || $self->error('no status_or_markup output') ) |
$html .= $self->diff_as_markup || $self->error('no diff_as_markup output'); |
125 |
. ( $self->diff_as_markup || $self->error('no diff_as_markup output') ) |
|
|
; |
|
126 |
warn "as_markup ",length($html)," bytes"; |
warn "as_markup ",length($html)," bytes"; |
127 |
|
|
128 |
return $html; |
return $html; |