36 |
close($svk) or die "can't close svk $exec: $@"; |
close($svk) or die "can't close svk $exec: $@"; |
37 |
} |
} |
38 |
|
|
39 |
|
our $svk_status_path = '^(\w+[\+\s]+)(.+)'; |
40 |
|
|
41 |
sub modified { |
sub modified { |
42 |
my ($self) = @_; |
my ($self) = @_; |
43 |
my @modified; |
my @modified; |
44 |
my $svk = $self->svk('status -q', sub { |
my $svk = $self->svk('status -q', sub { |
45 |
push @modified, $1 if /^\w+\s+(.+)/; |
push @modified, $2 if m{$svk_status_path}; |
46 |
}); |
}); |
47 |
return @modified; |
return @modified; |
48 |
} |
} |
66 |
} |
} |
67 |
} |
} |
68 |
|
|
|
sub checkbox { |
|
|
my ($self,$name,$value) = @_; |
|
|
my $checked = ''; |
|
|
my $all_checkboxes = $self->$name; |
|
|
$all_checkboxes = [ $all_checkboxes ] unless ref($all_checkboxes) eq 'ARRAY'; # sigh, too chatty |
|
|
$checked = ' checked' if grep { $_ eq $value } @$all_checkboxes; |
|
|
warn "# checkbox $name $value $checked\t", $self->dump( $self->$name ); |
|
|
qq|<input name="$name" value="$value" type="checkbox"$checked>|; |
|
|
} |
|
|
|
|
69 |
sub commit_as_markup { |
sub commit_as_markup { |
70 |
my ($self) = @_; |
my ($self) = @_; |
71 |
my $status = `svk status -q`; |
my $status = `svk status -q`; |
72 |
$status =~ s{^(\w+[\+\s]+)(\S+)$}{$1 . $self->checkbox('path',$2) . qq|<a href="#$2">$2</a>|}egm; |
$status =~ s{$svk_status_path}{$1 . $self->checkbox('path',$2) . qq|<a href="#$2">$2</a>|}egm; |
73 |
if ( $status ) { |
if ( $status ) { |
74 |
$self->add_css(qq| |
$self->add_css(qq| |
75 |
pre.l a { text-decoration: none; } |
pre.l a { text-decoration: none; } |
80 |
top: 1em; |
top: 1em; |
81 |
right: 1em; |
right: 1em; |
82 |
z-index: 10; |
z-index: 10; |
83 |
|
opacity: .2; |
84 |
|
filter: alpha(opacity=20); |
85 |
|
} |
86 |
|
form.commit:hover { |
87 |
|
opacity: 1; |
88 |
|
filter: alpha(opacity=100); |
89 |
} |
} |
90 |
| ); |
| ); |
91 |
|
|
94 |
<form class="commit" method="post"> |
<form class="commit" method="post"> |
95 |
<pre class="l">$status</pre> |
<pre class="l">$status</pre> |
96 |
<textarea name="commit_message" cols=40 rows=4></textarea> |
<textarea name="commit_message" cols=40 rows=4></textarea> |
97 |
<br><input type="submit" name="action" value="commit"> |
<br> |
98 |
|
<a target="Frey::Test::Runner" href="/Frey::Test::Runner/as_markup" title="run tests for all changes" style="float: right;">test</a> |
99 |
|
<input type="submit" name="action" value="commit"> |
100 |
</form> |
</form> |
101 |
|; |
|; |
102 |
$self->add_status( status => $status ); |
$self->add_status( status => $status ); |
113 |
|
|
114 |
$diff = $self->html_escape( $diff ); |
$diff = $self->html_escape( $diff ); |
115 |
$self->add_css( qq| |
$self->add_css( qq| |
116 |
|
pre span.add, |
117 |
|
pre span.del { |
118 |
|
float: left; |
119 |
|
width: 100%; |
120 |
|
} |
121 |
pre span.add { background: #dfd } |
pre span.add { background: #dfd } |
122 |
pre span.del { background: #fdd } |
pre span.del { background: #fdd } |
123 |
pre form.inline { display: inline } |
pre form.inline { display: inline } |
124 |
| ); |
| ); |
125 |
$diff =~ s{^(\+.+?)$}{<span class="add">$1</span>}gm; |
$diff =~ s{^(\+.*?)$}{<span class="add">$1</span>}gm; |
126 |
$diff =~ s{^(\-.+?)$}{<span class="del">$1</span>}gm; |
$diff =~ s{^(\-.*?)$}{<span class="del">$1</span>}gm; |
127 |
sub form { |
sub form { |
128 |
my ( $path, $action ) = @_; |
my ( $path, $action ) = @_; |
129 |
qq|<form class="inline"><input type="hidden" name="path" value="$path"><input type="submit" name="action" value="$action"></form>|; |
qq|<form class="inline" method="post"><input type="hidden" name="path" value="$path"><input type="submit" name="action" value="$action"></form>|; |
130 |
}; |
}; |
131 |
$diff =~ s{^(===\s+)(\S+)$}{$1 . form($2,'revert') . qq| <a name="$2" target="editor" href="/editor+$2+1">$2</a> | . form($2,'postpone') }gem; |
$diff =~ s{^(===\s+)(\S+)$}{$1 . form($2,'revert') . qq| <a name="$2" target="editor" href="/editor+$2+1">$2</a> | . form($2,'postpone') }gem; |
132 |
|
|
133 |
$diff = qq|<pre>$diff</pre>|; |
$diff = qq|<pre>$diff</pre>| if $diff; |
134 |
warn "diff_as_markup ",length($diff)," bytes"; |
warn "diff_as_markup ",length($diff)," bytes"; |
135 |
return $diff; |
return $diff; |
136 |
} |
} |
156 |
} else { |
} else { |
157 |
confess "need path" unless $self->path; |
confess "need path" unless $self->path; |
158 |
} |
} |
159 |
$cmd .= ' ' . join(' ',$self->path); |
|
160 |
|
my @paths = eval { @{ $self->path } }; # XXX sigh! |
161 |
|
@paths = ( $self->path ) unless @paths; |
162 |
|
warn "# path ", $self->dump( @paths ); |
163 |
|
|
164 |
|
$cmd .= ' ' . join( ' ',@paths ); |
165 |
} |
} |
166 |
if ( $cmd ) { |
if ( $cmd ) { |
167 |
$cmd .= ' 2>&1'; |
$cmd .= ' 2>&1'; |
172 |
|
|
173 |
return qq| |
return qq| |
174 |
Command <tt>$cmd</tt> produced output: |
Command <tt>$cmd</tt> produced output: |
175 |
<pre style="background: #ff8;"> |
<pre style="background: #ff8;">$out</pre> |
176 |
$out |
<a href="">reload page</a> to prevent this post from triggering again<br> |
|
</pre> |
|
177 |
|; |
|; |
178 |
} |
} |
179 |
|
|
186 |
|
|
187 |
$self->title( 'svk' . ( $self->action ? ' - ' . $self->action : '' ) ); # XXX without this we get wrong icon and title |
$self->title( 'svk' . ( $self->action ? ' - ' . $self->action : '' ) ); # XXX without this we get wrong icon and title |
188 |
|
|
189 |
$html .= $self->commit_as_markup . $self->diff_as_markup; |
$html .= $self->commit_as_markup . $self->diff_as_markup || |
190 |
|
qq|No changes in tracked files|; |
191 |
|
|
192 |
warn "as_markup ",length($html)," bytes"; |
warn "as_markup ",length($html)," bytes"; |
193 |
|
|