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

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

revision 807 by dpavlin, Thu Dec 11 00:27:19 2008 UTC revision 1013 by dpavlin, Sat Jan 24 19:35:41 2009 UTC
# Line 20  has repository => ( Line 20  has repository => (
20          default => 'file:///home/dpavlin/private/svn/Frey',          default => 'file:///home/dpavlin/private/svn/Frey',
21  );  );
22    
23    has path => (
24            is => 'rw',
25            isa => 'Str'
26    );
27    
28  has limit => (  has limit => (
29          is => 'rw',          is => 'rw',
30          isa => 'Int',          isa => 'Int',
# Line 48  sub iterator { Line 53  sub iterator {
53                  return;                  return;
54          }          }
55    
56          my $path = $self->repository;          my $path = $self->repository . $self->path;
57          warn "# path $path\n";          warn "# path $path\n";
58    
59          my $cmd;          my $cmd;
# Line 91  sub iterator { Line 96  sub iterator {
96          my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);          my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);
97    
98          foreach my $e (@{$xml->{'logentry'}}) {          foreach my $e (@{$xml->{'logentry'}}) {
99                  warn "# e = ",$self->dump( $e );                  warn "# e = ",$self->dump( $e ) if $self->debug;
100                  $coderef->($e);                  $coderef->($e);
101          }          }
102  }  }
# Line 108  sub as_markup { Line 113  sub as_markup {
113                  $foo =~ s/</&lt;/g;                  $foo =~ s/</&lt;/g;
114                  $foo =~ s/>/&gt;/g;                  $foo =~ s/>/&gt;/g;
115                  $foo =~ s/"/&quot;/g;                  $foo =~ s/"/&quot;/g;
116                  $foo =~ s/([\n\r][\n\r]+)/<\/p>$1<p>/gis;  #               $foo =~ s/([\n\r][\n\r]+)/$1<br\/>/gis;
117                  $foo =~ s/([\n\r]+)([\-\*]\s+)/$1<br\/>$2/gis;                  $foo =~ s/([\n\r]+)([\-\*]\s+)/$1<br\/>$2/gis;
118                  $foo =~ s/([\n\r]+)(r\d+:\s+)/$1<br\/>$2/gis;                  $foo =~ s/([\n\r]+)(r\d+:\s+)/$1<br\/>$2/gis;
119                  $foo =~ s/([\n\r]+)(\s+r\d+@)/$1<br\/>$2/gis;           # svk                  $foo =~ s/([\n\r]+)(\s+r\d+@)/$1<br\/>$2/gis;           # svk
120                  return $foo;                  return $foo;
121          }          }
122    
123          our $html = '';          my $repository = $self->repository;
124          sub html {          my $path = $self->path;
125                  $html .= join("\n", @_);  
126          }          our $html = qq|
127                    <h1><a href="?repository=$repository">$repository</a></h1>
128                    <h2>$path</h2>
129            |;
130    
131            $self->add_css(qq|
132                    .commit {
133                            clear: both;
134                            padding-top: 1em;
135                            padding-bottom: 1em;
136                            border-top: 1px dashed #ccc;
137                    }
138                    .files {
139                            color: #888;
140                            font-family: monospace;
141                            font-size: 80%;
142                            float: right;
143                            padding-bottom: 1.2em; /* fix 80% back to original 1em */
144                    }
145                    .files a {
146                            text-decoration: none;
147                            color: #888;
148                    }
149                    .date, .revision { color: #666; }
150                    .message {
151                            padding-top: 0.5em;
152                            padding-left: 2em; /* like blockquote */
153                            white-space: pre-wrap;
154                    }
155    
156                    ins { color: #8c8 }
157                    del { color: #c88 }
158            |);
159    
160            my $max_path_len = 0;
161            my $path_count;
162    
163          $self->iterator( sub {          $self->iterator( sub {
164                  my $e = shift;                  my $e = shift;
# Line 129  sub as_markup { Line 169  sub as_markup {
169                  $date =~ s/T/ /;                  $date =~ s/T/ /;
170                  $date =~ s/\.\d+Z$//;                  $date =~ s/\.\d+Z$//;
171    
172                  html '<p><tt>'.$date.'</tt> <em>',$e->{'author'},'</em> <tt style="color:#808080">r',$e->{'revision'},'</tt></p>';                  my $msg = $e->{'msg'};
173                    $msg = '' if ref($msg); # FIXME why do I need this, dammit?
174                    if ( $msg ) {
175                            $msg = encode( $msg );
176                            $msg = qq|<div class="message">$msg</div>|;
177                    }
178    
179                  my @files;                  my @files;
180    
# Line 140  sub as_markup { Line 185  sub as_markup {
185                                  push @files, "<ins>$path</ins>";                                  push @files, "<ins>$path</ins>";
186                          } elsif ($action eq "D") {                          } elsif ($action eq "D") {
187                                  push @files, "<del>$path</del>";                                  push @files, "<del>$path</del>";
188                          } else{                          } else {
189                                  push @files, $path;                                  push @files, $path;
190                          }                          }
191    
192                            $max_path_len = length $path if length $path > $max_path_len;
193                            $path_count->{$path}++;
194                  }                  }
195    
196                  html '<blockquote><p><tt style="color:#808080">',join(", ",@files),':</tt> ',encode($e->{'msg'}),'</p></blockquote>';                  $html .= qq|
197                            <div class="commit">
198                                    <span class="date">$date</span>
199                                    <em>$e->{author}</em>
200                                    <span class="revision">$e->{revision}</span>
201                                    <div class="files">\n
202                                    |
203                                    . join("<br>\n",
204                                            map {
205                                                    my $path = $_;
206                                                    $path =~ s{<[^>]+>}{}g;
207                                                    qq|<a href="?repository=$repository;path=$path" title="$path ##">$_</a>|
208                                            } @files
209                                    )
210                                    . qq|
211                                    </div>
212                                    $msg
213                            </div>
214                    |;
215    
216          });          });
217    
218            $self->add_css(qq|
219                    .files {
220                            width: ${max_path_len}ex;
221                    }
222            |);
223    
224            $html =~ s[title="(\S+) ##"]['title="' . $path_count->{$1} . '"']gse;
225    
226          return $html;          return $html;
227  }  }
228    

Legend:
Removed from v.807  
changed lines
  Added in v.1013

  ViewVC Help
Powered by ViewVC 1.1.26