/[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 532 by dpavlin, Wed Nov 26 07:57:12 2008 UTC revision 570 by dpavlin, Thu Nov 27 22:11:13 2008 UTC
# Line 4  use Moose; Line 4  use Moose;
4  extends 'Frey::ClassLoader';  extends 'Frey::ClassLoader';
5  with 'Frey::Web';  with 'Frey::Web';
6  with 'Frey::Session';  with 'Frey::Session';
7    with 'Frey::Web::CombineImages';
8    
9  use Frey::Run;  use Frey::Run;
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
# Line 18  has 'usage_on_top' => ( Line 19  has 'usage_on_top' => (
19  sub as_markup {  sub as_markup {
20          my $self = shift;          my $self = shift;
21          my $row;          my $row;
22            my @icons;
23    
24          my $usage = $self->session_dump( $self->usage );          my $usage = $self->session_dump( $self->usage );
25          #warn "# usage ",dump( $usage );          #warn "# usage ",dump( $usage );
26          foreach my $class ( $self->classes ) {          foreach my $class ( $self->classes ) {
27    
28                  my $icon = '';                  my $icon = '';
29                  if ( $self->can('icon_path') ) {                  if ( ! $self->can('icon_path') ) {
30                          $icon = $self->icon_path( $class );                          $self->TODO( "re-apply Frey::Web on $self" );
31                          $icon = qq|<img src="/$icon" alt="$class">| if $icon;                          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                  } else {                  } else {
38                          #warn "## $self doesn't know how to return icon_path";                          $icon = '';
39                  }                  }
40    
41                  my $html                  my $html
# Line 65  sub as_markup { Line 72  sub as_markup {
72                  $row->{$class} = $html;                  $row->{$class} = $html;
73          }          }
74    
75            my $icons_html = $self->combine_images( @icons );
76            sub icon {
77                    my ($icons_html,$path) = @_;
78                    warn "# icon $path";
79                    $icons_html->{ $path } || die "can't find $path in ",dump($icons_html);
80            };
81    
82          return          return
83                  qq|<table>| . join("\n",                  qq|<table>| . join("\n",
84                          map { $row->{$_} }                          map {
85                                    my $html = $row->{$_};
86                                    $html =~ s{<!-- icon:(\S+) -->}{icon($icons_html,$1)}gse;
87                                    $html;
88                            }
89                          sort {                          sort {
90                                  if ( $usage->{$a} || $usage->{$b} ) {                                  if ( $usage->{$a} || $usage->{$b} ) {
91                                          if ( $self->usage_on_top ) {                                          $self->usage_on_top ? $usage->{$b} <=> $usage->{$a} : $usage->{$a} <=> $usage->{$b};
                                                 $usage->{$b} <=> $usage->{$a};  
                                         } else {  
                                                 $usage->{$a} <=> $usage->{$b};  
                                         }  
92                                  } else {                                  } else {
93                                          $a cmp $b;                                          $self->usage_on_top ? $a cmp $b : $b cmp $a;
94                                  }                                  }
95                          }                          }
96                          keys %$row                          keys %$row

Legend:
Removed from v.532  
changed lines
  Added in v.570

  ViewVC Help
Powered by ViewVC 1.1.26