/[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 949 by dpavlin, Tue Jan 6 16:05:05 2009 UTC revision 968 by dpavlin, Fri Jan 9 14:52:58 2009 UTC
# Line 3  use Moose::Role; Line 3  use Moose::Role;
3    
4  with 'Frey::Session';  with 'Frey::Session';
5    
 #use Continuity::Widget::DomNode;  
6  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
7  use Carp qw/confess cluck carp/;  use Carp qw/confess cluck carp/;
8  use File::Slurp;  use File::Slurp;
# Line 71  has 'html_dump_width' => ( Line 70  has 'html_dump_width' => (
70          default => 250,          default => 250,
71  );  );
72    
73    has 'wrap_in_page' => (
74            documentation => 'wrap full html page with status bar around content',
75            is => 'rw',
76            isa => 'Bool',
77            default => 1,
78    );
79    
80  my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');  my %escape = ('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;');
81  my $escape_re  = join '|' => keys %escape;  my $escape_re  = join '|' => keys %escape;
82    
83  sub html_escape {  sub html_escape {
84          my ( $self, $html ) = @_;          my ( $self, $html ) = @_;
85            return '' unless defined $html;
86          $html =~ s/($escape_re)/$escape{$1}/g;          $html =~ s/($escape_re)/$escape{$1}/g;
87          return $html;          return $html;
88  }  }
# Line 238  sub add_js { Line 245  sub add_js {
245  our $reload_counter = 0;  our $reload_counter = 0;
246    
247    
248  =head2 page  =head2 html_page
249    
250    $self->page(    $self->html_page(
251          title => 'page title',          title => 'page title',
252          head  => '<!-- optional head markup -->',          head  => '<!-- optional head markup -->',
253          body  => '<b>Page Body</b>',          body  => '<b>Page Body</b>',
# Line 253  sub status { @status }; Line 260  sub status { @status };
260    
261  our $icon_html;  our $icon_html;
262    
263  sub page {  sub html_page {
264          my $self = shift;          my $self = shift;
265          my $a = {@_};          my $a = {@_};
266    
# Line 276  sub page { Line 283  sub page {
283                  warn "# no body, invoke $self->$run on ", ref($self);                  warn "# no body, invoke $self->$run on ", ref($self);
284                  $body = $self->$run;                  $body = $self->$run;
285          }          }
286          if ( $self->content_type !~ m{html} ) {          if ( $self->content_type !~ m{html} || ! $self->wrap_in_page ) {
287                  warn "# return only $self body ", $self->content_type;                  warn "# return only $self body ", $self->content_type;
288                  return $body                  return $body
289          } elsif ( ! defined $body ) {          } elsif ( ! defined $body ) {

Legend:
Removed from v.949  
changed lines
  Added in v.968

  ViewVC Help
Powered by ViewVC 1.1.26