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

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

revision 217 by dpavlin, Fri Oct 31 22:41:34 2008 UTC revision 555 by dpavlin, Thu Nov 27 17:39: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    with 'Frey::Web::CombineImages';
8    
9  use Frey::ClassLoader;  use Frey::Run;
10    use Data::Dump qw/dump/;
11    
12  our $markup;  has 'usage_on_top' => (
13            is => 'rw',
14            isa => 'Bool',
15            default => 1,
16            documentation => 'Show usage on top of list',
17    );
18    
19  sub markup {  sub as_markup {
20          return $markup if $markup;          my $self = shift;
21          my $f = Frey::ClassLoader->new;          my $row;
22          my $html;          my @icons;
23          foreach my $package ( $f->classes ) {  
24                  $html .= qq|<tr><td><a href="/~/$package" title="| . $f->package_path( $package ) . qq|">$package</a></td><td>|;          my $usage = $self->session_dump( $self->usage );
25                  if ( $package->can('meta') ) {          #warn "# usage ",dump( $usage );
26                          if ( $package->meta->isa('Moose::Meta::Role') ) {          foreach my $class ( $self->classes ) {
27    
28                    my $icon = '';
29                    if ( ! $self->can('icon_path') ) {
30                            warn "FIXME: re-apply Frey::Web on $self";
31                            Frey::Web->meta->apply( $self );
32                    }
33                    $icon = $self->icon_path( $class );
34                    if ($icon) {
35                            push @icons, $icon;
36                            $icon = qq|<!-- icon:$icon -->|;
37                    }
38    
39                    my $html
40                            = qq|<tr><td>$icon</td><td><a target="$class" href="/$class" title="|
41                            . $self->class_path( $class )
42                            . qq|">$class</a></td><td>|
43                            ;
44                    if ( $class->can('meta') ) {
45                            if ( $class->meta->isa('Moose::Meta::Role') ) {
46                                  $html .= qq|role|;                                  $html .= qq|role|;
47                          } else {                          } else {
48                                  $html .= qq|<a href="/od/$package">design</a>| if $package->can('collection');                                  $html .= qq|<a target="$class" href="/Frey-ObjectDesigner?class=$class">design</a>| if $class->can('collection');
49                          }                          }
50                  }                  }
51                  my @inspect;  
52                  push @inspect, qq|<a href="/ob/$package">collection</a>| if $package->can('collection_table');                  my @run = map {
53                  push @inspect, qq|<a href="/markup/$package">markup</a>| if $package->can('markup');                          s{^as_}{};
54                  push @inspect, qq|<a href="/request/$package">request</a>| if $package->can('request');                          qq|<a target="$class" href="/$class/as_$_" title="$class->as_$_">$_</a>|;
55                  $html .= qq|</td><td>| . join('&nbsp;', @inspect) . qq|</td></tr>|;                  } $self->class_runnable( $class );
56                    push @run, qq|<a target="$class" href="/Frey-ObjectBrowser?class=$class">collection</a>| if $class->can('collection_table');
57    
58                    my @inputs = $self->class_inputs( $class );
59    
60                    $usage->{$class} ||= 0;
61                    $html
62                            .= qq|</td><td>|
63                            . join(' ', @run)
64                            . qq|</td><td>|
65                            . ( @inputs ? '&larr; ' . join(' ', @inputs) : '' )
66                            . qq|</td><td>|
67                            . ( $usage->{$class} || '' )
68                            . qq|</td></tr>|
69                            ;
70                    $row->{$class} = $html;
71          }          }
72          $html = "<table>$html</table>" if $html;  
73          $markup = $html;          my $icons_html = $self->combine_images( @icons );
74            sub icon {
75                    my $path = shift;
76                    warn "# icon $path";
77                    $icons_html->{ $path } || die "can't find $path in ",dump($icons_html);
78            };
79    
80            return
81                    qq|<table>| . join("\n",
82                            map {
83                                    my $html = $row->{$_};
84                                    $html =~ s{<!-- icon:(\S+) -->}{icon($1)}gse;
85                                    $html;
86                            }
87                            sort {
88                                    if ( $usage->{$a} || $usage->{$b} ) {
89                                            $self->usage_on_top ? $usage->{$b} <=> $usage->{$a} : $usage->{$a} <=> $usage->{$b};
90                                    } else {
91                                            $self->usage_on_top ? $a cmp $b : $b cmp $a;
92                                    }
93                            }
94                            keys %$row
95                    ) . qq|</table>|;
96  }  }
97    
98  1;  1;

Legend:
Removed from v.217  
changed lines
  Added in v.555

  ViewVC Help
Powered by ViewVC 1.1.26