1 |
package Frey::ClassBrowser; |
package Frey::ClassBrowser; |
2 |
use Moose; |
use Moose; |
3 |
|
|
4 |
extends 'Frey'; |
extends 'Frey::ClassLoader'; |
5 |
|
with 'Frey::Web'; |
6 |
|
|
|
use Frey::ClassLoader; |
|
7 |
use Frey::Run; |
use Frey::Run; |
8 |
|
|
|
our $markup; |
|
|
|
|
9 |
sub markup { |
sub markup { |
10 |
return $markup if $markup; |
my $self = shift; |
11 |
my $f = Frey::ClassLoader->new; |
my @rows; |
12 |
my $html; |
foreach my $class ( $self->classes ) { |
13 |
foreach my $package ( $f->classes ) { |
my $html |
14 |
$html .= qq|<tr><td><a href="/~/$package" title="| . $f->package_path( $package ) . qq|">$package</a></td><td>|; |
= qq|<tr><td><a href="/$class" title="| |
15 |
if ( $package->can('meta') ) { |
. $self->class_path( $class ) |
16 |
if ( $package->meta->isa('Moose::Meta::Role') ) { |
. qq|">$class</a></td><td>| |
17 |
|
; |
18 |
|
if ( $class->can('meta') ) { |
19 |
|
if ( $class->meta->isa('Moose::Meta::Role') ) { |
20 |
$html .= qq|role|; |
$html .= qq|role|; |
21 |
} else { |
} else { |
22 |
$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'); |
23 |
} |
} |
24 |
} |
} |
25 |
my @inspect; |
my @run; |
26 |
push @inspect, qq|<a href="/ob/$package">collection</a>| if $package->can('collection_table'); |
my @input; |
27 |
foreach my $try ( Frey::Run->execute ) { |
push @run, qq|<a href="/Frey-ObjectBrowser?class=$class">collection</a>| if $class->can('collection_table'); |
28 |
push @inspect, qq|<a href="/$try/$package">$try</a>| if $package->can($try); |
my $class_method = $self->class_methods( $class ); |
29 |
|
foreach my $try ( Frey::Run->runnable ) { |
30 |
|
next unless $class->can($try); |
31 |
|
if ( $class_method->{ $try } ) { |
32 |
|
push @run, qq|<a href="/$class/$try">$try</a>|; |
33 |
|
} else { |
34 |
|
push @input, $try; |
35 |
|
} |
36 |
} |
} |
37 |
$html .= qq|</td><td>| . join(' ', @inspect) . qq|</td></tr>|; |
$html |
38 |
|
.= qq|</td><td>| |
39 |
|
. join(' ', @run) |
40 |
|
. qq|</td><td>| |
41 |
|
. ( @input ? '← ' . join(' ', @input) : '' ) |
42 |
|
. qq|</td></tr>| |
43 |
|
; |
44 |
|
push @rows, $html if $html; |
45 |
} |
} |
46 |
$html = "<table>$html</table>" if $html; |
return qq|<table>| . join("\n", @rows) . qq|</table>| if @rows; |
|
$markup = $html; |
|
47 |
} |
} |
48 |
|
|
49 |
1; |
1; |