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

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

revision 698 by dpavlin, Tue Dec 2 22:23:56 2008 UTC revision 848 by dpavlin, Mon Dec 15 18:57:29 2008 UTC
# Line 36  sub svk { Line 36  sub svk {
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  }  }
# Line 64  sub as_data { Line 66  sub as_data {
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; }
# Line 88  sub commit_as_markup { Line 80  sub commit_as_markup {
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    
# Line 113  sub diff_as_markup { Line 111  sub diff_as_markup {
111    
112          $diff = $self->html_escape( $diff );          $diff = $self->html_escape( $diff );
113          $self->add_css( qq|          $self->add_css( qq|
114            pre span.add,
115            pre span.del {
116                    float: left;
117                    width: 100%;
118            }
119          pre span.add { background: #dfd }          pre span.add { background: #dfd }
120          pre span.del { background: #fdd }          pre span.del { background: #fdd }
121          pre form.inline { display: inline }          pre form.inline { display: inline }
122          | );          | );
123          $diff =~ s{^(\+.+?)$}{<span class="add">$1</span>}gm;          $diff =~ s{^(\+.*?)$}{<span class="add">$1</span>}gm;
124          $diff =~ s{^(\-.+?)$}{<span class="del">$1</span>}gm;          $diff =~ s{^(\-.*?)$}{<span class="del">$1</span>}gm;
125          sub form {          sub form {
126                  my ( $path, $action ) = @_;                  my ( $path, $action ) = @_;
127                  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>|;
128          };          };
129          $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;
130    
131          $diff = qq|<pre>$diff</pre>|;          $diff = qq|<pre>$diff</pre>| if $diff;
132          warn "diff_as_markup ",length($diff)," bytes";          warn "diff_as_markup ",length($diff)," bytes";
133          return $diff;          return $diff;
134  }  }
# Line 151  sub action_as_markup { Line 154  sub action_as_markup {
154                  } else {                  } else {
155                          confess "need path" unless $self->path;                          confess "need path" unless $self->path;
156                  }                  }
157                  $cmd .= ' ' . join(' ',$self->path);  
158                    my @paths = eval { @{ $self->path } }; # XXX sigh!
159                    @paths = ( $self->path ) unless @paths;
160                    warn "# path ", $self->dump( @paths );
161    
162                    $cmd .= ' ' . join( ' ',@paths );
163          }          }
164          if ( $cmd ) {          if ( $cmd ) {
165                  $cmd .= ' 2>&1';                  $cmd .= ' 2>&1';
# Line 162  sub action_as_markup { Line 170  sub action_as_markup {
170    
171                  return qq|                  return qq|
172                          Command <tt>$cmd</tt> produced output:                          Command <tt>$cmd</tt> produced output:
173                          <pre style="background: #ff8;">                          <pre style="background: #ff8;">$out</pre>
174                          $out                          <a href="">reload page</a> to prevent this post from triggering again<br>
                         </pre>  
175                  |;                  |;
176          }          }
177    

Legend:
Removed from v.698  
changed lines
  Added in v.848

  ViewVC Help
Powered by ViewVC 1.1.26