/[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 591 by dpavlin, Fri Nov 28 16:39:37 2008 UTC revision 614 by dpavlin, Sat Nov 29 00:20:23 2008 UTC
# Line 7  with 'Frey::Web'; Line 7  with 'Frey::Web';
7  has commit_path => (  has commit_path => (
8          documentation => 'path to commit',          documentation => 'path to commit',
9          is => 'rw',          is => 'rw',
10          isa => '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 => (
# Line 57  sub as_data { Line 63  sub as_data {
63  sub status_as_markup {  sub status_as_markup {
64          my ($self) = @_;          my ($self) = @_;
65          my $status = `svk status -q`;          my $status = `svk status -q`;
66          $status =~ s{^(\w+\s+)(\S+)$}{$1<a href="#$2">$2</a>}gm;          $status =~ s{^(\w+\s+)(\S+)$}{$1<input name="commit_path" value="$2" type="checkbox"><a href="#$2">$2</a>}gm;
67          $self->add_css( qq| pre.l a { text-decoration: none; } | );          if ( $status ) {
68          $status = qq|<pre class="l">$status</pre>|;                  $self->add_css( qq| pre.l a { text-decoration: none; } | );
69          $self->add_status( $status );                  $status = qq|
70                            <form>
71                            <div style="background: #ffd; float: right; padding: 1em;">
72                                    <textarea name="message" width=20 height=4></textarea>
73                                    <br><input type="submit" value="Commit">
74                            </div>
75                            <pre class="l">$status</pre>
76                            </form>
77                    |;
78                    $self->add_status( $status );
79            }
80          warn "status_as_markup ",length($status)," bytes";          warn "status_as_markup ",length($status)," bytes";
81          return $status;          return $status;
82  }  }
# Line 74  sub diff_as_markup { Line 90  sub diff_as_markup {
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";
# Line 87  sub diff_as_markup { Line 104  sub diff_as_markup {
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 = $self->status_as_markup . $self->diff_as_markup;          $html .= $self->status_as_markup || $self->error('no status_or_markup output');
124            $html .= $self->diff_as_markup   || $self->error('no diff_as_markup output');
125    
126          warn "as_markup ",length($html)," bytes";          warn "as_markup ",length($html)," bytes";
127    
128          return $html;          return $html;

Legend:
Removed from v.591  
changed lines
  Added in v.614

  ViewVC Help
Powered by ViewVC 1.1.26