/[Frey]/branches/zimbardo/lib/Frey/Web.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 /branches/zimbardo/lib/Frey/Web.pm

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

revision 465 by dpavlin, Wed Nov 19 19:11:52 2008 UTC revision 476 by dpavlin, Thu Nov 20 12:56:37 2008 UTC
# Line 24  has 'status' => ( Line 24  has 'status' => (
24          isa => 'ArrayRef[HashRef[Str]]',          isa => 'ArrayRef[HashRef[Str]]',
25          lazy => 1,          lazy => 1,
26          default => sub { [          default => sub { [
                 { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup },  
27                  { 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup },                  { 'ClassBrowser' => Frey::ClassBrowser->new( usage_on_top => 0 )->as_markup },
28                    { 'Bookmarklets' => Frey::Bookmarklet->new->as_markup },
29          ] },          ] },
30  );  );
31    
# Line 49  has 'content_type' => ( Line 49  has 'content_type' => (
49          is => 'rw',          is => 'rw',
50          isa => 'Str',          isa => 'Str',
51          default => 'text/html',          default => 'text/html',
52            documentation => 'Content-type header',
53    );
54    
55    has 'dump_max_bytes' => (
56            is => 'rw',
57            isa => 'Int',
58            default => 4096,
59            documentation => 'Maximum dump size sent to browser before truncation',
60  );  );
61    
62  =head2 inline_smaller_than  =head2 inline_smaller_than
# Line 158  sub page { Line 166  sub page {
166                          if ( ref($content) ) {                          if ( ref($content) ) {
167                                  $content = '<code>' . dump($content) . '</code>';                                  $content = '<code>' . dump($content) . '</code>';
168                                  my $l = length($content);                                  my $l = length($content);
169                                  $content = qq|<span>$l bytes</span>| if $l > 1024;                                  $content = qq|<span>$l bytes</span>| if $l > $self->dump_max_bytes;
170                          } else {                          } else {
171                                  $content = qq|<span>$content</span>|;                                  $content = qq|<span>$content</span>|;
172                          }                          }
# Line 180  sub page { Line 188  sub page {
188                  $body = '<!-- no body -->';                  $body = '<!-- no body -->';
189          }          }
190    
191            $status_line
192                    .= qq|<span class="frey-popup">warn<code>|
193                    . $self->editor_links( join("", $self->warnings ) )
194                    . qq|</code></span>|
195                    if $self->warnings;
196    
197            my $right =
198                    qq|
199                            <span class="right">
200                            <a href="?reload=$reload_counter"><code>$url</code></a>
201                            </span>
202                    |;
203    
204          my $html = join("\n",          my $html = join("\n",
205                  qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|,                  qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|,
206                  $self->_head_html,                  $self->_head_html,
# Line 191  sub page { Line 212  sub page {
212                  $body                  $body
213                  <div class="frey-status-line">                  <div class="frey-status-line">
214                          <a href="/">Frey</a> $Frey::VERSION                          <a href="/">Frey</a> $Frey::VERSION
                         <a href="?reload=$reload_counter"><code>$url</code></a>  
215                          $status_line                          $status_line
216                            $right
217                  </div>                  </div>
218              </body></html>              </body></html>
219                  |,                  |,
# Line 203  sub page { Line 224  sub page {
224          return $html;          return $html;
225  }  }
226    
227    sub editor_links {
228            my ( $self, $error ) = @_;
229    
230            $error =~ s{at\s+(\S+)\s+line\s+(\d+)}
231                    {at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;
232    
233            $error =~ s{(via package ")([\w:]+)(")}
234                    {$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm;
235    
236            return $error;
237    }
238    
239  sub error {  sub error {
240          my $self = shift;          my $self = shift;
241          my $error = join(" ", @_);          my $error = join(" ", @_);
# Line 211  sub error { Line 244  sub error {
244          $error .= "\n\t" . join( "\n\t", @backtrace ) if @backtrace;          $error .= "\n\t" . join( "\n\t", @backtrace ) if @backtrace;
245    
246          warn "ERROR: $error\n";          warn "ERROR: $error\n";
247          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}          return
248                  {at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;                  qq|<pre class="frey-error">|
249          $error =~ s{(via package ")([\w:]+)(")}                  . $self->editor_links( $error ) .
250                  {$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm;                  qq|</pre>|
251                    ;
         return qq|<pre class="frey-error">$error</pre>|;  
252  }  }
253    
254  1;  1;

Legend:
Removed from v.465  
changed lines
  Added in v.476

  ViewVC Help
Powered by ViewVC 1.1.26