1 |
package Frey::ClassBrowser; |
2 |
use Moose; |
3 |
|
4 |
extends 'Frey::ClassLoader'; |
5 |
with 'Frey::Web'; |
6 |
|
7 |
use Frey::Run; |
8 |
|
9 |
sub markup { |
10 |
my $self = shift; |
11 |
my @rows; |
12 |
foreach my $class ( $self->classes ) { |
13 |
my $html |
14 |
= qq|<tr><td><a href="/$class" title="| |
15 |
. $self->class_path( $class ) |
16 |
. qq|">$class</a></td><td>| |
17 |
; |
18 |
if ( $class->can('meta') ) { |
19 |
if ( $class->meta->isa('Moose::Meta::Role') ) { |
20 |
$html .= qq|role|; |
21 |
} else { |
22 |
$html .= qq|<a href="/Frey-ObjectDesigner?class=$class">design</a>| if $class->can('collection'); |
23 |
} |
24 |
} |
25 |
my @run; |
26 |
my @input; |
27 |
push @run, qq|<a href="/Frey-ObjectBrowser?class=$class">collection</a>| if $class->can('collection_table'); |
28 |
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 |
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 |
return qq|<table>| . join("\n", @rows) . qq|</table>| if @rows; |
47 |
} |
48 |
|
49 |
1; |