/[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 385 by dpavlin, Mon Nov 17 20:14:12 2008 UTC revision 388 by dpavlin, Tue Nov 18 00:19:22 2008 UTC
# Line 1  Line 1 
1  package Frey::Web;  package Frey::Web;
2  use Moose::Role;  use Moose::Role;
3    
4    use Frey::Types;
5    
6  use Continuity::Widget::DomNode;  use Continuity::Widget::DomNode;
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8  use Carp qw/confess/;  use Carp qw/confess cluck/;
9  use File::Slurp;  use File::Slurp;
10    
11  has 'head' => (  has 'head' => (
# Line 12  has 'head' => ( Line 14  has 'head' => (
14          default => sub { [ 'static/frey.css' ] },          default => sub { [ 'static/frey.css' ] },
15  );  );
16    
17    has 'status' => (
18            is => 'rw',
19            isa => 'ArrayRef[HashRef[Str]]',
20            lazy => 1,
21            default => sub { [
22                    { 'Bookmarklets' => Frey::Bookmarklet->markup },
23                    { 'ClassBrowser' => Frey::ClassBrowser->markup },
24            ] },
25    );
26    
27    has 'urequest_url' => (
28            is => 'rw',
29            isa => 'Uri', coerce => 1,
30            default => '/',
31    );
32    
33  =head2 inline_smaller_than  =head2 inline_smaller_than
34    
35  Inline JavaScript and CSS smaller than this size into page reducing  Inline JavaScript and CSS smaller than this size into page reducing
# Line 104  sub page { Line 122  sub page {
122    
123          $reload_counter++;          $reload_counter++;
124    
125          my $html = qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|          my $status_line = '';
126          . $self->_head_html          foreach my $part ( @{ $self->status } ) {
127          . '<title>' . ( $a->{title} || ref($self) ) . '</title>'                  foreach my $name ( keys %$part ) {
128          . '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">'                          warn "### part [$name] = ", length( $part->{name} ), " bytes" if $self->debug;
129          . ( $a->{head} || '' )                          $status_line .= qq|<span class="frey-popup">$name<span>| . $part->{$name} . qq|</span></span>|;
130          . '</head><body>'                  }
131          . ( $a->{body} || '<!-- no body -->' )          }
132          . qq|<div class="frey-status-line">  
133                  <a href="/">Frey</a> $Frey::VERSION          my $html = join("\n",
134                  <a href="?reload=$reload_counter"><code>| . dump( $ENV{'REQUEST_URI'} ) . qq|</code></a>                  qq|<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"><html><head>|,
135                  <span class="frey-popup">Bookmarklets<span>| . Frey::Bookmarklet->markup . qq|</span></span>                  $self->_head_html,
136                  <span class="frey-popup">ClassBrowser<span>| . Frey::ClassBrowser->markup . qq|</span></span>                  '<title>' . ( $a->{title} || ref($self) ) . '</title>',
137                  <span class="frey-popup">ENV<span><code>| . dump( %ENV ) . qq|</code></span></span>                  '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">',
138                    ( $a->{head} || '' ),
139                    '</head><body>',
140                    ( $a->{body} || '<!-- no body -->' ),
141                    qq|
142                    <div class="frey-status-line">
143                            <a href="/">Frey</a> $Frey::VERSION
144                            <a href="?reload=$reload_counter"><code>| . $self->urequest_url . qq|</code></a>
145                            $status_line
146                  </div>                  </div>
147              </body></html>              </body></html>
148          |;                  |,
149            );
150    
151          warn "## >>> page ",length($html), " bytes\n" if $self->debug;          warn "## >>> page ",length($html), " bytes\n" if $self->debug;
152    
# Line 128  sub page { Line 155  sub page {
155    
156  sub error {  sub error {
157          my ( $self, $error ) = @_;          my ( $self, $error ) = @_;
158          warn $error;          cluck $error;
159          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}{ <a href="/editor$1+$2" target="editor">$1</a> line $2}gsm;          $error =~ s{at\s+(\S+)\s+line\s+(\d+)}{ <a href="/editor$1+$2" target="editor">$1</a> line $2}gsm;
160          return qq|<pre class="frey-error">$error</pre>|;          return qq|<pre class="frey-error">$error</pre>|;
161  }  }

Legend:
Removed from v.385  
changed lines
  Added in v.388

  ViewVC Help
Powered by ViewVC 1.1.26