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

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

revision 187 by dpavlin, Sat Sep 13 15:31:54 2008 UTC revision 530 by dpavlin, Wed Nov 26 04:27:00 2008 UTC
# Line 1  Line 1 
1  package Frey::ClassBrowser;  package Frey::ClassBrowser;
2  use Moose;  use Moose;
3    
4  extends 'Frey';  extends 'Frey::ClassLoader';
5  with 'Frey::Web';  with 'Frey::Web';
6    with 'Frey::Session';
7    
8  use Frey::ClassLoader;  use Frey::Run;
9    use Data::Dump qw/dump/;
10    
11  our $markup;  has 'usage_on_top' => (
12            is => 'rw',
13  sub markup {          isa => 'Bool',
14          return $markup if $markup;          default => 1,
15          my $f = Frey::ClassLoader->new;          documentation => 'Show usage on top of list',
16          my $html;  );
17          foreach my $package ( $f->classes ) {  
18                  $html .= qq|<tr><td><a href="/~/$package" title="| . $f->package_path( $package ) . qq|">$package</a></td><td>|;  sub as_markup {
19                  if ( $package->can('meta') ) {          my $self = shift;
20                          if ( $package->meta->isa('Moose::Meta::Role') ) {          my $row;
21    
22            my $usage = $self->session_dump( $self->usage );
23            #warn "# usage ",dump( $usage );
24            foreach my $class ( $self->classes ) {
25                    my $icon_path;
26                    eval { $icon_path = $self->icon_path( $class ); };
27                    my $html
28                            = qq|<tr><td>|
29                            . ( $icon_path ? qq|<img src="/$icon_path" alt="$class">| : '?' )
30                            . qq|</td><td><a target="introspect" href="/$class" title="|
31                            . $self->class_path( $class )
32                            . qq|">$class</a></td><td>|
33                            ;
34                    if ( $class->can('meta') ) {
35                            if ( $class->meta->isa('Moose::Meta::Role') ) {
36                                  $html .= qq|role|;                                  $html .= qq|role|;
37                          } else {                          } else {
38                                  $html .= qq|<a href="/od/$package">design</a>| if $package->can('collection');                                  $html .= qq|<a href="/Frey-ObjectDesigner?class=$class">design</a>| if $class->can('collection');
39                          }                          }
40                  }                  }
41                  my @inspect;  
42                  push @inspect, qq|<a href="/ob/$package">collection</a>| if $package->can('collection_table');                  my @run = map {
43                  push @inspect, qq|<a href="/markup/$package">markup</a>| if $package->can('markup');                          s{^as_}{};
44                  push @inspect, qq|<a href="/html/$package">html</a>| if $package->can('html');                          qq|<a href="/$class/as_$_" title="$class->as_$_">$_</a>|;
45                  $html .= qq|</td><td>| . join('&nbsp;', @inspect) . qq|</td></tr>|;                  } $self->class_runnable( $class );
46                    push @run, qq|<a href="/Frey-ObjectBrowser?class=$class">collection</a>| if $class->can('collection_table');
47    
48                    my @inputs = $self->class_inputs( $class );
49    
50                    $usage->{$class} ||= 0;
51                    $html
52                            .= qq|</td><td>|
53                            . join(' ', @run)
54                            . qq|</td><td>|
55                            . ( @inputs ? '&larr; ' . join(' ', @inputs) : '' )
56                            . qq|</td><td>|
57                            . ( $usage->{$class} || '' )
58                            . qq|</td></tr>|
59                            ;
60                    $row->{$class} = $html;
61          }          }
         $html = "<table>$html</table>" if $html;  
         $markup = $html;  
 }  
62    
63  sub html {          return
64          my ( $self, $req ) = @_;                  qq|<table>| . join("\n",
65          my $html = $self->page( body => qq|<h1>Classes</h1>| . $self->markup );                          map { $row->{$_} }
66          $req->print( $html );                          sort {
67                                    if ( $usage->{$a} || $usage->{$b} ) {
68                                            if ( $self->usage_on_top ) {
69                                                    $usage->{$b} <=> $usage->{$a};
70                                            } else {
71                                                    $usage->{$a} <=> $usage->{$b};
72                                            }
73                                    } else {
74                                            $a cmp $b;
75                                    }
76                            }
77                            keys %$row
78                    ) . qq|</table>|;
79  }  }
80    
81  1;  1;

Legend:
Removed from v.187  
changed lines
  Added in v.530

  ViewVC Help
Powered by ViewVC 1.1.26