/[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 684 by dpavlin, Tue Dec 2 18:12:38 2008 UTC revision 690 by dpavlin, Tue Dec 2 22:05:25 2008 UTC
# Line 17  has action => ( Line 17  has action => (
17  has path => (  has path => (
18          documentation => 'path to work with',          documentation => 'path to work with',
19          is => 'rw',          is => 'rw',
20          isa => 'Str',          isa => 'Str|ArrayRef',
21  );  );
22    
23  has commit_message => (  has commit_message => (
# Line 64  sub as_data { Line 64  sub as_data {
64          }          }
65  }  }
66    
67    sub checkbox {
68            my ($self,$name,$value) = @_;
69            my $checked = '';
70            my $all_checkboxes = $self->$name;
71            $all_checkboxes = [ $all_checkboxes ] unless ref($all_checkboxes) eq 'ARRAY'; # sigh, too chatty
72            $checked = ' checked' if grep { $_ eq $value } @$all_checkboxes;
73            warn "# checkbox $name $value $checked\t", $self->dump( $self->$name );
74            qq|<input name="$name" value="$value" type="checkbox"$checked>|;
75    }
76    
77  sub commit_as_markup {  sub commit_as_markup {
78          my ($self) = @_;          my ($self) = @_;
79          my $status = `svk status -q`;          my $status = `svk status -q`;
80          $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1<input name="commit_path" value="$2" type="checkbox"><a href="#$2">$2</a>}gm; # FIXME          $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1 . $self->checkbox('path',$2) . qq|<a href="#$2">$2</a>|}egm;
 #       $status =~ s{^(\w+[\+\s]+)(\S+)$}{$1<a href="#$2">$2</a>}gm;  
81          if ( $status ) {          if ( $status ) {
82                  $self->add_css(qq|                  $self->add_css(qq|
83                          pre.l a { text-decoration: none; }                          pre.l a { text-decoration: none; }
84                          form.commit {                          form.commit {
85                                  background: #ffd;                                  background: #eee;
86                                  padding: 1em 1em;                                  padding: 1em 1em;
87                                  position: fixed;                                  position: fixed;
88                                  top: 1em;                                  top: 1em;
# Line 121  sub diff_as_markup { Line 130  sub diff_as_markup {
130          return $diff;          return $diff;
131  }  }
132    
133  sub as_markup {  sub action_as_markup {
134          my ($self) = @_;          my ($self) = @_;
135    
         my $html = '';  
136          my $cmd;          my $cmd;
137    
138          if ( $self->action eq 'postpone' ) {          if ( $self->action eq 'postpone' ) {
# Line 137  sub as_markup { Line 145  sub as_markup {
145          } elsif ( $self->action ) {          } elsif ( $self->action ) {
146                  $cmd = 'svk ' . $self->action;                  $cmd = 'svk ' . $self->action;
147                  if ( $self->action eq 'commit' ) {                  if ( $self->action eq 'commit' ) {
148                          my $msg = $self->commit_message || confess "need commit message";                          my $msg = $self->commit_message || return $self->error( "need commit message\n" );
149                          $msg =~ s{"}{\\"}gs;                          $msg =~ s{"}{\\"}gs;
150                          $cmd .= qq{ -m "$msg"};                          $cmd .= qq{ -m "$msg"};
                 } elsif ( my $path = $self->path ) {  
                         $cmd .= " $path";  
151                  } else {                  } else {
152                          confess "need path" unless $self->path;                          confess "need path" unless $self->path;
153                  }                  }
154                    $cmd .= ' ' . join(' ',$self->path);
155          }          }
156          if ( $cmd ) {          if ( $cmd ) {
157                  $cmd .= ' 2>&1';                  $cmd .= ' 2>&1';
158                    warn "# cmd $cmd";
159    
160                  my $out = `$cmd`;                  my $out = `$cmd`;
161                  warn "$cmd $out";                  warn "# output of $cmd is: $out";
162    
163                  $html .= qq|                  return qq|
164                            Command <tt>$cmd</tt> produced output:
165                          <code style="background: #ff8;">                          <code style="background: #ff8;">
166                          $cmd\n                          $out
                         <b>$out</b>  
167                          </code>                          </code>
168                  |;                  |;
169          }          }
170    
171    }
172    
173    sub as_markup {
174            my ($self) = @_;
175    
176            my $html = $self->action_as_markup;
177    
178          $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
179    
180          $html .= $self->commit_as_markup . $self->diff_as_markup;          $html .= $self->commit_as_markup . $self->diff_as_markup;

Legend:
Removed from v.684  
changed lines
  Added in v.690

  ViewVC Help
Powered by ViewVC 1.1.26