/[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

Annotation of /trunk/lib/Frey/ClassBrowser.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (hide annotations)
Wed Nov 26 07:57:12 2008 UTC (15 years, 5 months ago) by dpavlin
File size: 1956 byte(s)
refactor Frey::Boostrap from Frey::Server to have correct warn handling

- we now use File::Tee to capture STDERR to file and display that
  (with filtering) for display
- added FREY_NO_LOG enviroment variable to disable logging (for perl -c)
- move all warnings handling into Frey::Web->warnings_html
- make Frey->debug Int (this touched a bunch of tests)
1 dpavlin 119 package Frey::ClassBrowser;
2     use Moose;
3    
4 dpavlin 308 extends 'Frey::ClassLoader';
5 dpavlin 418 with 'Frey::Web';
6 dpavlin 434 with 'Frey::Session';
7 dpavlin 119
8 dpavlin 223 use Frey::Run;
9 dpavlin 434 use Data::Dump qw/dump/;
10 dpavlin 119
11 dpavlin 434 has 'usage_on_top' => (
12     is => 'rw',
13     isa => 'Bool',
14     default => 1,
15     documentation => 'Show usage on top of list',
16     );
17    
18 dpavlin 455 sub as_markup {
19 dpavlin 308 my $self = shift;
20 dpavlin 434 my $row;
21    
22     my $usage = $self->session_dump( $self->usage );
23     #warn "# usage ",dump( $usage );
24 dpavlin 308 foreach my $class ( $self->classes ) {
25 dpavlin 531
26     my $icon = '';
27     if ( $self->can('icon_path') ) {
28     $icon = $self->icon_path( $class );
29     $icon = qq|<img src="/$icon" alt="$class">| if $icon;
30     } else {
31 dpavlin 532 #warn "## $self doesn't know how to return icon_path";
32 dpavlin 531 }
33    
34 dpavlin 427 my $html
35 dpavlin 531 = qq|<tr><td>$icon</td><td><a target="$class" href="/$class" title="|
36 dpavlin 427 . $self->class_path( $class )
37     . qq|">$class</a></td><td>|
38     ;
39 dpavlin 308 if ( $class->can('meta') ) {
40     if ( $class->meta->isa('Moose::Meta::Role') ) {
41 dpavlin 144 $html .= qq|role|;
42     } else {
43 dpavlin 531 $html .= qq|<a target="$class" href="/Frey-ObjectDesigner?class=$class">design</a>| if $class->can('collection');
44 dpavlin 144 }
45     }
46 dpavlin 459
47     my @run = map {
48     s{^as_}{};
49 dpavlin 531 qq|<a target="$class" href="/$class/as_$_" title="$class->as_$_">$_</a>|;
50 dpavlin 459 } $self->class_runnable( $class );
51 dpavlin 531 push @run, qq|<a target="$class" href="/Frey-ObjectBrowser?class=$class">collection</a>| if $class->can('collection_table');
52 dpavlin 455
53 dpavlin 459 my @inputs = $self->class_inputs( $class );
54    
55 dpavlin 434 $usage->{$class} ||= 0;
56 dpavlin 427 $html
57     .= qq|</td><td>|
58     . join(' ', @run)
59     . qq|</td><td>|
60 dpavlin 459 . ( @inputs ? '&larr; ' . join(' ', @inputs) : '' )
61 dpavlin 434 . qq|</td><td>|
62     . ( $usage->{$class} || '' )
63 dpavlin 427 . qq|</td></tr>|
64     ;
65 dpavlin 434 $row->{$class} = $html;
66 dpavlin 144 }
67 dpavlin 434
68     return
69     qq|<table>| . join("\n",
70     map { $row->{$_} }
71     sort {
72     if ( $usage->{$a} || $usage->{$b} ) {
73     if ( $self->usage_on_top ) {
74     $usage->{$b} <=> $usage->{$a};
75     } else {
76     $usage->{$a} <=> $usage->{$b};
77     }
78     } else {
79     $a cmp $b;
80     }
81     }
82     keys %$row
83     ) . qq|</table>|;
84 dpavlin 119 }
85    
86     1;

  ViewVC Help
Powered by ViewVC 1.1.26