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

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

trunk/lib/Frey/Dumper.pm revision 367 by dpavlin, Mon Nov 17 11:58:41 2008 UTC trunk/lib/Frey/View/Dumper.pm revision 1133 by dpavlin, Tue Jun 30 15:10:55 2009 UTC
# Line 1  Line 1 
1  package Frey::Dumper;  package Frey::View::Dumper;
2  use Moose;  use Moose;
3    
4  with 'Frey::Escape';  extends 'Frey';
5    with 'Frey::Web';
6    
7  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
8    use POSIX qw/strftime/;
9    use DateTime;
10    
11  =head1 NAME  =head1 DESCRIPTION
12    
13  Frey::Dumper - dump perl data as tree  dump C<data> as html tree
14    
15  =cut  =cut
16    
17  has data => (  has data => (
18          is => 'rw',          is => 'rw',
19          required => 1,          required => 1,
20            documentation => "input data",
21  );  );
22    
23  sub markup {  sub as_markup {
24          my ($self) = @_;          my ($self) = @_;
25          qq|<div class="frey-dumper">| . $self->unroll( $self->data ) . qq|</div>|;          qq|<div class="frey-dumper">| . $self->unroll( $self->data ) . qq|</div>|;
26  }  }
# Line 42  sub unroll { Line 46  sub unroll {
46                  $out .= "</ul>\n";                  $out .= "</ul>\n";
47          } else {          } else {
48                  $out .= " &rarr; " if $key;                  $out .= " &rarr; " if $key;
49                  if ( $data =~ m{<(\w+).*>.+</\1>} ) {                  if ( defined $data && $data =~ m{<(\w+).*>.+</\1>} ) {
50                          $out .= qq|<div style="background: #eee; color: #000" title="HTML">$data</div></li>|;                          $out .= qq|<div style="background: #eee; color: #000" title="HTML">$data</div></li>|;
51                    } elsif ( $data =~ m{^(\d+(?:\.\d+)?)$} && $1 <= time() ) {
52                            $out .= qq|<span title="| . DateTime->from_epoch( epoch => $1 ) . qq|">$data</span>|;
53                  } else {                  } else {
54                          $out .= "<span>" . $self->html_dump( $data ) . "</span></li>";                          $out .= "<span>" . $self->html_dump( $data ) . "</span></li>";
55                  }                  }
# Line 53  sub unroll { Line 59  sub unroll {
59          return $out;          return $out;
60  }  }
61    
62    __PACKAGE__->meta->make_immutable;
63    no Moose;
64    
65  1;  1;

Legend:
Removed from v.367  
changed lines
  Added in v.1133

  ViewVC Help
Powered by ViewVC 1.1.26