/[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 460 by dpavlin, Wed Nov 19 17:57:48 2008 UTC revision 473 by dpavlin, Thu Nov 20 11:56:41 2008 UTC
# Line 1  Line 1 
1  package Frey::Web;  package Frey::Web;
2  use Moose::Role;  use Moose::Role;
3    
4    with 'Frey::Backtrace';
5    
6  use Frey::Types;  use Frey::Types;
7    
8  use Continuity::Widget::DomNode;  use Continuity::Widget::DomNode;
# Line 22  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 178  sub page { Line 180  sub page {
180                  $body = '<!-- no body -->';                  $body = '<!-- no body -->';
181          }          }
182    
183            $status_line
184                    .= qq|<span class="frey-popup">warn<code>|
185                    . $self->editor_links( join("", $self->warnings ) )
186                    . qq|</code></span>|
187                    if $self->warnings;
188    
189            my $right =
190                    qq|
191                            <span class="right">
192                            <a href="?reload=$reload_counter"><code>$url</code></a>
193                            </span>
194                    |;
195    
196          my $html = join("\n",          my $html = join("\n",
197                  qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|,                  qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|,
198                  $self->_head_html,                  $self->_head_html,
# Line 189  sub page { Line 204  sub page {
204                  $body                  $body
205                  <div class="frey-status-line">                  <div class="frey-status-line">
206                          <a href="/">Frey</a> $Frey::VERSION                          <a href="/">Frey</a> $Frey::VERSION
                         <a href="?reload=$reload_counter"><code>$url</code></a>  
207                          $status_line                          $status_line
208                            $right
209                  </div>                  </div>
210              </body></html>              </body></html>
211                  |,                  |,
# Line 201  sub page { Line 216  sub page {
216          return $html;          return $html;
217  }  }
218    
219    sub editor_links {
220            my ( $self, $error ) = @_;
221    
222            $error =~ s{at\s+(\S+)\s+line\s+(\d+)}
223                    {at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;
224    
225            $error =~ s{(via package ")([\w:]+)(")}
226                    {$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm;
227    
228            return $error;
229    }
230    
231  sub error {  sub error {
232          my $self = shift;          my $self = shift;
233          my $error = join(" ", @_);          my $error = join(" ", @_);
234    
235          my @backtrace;          my @backtrace = $self->backtrace;
236          foreach ( 0 .. 5 ) {          $error .= "\n\t" . join( "\n\t", @backtrace ) if @backtrace;
                 my @caller = caller($_) or last;  
                 my @description = ( qw/  
                         package filename line  
                         subroutine hasargs  
                         wantarray evaltext is_require  
                         hints bitmask hinthash  
                 /);  
                 push @backtrace, join(' ',  
                         map {  
                                 $description[$_] . ': ' . dump $caller[$_]  
                         } ( 0 .. $#caller )  
                 );  
         }  
         if ( @backtrace ) {  
                 warn "# append backtrace: ", dump( @backtrace );  
                 $error .= "\n\t" . join( "\n\t", @backtrace );  
         }  
237    
238          warn "ERROR: $error\n";          warn "ERROR: $error\n";
239          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}{at <a target="editor" href="/editor+$1+$2">$1</a> line $2}gsm;          return
240          $error =~ s{(via package ")([\w:]+)(")}{$1<a target="editor" href="/editor+$2+1">$2</a>$3}gsm;                  qq|<pre class="frey-error">|
241          return qq|<pre class="frey-error">$error</pre>|;                  . $self->editor_links( $error ) .
242                    qq|</pre>|
243                    ;
244  }  }
245    
246  1;  1;

Legend:
Removed from v.460  
changed lines
  Added in v.473

  ViewVC Help
Powered by ViewVC 1.1.26